| Index: components/policy/core/common/schema_unittest.cc
|
| diff --git a/components/policy/core/common/schema_unittest.cc b/components/policy/core/common/schema_unittest.cc
|
| index e0c1603e2c6ecc50c671af0a35d5bc93bbdd8970..980eadf5e9e1a50ec4dfee9a8ab8d8592dada775 100644
|
| --- a/components/policy/core/common/schema_unittest.cc
|
| +++ b/components/policy/core/common/schema_unittest.cc
|
| @@ -676,5 +676,44 @@ TEST(SchemaTest, ItemsReference) {
|
| ASSERT_EQ(base::Value::TYPE_BOOLEAN, items.type());
|
| }
|
|
|
| +TEST(SchemaTest, BackwardsCompatibility) {
|
| + const char kTestSchema[] =
|
| + "{"
|
| + " \"type\": \"object\","
|
| + " \"properties\": {"
|
| + " \"magic\": { \"type\": \"array\" },"
|
| + " \"no magic\": {"
|
| + " \"type\": \"array\","
|
| + " \"items\": { \"type\": \"boolean\" }"
|
| + " }"
|
| + " }"
|
| + "}";
|
| +
|
| + {
|
| + std::string error;
|
| + Schema schema = Schema::Parse(kTestSchema, &error);
|
| + EXPECT_FALSE(schema.valid());
|
| + EXPECT_FALSE(error.empty());
|
| + }
|
| +
|
| + std::string error;
|
| + Schema schema = Schema::ParseWithBackwardsCompatibility(
|
| + kTestSchema, &error, true);
|
| + ASSERT_TRUE(schema.valid()) << error;
|
| +
|
| + Schema magic = schema.GetProperty("magic");
|
| + ASSERT_TRUE(magic.valid());
|
| + ASSERT_EQ(base::Value::TYPE_LIST, magic.type());
|
| + Schema items = magic.GetItems();
|
| + ASSERT_TRUE(items.valid());
|
| + EXPECT_EQ(base::Value::TYPE_STRING, items.type());
|
| +
|
| + Schema nomagic = schema.GetProperty("no magic");
|
| + ASSERT_TRUE(nomagic.valid());
|
| + ASSERT_EQ(base::Value::TYPE_LIST, nomagic.type());
|
| + items = nomagic.GetItems();
|
| + ASSERT_TRUE(items.valid());
|
| + EXPECT_EQ(base::Value::TYPE_BOOLEAN, items.type());
|
| +}
|
|
|
| } // namespace policy
|
|
|