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/file_path.h" | 7 #include "base/file_path.h" |
8 #include "base/file_util.h" | 8 #include "base/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" |
11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chromeos/chromeos_test_utils.h" | 13 #include "chromeos/chromeos_test_utils.h" |
14 | 14 |
15 namespace chromeos { | 15 namespace chromeos { |
16 namespace onc { | 16 namespace onc { |
17 namespace test_utils { | 17 namespace test_utils { |
18 | 18 |
19 namespace { | 19 namespace { |
20 | 20 |
21 // The name of the component directory to get the test data from. | 21 // The name of the component directory to get the test data from. |
22 const char kNetworkComponentDirectory[] = "network"; | 22 const char kNetworkComponentDirectory[] = "network"; |
23 | 23 |
24 } // namespace | 24 } // namespace |
25 | 25 |
26 std::string ReadTestData(const std::string& filename) { | 26 std::string ReadTestData(const std::string& filename) { |
27 FilePath path; | 27 base::FilePath path; |
28 if (!chromeos::test_utils::GetTestDataPath(kNetworkComponentDirectory, | 28 if (!chromeos::test_utils::GetTestDataPath(kNetworkComponentDirectory, |
29 filename, | 29 filename, |
30 &path)) { | 30 &path)) { |
31 NOTREACHED() << "Unable to get test data path for " | 31 NOTREACHED() << "Unable to get test data path for " |
32 << kNetworkComponentDirectory << "/" << filename; | 32 << kNetworkComponentDirectory << "/" << filename; |
33 return ""; | 33 return ""; |
34 } | 34 } |
35 std::string result; | 35 std::string result; |
36 file_util::ReadFileToString(path, &result); | 36 file_util::ReadFileToString(path, &result); |
37 return result; | 37 return result; |
38 } | 38 } |
39 | 39 |
40 scoped_ptr<base::DictionaryValue> ReadTestDictionary( | 40 scoped_ptr<base::DictionaryValue> ReadTestDictionary( |
41 const std::string& filename) { | 41 const std::string& filename) { |
42 base::DictionaryValue* dict = NULL; | 42 base::DictionaryValue* dict = NULL; |
43 FilePath path; | 43 base::FilePath path; |
44 if (!chromeos::test_utils::GetTestDataPath(kNetworkComponentDirectory, | 44 if (!chromeos::test_utils::GetTestDataPath(kNetworkComponentDirectory, |
45 filename, | 45 filename, |
46 &path)) { | 46 &path)) { |
47 NOTREACHED() << "Unable to get test dictionary path for " | 47 NOTREACHED() << "Unable to get test dictionary path for " |
48 << kNetworkComponentDirectory << "/" << filename; | 48 << kNetworkComponentDirectory << "/" << filename; |
49 return make_scoped_ptr(dict); | 49 return make_scoped_ptr(dict); |
50 } | 50 } |
51 | 51 |
52 JSONFileValueSerializer serializer(path); | 52 JSONFileValueSerializer serializer(path); |
53 serializer.set_allow_trailing_comma(true); | 53 serializer.set_allow_trailing_comma(true); |
(...skipping 20 matching lines...) Expand all Loading... |
74 return ::testing::AssertionSuccess() << "Dictionaries are equal"; | 74 return ::testing::AssertionSuccess() << "Dictionaries are equal"; |
75 | 75 |
76 return ::testing::AssertionFailure() << "Dictionaries are unequal.\n" | 76 return ::testing::AssertionFailure() << "Dictionaries are unequal.\n" |
77 << "Expected dictionary:\n" << *expected | 77 << "Expected dictionary:\n" << *expected |
78 << "Actual dictionary:\n" << *actual; | 78 << "Actual dictionary:\n" << *actual; |
79 } | 79 } |
80 | 80 |
81 } // namespace test_utils | 81 } // namespace test_utils |
82 } // namespace onc | 82 } // namespace onc |
83 } // namespace chromeos | 83 } // namespace chromeos |
OLD | NEW |