Yifan Hong | 537802d | 2018-08-15 13:15:42 -0700 | [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 <string> |
| 21 | |
| 22 | #include <gmock/gmock.h> |
| 23 | |
Yifan Hong | 012508e | 2019-07-22 18:30:40 -0700 | [diff] [blame] | 24 | #include "update_engine/common/boot_control_interface.h" |
| 25 | #include "update_engine/dynamic_partition_control_android.h" |
Yifan Hong | 537802d | 2018-08-15 13:15:42 -0700 | [diff] [blame] | 26 | #include "update_engine/dynamic_partition_control_interface.h" |
| 27 | |
| 28 | namespace chromeos_update_engine { |
| 29 | |
Yifan Hong | c049f93 | 2019-07-23 15:06:05 -0700 | [diff] [blame] | 30 | class MockDynamicPartitionControl : public DynamicPartitionControlInterface { |
| 31 | public: |
| 32 | MOCK_METHOD5(MapPartitionOnDeviceMapper, |
| 33 | bool(const std::string&, |
| 34 | const std::string&, |
| 35 | uint32_t, |
| 36 | bool, |
| 37 | std::string*)); |
| 38 | MOCK_METHOD0(Cleanup, void()); |
| 39 | MOCK_METHOD1(DeviceExists, bool(const std::string&)); |
| 40 | MOCK_METHOD1(GetState, ::android::dm::DmDeviceState(const std::string&)); |
| 41 | MOCK_METHOD2(GetDmDevicePathByName, bool(const std::string&, std::string*)); |
| 42 | MOCK_METHOD2(LoadMetadataBuilder, |
| 43 | std::unique_ptr<::android::fs_mgr::MetadataBuilder>( |
| 44 | const std::string&, uint32_t)); |
| 45 | MOCK_METHOD1(GetDeviceDir, bool(std::string*)); |
| 46 | MOCK_METHOD0(GetDynamicPartitionsFeatureFlag, FeatureFlag()); |
| 47 | MOCK_METHOD3(PreparePartitionsForUpdate, |
| 48 | bool(uint32_t, |
| 49 | uint32_t, |
| 50 | const BootControlInterface::PartitionMetadata&)); |
| 51 | MOCK_METHOD1(GetSuperPartitionName, std::string(uint32_t)); |
Yifan Hong | 413d572 | 2019-07-23 14:21:09 -0700 | [diff] [blame^] | 52 | MOCK_METHOD0(GetVirtualAbFeatureFlag, FeatureFlag()); |
Yifan Hong | c049f93 | 2019-07-23 15:06:05 -0700 | [diff] [blame] | 53 | }; |
| 54 | |
Yifan Hong | 012508e | 2019-07-22 18:30:40 -0700 | [diff] [blame] | 55 | class MockDynamicPartitionControlAndroid |
| 56 | : public DynamicPartitionControlAndroid { |
Yifan Hong | 537802d | 2018-08-15 13:15:42 -0700 | [diff] [blame] | 57 | public: |
Yifan Hong | af65ef1 | 2018-10-29 11:09:06 -0700 | [diff] [blame] | 58 | MOCK_METHOD5(MapPartitionOnDeviceMapper, |
| 59 | bool(const std::string&, |
| 60 | const std::string&, |
| 61 | uint32_t, |
| 62 | bool, |
| 63 | std::string*)); |
David Anderson | 4c891c9 | 2019-06-21 17:45:23 -0700 | [diff] [blame] | 64 | MOCK_METHOD1(UnmapPartitionOnDeviceMapper, bool(const std::string&)); |
Yifan Hong | 537802d | 2018-08-15 13:15:42 -0700 | [diff] [blame] | 65 | MOCK_METHOD0(Cleanup, void()); |
| 66 | MOCK_METHOD1(DeviceExists, bool(const std::string&)); |
| 67 | MOCK_METHOD1(GetState, ::android::dm::DmDeviceState(const std::string&)); |
| 68 | MOCK_METHOD2(GetDmDevicePathByName, bool(const std::string&, std::string*)); |
Yifan Hong | 6e706b1 | 2018-11-09 16:50:51 -0800 | [diff] [blame] | 69 | MOCK_METHOD3(LoadMetadataBuilder, |
Yifan Hong | 537802d | 2018-08-15 13:15:42 -0700 | [diff] [blame] | 70 | std::unique_ptr<::android::fs_mgr::MetadataBuilder>( |
Yifan Hong | 6e706b1 | 2018-11-09 16:50:51 -0800 | [diff] [blame] | 71 | const std::string&, uint32_t, uint32_t)); |
Yifan Hong | 537802d | 2018-08-15 13:15:42 -0700 | [diff] [blame] | 72 | MOCK_METHOD3(StoreMetadata, |
| 73 | bool(const std::string&, |
| 74 | android::fs_mgr::MetadataBuilder*, |
| 75 | uint32_t)); |
| 76 | MOCK_METHOD1(GetDeviceDir, bool(std::string*)); |
Yifan Hong | 186bb68 | 2019-07-23 14:04:39 -0700 | [diff] [blame] | 77 | MOCK_METHOD0(GetDynamicPartitionsFeatureFlag, FeatureFlag()); |
Yifan Hong | 700d7c1 | 2019-07-23 20:49:16 -0700 | [diff] [blame] | 78 | MOCK_METHOD1(GetSuperPartitionName, std::string(uint32_t)); |
Yifan Hong | 413d572 | 2019-07-23 14:21:09 -0700 | [diff] [blame^] | 79 | MOCK_METHOD0(GetVirtualAbFeatureFlag, FeatureFlag()); |
Yifan Hong | 537802d | 2018-08-15 13:15:42 -0700 | [diff] [blame] | 80 | }; |
| 81 | |
| 82 | } // namespace chromeos_update_engine |