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