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

Unified Diff: components/policy/core/common/schema_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: 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
« components/policy/core/common/schema.h ('K') | « components/policy/core/common/schema.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698