| 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> |
| 8 |
| 7 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| 9 #include "base/json/json_file_value_serializer.h" | 11 #include "base/json/json_file_value_serializer.h" |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/values.h" | 13 #include "base/values.h" |
| 12 #include "chromeos/chromeos_test_utils.h" | 14 #include "chromeos/chromeos_test_utils.h" |
| 13 | 15 |
| 14 namespace chromeos { | 16 namespace chromeos { |
| 15 namespace onc { | 17 namespace onc { |
| 16 namespace test_utils { | 18 namespace test_utils { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 | 52 |
| 51 JSONFileValueDeserializer deserializer(path); | 53 JSONFileValueDeserializer deserializer(path); |
| 52 deserializer.set_allow_trailing_comma(true); | 54 deserializer.set_allow_trailing_comma(true); |
| 53 | 55 |
| 54 std::string error_message; | 56 std::string error_message; |
| 55 scoped_ptr<base::Value> content = | 57 scoped_ptr<base::Value> content = |
| 56 deserializer.Deserialize(NULL, &error_message); | 58 deserializer.Deserialize(NULL, &error_message); |
| 57 CHECK(content != NULL) << "Couldn't json-deserialize file '" | 59 CHECK(content != NULL) << "Couldn't json-deserialize file '" |
| 58 << filename << "': " << error_message; | 60 << filename << "': " << error_message; |
| 59 | 61 |
| 60 dict = base::DictionaryValue::From(content.Pass()); | 62 dict = base::DictionaryValue::From(std::move(content)); |
| 61 CHECK(dict) << "File '" << filename | 63 CHECK(dict) << "File '" << filename |
| 62 << "' does not contain a dictionary as expected, but type " | 64 << "' does not contain a dictionary as expected, but type " |
| 63 << content->GetType(); | 65 << content->GetType(); |
| 64 return dict; | 66 return dict; |
| 65 } | 67 } |
| 66 | 68 |
| 67 ::testing::AssertionResult Equals(const base::Value* expected, | 69 ::testing::AssertionResult Equals(const base::Value* expected, |
| 68 const base::Value* actual) { | 70 const base::Value* actual) { |
| 69 CHECK(expected != NULL); | 71 CHECK(expected != NULL); |
| 70 if (actual == NULL) | 72 if (actual == NULL) |
| 71 return ::testing::AssertionFailure() << "Actual value pointer is NULL"; | 73 return ::testing::AssertionFailure() << "Actual value pointer is NULL"; |
| 72 | 74 |
| 73 if (expected->Equals(actual)) | 75 if (expected->Equals(actual)) |
| 74 return ::testing::AssertionSuccess() << "Values are equal"; | 76 return ::testing::AssertionSuccess() << "Values are equal"; |
| 75 | 77 |
| 76 return ::testing::AssertionFailure() << "Values are unequal.\n" | 78 return ::testing::AssertionFailure() << "Values are unequal.\n" |
| 77 << "Expected value:\n" << *expected | 79 << "Expected value:\n" << *expected |
| 78 << "Actual value:\n" << *actual; | 80 << "Actual value:\n" << *actual; |
| 79 } | 81 } |
| 80 | 82 |
| 81 } // namespace test_utils | 83 } // namespace test_utils |
| 82 } // namespace onc | 84 } // namespace onc |
| 83 } // namespace chromeos | 85 } // namespace chromeos |
| OLD | NEW |