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

Side by Side Diff: content/child/webcrypto/test/sha_unittest.cc

Issue 508643003: Rename digest.json --> sha.json (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 | « no previous file | content/test/data/webcrypto/digest.json » ('j') | 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/stl_util.h" 6 #include "base/stl_util.h"
7 #include "content/child/webcrypto/algorithm_dispatch.h" 7 #include "content/child/webcrypto/algorithm_dispatch.h"
8 #include "content/child/webcrypto/crypto_data.h" 8 #include "content/child/webcrypto/crypto_data.h"
9 #include "content/child/webcrypto/status.h" 9 #include "content/child/webcrypto/status.h"
10 #include "content/child/webcrypto/test/test_helpers.h" 10 #include "content/child/webcrypto/test/test_helpers.h"
11 #include "content/child/webcrypto/webcrypto_util.h" 11 #include "content/child/webcrypto/webcrypto_util.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h" 13 #include "third_party/WebKit/public/platform/WebCryptoAlgorithmParams.h"
14 #include "third_party/WebKit/public/platform/WebCryptoKey.h" 14 #include "third_party/WebKit/public/platform/WebCryptoKey.h"
15 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h" 15 #include "third_party/WebKit/public/platform/WebCryptoKeyAlgorithm.h"
16 16
17 namespace content { 17 namespace content {
18 18
19 namespace webcrypto { 19 namespace webcrypto {
20 20
21 namespace { 21 namespace {
22 22
23 TEST(WebCryptoShaTest, DigestSampleSets) { 23 TEST(WebCryptoShaTest, DigestSampleSets) {
24 scoped_ptr<base::ListValue> tests; 24 scoped_ptr<base::ListValue> tests;
25 // TODO(eroman): rename to sha.json 25 ASSERT_TRUE(ReadJsonTestFileToList("sha.json", &tests));
26 ASSERT_TRUE(ReadJsonTestFileToList("digest.json", &tests));
27 26
28 for (size_t test_index = 0; test_index < tests->GetSize(); ++test_index) { 27 for (size_t test_index = 0; test_index < tests->GetSize(); ++test_index) {
29 SCOPED_TRACE(test_index); 28 SCOPED_TRACE(test_index);
30 base::DictionaryValue* test; 29 base::DictionaryValue* test;
31 ASSERT_TRUE(tests->GetDictionary(test_index, &test)); 30 ASSERT_TRUE(tests->GetDictionary(test_index, &test));
32 31
33 blink::WebCryptoAlgorithm test_algorithm = 32 blink::WebCryptoAlgorithm test_algorithm =
34 GetDigestAlgorithm(test, "algorithm"); 33 GetDigestAlgorithm(test, "algorithm");
35 std::vector<uint8_t> test_input = GetBytesFromHexString(test, "input"); 34 std::vector<uint8_t> test_input = GetBytesFromHexString(test, "input");
36 std::vector<uint8_t> test_output = GetBytesFromHexString(test, "output"); 35 std::vector<uint8_t> test_output = GetBytesFromHexString(test, "output");
37 36
38 std::vector<uint8_t> output; 37 std::vector<uint8_t> output;
39 ASSERT_EQ(Status::Success(), 38 ASSERT_EQ(Status::Success(),
40 Digest(test_algorithm, CryptoData(test_input), &output)); 39 Digest(test_algorithm, CryptoData(test_input), &output));
41 EXPECT_BYTES_EQ(test_output, output); 40 EXPECT_BYTES_EQ(test_output, output);
42 } 41 }
43 } 42 }
44 43
45 TEST(WebCryptoShaTest, DigestSampleSetsInChunks) { 44 TEST(WebCryptoShaTest, DigestSampleSetsInChunks) {
46 scoped_ptr<base::ListValue> tests; 45 scoped_ptr<base::ListValue> tests;
47 ASSERT_TRUE(ReadJsonTestFileToList("digest.json", &tests)); 46 ASSERT_TRUE(ReadJsonTestFileToList("sha.json", &tests));
48 47
49 for (size_t test_index = 0; test_index < tests->GetSize(); ++test_index) { 48 for (size_t test_index = 0; test_index < tests->GetSize(); ++test_index) {
50 SCOPED_TRACE(test_index); 49 SCOPED_TRACE(test_index);
51 base::DictionaryValue* test; 50 base::DictionaryValue* test;
52 ASSERT_TRUE(tests->GetDictionary(test_index, &test)); 51 ASSERT_TRUE(tests->GetDictionary(test_index, &test));
53 52
54 blink::WebCryptoAlgorithm test_algorithm = 53 blink::WebCryptoAlgorithm test_algorithm =
55 GetDigestAlgorithm(test, "algorithm"); 54 GetDigestAlgorithm(test, "algorithm");
56 std::vector<uint8_t> test_input = GetBytesFromHexString(test, "input"); 55 std::vector<uint8_t> test_input = GetBytesFromHexString(test, "input");
57 std::vector<uint8_t> test_output = GetBytesFromHexString(test, "output"); 56 std::vector<uint8_t> test_output = GetBytesFromHexString(test, "output");
(...skipping 19 matching lines...) Expand all
77 EXPECT_TRUE(digestor->finish(output, output_length)); 76 EXPECT_TRUE(digestor->finish(output, output_length));
78 EXPECT_BYTES_EQ(test_output, CryptoData(output, output_length)); 77 EXPECT_BYTES_EQ(test_output, CryptoData(output, output_length));
79 } 78 }
80 } 79 }
81 80
82 } // namespace 81 } // namespace
83 82
84 } // namespace webcrypto 83 } // namespace webcrypto
85 84
86 } // namespace content 85 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/test/data/webcrypto/digest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698