• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_DEVICE_POLICY_PROVIDER_H_
18 #define UPDATE_ENGINE_UPDATE_MANAGER_FAKE_DEVICE_POLICY_PROVIDER_H_
19 
20 #include <set>
21 #include <string>
22 
23 #include "update_engine/update_manager/device_policy_provider.h"
24 #include "update_engine/update_manager/fake_variable.h"
25 
26 namespace chromeos_update_manager {
27 
28 // Fake implementation of the DevicePolicyProvider base class.
29 class FakeDevicePolicyProvider : public DevicePolicyProvider {
30  public:
FakeDevicePolicyProvider()31   FakeDevicePolicyProvider() {}
32 
var_device_policy_is_loaded()33   FakeVariable<bool>* var_device_policy_is_loaded() override {
34     return &var_device_policy_is_loaded_;
35   }
36 
var_release_channel()37   FakeVariable<std::string>* var_release_channel() override {
38     return &var_release_channel_;
39   }
40 
var_release_channel_delegated()41   FakeVariable<bool>* var_release_channel_delegated() override {
42     return &var_release_channel_delegated_;
43   }
44 
var_release_lts_tag()45   FakeVariable<std::string>* var_release_lts_tag() override {
46     return &var_release_lts_tag_;
47   }
48 
var_update_disabled()49   FakeVariable<bool>* var_update_disabled() override {
50     return &var_update_disabled_;
51   }
52 
var_target_version_prefix()53   FakeVariable<std::string>* var_target_version_prefix() override {
54     return &var_target_version_prefix_;
55   }
56 
var_rollback_to_target_version()57   FakeVariable<RollbackToTargetVersion>* var_rollback_to_target_version()
58       override {
59     return &var_rollback_to_target_version_;
60   }
61 
var_rollback_allowed_milestones()62   FakeVariable<int>* var_rollback_allowed_milestones() override {
63     return &var_rollback_allowed_milestones_;
64   }
65 
var_scatter_factor()66   FakeVariable<base::TimeDelta>* var_scatter_factor() override {
67     return &var_scatter_factor_;
68   }
69 
70   FakeVariable<std::set<chromeos_update_engine::ConnectionType>>*
var_allowed_connection_types_for_update()71   var_allowed_connection_types_for_update() override {
72     return &var_allowed_connection_types_for_update_;
73   }
74 
var_has_owner()75   FakeVariable<bool>* var_has_owner() override { return &var_has_owner_; }
76 
var_http_downloads_enabled()77   FakeVariable<bool>* var_http_downloads_enabled() override {
78     return &var_http_downloads_enabled_;
79   }
80 
var_au_p2p_enabled()81   FakeVariable<bool>* var_au_p2p_enabled() override {
82     return &var_au_p2p_enabled_;
83   }
84 
var_allow_kiosk_app_control_chrome_version()85   FakeVariable<bool>* var_allow_kiosk_app_control_chrome_version() override {
86     return &var_allow_kiosk_app_control_chrome_version_;
87   }
88 
var_auto_launched_kiosk_app_id()89   FakeVariable<std::string>* var_auto_launched_kiosk_app_id() override {
90     return &var_auto_launched_kiosk_app_id_;
91   }
92 
var_disallowed_time_intervals()93   FakeVariable<WeeklyTimeIntervalVector>* var_disallowed_time_intervals()
94       override {
95     return &var_disallowed_time_intervals_;
96   }
97 
var_channel_downgrade_behavior()98   FakeVariable<ChannelDowngradeBehavior>* var_channel_downgrade_behavior()
99       override {
100     return &var_channel_downgrade_behavior_;
101   }
102 
var_device_minimum_version()103   FakeVariable<base::Version>* var_device_minimum_version() override {
104     return &var_device_minimum_version_;
105   }
106 
var_quick_fix_build_token()107   FakeVariable<std::string>* var_quick_fix_build_token() override {
108     return &var_quick_fix_build_token_;
109   }
110 
111  private:
112   FakeVariable<bool> var_device_policy_is_loaded_{"policy_is_loaded",
113                                                   kVariableModePoll};
114   FakeVariable<std::string> var_release_channel_{"release_channel",
115                                                  kVariableModePoll};
116   FakeVariable<bool> var_release_channel_delegated_{"release_channel_delegated",
117                                                     kVariableModePoll};
118   FakeVariable<std::string> var_release_lts_tag_{"release_lts_tag",
119                                                  kVariableModePoll};
120   FakeVariable<bool> var_update_disabled_{"update_disabled", kVariableModePoll};
121   FakeVariable<std::string> var_target_version_prefix_{"target_version_prefix",
122                                                        kVariableModePoll};
123   FakeVariable<RollbackToTargetVersion> var_rollback_to_target_version_{
124       "rollback_to_target_version", kVariableModePoll};
125   FakeVariable<int> var_rollback_allowed_milestones_{
126       "rollback_allowed_milestones", kVariableModePoll};
127   FakeVariable<base::TimeDelta> var_scatter_factor_{"scatter_factor",
128                                                     kVariableModePoll};
129   FakeVariable<std::set<chromeos_update_engine::ConnectionType>>
130       var_allowed_connection_types_for_update_{
131           "allowed_connection_types_for_update", kVariableModePoll};
132   FakeVariable<bool> var_has_owner_{"owner", kVariableModePoll};
133   FakeVariable<bool> var_http_downloads_enabled_{"http_downloads_enabled",
134                                                  kVariableModePoll};
135   FakeVariable<bool> var_au_p2p_enabled_{"au_p2p_enabled", kVariableModePoll};
136   FakeVariable<bool> var_allow_kiosk_app_control_chrome_version_{
137       "allow_kiosk_app_control_chrome_version", kVariableModePoll};
138   FakeVariable<std::string> var_auto_launched_kiosk_app_id_{
139       "auto_launched_kiosk_app_id", kVariableModePoll};
140   FakeVariable<WeeklyTimeIntervalVector> var_disallowed_time_intervals_{
141       "disallowed_time_intervals", kVariableModeAsync};
142   FakeVariable<ChannelDowngradeBehavior> var_channel_downgrade_behavior_{
143       "channel_downgrade_behavior", kVariableModePoll};
144   FakeVariable<base::Version> var_device_minimum_version_{
145       "device_minimum_version", kVariableModePoll};
146   FakeVariable<std::string> var_quick_fix_build_token_{"quick_fix_build_token",
147                                                        kVariableModePoll};
148 
149   DISALLOW_COPY_AND_ASSIGN(FakeDevicePolicyProvider);
150 };
151 
152 }  // namespace chromeos_update_manager
153 
154 #endif  // UPDATE_ENGINE_UPDATE_MANAGER_FAKE_DEVICE_POLICY_PROVIDER_H_
155