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

Unified Diff: chrome/browser/policy/policy_loader_win_unittest.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: added bug url 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/policy_loader_win_unittest.cc
diff --git a/chrome/browser/policy/policy_loader_win_unittest.cc b/chrome/browser/policy/policy_loader_win_unittest.cc
index 519cc52e4c920956b61d63ecf9d81ad3f421b214..bb3647a801b4f87c83f0c67a3f8abce6acaa221d 100644
--- a/chrome/browser/policy/policy_loader_win_unittest.cc
+++ b/chrome/browser/policy/policy_loader_win_unittest.cc
@@ -1044,17 +1044,24 @@ TEST_F(PolicyLoaderWinTest, LoadIntegerEncodedValues) {
TEST_F(PolicyLoaderWinTest, DefaultPropertySchemaType) {
// Build a schema for an "object" with a default schema for its properties.
+ // Note that the top-level object can't have "additionalProperties", so
+ // a "policy" property is used instead.
base::DictionaryValue default_schema;
default_schema.SetString(schema::kType, "number");
base::DictionaryValue integer_schema;
integer_schema.SetString(schema::kType, "integer");
- base::DictionaryValue properties;
- properties.Set("special-int1", integer_schema.DeepCopy());
- properties.Set("special-int2", integer_schema.DeepCopy());
+ base::DictionaryValue policy_properties;
+ policy_properties.Set("special-int1", integer_schema.DeepCopy());
+ policy_properties.Set("special-int2", integer_schema.DeepCopy());
+ base::DictionaryValue policy_schema;
+ policy_schema.SetString(schema::kType, "object");
+ policy_schema.Set(schema::kProperties, policy_properties.DeepCopy());
+ policy_schema.Set(schema::kAdditionalProperties, default_schema.DeepCopy());
+ base::DictionaryValue schema_properties;
+ schema_properties.Set("policy", policy_schema.DeepCopy());
base::DictionaryValue schema;
schema.SetString(schema::kType, "object");
- schema.Set(schema::kProperties, properties.DeepCopy());
- schema.Set(schema::kAdditionalProperties, default_schema.DeepCopy());
+ schema.Set(schema::kProperties, schema_properties.DeepCopy());
const string16 kPathSuffix =
kTestPolicyKey + ASCIIToUTF16("\\3rdparty\\extensions\\test");
@@ -1069,7 +1076,10 @@ TEST_F(PolicyLoaderWinTest, DefaultPropertySchemaType) {
policy.SetInteger("double1", 789.0);
policy.SetString("double2", "123.456e7");
policy.SetString("invalid", "omg");
- EXPECT_TRUE(InstallValue(policy, HKEY_CURRENT_USER, kPathSuffix, kMandatory));
+ base::DictionaryValue all_policies;
+ all_policies.Set("policy", policy.DeepCopy());
+ EXPECT_TRUE(
+ InstallValue(all_policies, HKEY_CURRENT_USER, kPathSuffix, kMandatory));
base::DictionaryValue expected_policy;
expected_policy.SetInteger("special-int1", 123);
@@ -1077,9 +1087,11 @@ TEST_F(PolicyLoaderWinTest, DefaultPropertySchemaType) {
expected_policy.SetDouble("double1", 789.0);
expected_policy.SetDouble("double2", 123.456e7);
expected_policy.Set("invalid", base::Value::CreateNullValue());
+ base::DictionaryValue expected_policies;
+ expected_policies.Set("policy", expected_policy.DeepCopy());
PolicyBundle expected;
expected.Get(PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, "test"))
- .LoadFrom(&expected_policy, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER);
+ .LoadFrom(&expected_policies, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER);
EXPECT_TRUE(Matches(expected));
}

Powered by Google App Engine
This is Rietveld 408576698