• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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) { return true; }
32 
33   // Significant methods.
34   MOCK_METHOD1(SetResponse, void(const OmahaResponse& response));
35   MOCK_METHOD0(DownloadComplete, void());
36   MOCK_METHOD1(DownloadProgress, void(size_t count));
37   MOCK_METHOD0(UpdateResumed, void());
38   MOCK_METHOD0(UpdateRestarted, void());
39   MOCK_METHOD0(UpdateSucceeded, void());
40   MOCK_METHOD1(UpdateFailed, void(ErrorCode error));
41   MOCK_METHOD0(ResetUpdateStatus, void());
42   MOCK_METHOD0(ShouldBackoffDownload, bool());
43   MOCK_METHOD0(UpdateEngineStarted, void());
44   MOCK_METHOD0(Rollback, void());
45   MOCK_METHOD1(ExpectRebootInNewVersion,
46                void(const std::string& target_version_uid));
47   MOCK_METHOD0(P2PNewAttempt, void());
48   MOCK_METHOD0(P2PAttemptAllowed, bool());
49   MOCK_METHOD1(SetUsingP2PForDownloading, void(bool value));
50   MOCK_METHOD1(SetUsingP2PForSharing, void(bool value));
51   MOCK_METHOD1(SetScatteringWaitPeriod, void(base::TimeDelta));
52   MOCK_METHOD1(SetP2PUrl, void(const std::string&));
53   MOCK_METHOD0(NextPayload, bool());
54   MOCK_METHOD1(SetStagingWaitPeriod, void(base::TimeDelta));
55 
56   // Getters.
57   MOCK_METHOD0(GetResponseSignature, std::string());
58   MOCK_METHOD0(GetPayloadAttemptNumber, int());
59   MOCK_METHOD0(GetFullPayloadAttemptNumber, int());
60   MOCK_METHOD0(GetCurrentUrl, std::string());
61   MOCK_METHOD0(GetUrlFailureCount, uint32_t());
62   MOCK_METHOD0(GetUrlSwitchCount, uint32_t());
63   MOCK_METHOD0(GetNumResponsesSeen, int());
64   MOCK_METHOD0(GetBackoffExpiryTime, base::Time());
65   MOCK_METHOD0(GetUpdateDuration, base::TimeDelta());
66   MOCK_METHOD0(GetUpdateDurationUptime, base::TimeDelta());
67   MOCK_METHOD1(GetCurrentBytesDownloaded, uint64_t(DownloadSource source));
68   MOCK_METHOD1(GetTotalBytesDownloaded, uint64_t(DownloadSource source));
69   MOCK_METHOD0(GetNumReboots, uint32_t());
70   MOCK_METHOD0(GetRollbackHappened, bool());
71   MOCK_METHOD1(SetRollbackHappened, void(bool));
72   MOCK_METHOD0(GetRollbackVersion, std::string());
73   MOCK_METHOD0(GetP2PNumAttempts, int());
74   MOCK_METHOD0(GetP2PFirstAttemptTimestamp, base::Time());
75   MOCK_CONST_METHOD0(GetUsingP2PForDownloading, bool());
76   MOCK_CONST_METHOD0(GetUsingP2PForSharing, bool());
77   MOCK_METHOD0(GetScatteringWaitPeriod, base::TimeDelta());
78   MOCK_CONST_METHOD0(GetP2PUrl, std::string());
79   MOCK_METHOD0(GetStagingWaitPeriod, base::TimeDelta());
80 };
81 
82 }  // namespace chromeos_update_engine
83 
84 #endif  // UPDATE_ENGINE_MOCK_PAYLOAD_STATE_H_
85