1 // 2 // Copyright (C) 2014 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_UPDATE_MANAGER_FAKE_UPDATER_PROVIDER_H_ 18 #define UPDATE_ENGINE_UPDATE_MANAGER_FAKE_UPDATER_PROVIDER_H_ 19 20 #include <string> 21 22 #include "update_engine/update_manager/fake_variable.h" 23 #include "update_engine/update_manager/updater_provider.h" 24 25 namespace chromeos_update_manager { 26 27 // Fake implementation of the UpdaterProvider base class. 28 class FakeUpdaterProvider : public UpdaterProvider { 29 public: FakeUpdaterProvider()30 FakeUpdaterProvider() {} 31 var_updater_started_time()32 FakeVariable<base::Time>* var_updater_started_time() override { 33 return &var_updater_started_time_; 34 } 35 var_last_checked_time()36 FakeVariable<base::Time>* var_last_checked_time() override { 37 return &var_last_checked_time_; 38 } 39 var_update_completed_time()40 FakeVariable<base::Time>* var_update_completed_time() override { 41 return &var_update_completed_time_; 42 } 43 var_progress()44 FakeVariable<double>* var_progress() override { return &var_progress_; } 45 var_stage()46 FakeVariable<Stage>* var_stage() override { return &var_stage_; } 47 var_new_version()48 FakeVariable<std::string>* var_new_version() override { 49 return &var_new_version_; 50 } 51 var_payload_size()52 FakeVariable<uint64_t>* var_payload_size() override { 53 return &var_payload_size_; 54 } 55 var_curr_channel()56 FakeVariable<std::string>* var_curr_channel() override { 57 return &var_curr_channel_; 58 } 59 var_new_channel()60 FakeVariable<std::string>* var_new_channel() override { 61 return &var_new_channel_; 62 } 63 var_p2p_enabled()64 FakeVariable<bool>* var_p2p_enabled() override { return &var_p2p_enabled_; } 65 var_cellular_enabled()66 FakeVariable<bool>* var_cellular_enabled() override { 67 return &var_cellular_enabled_; 68 } 69 var_consecutive_failed_update_checks()70 FakeVariable<unsigned int>* var_consecutive_failed_update_checks() override { 71 return &var_consecutive_failed_update_checks_; 72 } 73 var_server_dictated_poll_interval()74 FakeVariable<unsigned int>* var_server_dictated_poll_interval() override { 75 return &var_server_dictated_poll_interval_; 76 } 77 var_forced_update_requested()78 FakeVariable<UpdateRequestStatus>* var_forced_update_requested() override { 79 return &var_forced_update_requested_; 80 } 81 var_update_restrictions()82 FakeVariable<UpdateRestrictions>* var_update_restrictions() override { 83 return &var_update_restrictions_; 84 } 85 var_test_update_check_interval_timeout()86 FakeVariable<int64_t>* var_test_update_check_interval_timeout() override { 87 return &var_test_update_check_interval_timeout_; 88 } 89 90 private: 91 FakeVariable<base::Time> var_updater_started_time_{"updater_started_time", 92 kVariableModePoll}; 93 FakeVariable<base::Time> var_last_checked_time_{"last_checked_time", 94 kVariableModePoll}; 95 FakeVariable<base::Time> var_update_completed_time_{"update_completed_time", 96 kVariableModePoll}; 97 FakeVariable<double> var_progress_{"progress", kVariableModePoll}; 98 FakeVariable<Stage> var_stage_{"stage", kVariableModePoll}; 99 FakeVariable<std::string> var_new_version_{"new_version", kVariableModePoll}; 100 FakeVariable<uint64_t> var_payload_size_{"payload_size", kVariableModePoll}; 101 FakeVariable<std::string> var_curr_channel_{"curr_channel", 102 kVariableModePoll}; 103 FakeVariable<std::string> var_new_channel_{"new_channel", kVariableModePoll}; 104 FakeVariable<bool> var_p2p_enabled_{"p2p_enabled", kVariableModeAsync}; 105 FakeVariable<bool> var_cellular_enabled_{"cellular_enabled", 106 kVariableModeAsync}; 107 FakeVariable<unsigned int> var_consecutive_failed_update_checks_{ 108 "consecutive_failed_update_checks", kVariableModePoll}; 109 FakeVariable<unsigned int> var_server_dictated_poll_interval_{ 110 "server_dictated_poll_interval", kVariableModePoll}; 111 FakeVariable<UpdateRequestStatus> var_forced_update_requested_{ 112 "forced_update_requested", kVariableModeAsync}; 113 FakeVariable<UpdateRestrictions> var_update_restrictions_{ 114 "update_restrictions", kVariableModePoll}; 115 FakeVariable<int64_t> var_test_update_check_interval_timeout_{ 116 "test_update_check_interval_timeout", kVariableModePoll}; 117 118 DISALLOW_COPY_AND_ASSIGN(FakeUpdaterProvider); 119 }; 120 121 } // namespace chromeos_update_manager 122 123 #endif // UPDATE_ENGINE_UPDATE_MANAGER_FAKE_UPDATER_PROVIDER_H_ 124