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: 31 FakeDevicePolicyProvider() {} 32 33 FakeVariable<bool>* var_device_policy_is_loaded() override { 34 return &var_device_policy_is_loaded_; 35 } 36 37 FakeVariable<std::string>* var_release_channel() override { 38 return &var_release_channel_; 39 } 40 41 FakeVariable<bool>* var_release_channel_delegated() override { 42 return &var_release_channel_delegated_; 43 } 44 45 FakeVariable<bool>* var_update_disabled() override { 46 return &var_update_disabled_; 47 } 48 49 FakeVariable<std::string>* var_target_version_prefix() override { 50 return &var_target_version_prefix_; 51 } 52 53 FakeVariable<RollbackToTargetVersion>* var_rollback_to_target_version() 54 override { 55 return &var_rollback_to_target_version_; 56 } 57 58 FakeVariable<int>* var_rollback_allowed_milestones() override { 59 return &var_rollback_allowed_milestones_; 60 } 61 62 FakeVariable<base::TimeDelta>* var_scatter_factor() override { 63 return &var_scatter_factor_; 64 } 65 66 FakeVariable<std::set<chromeos_update_engine::ConnectionType>>* 67 var_allowed_connection_types_for_update() override { 68 return &var_allowed_connection_types_for_update_; 69 } 70 71 FakeVariable<std::string>* var_owner() override { return &var_owner_; } 72 73 FakeVariable<bool>* var_http_downloads_enabled() override { 74 return &var_http_downloads_enabled_; 75 } 76 77 FakeVariable<bool>* var_au_p2p_enabled() override { 78 return &var_au_p2p_enabled_; 79 } 80 81 FakeVariable<bool>* var_allow_kiosk_app_control_chrome_version() override { 82 return &var_allow_kiosk_app_control_chrome_version_; 83 } 84 85 FakeVariable<std::string>* var_auto_launched_kiosk_app_id() override { 86 return &var_auto_launched_kiosk_app_id_; 87 } 88 89 FakeVariable<WeeklyTimeIntervalVector>* var_disallowed_time_intervals() 90 override { 91 return &var_disallowed_time_intervals_; 92 } 93 94 private: 95 FakeVariable<bool> var_device_policy_is_loaded_{"policy_is_loaded", 96 kVariableModePoll}; 97 FakeVariable<std::string> var_release_channel_{"release_channel", 98 kVariableModePoll}; 99 FakeVariable<bool> var_release_channel_delegated_{"release_channel_delegated", 100 kVariableModePoll}; 101 FakeVariable<bool> var_update_disabled_{"update_disabled", kVariableModePoll}; 102 FakeVariable<std::string> var_target_version_prefix_{"target_version_prefix", 103 kVariableModePoll}; 104 FakeVariable<RollbackToTargetVersion> var_rollback_to_target_version_{ 105 "rollback_to_target_version", kVariableModePoll}; 106 FakeVariable<int> var_rollback_allowed_milestones_{ 107 "rollback_allowed_milestones", kVariableModePoll}; 108 FakeVariable<base::TimeDelta> var_scatter_factor_{"scatter_factor", 109 kVariableModePoll}; 110 FakeVariable<std::set<chromeos_update_engine::ConnectionType>> 111 var_allowed_connection_types_for_update_{ 112 "allowed_connection_types_for_update", kVariableModePoll}; 113 FakeVariable<std::string> var_owner_{"owner", kVariableModePoll}; 114 FakeVariable<bool> var_http_downloads_enabled_{"http_downloads_enabled", 115 kVariableModePoll}; 116 FakeVariable<bool> var_au_p2p_enabled_{"au_p2p_enabled", kVariableModePoll}; 117 FakeVariable<bool> var_allow_kiosk_app_control_chrome_version_{ 118 "allow_kiosk_app_control_chrome_version", kVariableModePoll}; 119 FakeVariable<std::string> var_auto_launched_kiosk_app_id_{ 120 "auto_launched_kiosk_app_id", kVariableModePoll}; 121 FakeVariable<WeeklyTimeIntervalVector> var_disallowed_time_intervals_{ 122 "disallowed_time_intervals", kVariableModePoll}; 123 124 DISALLOW_COPY_AND_ASSIGN(FakeDevicePolicyProvider); 125 }; 126 127 } // namespace chromeos_update_manager 128 129 #endif // UPDATE_ENGINE_UPDATE_MANAGER_FAKE_DEVICE_POLICY_PROVIDER_H_ 130