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> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ptr_util.h" |
13 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
14 #include "components/policy/core/common/schema_internal.h" | 15 #include "components/policy/core/common/schema_internal.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 namespace policy { | 18 namespace policy { |
18 | 19 |
19 namespace { | 20 namespace { |
20 | 21 |
21 #define TestSchemaValidation(a, b, c, d) \ | 22 #define TestSchemaValidation(a, b, c, d) \ |
22 TestSchemaValidationHelper( \ | 23 TestSchemaValidationHelper( \ |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
633 | 634 |
634 // Unknown name. | 635 // Unknown name. |
635 bundle.Clear(); | 636 bundle.Clear(); |
636 bundle.SetBoolean("Unknown", true); | 637 bundle.SetBoolean("Unknown", true); |
637 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false); | 638 TestSchemaValidation(schema, bundle, SCHEMA_STRICT, false); |
638 | 639 |
639 // All of these will be valid. | 640 // All of these will be valid. |
640 bundle.Clear(); | 641 bundle.Clear(); |
641 bundle.SetBoolean("Boolean", true); | 642 bundle.SetBoolean("Boolean", true); |
642 bundle.SetInteger("Integer", 123); | 643 bundle.SetInteger("Integer", 123); |
643 bundle.Set("Null", base::Value::CreateNullValue()); | 644 bundle.Set("Null", base::MakeUnique<base::Value>()); |
644 bundle.Set("Number", new base::Value(3.14)); | 645 bundle.Set("Number", new base::Value(3.14)); |
645 bundle.SetString("String", "omg"); | 646 bundle.SetString("String", "omg"); |
646 | 647 |
647 { | 648 { |
648 base::ListValue list; | 649 base::ListValue list; |
649 list.AppendString("a string"); | 650 list.AppendString("a string"); |
650 list.AppendString("another string"); | 651 list.AppendString("another string"); |
651 bundle.Set("Array", list.DeepCopy()); | 652 bundle.Set("Array", list.DeepCopy()); |
652 } | 653 } |
653 | 654 |
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 | 1175 |
1175 EXPECT_FALSE(ParseFails(SchemaObjectWrapper( | 1176 EXPECT_FALSE(ParseFails(SchemaObjectWrapper( |
1176 "{" | 1177 "{" |
1177 " \"type\": \"integer\"," | 1178 " \"type\": \"integer\"," |
1178 " \"minimum\": 10," | 1179 " \"minimum\": 10," |
1179 " \"maximum\": 20" | 1180 " \"maximum\": 20" |
1180 "}"))); | 1181 "}"))); |
1181 } | 1182 } |
1182 | 1183 |
1183 } // namespace policy | 1184 } // namespace policy |
OLD | NEW |