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 "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/json/json_file_value_serializer.h" | 9 #include "base/json/json_file_value_serializer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 base::DictionaryValue* dict = NULL; | 41 base::DictionaryValue* dict = NULL; |
42 base::FilePath path; | 42 base::FilePath path; |
43 if (!chromeos::test_utils::GetTestDataPath(kNetworkComponentDirectory, | 43 if (!chromeos::test_utils::GetTestDataPath(kNetworkComponentDirectory, |
44 filename, | 44 filename, |
45 &path)) { | 45 &path)) { |
46 NOTREACHED() << "Unable to get test dictionary path for " | 46 NOTREACHED() << "Unable to get test dictionary path for " |
47 << kNetworkComponentDirectory << "/" << filename; | 47 << kNetworkComponentDirectory << "/" << filename; |
48 return make_scoped_ptr(dict); | 48 return make_scoped_ptr(dict); |
49 } | 49 } |
50 | 50 |
51 JSONFileValueSerializer serializer(path); | 51 JSONFileValueDeserializer deserializer(path); |
52 serializer.set_allow_trailing_comma(true); | 52 deserializer.set_allow_trailing_comma(true); |
53 | 53 |
54 std::string error_message; | 54 std::string error_message; |
55 base::Value* content = serializer.Deserialize(NULL, &error_message); | 55 base::Value* content = deserializer.Deserialize(NULL, &error_message); |
56 CHECK(content != NULL) << "Couldn't json-deserialize file '" | 56 CHECK(content != NULL) << "Couldn't json-deserialize file '" |
57 << filename << "': " << error_message; | 57 << filename << "': " << error_message; |
58 | 58 |
59 CHECK(content->GetAsDictionary(&dict)) | 59 CHECK(content->GetAsDictionary(&dict)) |
60 << "File '" << filename | 60 << "File '" << filename |
61 << "' does not contain a dictionary as expected, but type " | 61 << "' does not contain a dictionary as expected, but type " |
62 << content->GetType(); | 62 << content->GetType(); |
63 return make_scoped_ptr(dict); | 63 return make_scoped_ptr(dict); |
64 } | 64 } |
65 | 65 |
66 ::testing::AssertionResult Equals(const base::Value* expected, | 66 ::testing::AssertionResult Equals(const base::Value* expected, |
67 const base::Value* actual) { | 67 const base::Value* actual) { |
68 CHECK(expected != NULL); | 68 CHECK(expected != NULL); |
69 if (actual == NULL) | 69 if (actual == NULL) |
70 return ::testing::AssertionFailure() << "Actual value pointer is NULL"; | 70 return ::testing::AssertionFailure() << "Actual value pointer is NULL"; |
71 | 71 |
72 if (expected->Equals(actual)) | 72 if (expected->Equals(actual)) |
73 return ::testing::AssertionSuccess() << "Values are equal"; | 73 return ::testing::AssertionSuccess() << "Values are equal"; |
74 | 74 |
75 return ::testing::AssertionFailure() << "Values are unequal.\n" | 75 return ::testing::AssertionFailure() << "Values are unequal.\n" |
76 << "Expected value:\n" << *expected | 76 << "Expected value:\n" << *expected |
77 << "Actual value:\n" << *actual; | 77 << "Actual value:\n" << *actual; |
78 } | 78 } |
79 | 79 |
80 } // namespace test_utils | 80 } // namespace test_utils |
81 } // namespace onc | 81 } // namespace onc |
82 } // namespace chromeos | 82 } // namespace chromeos |
OLD | NEW |