blob: b3e0c24d5a1865924a66b57ca110b369d79bc64c [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 Hongc049f932019-07-23 15:06:05 -070031class MockDynamicPartitionControl : public DynamicPartitionControlInterface {
32 public:
33 MOCK_METHOD5(MapPartitionOnDeviceMapper,
34 bool(const std::string&,
35 const std::string&,
36 uint32_t,
37 bool,
38 std::string*));
39 MOCK_METHOD0(Cleanup, void());
Yifan Hongc049f932019-07-23 15:06:05 -070040 MOCK_METHOD0(GetDynamicPartitionsFeatureFlag, FeatureFlag());
Yifan Hongf033ecb2020-01-07 18:13:56 -080041 MOCK_METHOD5(
42 PreparePartitionsForUpdate,
43 bool(uint32_t, uint32_t, const DeltaArchiveManifest&, bool, uint64_t*));
Yifan Hong413d5722019-07-23 14:21:09 -070044 MOCK_METHOD0(GetVirtualAbFeatureFlag, FeatureFlag());
Yifan Honga33bca42019-09-03 20:29:45 -070045 MOCK_METHOD0(FinishUpdate, bool());
Yifan Hong2257ee12020-01-13 18:33:00 -080046 MOCK_METHOD0(CleanupSuccessfulUpdate, ErrorCode());
Yifan Hong90965502020-02-19 15:22:47 -080047 MOCK_METHOD3(GetCleanupPreviousUpdateAction,
48 std::unique_ptr<AbstractAction>(
49 BootControlInterface*,
50 PrefsInterface*,
51 CleanupPreviousUpdateActionDelegateInterface*));
Yifan Hongc049f932019-07-23 15:06:05 -070052};
53
Yifan Hong012508e2019-07-22 18:30:40 -070054class MockDynamicPartitionControlAndroid
55 : public DynamicPartitionControlAndroid {
Yifan Hong537802d2018-08-15 13:15:42 -070056 public:
Yifan Hongaf65ef12018-10-29 11:09:06 -070057 MOCK_METHOD5(MapPartitionOnDeviceMapper,
58 bool(const std::string&,
59 const std::string&,
60 uint32_t,
61 bool,
62 std::string*));
David Anderson4c891c92019-06-21 17:45:23 -070063 MOCK_METHOD1(UnmapPartitionOnDeviceMapper, bool(const std::string&));
Yifan Hong537802d2018-08-15 13:15:42 -070064 MOCK_METHOD0(Cleanup, void());
65 MOCK_METHOD1(DeviceExists, bool(const std::string&));
66 MOCK_METHOD1(GetState, ::android::dm::DmDeviceState(const std::string&));
67 MOCK_METHOD2(GetDmDevicePathByName, bool(const std::string&, std::string*));
Yifan Hong6e706b12018-11-09 16:50:51 -080068 MOCK_METHOD3(LoadMetadataBuilder,
Yifan Hong537802d2018-08-15 13:15:42 -070069 std::unique_ptr<::android::fs_mgr::MetadataBuilder>(
Yifan Hong6e706b12018-11-09 16:50:51 -080070 const std::string&, uint32_t, uint32_t));
Yifan Hong537802d2018-08-15 13:15:42 -070071 MOCK_METHOD3(StoreMetadata,
72 bool(const std::string&,
73 android::fs_mgr::MetadataBuilder*,
74 uint32_t));
75 MOCK_METHOD1(GetDeviceDir, bool(std::string*));
Yifan Hong186bb682019-07-23 14:04:39 -070076 MOCK_METHOD0(GetDynamicPartitionsFeatureFlag, FeatureFlag());
Yifan Hong700d7c12019-07-23 20:49:16 -070077 MOCK_METHOD1(GetSuperPartitionName, std::string(uint32_t));
Yifan Hong413d5722019-07-23 14:21:09 -070078 MOCK_METHOD0(GetVirtualAbFeatureFlag, FeatureFlag());
Yifan Honga33bca42019-09-03 20:29:45 -070079 MOCK_METHOD0(FinishUpdate, bool());
Yifan Hong6eec9952019-12-04 13:12:01 -080080
81 void set_fake_mapped_devices(const std::set<std::string>& fake) override {
82 DynamicPartitionControlAndroid::set_fake_mapped_devices(fake);
83 }
Yifan Hong537802d2018-08-15 13:15:42 -070084};
85
86} // namespace chromeos_update_engine