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

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

Issue 102493002: Use schemas bundled in extensions to convert policies loaded on Windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 7 years 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 #include "components/policy/core/common/configuration_policy_provider_test.h" 5 #include "components/policy/core/common/configuration_policy_provider_test.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/values.h" 10 #include "base/values.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 const char kKeyStringList[] = "StringListPolicy"; 119 const char kKeyStringList[] = "StringListPolicy";
120 const char kKeyDictionary[] = "DictionaryPolicy"; 120 const char kKeyDictionary[] = "DictionaryPolicy";
121 121
122 } // namespace test_keys 122 } // namespace test_keys
123 123
124 PolicyTestBase::PolicyTestBase() {} 124 PolicyTestBase::PolicyTestBase() {}
125 125
126 PolicyTestBase::~PolicyTestBase() {} 126 PolicyTestBase::~PolicyTestBase() {}
127 127
128 void PolicyTestBase::SetUp() { 128 void PolicyTestBase::SetUp() {
129 std::string error; 129 const PolicyNamespace ns(POLICY_DOMAIN_CHROME, "");
130 chrome_schema_ = Schema::Parse(kTestChromeSchema, &error); 130 ASSERT_TRUE(RegisterSchema(ns, kTestChromeSchema));
131 ASSERT_TRUE(chrome_schema_.valid()) << error;
132 schema_registry_.RegisterComponent(PolicyNamespace(POLICY_DOMAIN_CHROME, ""),
133 chrome_schema_);
134 } 131 }
135 132
136 void PolicyTestBase::TearDown() { 133 void PolicyTestBase::TearDown() {
137 loop_.RunUntilIdle(); 134 loop_.RunUntilIdle();
138 } 135 }
139 136
137 bool PolicyTestBase::RegisterSchema(const PolicyNamespace& ns,
138 const std::string& schema_string) {
139 std::string error;
140 Schema schema = Schema::Parse(schema_string, &error);
141 if (schema.valid()) {
142 schema_registry_.RegisterComponent(ns, schema);
143 return true;
144 }
145 ADD_FAILURE() << error;
146 return false;
147 }
148
140 PolicyProviderTestHarness::PolicyProviderTestHarness(PolicyLevel level, 149 PolicyProviderTestHarness::PolicyProviderTestHarness(PolicyLevel level,
141 PolicyScope scope) 150 PolicyScope scope)
142 : level_(level), scope_(scope) {} 151 : level_(level), scope_(scope) {}
143 152
144 PolicyProviderTestHarness::~PolicyProviderTestHarness() {} 153 PolicyProviderTestHarness::~PolicyProviderTestHarness() {}
145 154
146 PolicyLevel PolicyProviderTestHarness::policy_level() const { 155 PolicyLevel PolicyProviderTestHarness::policy_level() const {
147 return level_; 156 return level_;
148 } 157 }
149 158
150 PolicyScope PolicyProviderTestHarness::policy_scope() const { 159 PolicyScope PolicyProviderTestHarness::policy_scope() const {
151 return scope_; 160 return scope_;
152 } 161 }
153 162
154 void PolicyProviderTestHarness::Install3rdPartyPolicy( 163 void PolicyProviderTestHarness::Install3rdPartyPolicy(
155 const base::DictionaryValue* policies) { 164 const base::DictionaryValue* policies) {
156 FAIL(); 165 FAIL();
157 } 166 }
158 167
159 ConfigurationPolicyProviderTest::ConfigurationPolicyProviderTest() {} 168 ConfigurationPolicyProviderTest::ConfigurationPolicyProviderTest() {}
160 169
161 ConfigurationPolicyProviderTest::~ConfigurationPolicyProviderTest() {} 170 ConfigurationPolicyProviderTest::~ConfigurationPolicyProviderTest() {}
162 171
163 void ConfigurationPolicyProviderTest::SetUp() { 172 void ConfigurationPolicyProviderTest::SetUp() {
164 PolicyTestBase::SetUp(); 173 PolicyTestBase::SetUp();
165 174
166 test_harness_.reset((*GetParam())()); 175 test_harness_.reset((*GetParam())());
167 test_harness_->SetUp(); 176 test_harness_->SetUp();
168 177
178 const PolicyNamespace chrome_ns(POLICY_DOMAIN_CHROME, "");
179 Schema chrome_schema = *schema_registry_.schema_map()->GetSchema(chrome_ns);
169 Schema extension_schema = 180 Schema extension_schema =
170 chrome_schema_.GetKnownProperty(test_keys::kKeyDictionary); 181 chrome_schema.GetKnownProperty(test_keys::kKeyDictionary);
171 ASSERT_TRUE(extension_schema.valid()); 182 ASSERT_TRUE(extension_schema.valid());
172 schema_registry_.RegisterComponent( 183 schema_registry_.RegisterComponent(
173 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, 184 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS,
174 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), 185 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"),
175 extension_schema); 186 extension_schema);
176 schema_registry_.RegisterComponent( 187 schema_registry_.RegisterComponent(
177 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, 188 PolicyNamespace(POLICY_DOMAIN_EXTENSIONS,
178 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"), 189 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"),
179 extension_schema); 190 extension_schema);
180 schema_registry_.RegisterComponent( 191 schema_registry_.RegisterComponent(
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, 405 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS,
395 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) 406 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"))
396 .CopyFrom(expected_policy); 407 .CopyFrom(expected_policy);
397 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, 408 expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS,
398 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")) 409 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"))
399 .CopyFrom(expected_policy); 410 .CopyFrom(expected_policy);
400 EXPECT_TRUE(provider_->policies().Equals(expected_bundle)); 411 EXPECT_TRUE(provider_->policies().Equals(expected_bundle));
401 } 412 }
402 413
403 } // namespace policy 414 } // namespace policy
OLDNEW
« no previous file with comments | « components/policy/core/common/configuration_policy_provider_test.h ('k') | components/policy/core/common/policy_loader_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698