blob: ad22de5242dfecd6b26fa57c63f0df865f4107bd [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
2// Copyright (C) 2012 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//
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080016
Gilad Arnoldcf175a02014-07-10 16:48:47 -070017#ifndef UPDATE_ENGINE_MOCK_PAYLOAD_STATE_H_
18#define UPDATE_ENGINE_MOCK_PAYLOAD_STATE_H_
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080019
Alex Vakulenkod2779df2014-06-16 13:19:00 -070020#include <string>
21
Alex Deymo8427b4a2014-11-05 14:00:32 -080022#include <gmock/gmock.h>
23
Jay Srinivasan2b5a0f02012-12-19 17:25:56 -080024#include "update_engine/omaha_request_action.h"
25#include "update_engine/payload_state_interface.h"
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080026
27namespace chromeos_update_engine {
28
Amin Hassani7cc8bb02019-01-14 16:29:47 -080029class MockPayloadState : public PayloadStateInterface {
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080030 public:
Amin Hassani7cc8bb02019-01-14 16:29:47 -080031 bool Initialize(SystemState* system_state) { return true; }
Jay Srinivasan2b5a0f02012-12-19 17:25:56 -080032
Jay Srinivasan08262882012-12-28 19:29:43 -080033 // Significant methods.
Jay Srinivasan2b5a0f02012-12-19 17:25:56 -080034 MOCK_METHOD1(SetResponse, void(const OmahaResponse& response));
35 MOCK_METHOD0(DownloadComplete, void());
36 MOCK_METHOD1(DownloadProgress, void(size_t count));
Chris Sosabe45bef2013-04-09 18:25:12 -070037 MOCK_METHOD0(UpdateResumed, void());
Jay Srinivasan19409b72013-04-12 19:23:36 -070038 MOCK_METHOD0(UpdateRestarted, void());
David Zeuthen9a017f22013-04-11 16:10:26 -070039 MOCK_METHOD0(UpdateSucceeded, void());
David Zeuthena99981f2013-04-29 13:42:47 -070040 MOCK_METHOD1(UpdateFailed, void(ErrorCode error));
Alex Deymo42432912013-07-12 20:21:15 -070041 MOCK_METHOD0(ResetUpdateStatus, void());
Jay Srinivasan08262882012-12-28 19:29:43 -080042 MOCK_METHOD0(ShouldBackoffDownload, bool());
David Zeuthene4c58bf2013-06-18 17:26:50 -070043 MOCK_METHOD0(UpdateEngineStarted, void());
Chris Sosaaa18e162013-06-20 13:20:30 -070044 MOCK_METHOD0(Rollback, void());
Alex Deymo42432912013-07-12 20:21:15 -070045 MOCK_METHOD1(ExpectRebootInNewVersion,
46 void(const std::string& target_version_uid));
David Zeuthenbb8bdc72013-09-03 13:43:48 -070047 MOCK_METHOD0(P2PNewAttempt, void());
48 MOCK_METHOD0(P2PAttemptAllowed, bool());
Gilad Arnoldcf175a02014-07-10 16:48:47 -070049 MOCK_METHOD1(SetUsingP2PForDownloading, void(bool value));
Gilad Arnold74b5f552014-10-07 08:17:16 -070050 MOCK_METHOD1(SetUsingP2PForSharing, void(bool value));
Gilad Arnold519cfc72014-10-02 10:34:54 -070051 MOCK_METHOD1(SetScatteringWaitPeriod, void(base::TimeDelta));
Gilad Arnold74b5f552014-10-07 08:17:16 -070052 MOCK_METHOD1(SetP2PUrl, void(const std::string&));
Sen Jiang6c736682017-03-10 15:01:36 -080053 MOCK_METHOD0(NextPayload, bool());
Adolfo Victoriad3a1e352018-07-16 11:40:47 -070054 MOCK_METHOD1(SetStagingWaitPeriod, void(base::TimeDelta));
Jay Srinivasan08262882012-12-28 19:29:43 -080055
56 // Getters.
57 MOCK_METHOD0(GetResponseSignature, std::string());
Alex Deymo820cc702013-06-28 15:43:46 -070058 MOCK_METHOD0(GetPayloadAttemptNumber, int());
59 MOCK_METHOD0(GetFullPayloadAttemptNumber, int());
Jay Srinivasan53173b92013-05-17 17:13:01 -070060 MOCK_METHOD0(GetCurrentUrl, std::string());
Jay Srinivasan2b5a0f02012-12-19 17:25:56 -080061 MOCK_METHOD0(GetUrlFailureCount, uint32_t());
David Zeuthencc6f9962013-04-18 11:57:24 -070062 MOCK_METHOD0(GetUrlSwitchCount, uint32_t());
David Zeuthena573d6f2013-06-14 16:13:36 -070063 MOCK_METHOD0(GetNumResponsesSeen, int());
Jay Srinivasan08262882012-12-28 19:29:43 -080064 MOCK_METHOD0(GetBackoffExpiryTime, base::Time());
David Zeuthen9a017f22013-04-11 16:10:26 -070065 MOCK_METHOD0(GetUpdateDuration, base::TimeDelta());
66 MOCK_METHOD0(GetUpdateDurationUptime, base::TimeDelta());
Jay Srinivasan19409b72013-04-12 19:23:36 -070067 MOCK_METHOD1(GetCurrentBytesDownloaded, uint64_t(DownloadSource source));
68 MOCK_METHOD1(GetTotalBytesDownloaded, uint64_t(DownloadSource source));
Chris Sosabe45bef2013-04-09 18:25:12 -070069 MOCK_METHOD0(GetNumReboots, uint32_t());
Marton Hunyadye58bddb2018-04-10 20:27:26 +020070 MOCK_METHOD0(GetRollbackHappened, bool());
71 MOCK_METHOD1(SetRollbackHappened, void(bool));
Chris Sosaaa18e162013-06-20 13:20:30 -070072 MOCK_METHOD0(GetRollbackVersion, std::string());
David Zeuthenbb8bdc72013-09-03 13:43:48 -070073 MOCK_METHOD0(GetP2PNumAttempts, int());
74 MOCK_METHOD0(GetP2PFirstAttemptTimestamp, base::Time());
Gilad Arnold74b5f552014-10-07 08:17:16 -070075 MOCK_CONST_METHOD0(GetUsingP2PForDownloading, bool());
76 MOCK_CONST_METHOD0(GetUsingP2PForSharing, bool());
Gilad Arnold519cfc72014-10-02 10:34:54 -070077 MOCK_METHOD0(GetScatteringWaitPeriod, base::TimeDelta());
Gilad Arnold74b5f552014-10-07 08:17:16 -070078 MOCK_CONST_METHOD0(GetP2PUrl, std::string());
Adolfo Victoriad3a1e352018-07-16 11:40:47 -070079 MOCK_METHOD0(GetStagingWaitPeriod, base::TimeDelta());
Jay Srinivasan6f6ea002012-12-14 11:26:28 -080080};
81
82} // namespace chromeos_update_engine
83
Gilad Arnoldcf175a02014-07-10 16:48:47 -070084#endif // UPDATE_ENGINE_MOCK_PAYLOAD_STATE_H_