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

Side by Side Diff: chrome/browser/extensions/policy_handlers_unittest.cc

Issue 140343002: extensions: Relocate pref name constants. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add missing include for mac Created 6 years, 11 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 | Annotate | Revision Log
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 "base/prefs/pref_value_map.h" 5 #include "base/prefs/pref_value_map.h"
6 #include "chrome/browser/extensions/external_policy_loader.h" 6 #include "chrome/browser/extensions/external_policy_loader.h"
7 #include "chrome/browser/extensions/policy_handlers.h" 7 #include "chrome/browser/extensions/policy_handlers.h"
8 #include "chrome/common/pref_names.h" 8 #include "chrome/common/pref_names.h"
9 #include "components/policy/core/browser/policy_error_map.h" 9 #include "components/policy/core/browser/policy_error_map.h"
10 #include "components/policy/core/common/policy_map.h" 10 #include "components/policy/core/common/policy_map.h"
11 #include "extensions/browser/pref_names.h"
11 #include "policy/policy_constants.h" 12 #include "policy/policy_constants.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 14
14 namespace extensions { 15 namespace extensions {
15 16
16 const char kTestPref[] = "unit_test.test_pref"; 17 const char kTestPref[] = "unit_test.test_pref";
17 18
18 TEST(ExtensionListPolicyHandlerTest, CheckPolicySettings) { 19 TEST(ExtensionListPolicyHandlerTest, CheckPolicySettings) {
19 base::ListValue list; 20 base::ListValue list;
20 policy::PolicyMap policy_map; 21 policy::PolicyMap policy_map;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 162
162 TEST(ExtensionInstallForcelistPolicyHandlerTest, ApplyPolicySettings) { 163 TEST(ExtensionInstallForcelistPolicyHandlerTest, ApplyPolicySettings) {
163 base::ListValue policy; 164 base::ListValue policy;
164 base::DictionaryValue expected; 165 base::DictionaryValue expected;
165 policy::PolicyMap policy_map; 166 policy::PolicyMap policy_map;
166 PrefValueMap prefs; 167 PrefValueMap prefs;
167 base::Value* value = NULL; 168 base::Value* value = NULL;
168 ExtensionInstallForcelistPolicyHandler handler; 169 ExtensionInstallForcelistPolicyHandler handler;
169 170
170 handler.ApplyPolicySettings(policy_map, &prefs); 171 handler.ApplyPolicySettings(policy_map, &prefs);
171 EXPECT_FALSE(prefs.GetValue(prefs::kExtensionInstallForceList, &value)); 172 EXPECT_FALSE(prefs.GetValue(pref_names::kInstallForceList, &value));
172 EXPECT_FALSE(value); 173 EXPECT_FALSE(value);
173 174
174 policy_map.Set(policy::key::kExtensionInstallForcelist, 175 policy_map.Set(policy::key::kExtensionInstallForcelist,
175 policy::POLICY_LEVEL_MANDATORY, 176 policy::POLICY_LEVEL_MANDATORY,
176 policy::POLICY_SCOPE_USER, 177 policy::POLICY_SCOPE_USER,
177 policy.DeepCopy(), 178 policy.DeepCopy(),
178 NULL); 179 NULL);
179 handler.ApplyPolicySettings(policy_map, &prefs); 180 handler.ApplyPolicySettings(policy_map, &prefs);
180 EXPECT_TRUE(prefs.GetValue(prefs::kExtensionInstallForceList, &value)); 181 EXPECT_TRUE(prefs.GetValue(pref_names::kInstallForceList, &value));
181 EXPECT_TRUE(base::Value::Equals(&expected, value)); 182 EXPECT_TRUE(base::Value::Equals(&expected, value));
182 183
183 policy.AppendString("abcdefghijklmnopabcdefghijklmnop;http://example.com"); 184 policy.AppendString("abcdefghijklmnopabcdefghijklmnop;http://example.com");
184 extensions::ExternalPolicyLoader::AddExtension( 185 extensions::ExternalPolicyLoader::AddExtension(
185 &expected, "abcdefghijklmnopabcdefghijklmnop", "http://example.com"); 186 &expected, "abcdefghijklmnopabcdefghijklmnop", "http://example.com");
186 policy_map.Set(policy::key::kExtensionInstallForcelist, 187 policy_map.Set(policy::key::kExtensionInstallForcelist,
187 policy::POLICY_LEVEL_MANDATORY, 188 policy::POLICY_LEVEL_MANDATORY,
188 policy::POLICY_SCOPE_USER, 189 policy::POLICY_SCOPE_USER,
189 policy.DeepCopy(), 190 policy.DeepCopy(),
190 NULL); 191 NULL);
191 handler.ApplyPolicySettings(policy_map, &prefs); 192 handler.ApplyPolicySettings(policy_map, &prefs);
192 EXPECT_TRUE(prefs.GetValue(prefs::kExtensionInstallForceList, &value)); 193 EXPECT_TRUE(prefs.GetValue(pref_names::kInstallForceList, &value));
193 EXPECT_TRUE(base::Value::Equals(&expected, value)); 194 EXPECT_TRUE(base::Value::Equals(&expected, value));
194 195
195 policy.AppendString("invalid"); 196 policy.AppendString("invalid");
196 policy_map.Set(policy::key::kExtensionInstallForcelist, 197 policy_map.Set(policy::key::kExtensionInstallForcelist,
197 policy::POLICY_LEVEL_MANDATORY, 198 policy::POLICY_LEVEL_MANDATORY,
198 policy::POLICY_SCOPE_USER, 199 policy::POLICY_SCOPE_USER,
199 policy.DeepCopy(), 200 policy.DeepCopy(),
200 NULL); 201 NULL);
201 handler.ApplyPolicySettings(policy_map, &prefs); 202 handler.ApplyPolicySettings(policy_map, &prefs);
202 EXPECT_TRUE(prefs.GetValue(prefs::kExtensionInstallForceList, &value)); 203 EXPECT_TRUE(prefs.GetValue(pref_names::kInstallForceList, &value));
203 EXPECT_TRUE(base::Value::Equals(&expected, value)); 204 EXPECT_TRUE(base::Value::Equals(&expected, value));
204 } 205 }
205 206
206 TEST(ExtensionURLPatternListPolicyHandlerTest, CheckPolicySettings) { 207 TEST(ExtensionURLPatternListPolicyHandlerTest, CheckPolicySettings) {
207 base::ListValue list; 208 base::ListValue list;
208 policy::PolicyMap policy_map; 209 policy::PolicyMap policy_map;
209 policy::PolicyErrorMap errors; 210 policy::PolicyErrorMap errors;
210 ExtensionURLPatternListPolicyHandler handler( 211 ExtensionURLPatternListPolicyHandler handler(
211 policy::key::kExtensionInstallSources, kTestPref); 212 policy::key::kExtensionInstallSources, kTestPref);
212 213
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 policy::POLICY_LEVEL_MANDATORY, 278 policy::POLICY_LEVEL_MANDATORY,
278 policy::POLICY_SCOPE_USER, 279 policy::POLICY_SCOPE_USER,
279 list.DeepCopy(), 280 list.DeepCopy(),
280 NULL); 281 NULL);
281 handler.ApplyPolicySettings(policy_map, &prefs); 282 handler.ApplyPolicySettings(policy_map, &prefs);
282 ASSERT_TRUE(prefs.GetValue(kTestPref, &value)); 283 ASSERT_TRUE(prefs.GetValue(kTestPref, &value));
283 EXPECT_TRUE(base::Value::Equals(&list, value)); 284 EXPECT_TRUE(base::Value::Equals(&list, value));
284 } 285 }
285 286
286 } // namespace extensions 287 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698