| 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 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/message_loop.h" | 14 #include "base/message_loop.h" |
| 15 #include "chrome/browser/policy/asynchronous_policy_test_base.h" | 15 #include "chrome/browser/policy/asynchronous_policy_test_base.h" |
| 16 #include "content/public/test/test_browser_thread.h" | 16 #include "content/public/test/test_browser_thread.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class DictionaryValue; | 20 class DictionaryValue; |
| 21 class ListValue; | 21 class ListValue; |
| 22 class Value; | 22 class Value; |
| 23 } | 23 } |
| 24 | 24 |
| 25 namespace policy { | 25 namespace policy { |
| 26 | 26 |
| 27 class AsynchronousPolicyProvider; | 27 class ConfigurationPolicyProvider; |
| 28 struct PolicyDefinitionList; | 28 struct PolicyDefinitionList; |
| 29 | 29 |
| 30 // A stripped-down policy definition list that contains entries for the | 30 // A stripped-down policy definition list that contains entries for the |
| 31 // different policy setting types supported. | 31 // different policy setting types supported. |
| 32 namespace test_policy_definitions { | 32 namespace test_policy_definitions { |
| 33 | 33 |
| 34 // String policy keys. | 34 // String policy keys. |
| 35 extern const char kKeyString[]; | 35 extern const char kKeyString[]; |
| 36 extern const char kKeyBoolean[]; | 36 extern const char kKeyBoolean[]; |
| 37 extern const char kKeyInteger[]; | 37 extern const char kKeyInteger[]; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 50 public: | 50 public: |
| 51 // |level| and |scope| are the level and scope of the policies returned by | 51 // |level| and |scope| are the level and scope of the policies returned by |
| 52 // the providers from CreateProvider(). | 52 // the providers from CreateProvider(). |
| 53 PolicyProviderTestHarness(PolicyLevel level, PolicyScope scope); | 53 PolicyProviderTestHarness(PolicyLevel level, PolicyScope scope); |
| 54 virtual ~PolicyProviderTestHarness(); | 54 virtual ~PolicyProviderTestHarness(); |
| 55 | 55 |
| 56 // Actions to run at gtest SetUp() time. | 56 // Actions to run at gtest SetUp() time. |
| 57 virtual void SetUp() = 0; | 57 virtual void SetUp() = 0; |
| 58 | 58 |
| 59 // Create a new policy provider. | 59 // Create a new policy provider. |
| 60 virtual AsynchronousPolicyProvider* CreateProvider( | 60 virtual ConfigurationPolicyProvider* CreateProvider( |
| 61 const PolicyDefinitionList* policy_definition_list) = 0; | 61 const PolicyDefinitionList* policy_definition_list) = 0; |
| 62 | 62 |
| 63 // Returns the policy level and scope set by the policy provider. | 63 // Returns the policy level and scope set by the policy provider. |
| 64 PolicyLevel policy_level() const; | 64 PolicyLevel policy_level() const; |
| 65 PolicyScope policy_scope() const; | 65 PolicyScope policy_scope() const; |
| 66 | 66 |
| 67 // Helpers to configure the environment the policy provider reads from. | 67 // Helpers to configure the environment the policy provider reads from. |
| 68 virtual void InstallEmptyPolicy() = 0; | 68 virtual void InstallEmptyPolicy() = 0; |
| 69 virtual void InstallStringPolicy(const std::string& policy_name, | 69 virtual void InstallStringPolicy(const std::string& policy_name, |
| 70 const std::string& policy_value) = 0; | 70 const std::string& policy_value) = 0; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 101 virtual void SetUp() OVERRIDE; | 101 virtual void SetUp() OVERRIDE; |
| 102 virtual void TearDown() OVERRIDE; | 102 virtual void TearDown() OVERRIDE; |
| 103 | 103 |
| 104 // Installs a valid policy and checks whether the provider returns the | 104 // Installs a valid policy and checks whether the provider returns the |
| 105 // |expected_value|. | 105 // |expected_value|. |
| 106 void CheckValue(const char* policy_name, | 106 void CheckValue(const char* policy_name, |
| 107 const base::Value& expected_value, | 107 const base::Value& expected_value, |
| 108 base::Closure install_value); | 108 base::Closure install_value); |
| 109 | 109 |
| 110 scoped_ptr<PolicyProviderTestHarness> test_harness_; | 110 scoped_ptr<PolicyProviderTestHarness> test_harness_; |
| 111 scoped_ptr<AsynchronousPolicyProvider> provider_; | 111 scoped_ptr<ConfigurationPolicyProvider> provider_; |
| 112 | 112 |
| 113 private: | 113 private: |
| 114 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProviderTest); | 114 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProviderTest); |
| 115 }; | 115 }; |
| 116 | 116 |
| 117 } // namespace policy | 117 } // namespace policy |
| 118 | 118 |
| 119 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_TEST_H_ | 119 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_TEST_H_ |
| OLD | NEW |