OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/policy/core/common/schema.h" | 5 #include "components/policy/core/common/schema.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID_TOPLEVEL, true); | 851 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID_TOPLEVEL, true); |
852 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID, true); | 852 TestSchemaValidation(subschema, root, SCHEMA_ALLOW_INVALID, true); |
853 TestSchemaValidationWithPath(subschema, root, "items[0].List.items[1]"); | 853 TestSchemaValidationWithPath(subschema, root, "items[0].List.items[1]"); |
854 } | 854 } |
855 | 855 |
856 // Tests on StringWithPattern. | 856 // Tests on StringWithPattern. |
857 { | 857 { |
858 Schema subschema = schema.GetProperty("StringWithPattern"); | 858 Schema subschema = schema.GetProperty("StringWithPattern"); |
859 ASSERT_TRUE(subschema.valid()); | 859 ASSERT_TRUE(subschema.valid()); |
860 | 860 |
861 TestSchemaValidation( | 861 TestSchemaValidation(subschema, base::Value("foobar"), SCHEMA_STRICT, |
862 subschema, base::StringValue("foobar"), SCHEMA_STRICT, false); | 862 false); |
863 TestSchemaValidation( | 863 TestSchemaValidation(subschema, base::Value("foo"), SCHEMA_STRICT, true); |
864 subschema, base::StringValue("foo"), SCHEMA_STRICT, true); | 864 TestSchemaValidation(subschema, base::Value("fo"), SCHEMA_STRICT, false); |
865 TestSchemaValidation( | 865 TestSchemaValidation(subschema, base::Value("fooo"), SCHEMA_STRICT, true); |
866 subschema, base::StringValue("fo"), SCHEMA_STRICT, false); | 866 TestSchemaValidation(subschema, base::Value("^foo+$"), SCHEMA_STRICT, |
867 TestSchemaValidation( | 867 false); |
868 subschema, base::StringValue("fooo"), SCHEMA_STRICT, true); | |
869 TestSchemaValidation( | |
870 subschema, base::StringValue("^foo+$"), SCHEMA_STRICT, false); | |
871 } | 868 } |
872 | 869 |
873 // Tests on ObjectWithPatternProperties. | 870 // Tests on ObjectWithPatternProperties. |
874 { | 871 { |
875 Schema subschema = schema.GetProperty("ObjectWithPatternProperties"); | 872 Schema subschema = schema.GetProperty("ObjectWithPatternProperties"); |
876 ASSERT_TRUE(subschema.valid()); | 873 ASSERT_TRUE(subschema.valid()); |
877 base::DictionaryValue root; | 874 base::DictionaryValue root; |
878 | 875 |
879 ASSERT_EQ(1u, subschema.GetPatternProperties("fooo").size()); | 876 ASSERT_EQ(1u, subschema.GetPatternProperties("fooo").size()); |
880 ASSERT_EQ(1u, subschema.GetPatternProperties("foo").size()); | 877 ASSERT_EQ(1u, subschema.GetPatternProperties("foo").size()); |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 | 1174 |
1178 EXPECT_FALSE(ParseFails(SchemaObjectWrapper( | 1175 EXPECT_FALSE(ParseFails(SchemaObjectWrapper( |
1179 "{" | 1176 "{" |
1180 " \"type\": \"integer\"," | 1177 " \"type\": \"integer\"," |
1181 " \"minimum\": 10," | 1178 " \"minimum\": 10," |
1182 " \"maximum\": 20" | 1179 " \"maximum\": 20" |
1183 "}"))); | 1180 "}"))); |
1184 } | 1181 } |
1185 | 1182 |
1186 } // namespace policy | 1183 } // namespace policy |
OLD | NEW |