Chromium Code Reviews| Index: chrome/browser/policy/configuration_policy_provider_test.cc |
| diff --git a/chrome/browser/policy/configuration_policy_provider_test.cc b/chrome/browser/policy/configuration_policy_provider_test.cc |
| index 55ef224cada861d9c7852bb4df1d7338239fd0ed..e9c8361af409d66072cb8ff15f6021ef860f291c 100644 |
| --- a/chrome/browser/policy/configuration_policy_provider_test.cc |
| +++ b/chrome/browser/policy/configuration_policy_provider_test.cc |
| @@ -21,6 +21,96 @@ using ::testing::_; |
| namespace policy { |
| +const char kTestChromeSchema[] = |
| + "{" |
| + " \"type\": \"object\"," |
| + " \"properties\": {" |
| + " \"StringPolicy\": { \"type\": \"string\" }," |
| + " \"BooleanPolicy\": { \"type\": \"boolean\" }," |
| + " \"IntegerPolicy\": { \"type\": \"integer\" }," |
| + " \"StringListPolicy\": {" |
| + " \"type\": \"array\"," |
| + " \"items\": { \"type\": \"string\" }" |
| + " }," |
| + " \"DictionaryPolicy\": {" |
| + " \"type\": \"object\"," |
| + " \"properties\": {" |
| + " \"bool\": { \"type\": \"boolean\" }," |
| + " \"double\": { \"type\": \"number\" }," |
| + " \"int\": { \"type\": \"integer\" }," |
| + " \"string\": { \"type\": \"string\" }," |
| + " \"array\": {" |
| + " \"type\": \"array\"," |
| + " \"items\": { \"type\": \"string\" }" |
| + " }," |
| + " \"dictionary\": {" |
| + " \"type\": \"object\"," |
| + " \"properties\": {" |
| + " \"sub\": { \"type\": \"string\" }," |
| + " \"sublist\": {" |
| + " \"type\": \"array\"," |
| + " \"items\": {" |
| + " \"type\": \"object\"," |
| + " \"properties\": {" |
| + " \"aaa\": { \"type\": \"integer\" }," |
| + " \"bbb\": { \"type\": \"integer\" }," |
| + " \"ccc\": { \"type\": \"string\" }," |
| + " \"ddd\": { \"type\": \"string\" }" |
| + " }" |
| + " }" |
| + " }" |
| + " }" |
| + " }," |
| + " \"list\": {" |
| + " \"type\": \"array\"," |
| + " \"items\": {" |
| + " \"type\": \"object\"," |
| + " \"properties\": {" |
| + " \"subdictindex\": { \"type\": \"integer\" }," |
| + " \"subdict\": {" |
| + " \"type\": \"object\"," |
| + " \"properties\": {" |
| + " \"bool\": { \"type\": \"boolean\" }," |
| + " \"double\": { \"type\": \"number\" }," |
| + " \"int\": { \"type\": \"integer\" }," |
| + " \"string\": { \"type\": \"string\" }" |
| + " }" |
| + " }" |
| + " }" |
| + " }" |
| + " }," |
| + " \"dict\": {" |
| + " \"type\": \"object\"," |
| + " \"properties\": {" |
| + " \"bool\": { \"type\": \"boolean\" }," |
| + " \"double\": { \"type\": \"number\" }," |
| + " \"int\": { \"type\": \"integer\" }," |
| + " \"string\": { \"type\": \"string\" }," |
| + " \"list\": {" |
| + " \"type\": \"array\"," |
| + " \"items\": {" |
| + " \"type\": \"object\"," |
| + " \"properties\": {" |
| + " \"subdictindex\": { \"type\": \"integer\" }," |
| + " \"subdict\": {" |
| + " \"type\": \"object\"," |
| + " \"properties\": {" |
| + " \"bool\": { \"type\": \"boolean\" }," |
| + " \"double\": { \"type\": \"number\" }," |
| + " \"int\": { \"type\": \"integer\" }," |
| + " \"string\": { \"type\": \"string\" }" |
| + " }" |
| + " }" |
| + " }" |
| + " }" |
| + " }" |
| + " }" |
| + " }" |
| + " }" |
| + " }" |
| + " }" |
| + "}"; |
| + |
| namespace test_policy_definitions { |
| const char kKeyString[] = "StringPolicy"; |
| @@ -47,6 +137,14 @@ PolicyTestBase::PolicyTestBase() {} |
| PolicyTestBase::~PolicyTestBase() {} |
| +void PolicyTestBase::SetUp() { |
| + std::string error; |
| + chrome_schema_ = Schema::Parse(kTestChromeSchema, &error); |
| + ASSERT_TRUE(chrome_schema_.valid()) << error; |
| + schema_registry_.RegisterComponent(PolicyNamespace(POLICY_DOMAIN_CHROME, ""), |
|
bartfab (slow)
2013/11/05 15:53:04
Nit: #include "components/policy/core/common/polic
Joao da Silva
2013/11/07 13:15:00
Done.
|
| + chrome_schema_); |
| +} |
| + |
| void PolicyTestBase::TearDown() { |
| loop_.RunUntilIdle(); |
| } |
| @@ -80,9 +178,27 @@ void ConfigurationPolicyProviderTest::SetUp() { |
| test_harness_.reset((*GetParam())()); |
| test_harness_->SetUp(); |
| + Schema extension_schema = |
| + chrome_schema_.GetKnownProperty(test_policy_definitions::kKeyDictionary); |
| + ASSERT_TRUE(extension_schema.valid()); |
| + schema_registry_.RegisterComponent( |
| + PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, |
| + "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), |
| + extension_schema); |
| + schema_registry_.RegisterComponent( |
| + PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, |
| + "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"), |
| + extension_schema); |
| + schema_registry_.RegisterComponent( |
| + PolicyNamespace(POLICY_DOMAIN_EXTENSIONS, |
| + "cccccccccccccccccccccccccccccccc"), |
| + extension_schema); |
| + |
| provider_.reset(test_harness_->CreateProvider( |
| - loop_.message_loop_proxy(), &test_policy_definitions::kList)); |
| - provider_->Init(); |
| + &schema_registry_, |
| + loop_.message_loop_proxy(), |
| + &test_policy_definitions::kList)); |
| + provider_->Init(&schema_registry_); |
| // Some providers do a reload on init. Make sure any notifications generated |
| // are fired now. |
| loop_.RunUntilIdle(); |
| @@ -172,13 +288,14 @@ TEST_P(ConfigurationPolicyProviderTest, StringListValue) { |
| TEST_P(ConfigurationPolicyProviderTest, DictionaryValue) { |
| base::DictionaryValue expected_value; |
| expected_value.SetBoolean("bool", true); |
| + expected_value.SetDouble("double", 123.456); |
| expected_value.SetInteger("int", 123); |
| - expected_value.SetString("str", "omg"); |
| + expected_value.SetString("string", "omg"); |
| base::ListValue* list = new base::ListValue(); |
| list->Set(0U, base::Value::CreateStringValue("first")); |
| list->Set(1U, base::Value::CreateStringValue("second")); |
| - expected_value.Set("list", list); |
| + expected_value.Set("array", list); |
| base::DictionaryValue* dict = new base::DictionaryValue(); |
| dict->SetString("sub", "value"); |
| @@ -192,7 +309,7 @@ TEST_P(ConfigurationPolicyProviderTest, DictionaryValue) { |
| sub->SetString("ddd", "444"); |
| list->Append(sub); |
| dict->Set("sublist", list); |
| - expected_value.Set("dict", dict); |
| + expected_value.Set("dictionary", dict); |
| CheckValue(test_policy_definitions::kKeyDictionary, |
| expected_value, |
| @@ -283,7 +400,7 @@ TEST_P(Configuration3rdPartyPolicyProviderTest, Load3rdParty) { |
| policy_dict.SetBoolean("bool", true); |
| policy_dict.SetDouble("double", 123.456); |
| policy_dict.SetInteger("int", 789); |
| - policy_dict.SetString("str", "string value"); |
| + policy_dict.SetString("string", "string value"); |
| base::ListValue* list = new base::ListValue(); |
| for (int i = 0; i < 2; ++i) { |