blob: c933e8725e05f5d7c77b8569d69623f09b138b51 [file] [log] [blame]
Yifan Hong537802d2018-08-15 13:15:42 -07001//
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>
Yifan Hong6eec9952019-12-04 13:12:01 -080020#include <set>
Yifan Hong537802d2018-08-15 13:15:42 -070021#include <string>
22
23#include <gmock/gmock.h>
24
Yifan Hong012508e2019-07-22 18:30:40 -070025#include "update_engine/common/boot_control_interface.h"
Yifan Hong15726b92019-11-05 19:06:48 -080026#include "update_engine/common/dynamic_partition_control_interface.h"
Yifan Hong012508e2019-07-22 18:30:40 -070027#include "update_engine/dynamic_partition_control_android.h"
Yifan Hong537802d2018-08-15 13:15:42 -070028
29namespace chromeos_update_engine {
30
Yifan Hong012508e2019-07-22 18:30:40 -070031class MockDynamicPartitionControlAndroid
32 : public DynamicPartitionControlAndroid {
Yifan Hong537802d2018-08-15 13:15:42 -070033 public:
Yifan Hong5f32ee22020-04-15 18:22:39 -070034 MOCK_METHOD(
35 bool,
36 MapPartitionOnDeviceMapper,
37 (const std::string&, const std::string&, uint32_t, bool, std::string*),
38 (override));
39 MOCK_METHOD(bool,
40 UnmapPartitionOnDeviceMapper,
41 (const std::string&),
42 (override));
43 MOCK_METHOD(void, Cleanup, (), (override));
44 MOCK_METHOD(bool, DeviceExists, (const std::string&), (override));
45 MOCK_METHOD(::android::dm::DmDeviceState,
46 GetState,
47 (const std::string&),
48 (override));
49 MOCK_METHOD(bool,
50 GetDmDevicePathByName,
51 (const std::string&, std::string*),
52 (override));
53 MOCK_METHOD(std::unique_ptr<::android::fs_mgr::MetadataBuilder>,
54 LoadMetadataBuilder,
55 (const std::string&, uint32_t, uint32_t),
56 (override));
57 MOCK_METHOD(bool,
58 StoreMetadata,
59 (const std::string&, android::fs_mgr::MetadataBuilder*, uint32_t),
60 (override));
61 MOCK_METHOD(bool, GetDeviceDir, (std::string*), (override));
62 MOCK_METHOD(FeatureFlag, GetDynamicPartitionsFeatureFlag, (), (override));
63 MOCK_METHOD(std::string, GetSuperPartitionName, (uint32_t), (override));
64 MOCK_METHOD(FeatureFlag, GetVirtualAbFeatureFlag, (), (override));
65 MOCK_METHOD(bool, FinishUpdate, (bool), (override));
66 MOCK_METHOD(bool,
67 GetSystemOtherPath,
68 (uint32_t, uint32_t, const std::string&, std::string*, bool*),
69 (override));
70 MOCK_METHOD(bool,
71 EraseSystemOtherAvbFooter,
72 (uint32_t, uint32_t),
73 (override));
74 MOCK_METHOD(std::optional<bool>, IsAvbEnabledOnSystemOther, (), (override));
Yifan Hong6eec9952019-12-04 13:12:01 -080075
76 void set_fake_mapped_devices(const std::set<std::string>& fake) override {
77 DynamicPartitionControlAndroid::set_fake_mapped_devices(fake);
78 }
Yifan Hong29692902020-03-26 12:47:05 -070079
80 bool RealGetSystemOtherPath(uint32_t source_slot,
81 uint32_t target_slot,
82 const std::string& partition_name_suffix,
83 std::string* path,
84 bool* should_unmap) {
85 return DynamicPartitionControlAndroid::GetSystemOtherPath(
86 source_slot, target_slot, partition_name_suffix, path, should_unmap);
87 }
88
89 bool RealEraseSystemOtherAvbFooter(uint32_t source_slot,
90 uint32_t target_slot) {
91 return DynamicPartitionControlAndroid::EraseSystemOtherAvbFooter(
92 source_slot, target_slot);
93 }
94
95 std::optional<bool> RealIsAvbEnabledInFstab(const std::string& path) {
96 return DynamicPartitionControlAndroid::IsAvbEnabledInFstab(path);
97 }
Yifan Hong537802d2018-08-15 13:15:42 -070098};
99
100} // namespace chromeos_update_engine