Lines Matching refs:schema
5 #include "components/policy/core/common/schema.h"
133 Schema schema = Schema::Parse(content, &error);
134 if (schema.valid())
141 Schema schema,
148 // Test that Schema::Validate() works as expected.
150 bool returned = schema.Validate(value, strategy, NULL, &error);
153 // Test that Schema::Normalize() will return the same value as
154 // Schema::Validate().
159 schema.Normalize(cloned_value.get(), strategy, NULL, &error, &touched);
162 bool strictly_valid = schema.Validate(value, SCHEMA_STRICT, NULL, &error);
165 // Test that Schema::Normalize() have actually dropped invalid and unknown
169 schema.Validate(*cloned_value.get(), SCHEMA_STRICT, NULL, &error))
172 schema.Normalize(cloned_value.get(), SCHEMA_STRICT, NULL, &error, NULL))
177 void TestSchemaValidationWithPath(Schema schema,
183 bool returned = schema.Validate(value, SCHEMA_STRICT, &error_path, &error);
257 Schema schema = Schema::Parse(
269 ASSERT_TRUE(schema.valid()) << error;
270 ASSERT_EQ(base::Value::TYPE_DICTIONARY, schema.type());
272 schema = schema.GetKnownProperty("sub");
273 ASSERT_TRUE(schema.valid());
274 ASSERT_EQ(base::Value::TYPE_DICTIONARY, schema.type());
277 Schema::Iterator it = schema.GetPropertiesIterator();
281 schema = it.schema();
286 ASSERT_TRUE(schema.valid());
287 EXPECT_EQ(base::Value::TYPE_STRING, schema.type());
294 Schema schema = Schema::Parse(kTestSchema, &error);
295 ASSERT_TRUE(schema.valid()) << error;
297 ASSERT_EQ(base::Value::TYPE_DICTIONARY, schema.type());
298 EXPECT_FALSE(schema.GetProperty("invalid").valid());
300 Schema sub = schema.GetProperty("Boolean");
304 sub = schema.GetProperty("Integer");
308 sub = schema.GetProperty("Null");
312 sub = schema.GetProperty("Number");
316 sub = schema.GetProperty("String");
320 sub = schema.GetProperty("Array");
327 sub = schema.GetProperty("ArrayOfObjects");
333 Schema subsub = sub.GetProperty("one");
342 sub = schema.GetProperty("ArrayOfArray");
352 sub = schema.GetProperty("Object");
365 sub = schema.GetProperty("IntegerWithEnums");
369 sub = schema.GetProperty("IntegerWithEnumsGaps");
373 sub = schema.GetProperty("StringWithEnums");
377 sub = schema.GetProperty("IntegerWithRange");
381 sub = schema.GetProperty("StringWithPattern");
385 sub = schema.GetProperty("ObjectWithPatternProperties");
412 Schema::Iterator it = schema.GetPropertiesIterator();
416 ASSERT_TRUE(it.schema().valid());
417 EXPECT_EQ(kExpectedProperties[i].expected_type, it.schema().type());
426 Schema schema = Schema::Parse("{ \"type\": \"object\" }", &error);
427 ASSERT_TRUE(schema.valid()) << error;
428 ASSERT_EQ(base::Value::TYPE_DICTIONARY, schema.type());
430 // This empty schema should never find named properties.
431 EXPECT_FALSE(schema.GetKnownProperty("").valid());
432 EXPECT_FALSE(schema.GetKnownProperty("xyz").valid());
433 EXPECT_TRUE(schema.GetPropertiesIterator().IsAtEnd());
435 schema = Schema::Parse(
442 ASSERT_TRUE(schema.valid()) << error;
443 ASSERT_EQ(base::Value::TYPE_DICTIONARY, schema.type());
445 EXPECT_FALSE(schema.GetKnownProperty("").valid());
446 EXPECT_FALSE(schema.GetKnownProperty("xyz").valid());
447 EXPECT_TRUE(schema.GetKnownProperty("Boolean").valid());
449 schema = Schema::Parse(
460 ASSERT_TRUE(schema.valid()) << error;
461 ASSERT_EQ(base::Value::TYPE_DICTIONARY, schema.type());
463 EXPECT_FALSE(schema.GetKnownProperty("").valid());
464 EXPECT_FALSE(schema.GetKnownProperty("xyz").valid());
477 Schema sub = schema.GetKnownProperty(kExpectedKeys[i].expected_key);
542 Schema schema = Schema::Wrap(&kData);
543 ASSERT_TRUE(schema.valid());
544 EXPECT_EQ(base::Value::TYPE_DICTIONARY, schema.type());
561 Schema::Iterator it = schema.GetPropertiesIterator();
565 Schema sub = it.schema();
570 Schema items = sub.GetItems();
579 Schema sub = schema.GetAdditionalProperties();
582 Schema subsub = sub.GetItems();
585 Schema subsubsub = subsub.GetItems();
589 SchemaList schema_list = schema.GetPatternProperties("barr");
595 EXPECT_TRUE(schema.GetPatternProperties("ba").empty());
596 EXPECT_TRUE(schema.GetPatternProperties("bar+$").empty());
601 Schema schema = Schema::Parse(kTestSchema, &error);
602 ASSERT_TRUE(schema.valid()) << error;
605 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, true);
609 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
617 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
626 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
632 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
683 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, true);
686 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
690 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
692 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
694 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, true);
696 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
698 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
700 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
702 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
704 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, true);
706 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
708 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
712 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
716 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
721 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
722 TestSchemaValidation(schema, bundle, SCHEMA_ALLOW_UNKNOWN_TOPLEVEL, true);
723 TestSchemaValidation(schema, bundle, SCHEMA_ALLOW_UNKNOWN, true);
724 TestSchemaValidationWithPath(schema, bundle, "");
729 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false);
730 TestSchemaValidation(schema, bundle, SCHEMA_ALLOW_INVALID_TOPLEVEL, true);
731 TestSchemaValidation(schema, bundle, SCHEMA_ALLOW_INVALID, true);
732 TestSchemaValidationWithPath(schema, bundle, "Boolean");
737 Schema subschema = schema.GetProperty("ObjectOfObject");
764 Schema subschema = schema.GetProperty("ArrayOfObjects");
795 Schema subschema = schema.GetProperty("ObjectOfArray");
822 Schema subschema = schema.GetProperty("ArrayOfObjectOfArray");
851 Schema subschema = schema.GetProperty("StringWithPattern");
868 Schema subschema = schema.GetProperty("ObjectWithPatternProperties");
918 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, true);
975 // Verifies that references can go to a parent schema, to define a
978 Schema schema = Schema::Parse(
996 ASSERT_TRUE(schema.valid()) << error;
997 ASSERT_EQ(base::Value::TYPE_DICTIONARY, schema.type());
999 Schema parent = schema.GetKnownProperty("bookmarks");
1005 Schema items = parent.GetItems();
1009 Schema prop = items.GetKnownProperty("name");
1028 Schema schema = Schema::Parse(
1046 ASSERT_TRUE(schema.valid()) << error;
1047 ASSERT_EQ(base::Value::TYPE_DICTIONARY, schema.type());
1050 Schema sub = schema.GetKnownProperty(std::string(1, c));
1059 Schema schema = Schema::Parse(
1075 ASSERT_TRUE(schema.valid()) << error;
1076 ASSERT_EQ(base::Value::TYPE_DICTIONARY, schema.type());
1078 Schema policy = schema.GetKnownProperty("policy");
1082 Schema foo = policy.GetKnownProperty("foo");
1086 Schema additional = policy.GetAdditionalProperties();
1090 Schema x = policy.GetProperty("x");
1098 Schema schema = Schema::Parse(
1112 ASSERT_TRUE(schema.valid()) << error;
1113 ASSERT_EQ(base::Value::TYPE_DICTIONARY, schema.type());
1115 Schema foo = schema.GetKnownProperty("foo");
1119 Schema list = schema.GetKnownProperty("list");
1123 Schema items = list.GetItems();