Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: components/policy/core/common/configuration_policy_provider_test.h

Issue 1304843004: Add source column to chrome://policy showing the origins of policies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed another test. Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 COMPONENTS_POLICY_CORE_COMMON_CONFIGURATION_POLICY_PROVIDER_TEST_H_ 5 #ifndef COMPONENTS_POLICY_CORE_COMMON_CONFIGURATION_POLICY_PROVIDER_TEST_H_
6 #define COMPONENTS_POLICY_CORE_COMMON_CONFIGURATION_POLICY_PROVIDER_TEST_H_ 6 #define COMPONENTS_POLICY_CORE_COMMON_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"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 private: 59 private:
60 DISALLOW_COPY_AND_ASSIGN(PolicyTestBase); 60 DISALLOW_COPY_AND_ASSIGN(PolicyTestBase);
61 }; 61 };
62 62
63 // An interface for creating a test policy provider and creating a policy 63 // An interface for creating a test policy provider and creating a policy
64 // provider instance for testing. Used as the parameter to the abstract 64 // provider instance for testing. Used as the parameter to the abstract
65 // ConfigurationPolicyProviderTest below. 65 // ConfigurationPolicyProviderTest below.
66 class PolicyProviderTestHarness { 66 class PolicyProviderTestHarness {
67 public: 67 public:
68 // |level| and |scope| are the level and scope of the policies returned by 68 // |level|, |scope| and |source| are the level, scope and source of the
69 // the providers from CreateProvider(). 69 // policies returned by the providers from CreateProvider().
70 PolicyProviderTestHarness(PolicyLevel level, PolicyScope scope); 70 PolicyProviderTestHarness(PolicyLevel level,
71 PolicyScope scope,
72 PolicySource source);
71 virtual ~PolicyProviderTestHarness(); 73 virtual ~PolicyProviderTestHarness();
72 74
73 // Actions to run at gtest SetUp() time. 75 // Actions to run at gtest SetUp() time.
74 virtual void SetUp() = 0; 76 virtual void SetUp() = 0;
75 77
76 // Create a new policy provider. 78 // Create a new policy provider.
77 virtual ConfigurationPolicyProvider* CreateProvider( 79 virtual ConfigurationPolicyProvider* CreateProvider(
78 SchemaRegistry* registry, 80 SchemaRegistry* registry,
79 scoped_refptr<base::SequencedTaskRunner> task_runner) = 0; 81 scoped_refptr<base::SequencedTaskRunner> task_runner) = 0;
80 82
81 // Returns the policy level and scope set by the policy provider. 83 // Returns the policy level, scope and source set by the policy provider.
82 PolicyLevel policy_level() const; 84 PolicyLevel policy_level() const;
83 PolicyScope policy_scope() const; 85 PolicyScope policy_scope() const;
86 PolicySource policy_source() const;
84 87
85 // Helpers to configure the environment the policy provider reads from. 88 // Helpers to configure the environment the policy provider reads from.
86 virtual void InstallEmptyPolicy() = 0; 89 virtual void InstallEmptyPolicy() = 0;
87 virtual void InstallStringPolicy(const std::string& policy_name, 90 virtual void InstallStringPolicy(const std::string& policy_name,
88 const std::string& policy_value) = 0; 91 const std::string& policy_value) = 0;
89 virtual void InstallIntegerPolicy(const std::string& policy_name, 92 virtual void InstallIntegerPolicy(const std::string& policy_name,
90 int policy_value) = 0; 93 int policy_value) = 0;
91 virtual void InstallBooleanPolicy(const std::string& policy_name, 94 virtual void InstallBooleanPolicy(const std::string& policy_name,
92 bool policy_value) = 0; 95 bool policy_value) = 0;
93 virtual void InstallStringListPolicy(const std::string& policy_name, 96 virtual void InstallStringListPolicy(const std::string& policy_name,
94 const base::ListValue* policy_value) = 0; 97 const base::ListValue* policy_value) = 0;
95 virtual void InstallDictionaryPolicy( 98 virtual void InstallDictionaryPolicy(
96 const std::string& policy_name, 99 const std::string& policy_name,
97 const base::DictionaryValue* policy_value) = 0; 100 const base::DictionaryValue* policy_value) = 0;
98 101
99 // Not every provider supports installing 3rd party policy. Those who do 102 // Not every provider supports installing 3rd party policy. Those who do
100 // should override this method; the default just makes the test fail. 103 // should override this method; the default just makes the test fail.
101 virtual void Install3rdPartyPolicy(const base::DictionaryValue* policies); 104 virtual void Install3rdPartyPolicy(const base::DictionaryValue* policies);
102 105
103 private: 106 private:
104 PolicyLevel level_; 107 PolicyLevel level_;
105 PolicyScope scope_; 108 PolicyScope scope_;
109 PolicySource source_;
106 110
107 DISALLOW_COPY_AND_ASSIGN(PolicyProviderTestHarness); 111 DISALLOW_COPY_AND_ASSIGN(PolicyProviderTestHarness);
108 }; 112 };
109 113
110 // A factory method for creating a test harness. 114 // A factory method for creating a test harness.
111 typedef PolicyProviderTestHarness* (*CreatePolicyProviderTestHarness)(); 115 typedef PolicyProviderTestHarness* (*CreatePolicyProviderTestHarness)();
112 116
113 // Abstract policy provider test. This is meant to be instantiated for each 117 // Abstract policy provider test. This is meant to be instantiated for each
114 // policy provider implementation, passing in a suitable harness factory 118 // policy provider implementation, passing in a suitable harness factory
115 // function as the test parameter. 119 // function as the test parameter.
(...skipping 29 matching lines...) Expand all
145 Configuration3rdPartyPolicyProviderTest(); 149 Configuration3rdPartyPolicyProviderTest();
146 virtual ~Configuration3rdPartyPolicyProviderTest(); 150 virtual ~Configuration3rdPartyPolicyProviderTest();
147 151
148 private: 152 private:
149 DISALLOW_COPY_AND_ASSIGN(Configuration3rdPartyPolicyProviderTest); 153 DISALLOW_COPY_AND_ASSIGN(Configuration3rdPartyPolicyProviderTest);
150 }; 154 };
151 155
152 } // namespace policy 156 } // namespace policy
153 157
154 #endif // COMPONENTS_POLICY_CORE_COMMON_CONFIGURATION_POLICY_PROVIDER_TEST_H_ 158 #endif // COMPONENTS_POLICY_CORE_COMMON_CONFIGURATION_POLICY_PROVIDER_TEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698