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