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

Unified Diff: chrome/browser/policy/configuration_policy_provider_test.cc

Issue 22645011: policy: use JSON schema to deserialize entries from Windows registry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix 3rd party policy unit tests Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/policy/async_policy_loader.cc ('k') | chrome/browser/policy/policy_domain_descriptor.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..cc3dcf2da44fb91a52ad69a68b9d8faf7c456814 100644
--- a/chrome/browser/policy/configuration_policy_provider_test.cc
+++ b/chrome/browser/policy/configuration_policy_provider_test.cc
@@ -19,6 +19,35 @@
using ::testing::Mock;
using ::testing::_;
+namespace {
+// Builds a DictionaryValue for testing.
+// On Windows this matches the Chrome policy test schema.
+void BuildTestDictionaryValue(base::DictionaryValue& value) {
+ value.SetBoolean("bool", true);
+ value.SetInteger("int", 123);
+ value.SetString("str", "omg");
+
+ base::ListValue* list = new base::ListValue();
+ list->Set(0U, base::Value::CreateStringValue("first"));
+ list->Set(1U, base::Value::CreateStringValue("second"));
+ value.Set("list", list);
+
+ base::DictionaryValue* dict = new base::DictionaryValue();
+ dict->SetString("sub", "value");
+ list = new base::ListValue();
+ base::DictionaryValue* sub = new base::DictionaryValue();
+ sub->SetInteger("aaa", 111);
+ sub->SetInteger("bbb", 222);
+ list->Append(sub);
+ sub = new base::DictionaryValue();
+ sub->SetString("ccc", "333");
+ sub->SetString("ddd", "444");
+ list->Append(sub);
+ dict->Set("sublist", list);
+ value.Set("dict", dict);
+}
+} // namespace
+
namespace policy {
namespace test_policy_definitions {
@@ -171,29 +200,7 @@ TEST_P(ConfigurationPolicyProviderTest, StringListValue) {
TEST_P(ConfigurationPolicyProviderTest, DictionaryValue) {
base::DictionaryValue expected_value;
- expected_value.SetBoolean("bool", true);
- expected_value.SetInteger("int", 123);
- expected_value.SetString("str", "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);
-
- base::DictionaryValue* dict = new base::DictionaryValue();
- dict->SetString("sub", "value");
- list = new base::ListValue();
- base::DictionaryValue* sub = new base::DictionaryValue();
- sub->SetInteger("aaa", 111);
- sub->SetInteger("bbb", 222);
- list->Append(sub);
- sub = new base::DictionaryValue();
- sub->SetString("ccc", "333");
- sub->SetString("ddd", "444");
- list->Append(sub);
- dict->Set("sublist", list);
- expected_value.Set("dict", dict);
-
+ BuildTestDictionaryValue(expected_value);
CheckValue(test_policy_definitions::kKeyDictionary,
expected_value,
base::Bind(&PolicyProviderTestHarness::InstallDictionaryPolicy,
@@ -279,6 +286,13 @@ Configuration3rdPartyPolicyProviderTest::
~Configuration3rdPartyPolicyProviderTest() {}
TEST_P(Configuration3rdPartyPolicyProviderTest, Load3rdParty) {
+ // Install a Chrome policy.
+ base::DictionaryValue chrome_policy_dict;
+ BuildTestDictionaryValue(chrome_policy_dict);
+ test_harness_->InstallDictionaryPolicy(
+ test_policy_definitions::kKeyDictionary, &chrome_policy_dict);
+
+ // Install 3rd party policies.
base::DictionaryValue policy_dict;
policy_dict.SetBoolean("bool", true);
policy_dict.SetDouble("double", 123.456);
@@ -295,10 +309,6 @@ TEST_P(Configuration3rdPartyPolicyProviderTest, Load3rdParty) {
policy_dict.Set("list", list);
policy_dict.Set("dict", policy_dict.DeepCopy());
- // Install these policies as a Chrome policy.
- test_harness_->InstallDictionaryPolicy(
- test_policy_definitions::kKeyDictionary, &policy_dict);
- // Install them as 3rd party policies too.
base::DictionaryValue policy_3rdparty;
policy_3rdparty.Set("extensions.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
policy_dict.DeepCopy());
@@ -318,7 +328,7 @@ TEST_P(Configuration3rdPartyPolicyProviderTest, Load3rdParty) {
expected_policy.Set(test_policy_definitions::kKeyDictionary,
test_harness_->policy_level(),
test_harness_->policy_scope(),
- policy_dict.DeepCopy(),
+ chrome_policy_dict.DeepCopy(),
NULL);
PolicyBundle expected_bundle;
expected_bundle.Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string()))
« no previous file with comments | « chrome/browser/policy/async_policy_loader.cc ('k') | chrome/browser/policy/policy_domain_descriptor.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698