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/json_schema/json_schema_validator_unittest_base.h" | 5 #include "components/json_schema/json_schema_validator_unittest_base.h" |
6 | 6 |
7 #include <cfloat> | 7 #include <cfloat> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <memory> | 10 #include <memory> |
11 | 11 |
12 #include "base/base_paths.h" | 12 #include "base/base_paths.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/json/json_file_value_serializer.h" | 14 #include "base/json/json_file_value_serializer.h" |
15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/memory/ptr_util.h" |
16 #include "base/path_service.h" | 17 #include "base/path_service.h" |
17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
18 #include "base/values.h" | 19 #include "base/values.h" |
19 #include "components/json_schema/json_schema_constants.h" | 20 #include "components/json_schema/json_schema_constants.h" |
20 #include "components/json_schema/json_schema_validator.h" | 21 #include "components/json_schema/json_schema_validator.h" |
21 | 22 |
22 namespace schema = json_schema_constants; | 23 namespace schema = json_schema_constants; |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 std::unique_ptr<base::DictionaryValue> schema( | 92 std::unique_ptr<base::DictionaryValue> schema( |
92 LoadDictionary("complex_schema.json")); | 93 LoadDictionary("complex_schema.json")); |
93 std::unique_ptr<base::ListValue> instance(LoadList("complex_instance.json")); | 94 std::unique_ptr<base::ListValue> instance(LoadList("complex_instance.json")); |
94 | 95 |
95 ASSERT_TRUE(schema.get()); | 96 ASSERT_TRUE(schema.get()); |
96 ASSERT_TRUE(instance.get()); | 97 ASSERT_TRUE(instance.get()); |
97 | 98 |
98 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); | 99 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); |
99 instance->Remove(instance->GetSize() - 1, NULL); | 100 instance->Remove(instance->GetSize() - 1, NULL); |
100 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); | 101 ExpectValid(TEST_SOURCE, instance.get(), schema.get(), NULL); |
101 instance->Append(new base::DictionaryValue()); | 102 instance->Append(base::MakeUnique<base::DictionaryValue>()); |
102 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "1", | 103 ExpectNotValid(TEST_SOURCE, instance.get(), schema.get(), NULL, "1", |
103 JSONSchemaValidator::FormatErrorMessage( | 104 JSONSchemaValidator::FormatErrorMessage( |
104 JSONSchemaValidator::kInvalidType, | 105 JSONSchemaValidator::kInvalidType, |
105 schema::kNumber, | 106 schema::kNumber, |
106 schema::kObject)); | 107 schema::kObject)); |
107 instance->Remove(instance->GetSize() - 1, NULL); | 108 instance->Remove(instance->GetSize() - 1, NULL); |
108 | 109 |
109 base::DictionaryValue* item = NULL; | 110 base::DictionaryValue* item = NULL; |
110 ASSERT_TRUE(instance->GetDictionary(0, &item)); | 111 ASSERT_TRUE(instance->GetDictionary(0, &item)); |
111 item->SetString("url", "xxxxxxxxxxx"); | 112 item->SetString("url", "xxxxxxxxxxx"); |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 schema::kInteger)); | 758 schema::kInteger)); |
758 | 759 |
759 schema->SetString(schema::kType, schema::kNull); | 760 schema->SetString(schema::kType, schema::kNull); |
760 ExpectNotValid( | 761 ExpectNotValid( |
761 TEST_SOURCE, | 762 TEST_SOURCE, |
762 std::unique_ptr<base::Value>(new base::FundamentalValue(false)).get(), | 763 std::unique_ptr<base::Value>(new base::FundamentalValue(false)).get(), |
763 schema.get(), NULL, std::string(), | 764 schema.get(), NULL, std::string(), |
764 JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType, | 765 JSONSchemaValidator::FormatErrorMessage(JSONSchemaValidator::kInvalidType, |
765 schema::kNull, schema::kBoolean)); | 766 schema::kNull, schema::kBoolean)); |
766 } | 767 } |
OLD | NEW |