OLD | NEW |
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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 base::HexStringToBytes(hex, &bytes); | 161 base::HexStringToBytes(hex, &bytes); |
162 return bytes; | 162 return bytes; |
163 } | 163 } |
164 | 164 |
165 std::vector<uint8_t> MakeJsonVector(const std::string& json_string) { | 165 std::vector<uint8_t> MakeJsonVector(const std::string& json_string) { |
166 return std::vector<uint8_t>(json_string.begin(), json_string.end()); | 166 return std::vector<uint8_t>(json_string.begin(), json_string.end()); |
167 } | 167 } |
168 | 168 |
169 std::vector<uint8_t> MakeJsonVector(const base::DictionaryValue& dict) { | 169 std::vector<uint8_t> MakeJsonVector(const base::DictionaryValue& dict) { |
170 std::string json; | 170 std::string json; |
171 base::JSONWriter::Write(&dict, &json); | 171 base::JSONWriter::Write(dict, &json); |
172 return MakeJsonVector(json); | 172 return MakeJsonVector(json); |
173 } | 173 } |
174 | 174 |
175 ::testing::AssertionResult ReadJsonTestFile(const char* test_file_name, | 175 ::testing::AssertionResult ReadJsonTestFile(const char* test_file_name, |
176 scoped_ptr<base::Value>* value) { | 176 scoped_ptr<base::Value>* value) { |
177 base::FilePath test_data_dir; | 177 base::FilePath test_data_dir; |
178 if (!PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir)) | 178 if (!PathService::Get(base::DIR_SOURCE_ROOT, &test_data_dir)) |
179 return ::testing::AssertionFailure() << "Couldn't retrieve test dir"; | 179 return ::testing::AssertionFailure() << "Couldn't retrieve test dir"; |
180 | 180 |
181 base::FilePath file_path = test_data_dir.AppendASCII("components") | 181 base::FilePath file_path = test_data_dir.AppendASCII("components") |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 return blink::WebCryptoNamedCurveP384; | 679 return blink::WebCryptoNamedCurveP384; |
680 if (curve_str == "P-521") | 680 if (curve_str == "P-521") |
681 return blink::WebCryptoNamedCurveP521; | 681 return blink::WebCryptoNamedCurveP521; |
682 else | 682 else |
683 ADD_FAILURE() << "Unrecognized curve name: " << curve_str; | 683 ADD_FAILURE() << "Unrecognized curve name: " << curve_str; |
684 | 684 |
685 return blink::WebCryptoNamedCurveP384; | 685 return blink::WebCryptoNamedCurveP384; |
686 } | 686 } |
687 | 687 |
688 } // namespace webcrypto | 688 } // namespace webcrypto |
OLD | NEW |