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

Side by Side Diff: extensions/browser/content_hash_tree_unittest.cc

Issue 2236443003: extensions: Use stl utilities from the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't add braces Created 4 years, 4 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 | « extensions/browser/content_hash_tree.cc ('k') | extensions/browser/content_verifier.cc » ('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 "extensions/browser/content_hash_tree.h" 5 #include "extensions/browser/content_hash_tree.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "crypto/secure_hash.h" 10 #include "crypto/secure_hash.h"
(...skipping 25 matching lines...) Expand all
36 EXPECT_EQ(node1, ComputeTreeHashRoot(nodes, 16)); 36 EXPECT_EQ(node1, ComputeTreeHashRoot(nodes, 16));
37 37
38 // Two nodes. 38 // Two nodes.
39 std::string node2 = FakeSignatureWithSeed(2); 39 std::string node2 = FakeSignatureWithSeed(2);
40 nodes.push_back(node2); 40 nodes.push_back(node2);
41 41
42 std::string expected(kSHA256Length, 0); 42 std::string expected(kSHA256Length, 0);
43 std::unique_ptr<SecureHash> hash(SecureHash::Create(SecureHash::SHA256)); 43 std::unique_ptr<SecureHash> hash(SecureHash::Create(SecureHash::SHA256));
44 hash->Update(node1.data(), node1.size()); 44 hash->Update(node1.data(), node1.size());
45 hash->Update(node2.data(), node2.size()); 45 hash->Update(node2.data(), node2.size());
46 hash->Finish(string_as_array(&expected), expected.size()); 46 hash->Finish(base::string_as_array(&expected), expected.size());
47 EXPECT_EQ(expected, ComputeTreeHashRoot(nodes, 16)); 47 EXPECT_EQ(expected, ComputeTreeHashRoot(nodes, 16));
48 } 48 }
49 49
50 TEST(ContentHashTreeTest, HashTreeMultipleLevels) { 50 TEST(ContentHashTreeTest, HashTreeMultipleLevels) {
51 std::vector<std::string> nodes; 51 std::vector<std::string> nodes;
52 for (int i = 0; i < 3; i++) { 52 for (int i = 0; i < 3; i++) {
53 std::string node; 53 std::string node;
54 nodes.push_back(FakeSignatureWithSeed(i)); 54 nodes.push_back(FakeSignatureWithSeed(i));
55 } 55 }
56 56
(...skipping 13 matching lines...) Expand all
70 // 1 2 3 70 // 1 2 3
71 // where 4 is the hash of 1 and 2, 5 is the hash of 3, and 6 is the 71 // where 4 is the hash of 1 and 2, 5 is the hash of 3, and 6 is the
72 // hash of 4 and 5. 72 // hash of 4 and 5.
73 std::string hash_of_first_2 = crypto::SHA256HashString(nodes[0] + nodes[1]); 73 std::string hash_of_first_2 = crypto::SHA256HashString(nodes[0] + nodes[1]);
74 std::string hash_of_third = crypto::SHA256HashString(nodes[2]); 74 std::string hash_of_third = crypto::SHA256HashString(nodes[2]);
75 expected = crypto::SHA256HashString(hash_of_first_2 + hash_of_third); 75 expected = crypto::SHA256HashString(hash_of_first_2 + hash_of_third);
76 EXPECT_EQ(expected, ComputeTreeHashRoot(nodes, 2)); 76 EXPECT_EQ(expected, ComputeTreeHashRoot(nodes, 2));
77 } 77 }
78 78
79 } // namespace extensions 79 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/content_hash_tree.cc ('k') | extensions/browser/content_verifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698