1 // Copyright (C) 2020 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //      http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #include <libsnapshot/snapshot.h>
18 
19 #include <gmock/gmock.h>
20 
21 namespace android::snapshot {
22 
23 class MockSnapshotManager : public ISnapshotManager {
24   public:
25     MOCK_METHOD(bool, BeginUpdate, (), (override));
26     MOCK_METHOD(bool, CancelUpdate, (), (override));
27     MOCK_METHOD(bool, FinishedSnapshotWrites, (bool wipe), (override));
28     MOCK_METHOD(bool, InitiateMerge, (uint64_t * cow_file_size), (override));
29 
30     MOCK_METHOD(UpdateState, ProcessUpdateState,
31                 (const std::function<bool()>& callback, const std::function<bool()>& before_cancel),
32                 (override));
33     MOCK_METHOD(UpdateState, GetUpdateState, (double* progress), (override));
34     MOCK_METHOD(Return, CreateUpdateSnapshots,
35                 (const chromeos_update_engine::DeltaArchiveManifest& manifest), (override));
36     MOCK_METHOD(bool, MapUpdateSnapshot,
37                 (const android::fs_mgr::CreateLogicalPartitionParams& params,
38                  std::string* snapshot_path),
39                 (override));
40     MOCK_METHOD(bool, UnmapUpdateSnapshot, (const std::string& target_partition_name), (override));
41     MOCK_METHOD(bool, NeedSnapshotsInFirstStageMount, (), (override));
42     MOCK_METHOD(bool, CreateLogicalAndSnapshotPartitions,
43                 (const std::string& super_device, const std::chrono::milliseconds& timeout_ms),
44                 (override));
45     MOCK_METHOD(bool, HandleImminentDataWipe, (const std::function<void()>& callback), (override));
46     MOCK_METHOD(bool, FinishMergeInRecovery, (), (override));
47     MOCK_METHOD(CreateResult, RecoveryCreateSnapshotDevices, (), (override));
48     MOCK_METHOD(CreateResult, RecoveryCreateSnapshotDevices,
49                 (const std::unique_ptr<AutoDevice>& metadata_device), (override));
50     MOCK_METHOD(bool, Dump, (std::ostream & os), (override));
51     MOCK_METHOD(std::unique_ptr<AutoDevice>, EnsureMetadataMounted, (), (override));
52     MOCK_METHOD(ISnapshotMergeStats*, GetSnapshotMergeStatsInstance, (), (override));
53 };
54 
55 }  // namespace android::snapshot
56