| Index: chrome/browser/policy/policy_domain_descriptor_unittest.cc
|
| diff --git a/chrome/browser/policy/policy_domain_descriptor_unittest.cc b/chrome/browser/policy/policy_domain_descriptor_unittest.cc
|
| index 4ef89fc9ae3477db9a7fc39030e32c2694e93ed6..4ce2cfe0c5bcc4fc5ba11848a08eefc6564b4427 100644
|
| --- a/chrome/browser/policy/policy_domain_descriptor_unittest.cc
|
| +++ b/chrome/browser/policy/policy_domain_descriptor_unittest.cc
|
| @@ -13,6 +13,7 @@
|
| #include "chrome/browser/policy/external_data_manager.h"
|
| #include "chrome/browser/policy/policy_bundle.h"
|
| #include "chrome/browser/policy/policy_map.h"
|
| +#include "policy/policy_constants.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| namespace policy {
|
| @@ -215,4 +216,72 @@ TEST_F(PolicyDomainDescriptorTest, LegacyComponents) {
|
| EXPECT_TRUE(bundle.Equals(expected_bundle));
|
| }
|
|
|
| +TEST_F(PolicyDomainDescriptorTest, ChromePolicyDomainDescriptor) {
|
| + scoped_refptr<PolicyDomainDescriptor> descriptor = new PolicyDomainDescriptor(
|
| + POLICY_DOMAIN_CHROME);
|
| + descriptor->RegisterComponent("", SchemaOwner::Wrap(GetChromeSchemaData()));
|
| +
|
| + EXPECT_EQ(POLICY_DOMAIN_CHROME, descriptor->domain());
|
| + ASSERT_EQ(1u, descriptor->components().size());
|
| + ASSERT_EQ("", descriptor->components().begin()->first);
|
| + Schema schema = descriptor->components().begin()->second;
|
| + ASSERT_TRUE(schema.valid());
|
| +
|
| + EXPECT_EQ(base::Value::TYPE_DICTIONARY, schema.type());
|
| +
|
| + Schema subschema = schema.GetAdditionalProperties();
|
| + EXPECT_FALSE(subschema.valid());
|
| +
|
| + subschema = schema.GetProperty("no such policy exists");
|
| + EXPECT_FALSE(subschema.valid());
|
| +
|
| + subschema = schema.GetProperty(key::kAlternateErrorPagesEnabled);
|
| + ASSERT_TRUE(subschema.valid());
|
| + EXPECT_EQ(base::Value::TYPE_BOOLEAN, subschema.type());
|
| +
|
| + subschema = schema.GetProperty(key::kIncognitoModeAvailability);
|
| + ASSERT_TRUE(subschema.valid());
|
| + EXPECT_EQ(base::Value::TYPE_INTEGER, subschema.type());
|
| +
|
| + subschema = schema.GetProperty(key::kProxyMode);
|
| + ASSERT_TRUE(subschema.valid());
|
| + EXPECT_EQ(base::Value::TYPE_STRING, subschema.type());
|
| +
|
| + subschema = schema.GetProperty(key::kCookiesAllowedForUrls);
|
| + ASSERT_TRUE(subschema.valid());
|
| + EXPECT_EQ(base::Value::TYPE_LIST, subschema.type());
|
| + ASSERT_TRUE(subschema.GetItems().valid());
|
| + EXPECT_EQ(base::Value::TYPE_STRING, subschema.GetItems().type());
|
| +
|
| + subschema = schema.GetProperty(key::kProxySettings);
|
| + ASSERT_TRUE(subschema.valid());
|
| + EXPECT_EQ(base::Value::TYPE_DICTIONARY, subschema.type());
|
| + EXPECT_FALSE(subschema.GetAdditionalProperties().valid());
|
| + EXPECT_FALSE(subschema.GetProperty("no such proxy key exists").valid());
|
| + ASSERT_TRUE(subschema.GetProperty(key::kProxyMode).valid());
|
| + ASSERT_TRUE(subschema.GetProperty(key::kProxyServer).valid());
|
| + ASSERT_TRUE(subschema.GetProperty(key::kProxyServerMode).valid());
|
| + ASSERT_TRUE(subschema.GetProperty(key::kProxyPacUrl).valid());
|
| + ASSERT_TRUE(subschema.GetProperty(key::kProxyBypassList).valid());
|
| +
|
| + // The properties are iterated in order.
|
| + const char* kExpectedProperties[] = {
|
| + key::kProxyBypassList,
|
| + key::kProxyMode,
|
| + key::kProxyPacUrl,
|
| + key::kProxyServer,
|
| + key::kProxyServerMode,
|
| + NULL,
|
| + };
|
| + const char** next = kExpectedProperties;
|
| + for (Schema::Iterator it(subschema.GetPropertiesIterator());
|
| + !it.IsAtEnd(); it.Advance(), ++next) {
|
| + ASSERT_TRUE(*next != NULL);
|
| + EXPECT_STREQ(*next, it.key());
|
| + ASSERT_TRUE(it.schema().valid());
|
| + EXPECT_EQ(base::Value::TYPE_STRING, it.schema().type());
|
| + }
|
| + EXPECT_TRUE(*next == NULL);
|
| +}
|
| +
|
| } // namespace policy
|
|
|