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 #include <payload_consumer/file_descriptor.h> 19 20 #include <gmock/gmock.h> 21 22 namespace android::snapshot { 23 24 class MockSnapshotManager : public ISnapshotManager { 25 public: 26 MOCK_METHOD(bool, BeginUpdate, (), (override)); 27 MOCK_METHOD(bool, CancelUpdate, (), (override)); 28 MOCK_METHOD(bool, FinishedSnapshotWrites, (bool wipe), (override)); 29 MOCK_METHOD(void, UpdateCowStats, (ISnapshotMergeStats * stats), (override)); 30 MOCK_METHOD(MergeFailureCode, ReadMergeFailureCode, (), (override)); 31 MOCK_METHOD(bool, InitiateMerge, (), (override)); 32 33 MOCK_METHOD(UpdateState, ProcessUpdateState, 34 (const std::function<bool()>& callback, const std::function<bool()>& before_cancel), 35 (override)); 36 MOCK_METHOD(UpdateState, GetUpdateState, (double* progress), (override)); 37 MOCK_METHOD(bool, UpdateUsesCompression, (), (override)); 38 MOCK_METHOD(Return, CreateUpdateSnapshots, 39 (const chromeos_update_engine::DeltaArchiveManifest& manifest), (override)); 40 MOCK_METHOD(bool, MapUpdateSnapshot, 41 (const android::fs_mgr::CreateLogicalPartitionParams& params, 42 std::string* snapshot_path), 43 (override)); 44 MOCK_METHOD(std::unique_ptr<ISnapshotWriter>, OpenSnapshotWriter, 45 (const android::fs_mgr::CreateLogicalPartitionParams& params, 46 const std::optional<std::string>&), 47 (override)); 48 MOCK_METHOD(bool, UnmapUpdateSnapshot, (const std::string& target_partition_name), (override)); 49 MOCK_METHOD(bool, NeedSnapshotsInFirstStageMount, (), (override)); 50 MOCK_METHOD(bool, CreateLogicalAndSnapshotPartitions, 51 (const std::string& super_device, const std::chrono::milliseconds& timeout_ms), 52 (override)); 53 MOCK_METHOD(bool, MapAllSnapshots, (const std::chrono::milliseconds& timeout_ms), (override)); 54 MOCK_METHOD(bool, UnmapAllSnapshots, (), (override)); 55 MOCK_METHOD(bool, HandleImminentDataWipe, (const std::function<void()>& callback), (override)); 56 MOCK_METHOD(bool, FinishMergeInRecovery, (), (override)); 57 MOCK_METHOD(CreateResult, RecoveryCreateSnapshotDevices, (), (override)); 58 MOCK_METHOD(CreateResult, RecoveryCreateSnapshotDevices, 59 (const std::unique_ptr<AutoDevice>& metadata_device), (override)); 60 MOCK_METHOD(bool, Dump, (std::ostream & os), (override)); 61 MOCK_METHOD(std::unique_ptr<AutoDevice>, EnsureMetadataMounted, (), (override)); 62 MOCK_METHOD(ISnapshotMergeStats*, GetSnapshotMergeStatsInstance, (), (override)); 63 MOCK_METHOD(std::string, ReadSourceBuildFingerprint, (), (override)); 64 }; 65 66 } // namespace android::snapshot 67