blob: 0f2133721ad0d6488c7acb0eb632c1fb6f1f15fa [file] [log] [blame]
Kelvin Zhangcfe694f2020-11-13 13:10:42 -05001//
2// Copyright (C) 2020 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#ifndef UPDATE_ENGINE_MOCK_PARTITION_WRITER_H_
18#define UPDATE_ENGINE_MOCK_PARTITION_WRITER_H_
19
20#include <gmock/gmock.h>
21
22#include "common/error_code.h"
23#include "payload_generator/delta_diff_generator.h"
24#include "update_engine/payload_consumer/partition_writer.h"
25
26namespace chromeos_update_engine {
27class MockPartitionWriter : public PartitionWriter {
28 public:
29 MockPartitionWriter() : PartitionWriter({}, {}, nullptr, kBlockSize, false) {}
30 virtual ~MockPartitionWriter() = default;
31
32 // Perform necessary initialization work before InstallOperation can be
33 // applied to this partition
34 MOCK_METHOD(bool, Init, (const InstallPlan*, bool, size_t), (override));
35
36 // |CheckpointUpdateProgress| will be called after SetNextOpIndex(), but it's
37 // optional. DeltaPerformer may or may not call this everytime an operation is
38 // applied.
39 MOCK_METHOD(void, CheckpointUpdateProgress, (size_t), (override));
40
41 // These perform a specific type of operation and return true on success.
42 // |error| will be set if source hash mismatch, otherwise |error| might not be
43 // set even if it fails.
44 MOCK_METHOD(bool,
45 PerformReplaceOperation,
46 (const InstallOperation&, const void*, size_t),
47 (override));
48 MOCK_METHOD(bool,
49 PerformZeroOrDiscardOperation,
50 (const InstallOperation&),
51 (override));
52 MOCK_METHOD(bool,
53 PerformSourceCopyOperation,
54 (const InstallOperation&, ErrorCode*),
55 (override));
56 MOCK_METHOD(bool,
Tianjie8e0090d2021-08-30 22:35:21 -070057 PerformDiffOperation,
Kelvin Zhangcfe694f2020-11-13 13:10:42 -050058 (const InstallOperation&, ErrorCode*, const void*, size_t),
59 (override));
60};
61
62} // namespace chromeos_update_engine
63
64#endif