| 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 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/callback_forward.h" | 11 #include "base/callback_forward.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
| 15 #include "chrome/browser/policy/policy_types.h" | 15 #include "chrome/browser/policy/policy_types.h" |
| 16 #include "chrome/browser/policy/schema_registry.h" |
| 17 #include "components/policy/core/common/schema.h" |
| 16 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
| 17 | 19 |
| 18 namespace base { | 20 namespace base { |
| 19 class DictionaryValue; | 21 class DictionaryValue; |
| 20 class ListValue; | 22 class ListValue; |
| 21 class SequencedTaskRunner; | 23 class SequencedTaskRunner; |
| 22 class Value; | 24 class Value; |
| 23 } | 25 } |
| 24 | 26 |
| 25 namespace policy { | 27 namespace policy { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 42 extern const PolicyDefinitionList kList; | 44 extern const PolicyDefinitionList kList; |
| 43 | 45 |
| 44 } // namespace test_policy_definitions | 46 } // namespace test_policy_definitions |
| 45 | 47 |
| 46 class PolicyTestBase : public testing::Test { | 48 class PolicyTestBase : public testing::Test { |
| 47 public: | 49 public: |
| 48 PolicyTestBase(); | 50 PolicyTestBase(); |
| 49 virtual ~PolicyTestBase(); | 51 virtual ~PolicyTestBase(); |
| 50 | 52 |
| 51 // testing::Test: | 53 // testing::Test: |
| 54 virtual void SetUp() OVERRIDE; |
| 52 virtual void TearDown() OVERRIDE; | 55 virtual void TearDown() OVERRIDE; |
| 53 | 56 |
| 54 protected: | 57 protected: |
| 58 Schema chrome_schema_; |
| 59 SchemaRegistry schema_registry_; |
| 60 |
| 55 // Create an actual IO loop (needed by FilePathWatcher). | 61 // Create an actual IO loop (needed by FilePathWatcher). |
| 56 base::MessageLoopForIO loop_; | 62 base::MessageLoopForIO loop_; |
| 57 | 63 |
| 58 private: | 64 private: |
| 59 DISALLOW_COPY_AND_ASSIGN(PolicyTestBase); | 65 DISALLOW_COPY_AND_ASSIGN(PolicyTestBase); |
| 60 }; | 66 }; |
| 61 | 67 |
| 62 // An interface for creating a test policy provider and creating a policy | 68 // An interface for creating a test policy provider and creating a policy |
| 63 // provider instance for testing. Used as the parameter to the abstract | 69 // provider instance for testing. Used as the parameter to the abstract |
| 64 // ConfigurationPolicyProviderTest below. | 70 // ConfigurationPolicyProviderTest below. |
| 65 class PolicyProviderTestHarness { | 71 class PolicyProviderTestHarness { |
| 66 public: | 72 public: |
| 67 // |level| and |scope| are the level and scope of the policies returned by | 73 // |level| and |scope| are the level and scope of the policies returned by |
| 68 // the providers from CreateProvider(). | 74 // the providers from CreateProvider(). |
| 69 PolicyProviderTestHarness(PolicyLevel level, PolicyScope scope); | 75 PolicyProviderTestHarness(PolicyLevel level, PolicyScope scope); |
| 70 virtual ~PolicyProviderTestHarness(); | 76 virtual ~PolicyProviderTestHarness(); |
| 71 | 77 |
| 72 // Actions to run at gtest SetUp() time. | 78 // Actions to run at gtest SetUp() time. |
| 73 virtual void SetUp() = 0; | 79 virtual void SetUp() = 0; |
| 74 | 80 |
| 75 // Create a new policy provider. | 81 // Create a new policy provider. |
| 76 virtual ConfigurationPolicyProvider* CreateProvider( | 82 virtual ConfigurationPolicyProvider* CreateProvider( |
| 83 SchemaRegistry* registry, |
| 77 scoped_refptr<base::SequencedTaskRunner> task_runner, | 84 scoped_refptr<base::SequencedTaskRunner> task_runner, |
| 78 const PolicyDefinitionList* policy_definition_list) = 0; | 85 const PolicyDefinitionList* policy_definition_list) = 0; |
| 79 | 86 |
| 80 // Returns the policy level and scope set by the policy provider. | 87 // Returns the policy level and scope set by the policy provider. |
| 81 PolicyLevel policy_level() const; | 88 PolicyLevel policy_level() const; |
| 82 PolicyScope policy_scope() const; | 89 PolicyScope policy_scope() const; |
| 83 | 90 |
| 84 // Helpers to configure the environment the policy provider reads from. | 91 // Helpers to configure the environment the policy provider reads from. |
| 85 virtual void InstallEmptyPolicy() = 0; | 92 virtual void InstallEmptyPolicy() = 0; |
| 86 virtual void InstallStringPolicy(const std::string& policy_name, | 93 virtual void InstallStringPolicy(const std::string& policy_name, |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 Configuration3rdPartyPolicyProviderTest(); | 151 Configuration3rdPartyPolicyProviderTest(); |
| 145 virtual ~Configuration3rdPartyPolicyProviderTest(); | 152 virtual ~Configuration3rdPartyPolicyProviderTest(); |
| 146 | 153 |
| 147 private: | 154 private: |
| 148 DISALLOW_COPY_AND_ASSIGN(Configuration3rdPartyPolicyProviderTest); | 155 DISALLOW_COPY_AND_ASSIGN(Configuration3rdPartyPolicyProviderTest); |
| 149 }; | 156 }; |
| 150 | 157 |
| 151 } // namespace policy | 158 } // namespace policy |
| 152 | 159 |
| 153 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_TEST_H_ | 160 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_TEST_H_ |
| OLD | NEW |