Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_TEST_H_ | 5 #ifndef CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_TEST_H_ |
| 6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_TEST_H_ | 6 #define CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_TEST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 // Policy definition list that contains entries for the keys above. | 41 // Policy definition list that contains entries for the keys above. |
| 42 extern const PolicyDefinitionList kList; | 42 extern const PolicyDefinitionList kList; |
| 43 | 43 |
| 44 } // namespace test_policy_definitions | 44 } // namespace test_policy_definitions |
| 45 | 45 |
| 46 // An interface for creating a test policy provider and creating a policy | 46 // An interface for creating a test policy provider and creating a policy |
| 47 // provider instance for testing. Used as the parameter to the abstract | 47 // provider instance for testing. Used as the parameter to the abstract |
| 48 // ConfigurationPolicyProviderTest below. | 48 // ConfigurationPolicyProviderTest below. |
| 49 class PolicyProviderTestHarness { | 49 class PolicyProviderTestHarness { |
| 50 public: | 50 public: |
| 51 PolicyProviderTestHarness(); | 51 // |level| and |scope| are the level and scope of the policies returned by |
| 52 // the providers from CreateProvider(). | |
| 53 PolicyProviderTestHarness(PolicyLevel level, PolicyScope scope); | |
| 52 virtual ~PolicyProviderTestHarness(); | 54 virtual ~PolicyProviderTestHarness(); |
| 53 | 55 |
| 54 // Actions to run at gtest SetUp() time. | 56 // Actions to run at gtest SetUp() time. |
| 55 virtual void SetUp() = 0; | 57 virtual void SetUp() = 0; |
| 56 | 58 |
| 57 // Create a new policy provider. | 59 // Create a new policy provider. |
| 58 virtual AsynchronousPolicyProvider* CreateProvider( | 60 virtual AsynchronousPolicyProvider* CreateProvider( |
| 59 const PolicyDefinitionList* policy_definition_list) = 0; | 61 const PolicyDefinitionList* policy_definition_list) = 0; |
| 60 | 62 |
| 63 // Returns the policy level and scope set by the policy provider. | |
| 64 virtual PolicyLevel GetPolicyLevel() const; | |
|
Mattias Nissler (ping if slow)
2012/05/15 17:07:24
no need to make these virtual any longer, and the
Joao da Silva
2012/05/16 10:25:44
Done.
| |
| 65 virtual PolicyScope GetPolicyScope() const; | |
| 66 | |
| 61 // Helpers to configure the environment the policy provider reads from. | 67 // Helpers to configure the environment the policy provider reads from. |
| 62 virtual void InstallEmptyPolicy() = 0; | 68 virtual void InstallEmptyPolicy() = 0; |
| 63 virtual void InstallStringPolicy(const std::string& policy_name, | 69 virtual void InstallStringPolicy(const std::string& policy_name, |
| 64 const std::string& policy_value) = 0; | 70 const std::string& policy_value) = 0; |
| 65 virtual void InstallIntegerPolicy(const std::string& policy_name, | 71 virtual void InstallIntegerPolicy(const std::string& policy_name, |
| 66 int policy_value) = 0; | 72 int policy_value) = 0; |
| 67 virtual void InstallBooleanPolicy(const std::string& policy_name, | 73 virtual void InstallBooleanPolicy(const std::string& policy_name, |
| 68 bool policy_value) = 0; | 74 bool policy_value) = 0; |
| 69 virtual void InstallStringListPolicy(const std::string& policy_name, | 75 virtual void InstallStringListPolicy(const std::string& policy_name, |
| 70 const base::ListValue* policy_value) = 0; | 76 const base::ListValue* policy_value) = 0; |
| 71 virtual void InstallDictionaryPolicy( | 77 virtual void InstallDictionaryPolicy( |
| 72 const std::string& policy_name, | 78 const std::string& policy_name, |
| 73 const base::DictionaryValue* policy_value) = 0; | 79 const base::DictionaryValue* policy_value) = 0; |
| 74 | 80 |
| 75 private: | 81 private: |
| 82 PolicyLevel level_; | |
| 83 PolicyScope scope_; | |
| 84 | |
| 76 DISALLOW_COPY_AND_ASSIGN(PolicyProviderTestHarness); | 85 DISALLOW_COPY_AND_ASSIGN(PolicyProviderTestHarness); |
| 77 }; | 86 }; |
| 78 | 87 |
| 79 // A factory method for creating a test harness. | 88 // A factory method for creating a test harness. |
| 80 typedef PolicyProviderTestHarness* (*CreatePolicyProviderTestHarness)(); | 89 typedef PolicyProviderTestHarness* (*CreatePolicyProviderTestHarness)(); |
| 81 | 90 |
| 82 // Abstract policy provider test. This is meant to be instantiated for each | 91 // Abstract policy provider test. This is meant to be instantiated for each |
| 83 // policy provider implementation, passing in a suitable harness factory | 92 // policy provider implementation, passing in a suitable harness factory |
| 84 // function as the test parameter. | 93 // function as the test parameter. |
| 85 class ConfigurationPolicyProviderTest | 94 class ConfigurationPolicyProviderTest |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 101 scoped_ptr<PolicyProviderTestHarness> test_harness_; | 110 scoped_ptr<PolicyProviderTestHarness> test_harness_; |
| 102 scoped_ptr<AsynchronousPolicyProvider> provider_; | 111 scoped_ptr<AsynchronousPolicyProvider> provider_; |
| 103 | 112 |
| 104 private: | 113 private: |
| 105 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProviderTest); | 114 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProviderTest); |
| 106 }; | 115 }; |
| 107 | 116 |
| 108 } // namespace policy | 117 } // namespace policy |
| 109 | 118 |
| 110 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_TEST_H_ | 119 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_TEST_H_ |
| OLD | NEW |