mock_payload_state.h 3.3 KB

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