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 "chromeos/network/onc/onc_test_utils.h" | 5 #include "chromeos/network/onc/onc_test_utils.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
11 #include "base/json/json_file_value_serializer.h" | 11 #include "base/json/json_file_value_serializer.h" |
| 12 #include "base/json/json_reader.h" |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "base/values.h" | 14 #include "base/values.h" |
14 #include "chromeos/chromeos_test_utils.h" | 15 #include "chromeos/chromeos_test_utils.h" |
15 | 16 |
16 namespace chromeos { | 17 namespace chromeos { |
17 namespace onc { | 18 namespace onc { |
18 namespace test_utils { | 19 namespace test_utils { |
19 | 20 |
20 namespace { | 21 namespace { |
21 | 22 |
(...skipping 21 matching lines...) Expand all Loading... |
43 std::unique_ptr<base::DictionaryValue> dict; | 44 std::unique_ptr<base::DictionaryValue> dict; |
44 base::FilePath path; | 45 base::FilePath path; |
45 if (!chromeos::test_utils::GetTestDataPath(kNetworkComponentDirectory, | 46 if (!chromeos::test_utils::GetTestDataPath(kNetworkComponentDirectory, |
46 filename, | 47 filename, |
47 &path)) { | 48 &path)) { |
48 NOTREACHED() << "Unable to get test dictionary path for " | 49 NOTREACHED() << "Unable to get test dictionary path for " |
49 << kNetworkComponentDirectory << "/" << filename; | 50 << kNetworkComponentDirectory << "/" << filename; |
50 return dict; | 51 return dict; |
51 } | 52 } |
52 | 53 |
53 JSONFileValueDeserializer deserializer(path); | 54 JSONFileValueDeserializer deserializer(path, |
54 deserializer.set_allow_trailing_comma(true); | 55 base::JSON_ALLOW_TRAILING_COMMAS); |
55 | 56 |
56 std::string error_message; | 57 std::string error_message; |
57 std::unique_ptr<base::Value> content = | 58 std::unique_ptr<base::Value> content = |
58 deserializer.Deserialize(NULL, &error_message); | 59 deserializer.Deserialize(NULL, &error_message); |
59 CHECK(content != NULL) << "Couldn't json-deserialize file '" | 60 CHECK(content != NULL) << "Couldn't json-deserialize file '" |
60 << filename << "': " << error_message; | 61 << filename << "': " << error_message; |
61 | 62 |
62 dict = base::DictionaryValue::From(std::move(content)); | 63 dict = base::DictionaryValue::From(std::move(content)); |
63 CHECK(dict) << "File '" << filename | 64 CHECK(dict) << "File '" << filename |
64 << "' does not contain a dictionary as expected, but type " | 65 << "' does not contain a dictionary as expected, but type " |
(...skipping 11 matching lines...) Expand all Loading... |
76 return ::testing::AssertionSuccess() << "Values are equal"; | 77 return ::testing::AssertionSuccess() << "Values are equal"; |
77 | 78 |
78 return ::testing::AssertionFailure() << "Values are unequal.\n" | 79 return ::testing::AssertionFailure() << "Values are unequal.\n" |
79 << "Expected value:\n" << *expected | 80 << "Expected value:\n" << *expected |
80 << "Actual value:\n" << *actual; | 81 << "Actual value:\n" << *actual; |
81 } | 82 } |
82 | 83 |
83 } // namespace test_utils | 84 } // namespace test_utils |
84 } // namespace onc | 85 } // namespace onc |
85 } // namespace chromeos | 86 } // namespace chromeos |
OLD | NEW |