blob: db8e83443962b7a3351403edbce226b70d9fb450 [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>
20#include <string>
21
22#include <gmock/gmock.h>
23
Yifan Hong012508e2019-07-22 18:30:40 -070024#include "update_engine/common/boot_control_interface.h"
Yifan Hong15726b92019-11-05 19:06:48 -080025#include "update_engine/common/dynamic_partition_control_interface.h"
Yifan Hong012508e2019-07-22 18:30:40 -070026#include "update_engine/dynamic_partition_control_android.h"
Yifan Hong537802d2018-08-15 13:15:42 -070027
28namespace chromeos_update_engine {
29
Yifan Hongc049f932019-07-23 15:06:05 -070030class 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());
Yifan Hongc049f932019-07-23 15:06:05 -070039 MOCK_METHOD0(GetDynamicPartitionsFeatureFlag, FeatureFlag());
Yifan Hongf0f4a912019-09-26 17:51:33 -070040 MOCK_METHOD4(PreparePartitionsForUpdate,
41 bool(uint32_t, uint32_t, const DeltaArchiveManifest&, bool));
Yifan Hong413d5722019-07-23 14:21:09 -070042 MOCK_METHOD0(GetVirtualAbFeatureFlag, FeatureFlag());
Yifan Honga33bca42019-09-03 20:29:45 -070043 MOCK_METHOD0(FinishUpdate, bool());
Yifan Hongc049f932019-07-23 15:06:05 -070044};
45
Yifan Hong012508e2019-07-22 18:30:40 -070046class MockDynamicPartitionControlAndroid
47 : public DynamicPartitionControlAndroid {
Yifan Hong537802d2018-08-15 13:15:42 -070048 public:
Yifan Hongaf65ef12018-10-29 11:09:06 -070049 MOCK_METHOD5(MapPartitionOnDeviceMapper,
50 bool(const std::string&,
51 const std::string&,
52 uint32_t,
53 bool,
54 std::string*));
David Anderson4c891c92019-06-21 17:45:23 -070055 MOCK_METHOD1(UnmapPartitionOnDeviceMapper, bool(const std::string&));
Yifan Hong537802d2018-08-15 13:15:42 -070056 MOCK_METHOD0(Cleanup, void());
57 MOCK_METHOD1(DeviceExists, bool(const std::string&));
58 MOCK_METHOD1(GetState, ::android::dm::DmDeviceState(const std::string&));
59 MOCK_METHOD2(GetDmDevicePathByName, bool(const std::string&, std::string*));
Yifan Hong6e706b12018-11-09 16:50:51 -080060 MOCK_METHOD3(LoadMetadataBuilder,
Yifan Hong537802d2018-08-15 13:15:42 -070061 std::unique_ptr<::android::fs_mgr::MetadataBuilder>(
Yifan Hong6e706b12018-11-09 16:50:51 -080062 const std::string&, uint32_t, uint32_t));
Yifan Hong537802d2018-08-15 13:15:42 -070063 MOCK_METHOD3(StoreMetadata,
64 bool(const std::string&,
65 android::fs_mgr::MetadataBuilder*,
66 uint32_t));
67 MOCK_METHOD1(GetDeviceDir, bool(std::string*));
Yifan Hong186bb682019-07-23 14:04:39 -070068 MOCK_METHOD0(GetDynamicPartitionsFeatureFlag, FeatureFlag());
Yifan Hong700d7c12019-07-23 20:49:16 -070069 MOCK_METHOD1(GetSuperPartitionName, std::string(uint32_t));
Yifan Hong413d5722019-07-23 14:21:09 -070070 MOCK_METHOD0(GetVirtualAbFeatureFlag, FeatureFlag());
Yifan Honga33bca42019-09-03 20:29:45 -070071 MOCK_METHOD0(FinishUpdate, bool());
Yifan Hong537802d2018-08-15 13:15:42 -070072};
73
74} // namespace chromeos_update_engine