Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(897)

Side by Side Diff: chromeos/network/onc/onc_test_utils.cc

Issue 2475583002: Adds option for JSON reader to allow invalid utf characters (Closed)
Patch Set: comment Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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
OLDNEW
« no previous file with comments | « chrome/browser/ui/app_list/start_page_service.cc ('k') | chromeos/network/onc/onc_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698