OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/common/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 |
| 11 #include "base/base_paths.h" |
11 #include "base/file_util.h" | 12 #include "base/file_util.h" |
12 #include "base/json/json_file_value_serializer.h" | 13 #include "base/json/json_file_value_serializer.h" |
13 #include "base/logging.h" | 14 #include "base/logging.h" |
14 #include "base/memory/scoped_ptr.h" | 15 #include "base/memory/scoped_ptr.h" |
15 #include "base/path_service.h" | 16 #include "base/path_service.h" |
16 #include "base/strings/stringprintf.h" | 17 #include "base/strings/stringprintf.h" |
17 #include "base/values.h" | 18 #include "base/values.h" |
18 #include "chrome/common/chrome_paths.h" | 19 #include "components/json_schema/json_schema_constants.h" |
19 #include "chrome/common/json_schema/json_schema_constants.h" | 20 #include "components/json_schema/json_schema_validator.h" |
20 #include "chrome/common/json_schema/json_schema_validator.h" | |
21 | 21 |
22 namespace schema = json_schema_constants; | 22 namespace schema = json_schema_constants; |
23 | 23 |
24 namespace { | 24 namespace { |
25 | 25 |
26 #define TEST_SOURCE base::StringPrintf("%s:%i", __FILE__, __LINE__) | 26 #define TEST_SOURCE base::StringPrintf("%s:%i", __FILE__, __LINE__) |
27 | 27 |
28 base::Value* LoadValue(const std::string& filename) { | 28 base::Value* LoadValue(const std::string& filename) { |
29 base::FilePath path; | 29 base::FilePath path; |
30 PathService::Get(chrome::DIR_TEST_DATA, &path); | 30 PathService::Get(base::DIR_SOURCE_ROOT, &path); |
31 path = path.AppendASCII("json_schema_validator").AppendASCII(filename); | 31 path = path.AppendASCII("components") |
| 32 .AppendASCII("test") |
| 33 .AppendASCII("data") |
| 34 .AppendASCII("json_schema") |
| 35 .AppendASCII(filename); |
32 EXPECT_TRUE(base::PathExists(path)); | 36 EXPECT_TRUE(base::PathExists(path)); |
33 | 37 |
34 std::string error_message; | 38 std::string error_message; |
35 JSONFileValueSerializer serializer(path); | 39 JSONFileValueSerializer serializer(path); |
36 base::Value* result = serializer.Deserialize(NULL, &error_message); | 40 base::Value* result = serializer.Deserialize(NULL, &error_message); |
37 if (!result) | 41 if (!result) |
38 ADD_FAILURE() << "Could not parse JSON: " << error_message; | 42 ADD_FAILURE() << "Could not parse JSON: " << error_message; |
39 return result; | 43 return result; |
40 } | 44 } |
41 | 45 |
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
717 schema->SetString(schema::kType, schema::kNull); | 721 schema->SetString(schema::kType, schema::kNull); |
718 ExpectNotValid( | 722 ExpectNotValid( |
719 TEST_SOURCE, | 723 TEST_SOURCE, |
720 scoped_ptr<base::Value>(new base::FundamentalValue(false)).get(), | 724 scoped_ptr<base::Value>(new base::FundamentalValue(false)).get(), |
721 schema.get(), | 725 schema.get(), |
722 NULL, | 726 NULL, |
723 std::string(), | 727 std::string(), |
724 JSONSchemaValidator::FormatErrorMessage( | 728 JSONSchemaValidator::FormatErrorMessage( |
725 JSONSchemaValidator::kInvalidType, schema::kNull, schema::kBoolean)); | 729 JSONSchemaValidator::kInvalidType, schema::kNull, schema::kBoolean)); |
726 } | 730 } |
OLD | NEW |