Alex Deymo | 2b19cfb | 2015-03-26 00:35:07 -0700 | [diff] [blame^] | 1 | // Copyright 2015 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "update_engine/payload_generator/fake_filesystem.h" |
| 6 | |
| 7 | #include <gtest/gtest.h> |
| 8 | |
| 9 | namespace chromeos_update_engine { |
| 10 | |
| 11 | FakeFilesystem::FakeFilesystem(uint64_t block_size, uint64_t block_count) : |
| 12 | block_size_(block_size), |
| 13 | block_count_(block_count) { |
| 14 | } |
| 15 | |
| 16 | size_t FakeFilesystem::GetBlockSize() const { |
| 17 | return block_size_; |
| 18 | } |
| 19 | |
| 20 | size_t FakeFilesystem::GetBlockCount() const { |
| 21 | return block_count_; |
| 22 | } |
| 23 | |
| 24 | bool FakeFilesystem::GetFiles(std::vector<File>* files) const { |
| 25 | *files = files_; |
| 26 | return true; |
| 27 | } |
| 28 | |
| 29 | void FakeFilesystem::AddFile(const std::string& filename, |
| 30 | const std::vector<Extent> extents) { |
| 31 | File file; |
| 32 | file.name = filename; |
| 33 | file.extents = extents; |
| 34 | for (const Extent& extent : extents) { |
| 35 | EXPECT_LE(0, extent.start_block()); |
| 36 | EXPECT_LE(extent.start_block() + extent.num_blocks(), block_count_); |
| 37 | } |
| 38 | files_.push_back(file); |
| 39 | } |
| 40 | |
| 41 | } // namespace chromeos_update_engine |