| Kelvin Zhang | 4485897 | 2020-11-11 09:25:01 -0500 | [diff] [blame] | 1 | // | 
|  | 2 | // Copyright (C) 2018 The Android Open Source Project | 
|  | 3 | // | 
|  | 4 | // Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 5 | // you may not use this file except in compliance with the License. | 
|  | 6 | // You may obtain a copy of the License at | 
|  | 7 | // | 
|  | 8 | //      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 9 | // | 
|  | 10 | // Unless required by applicable law or agreed to in writing, software | 
|  | 11 | // distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 13 | // See the License for the specific language governing permissions and | 
|  | 14 | // limitations under the License. | 
|  | 15 | // | 
|  | 16 |  | 
|  | 17 | #include <stdint.h> | 
|  | 18 |  | 
|  | 19 | #include <memory> | 
|  | 20 | #include <set> | 
|  | 21 | #include <string> | 
|  | 22 | #include <vector> | 
|  | 23 |  | 
|  | 24 | #include <gmock/gmock.h> | 
| David Anderson | a4b7ba6 | 2023-05-10 21:41:37 -0700 | [diff] [blame] | 25 | #include <libsnapshot/cow_writer.h> | 
| Kelvin Zhang | 4485897 | 2020-11-11 09:25:01 -0500 | [diff] [blame] | 26 |  | 
|  | 27 | #include "update_engine/common/dynamic_partition_control_interface.h" | 
|  | 28 | #include "update_engine/payload_consumer/file_descriptor.h" | 
|  | 29 |  | 
|  | 30 | namespace chromeos_update_engine { | 
|  | 31 |  | 
|  | 32 | class MockDynamicPartitionControl : public DynamicPartitionControlInterface { | 
|  | 33 | public: | 
|  | 34 | MOCK_METHOD(void, Cleanup, (), (override)); | 
|  | 35 | MOCK_METHOD(bool, GetDeviceDir, (std::string*), (override)); | 
|  | 36 | MOCK_METHOD(FeatureFlag, GetDynamicPartitionsFeatureFlag, (), (override)); | 
|  | 37 | MOCK_METHOD(FeatureFlag, GetVirtualAbCompressionFeatureFlag, (), (override)); | 
| Kelvin Zhang | 1c4b981 | 2022-04-06 17:29:00 -0700 | [diff] [blame] | 38 | MOCK_METHOD(FeatureFlag, | 
|  | 39 | GetVirtualAbCompressionXorFeatureFlag, | 
|  | 40 | (), | 
|  | 41 | (override)); | 
| David Anderson | e35b438 | 2022-03-08 23:18:29 -0800 | [diff] [blame] | 42 | MOCK_METHOD(FeatureFlag, | 
|  | 43 | GetVirtualAbUserspaceSnapshotsFeatureFlag, | 
|  | 44 | (), | 
|  | 45 | (override)); | 
| Kelvin Zhang | 4485897 | 2020-11-11 09:25:01 -0500 | [diff] [blame] | 46 | MOCK_METHOD(FeatureFlag, GetVirtualAbFeatureFlag, (), (override)); | 
|  | 47 | MOCK_METHOD(bool, FinishUpdate, (bool), (override)); | 
| Kelvin Zhang | 1a0ed71 | 2022-01-26 16:09:05 -0800 | [diff] [blame] | 48 | MOCK_METHOD(std::unique_ptr<FileDescriptor>, | 
| Kelvin Zhang | 21a4991 | 2021-03-12 14:28:33 -0500 | [diff] [blame] | 49 | OpenCowFd, | 
| Kelvin Zhang | 4485897 | 2020-11-11 09:25:01 -0500 | [diff] [blame] | 50 | (const std::string& unsuffixed_partition_name, | 
|  | 51 | const std::optional<std::string>& source_path, | 
|  | 52 | bool is_append), | 
|  | 53 | (override)); | 
|  | 54 | MOCK_METHOD(bool, MapAllPartitions, (), (override)); | 
|  | 55 | MOCK_METHOD(bool, UnmapAllPartitions, (), (override)); | 
|  | 56 |  | 
|  | 57 | MOCK_METHOD(bool, | 
|  | 58 | OptimizeOperation, | 
|  | 59 | (const std::string&, const InstallOperation&, InstallOperation*), | 
|  | 60 | (override)); | 
|  | 61 |  | 
| David Anderson | a4b7ba6 | 2023-05-10 21:41:37 -0700 | [diff] [blame] | 62 | MOCK_METHOD(std::unique_ptr<android::snapshot::ICowWriter>, | 
| Kelvin Zhang | 76f10b8 | 2021-06-25 18:45:46 -0400 | [diff] [blame] | 63 | OpenCowWriter, | 
| David Anderson | a4b7ba6 | 2023-05-10 21:41:37 -0700 | [diff] [blame] | 64 | (const std::string&, | 
|  | 65 | const std::optional<std::string>&, | 
|  | 66 | std::optional<uint64_t> label), | 
| Kelvin Zhang | 76f10b8 | 2021-06-25 18:45:46 -0400 | [diff] [blame] | 67 | (override)); | 
| Kelvin Zhang | 4485897 | 2020-11-11 09:25:01 -0500 | [diff] [blame] | 68 |  | 
| Daniel Zheng | eede4c8 | 2023-06-13 11:21:06 -0700 | [diff] [blame] | 69 | MOCK_METHOD(bool, | 
|  | 70 | PreparePartitionsForUpdate, | 
|  | 71 | (uint32_t, | 
|  | 72 | uint32_t, | 
|  | 73 | const DeltaArchiveManifest&, | 
|  | 74 | bool, | 
|  | 75 | uint64_t*, | 
|  | 76 | ErrorCode*), | 
|  | 77 | (override)); | 
| Kelvin Zhang | 4485897 | 2020-11-11 09:25:01 -0500 | [diff] [blame] | 78 |  | 
|  | 79 | MOCK_METHOD(bool, ResetUpdate, (PrefsInterface*), (override)); | 
|  | 80 | MOCK_METHOD(std::unique_ptr<AbstractAction>, | 
|  | 81 | GetCleanupPreviousUpdateAction, | 
|  | 82 | (BootControlInterface*, | 
|  | 83 | PrefsInterface*, | 
|  | 84 | CleanupPreviousUpdateActionDelegateInterface*), | 
|  | 85 | (override)); | 
|  | 86 | MOCK_METHOD(bool, | 
|  | 87 | ListDynamicPartitionsForSlot, | 
| Tianjie | 3a55fc2 | 2021-02-13 16:02:22 -0800 | [diff] [blame] | 88 | (uint32_t, uint32_t, std::vector<std::string>*), | 
| Kelvin Zhang | 4485897 | 2020-11-11 09:25:01 -0500 | [diff] [blame] | 89 | (override)); | 
| Tianjie | 3a55fc2 | 2021-02-13 16:02:22 -0800 | [diff] [blame] | 90 |  | 
| Kelvin Zhang | 4485897 | 2020-11-11 09:25:01 -0500 | [diff] [blame] | 91 | MOCK_METHOD(bool, | 
|  | 92 | VerifyExtentsForUntouchedPartitions, | 
|  | 93 | (uint32_t, uint32_t, const std::vector<std::string>&), | 
|  | 94 | (override)); | 
| Kelvin Zhang | ebd115e | 2021-03-08 16:10:25 -0500 | [diff] [blame] | 95 | MOCK_METHOD(bool, | 
|  | 96 | IsDynamicPartition, | 
|  | 97 | (const std::string&, uint32_t slot), | 
|  | 98 | (override)); | 
| Yifan Hong | b0cbd39 | 2021-02-04 11:11:45 -0800 | [diff] [blame] | 99 | MOCK_METHOD(bool, UpdateUsesSnapshotCompression, (), (override)); | 
| Kelvin Zhang | 4485897 | 2020-11-11 09:25:01 -0500 | [diff] [blame] | 100 | }; | 
|  | 101 |  | 
|  | 102 | }  // namespace chromeos_update_engine |