1 //
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 //
16 
17 #ifndef UPDATE_ENGINE_MOCK_PAYLOAD_STATE_H_
18 #define UPDATE_ENGINE_MOCK_PAYLOAD_STATE_H_
19 
20 #include <string>
21 
22 #include <gmock/gmock.h>
23 
24 #include "update_engine/omaha_request_action.h"
25 #include "update_engine/payload_state_interface.h"
26 
27 namespace chromeos_update_engine {
28 
29 class MockPayloadState: public PayloadStateInterface {
30  public:
Initialize(SystemState * system_state)31   bool Initialize(SystemState* system_state) {
32     return true;
33   }
34 
35   // Significant methods.
36   MOCK_METHOD1(SetResponse, void(const OmahaResponse& response));
37   MOCK_METHOD0(DownloadComplete, void());
38   MOCK_METHOD1(DownloadProgress, void(size_t count));
39   MOCK_METHOD0(UpdateResumed, void());
40   MOCK_METHOD0(UpdateRestarted, void());
41   MOCK_METHOD0(UpdateSucceeded, void());
42   MOCK_METHOD1(UpdateFailed, void(ErrorCode error));
43   MOCK_METHOD0(ResetUpdateStatus, void());
44   MOCK_METHOD0(ShouldBackoffDownload, bool());
45   MOCK_METHOD0(UpdateEngineStarted, void());
46   MOCK_METHOD0(Rollback, void());
47   MOCK_METHOD1(ExpectRebootInNewVersion,
48                void(const std::string& target_version_uid));
49   MOCK_METHOD0(P2PNewAttempt, void());
50   MOCK_METHOD0(P2PAttemptAllowed, bool());
51   MOCK_METHOD1(SetUsingP2PForDownloading, void(bool value));
52   MOCK_METHOD1(SetUsingP2PForSharing, void(bool value));
53   MOCK_METHOD1(SetScatteringWaitPeriod, void(base::TimeDelta));
54   MOCK_METHOD1(SetP2PUrl, void(const std::string&));
55   MOCK_METHOD0(NextPayload, bool());
56 
57   // Getters.
58   MOCK_METHOD0(GetResponseSignature, std::string());
59   MOCK_METHOD0(GetPayloadAttemptNumber, int());
60   MOCK_METHOD0(GetFullPayloadAttemptNumber, int());
61   MOCK_METHOD0(GetCurrentUrl, std::string());
62   MOCK_METHOD0(GetUrlFailureCount, uint32_t());
63   MOCK_METHOD0(GetUrlSwitchCount, uint32_t());
64   MOCK_METHOD0(GetNumResponsesSeen, int());
65   MOCK_METHOD0(GetBackoffExpiryTime, base::Time());
66   MOCK_METHOD0(GetUpdateDuration, base::TimeDelta());
67   MOCK_METHOD0(GetUpdateDurationUptime, base::TimeDelta());
68   MOCK_METHOD1(GetCurrentBytesDownloaded, uint64_t(DownloadSource source));
69   MOCK_METHOD1(GetTotalBytesDownloaded, uint64_t(DownloadSource source));
70   MOCK_METHOD0(GetNumReboots, uint32_t());
71   MOCK_METHOD0(GetRollbackVersion, std::string());
72   MOCK_METHOD0(GetP2PNumAttempts, int());
73   MOCK_METHOD0(GetP2PFirstAttemptTimestamp, base::Time());
74   MOCK_CONST_METHOD0(GetUsingP2PForDownloading, bool());
75   MOCK_CONST_METHOD0(GetUsingP2PForSharing, bool());
76   MOCK_METHOD0(GetScatteringWaitPeriod, base::TimeDelta());
77   MOCK_CONST_METHOD0(GetP2PUrl, std::string());
78   MOCK_CONST_METHOD0(GetAttemptErrorCode, ErrorCode());
79 };
80 
81 }  // namespace chromeos_update_engine
82 
83 #endif  // UPDATE_ENGINE_MOCK_PAYLOAD_STATE_H_
84