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 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 base::FilePath path; | 29 base::FilePath path; |
30 PathService::Get(base::DIR_SOURCE_ROOT, &path); | 30 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
31 path = path.AppendASCII("components") | 31 path = path.AppendASCII("components") |
32 .AppendASCII("test") | 32 .AppendASCII("test") |
33 .AppendASCII("data") | 33 .AppendASCII("data") |
34 .AppendASCII("json_schema") | 34 .AppendASCII("json_schema") |
35 .AppendASCII(filename); | 35 .AppendASCII(filename); |
36 EXPECT_TRUE(base::PathExists(path)); | 36 EXPECT_TRUE(base::PathExists(path)); |
37 | 37 |
38 std::string error_message; | 38 std::string error_message; |
39 JSONFileValueSerializer serializer(path); | 39 JSONFileValueDeserializer deserializer(path); |
40 base::Value* result = serializer.Deserialize(NULL, &error_message); | 40 base::Value* result = deserializer.Deserialize(NULL, &error_message); |
41 if (!result) | 41 if (!result) |
42 ADD_FAILURE() << "Could not parse JSON: " << error_message; | 42 ADD_FAILURE() << "Could not parse JSON: " << error_message; |
43 return result; | 43 return result; |
44 } | 44 } |
45 | 45 |
46 base::Value* LoadValue(const std::string& filename, base::Value::Type type) { | 46 base::Value* LoadValue(const std::string& filename, base::Value::Type type) { |
47 scoped_ptr<base::Value> result(LoadValue(filename)); | 47 scoped_ptr<base::Value> result(LoadValue(filename)); |
48 if (!result.get()) | 48 if (!result.get()) |
49 return NULL; | 49 return NULL; |
50 if (!result->IsType(type)) { | 50 if (!result->IsType(type)) { |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
762 schema->SetString(schema::kType, schema::kNull); | 762 schema->SetString(schema::kType, schema::kNull); |
763 ExpectNotValid( | 763 ExpectNotValid( |
764 TEST_SOURCE, | 764 TEST_SOURCE, |
765 scoped_ptr<base::Value>(new base::FundamentalValue(false)).get(), | 765 scoped_ptr<base::Value>(new base::FundamentalValue(false)).get(), |
766 schema.get(), | 766 schema.get(), |
767 NULL, | 767 NULL, |
768 std::string(), | 768 std::string(), |
769 JSONSchemaValidator::FormatErrorMessage( | 769 JSONSchemaValidator::FormatErrorMessage( |
770 JSONSchemaValidator::kInvalidType, schema::kNull, schema::kBoolean)); | 770 JSONSchemaValidator::kInvalidType, schema::kNull, schema::kBoolean)); |
771 } | 771 } |
OLD | NEW |