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

Side by Side Diff: components/webcrypto/test/test_helpers.cc

Issue 1323923002: Remove use of JSONReader::DeprecatedRead from components/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Error fix Created 5 years, 3 months 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
« no previous file with comments | « components/web_resource/promo_resource_service_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/webcrypto/test/test_helpers.h" 5 #include "components/webcrypto/test/test_helpers.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 if (!base::ReadFileToString(file_path, &file_contents)) { 194 if (!base::ReadFileToString(file_path, &file_contents)) {
195 return ::testing::AssertionFailure() 195 return ::testing::AssertionFailure()
196 << "Couldn't read test file: " << file_path.value(); 196 << "Couldn't read test file: " << file_path.value();
197 } 197 }
198 198
199 // Strip C++ style comments out of the "json" file, otherwise it cannot be 199 // Strip C++ style comments out of the "json" file, otherwise it cannot be
200 // parsed. 200 // parsed.
201 re2::RE2::GlobalReplace(&file_contents, re2::RE2("\\s*//.*"), ""); 201 re2::RE2::GlobalReplace(&file_contents, re2::RE2("\\s*//.*"), "");
202 202
203 // Parse the JSON to a dictionary. 203 // Parse the JSON to a dictionary.
204 value->reset(base::JSONReader::DeprecatedRead(file_contents)); 204 *value = base::JSONReader::Read(file_contents);
205 if (!value->get()) { 205 if (!value->get()) {
206 return ::testing::AssertionFailure() 206 return ::testing::AssertionFailure()
207 << "Couldn't parse test file JSON: " << file_path.value(); 207 << "Couldn't parse test file JSON: " << file_path.value();
208 } 208 }
209 209
210 return ::testing::AssertionSuccess(); 210 return ::testing::AssertionSuccess();
211 } 211 }
212 212
213 ::testing::AssertionResult ReadJsonTestFileToList( 213 ::testing::AssertionResult ReadJsonTestFileToList(
214 const char* test_file_name, 214 const char* test_file_name,
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 blink::WebCryptoKey* key) { 421 blink::WebCryptoKey* key) {
422 return ImportKey(blink::WebCryptoKeyFormatJwk, 422 return ImportKey(blink::WebCryptoKeyFormatJwk,
423 CryptoData(MakeJsonVector(dict)), algorithm, extractable, 423 CryptoData(MakeJsonVector(dict)), algorithm, extractable,
424 usages, key); 424 usages, key);
425 } 425 }
426 426
427 scoped_ptr<base::DictionaryValue> GetJwkDictionary( 427 scoped_ptr<base::DictionaryValue> GetJwkDictionary(
428 const std::vector<uint8_t>& json) { 428 const std::vector<uint8_t>& json) {
429 base::StringPiece json_string( 429 base::StringPiece json_string(
430 reinterpret_cast<const char*>(vector_as_array(&json)), json.size()); 430 reinterpret_cast<const char*>(vector_as_array(&json)), json.size());
431 base::Value* value = base::JSONReader::DeprecatedRead(json_string); 431 scoped_ptr<base::Value> value = base::JSONReader::Read(json_string);
432 EXPECT_TRUE(value); 432 EXPECT_TRUE(value.get());
433 base::DictionaryValue* dict_value = NULL; 433 EXPECT_TRUE(value->IsType(base::Value::TYPE_DICTIONARY));
434 value->GetAsDictionary(&dict_value); 434
435 return scoped_ptr<base::DictionaryValue>(dict_value); 435 return scoped_ptr<base::DictionaryValue>(
436 static_cast<base::DictionaryValue*>(value.release()));
436 } 437 }
437 438
438 // Verifies the input dictionary contains the expected values. Exact matches are 439 // Verifies the input dictionary contains the expected values. Exact matches are
439 // required on the fields examined. 440 // required on the fields examined.
440 ::testing::AssertionResult VerifyJwk( 441 ::testing::AssertionResult VerifyJwk(
441 const scoped_ptr<base::DictionaryValue>& dict, 442 const scoped_ptr<base::DictionaryValue>& dict,
442 const std::string& kty_expected, 443 const std::string& kty_expected,
443 const std::string& alg_expected, 444 const std::string& alg_expected,
444 blink::WebCryptoKeyUsageMask use_mask_expected) { 445 blink::WebCryptoKeyUsageMask use_mask_expected) {
445 // ---- kty 446 // ---- kty
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 return blink::WebCryptoNamedCurveP384; 688 return blink::WebCryptoNamedCurveP384;
688 if (curve_str == "P-521") 689 if (curve_str == "P-521")
689 return blink::WebCryptoNamedCurveP521; 690 return blink::WebCryptoNamedCurveP521;
690 else 691 else
691 ADD_FAILURE() << "Unrecognized curve name: " << curve_str; 692 ADD_FAILURE() << "Unrecognized curve name: " << curve_str;
692 693
693 return blink::WebCryptoNamedCurveP384; 694 return blink::WebCryptoNamedCurveP384;
694 } 695 }
695 696
696 } // namespace webcrypto 697 } // namespace webcrypto
OLDNEW
« no previous file with comments | « components/web_resource/promo_resource_service_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698