| OLD | NEW |
| 1 // Copyright (c) 2011 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/test/test_browser_thread.h" | 16 #include "content/test/test_browser_thread.h" |
| 17 #include "policy/configuration_policy_type.h" | |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 19 | 18 |
| 20 namespace base { | 19 namespace base { |
| 21 class ListValue; | 20 class ListValue; |
| 22 } | 21 } |
| 23 | 22 |
| 24 namespace policy { | 23 namespace policy { |
| 25 | 24 |
| 26 class AsynchronousPolicyProvider; | 25 class AsynchronousPolicyProvider; |
| 27 struct PolicyDefinitionList; | 26 struct PolicyDefinitionList; |
| 28 | 27 |
| 29 // A stripped-down policy definition list that contains entries for the | 28 // A stripped-down policy definition list that contains entries for the |
| 30 // different policy setting types supported. | 29 // different policy setting types supported. |
| 31 namespace test_policy_definitions { | 30 namespace test_policy_definitions { |
| 32 | 31 |
| 33 // String policy keys. | 32 // String policy keys. |
| 34 extern const char kKeyString[]; | 33 extern const char kKeyString[]; |
| 35 extern const char kKeyBoolean[]; | 34 extern const char kKeyBoolean[]; |
| 36 extern const char kKeyInteger[]; | 35 extern const char kKeyInteger[]; |
| 37 extern const char kKeyStringList[]; | 36 extern const char kKeyStringList[]; |
| 38 | 37 |
| 39 // Corresponding type constants. | |
| 40 extern const ConfigurationPolicyType kPolicyString; | |
| 41 extern const ConfigurationPolicyType kPolicyBoolean; | |
| 42 extern const ConfigurationPolicyType kPolicyInteger; | |
| 43 extern const ConfigurationPolicyType kPolicyStringList; | |
| 44 | |
| 45 // Policy definition list that contains entries for the keys above. | 38 // Policy definition list that contains entries for the keys above. |
| 46 extern const PolicyDefinitionList kList; | 39 extern const PolicyDefinitionList kList; |
| 47 | 40 |
| 48 } // namespace test_policy_definitions | 41 } // namespace test_policy_definitions |
| 49 | 42 |
| 50 // An interface for creating a test policy provider and creating a policy | 43 // An interface for creating a test policy provider and creating a policy |
| 51 // provider instance for testing. Used as the parameter to the abstract | 44 // provider instance for testing. Used as the parameter to the abstract |
| 52 // ConfigurationPolicyProviderTest below. | 45 // ConfigurationPolicyProviderTest below. |
| 53 class PolicyProviderTestHarness { | 46 class PolicyProviderTestHarness { |
| 54 public: | 47 public: |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 protected: | 82 protected: |
| 90 ConfigurationPolicyProviderTest(); | 83 ConfigurationPolicyProviderTest(); |
| 91 virtual ~ConfigurationPolicyProviderTest(); | 84 virtual ~ConfigurationPolicyProviderTest(); |
| 92 | 85 |
| 93 virtual void SetUp() OVERRIDE; | 86 virtual void SetUp() OVERRIDE; |
| 94 virtual void TearDown() OVERRIDE; | 87 virtual void TearDown() OVERRIDE; |
| 95 | 88 |
| 96 // Installs a valid policy and checks whether the provider returns the | 89 // Installs a valid policy and checks whether the provider returns the |
| 97 // |expected_value|. | 90 // |expected_value|. |
| 98 void CheckValue(const char* policy_name, | 91 void CheckValue(const char* policy_name, |
| 99 ConfigurationPolicyType policy_type, | |
| 100 const base::Value& expected_value, | 92 const base::Value& expected_value, |
| 101 base::Closure install_value); | 93 base::Closure install_value); |
| 102 | 94 |
| 103 scoped_ptr<PolicyProviderTestHarness> test_harness_; | 95 scoped_ptr<PolicyProviderTestHarness> test_harness_; |
| 104 scoped_ptr<AsynchronousPolicyProvider> provider_; | 96 scoped_ptr<AsynchronousPolicyProvider> provider_; |
| 105 | 97 |
| 106 private: | 98 private: |
| 107 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProviderTest); | 99 DISALLOW_COPY_AND_ASSIGN(ConfigurationPolicyProviderTest); |
| 108 }; | 100 }; |
| 109 | 101 |
| 110 } // namespace policy | 102 } // namespace policy |
| 111 | 103 |
| 112 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_TEST_H_ | 104 #endif // CHROME_BROWSER_POLICY_CONFIGURATION_POLICY_PROVIDER_TEST_H_ |
| OLD | NEW |