Commit 684a1b2f authored by Nigel Tao's avatar Nigel Tao Committed by Commit Bot

Upgrade ntp_snippets from deprecated base::JSONReader API

Bug: 1070409
Change-Id: I027c6347b63b1ff5d327470d4eeedd7bd5447018
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2222071Reviewed-by: default avatarCarlos Knippschild <carlosk@chromium.org>
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#774485}
parent 065b0a7f
...@@ -45,24 +45,21 @@ using testing::NotNull; ...@@ -45,24 +45,21 @@ using testing::NotNull;
using testing::StrEq; using testing::StrEq;
MATCHER_P(EqualsJSON, json, "equals JSON") { MATCHER_P(EqualsJSON, json, "equals JSON") {
std::unique_ptr<base::Value> expected = base::Optional<base::Value> expected = base::JSONReader::Read(json);
base::JSONReader::ReadDeprecated(json);
if (!expected) { if (!expected) {
*result_listener << "INTERNAL ERROR: couldn't parse expected JSON"; *result_listener << "INTERNAL ERROR: couldn't parse expected JSON";
return false; return false;
} }
std::string err_msg; base::JSONReader::ValueWithError actual =
int err_line, err_col; base::JSONReader::ReadAndReturnValueWithError(arg);
std::unique_ptr<base::Value> actual = if (!actual.value) {
base::JSONReader::ReadAndReturnErrorDeprecated( *result_listener << "input:" << actual.error_line << ":"
arg, base::JSON_PARSE_RFC, nullptr, &err_msg, &err_line, &err_col); << actual.error_column << ": "
if (!actual) { << "parse error: " << actual.error_message;
*result_listener << "input:" << err_line << ":" << err_col << ": "
<< "parse error: " << err_msg;
return false; return false;
} }
return *expected == *actual; return *expected == *actual.value;
} }
} // namespace } // namespace
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment