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

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

Issue 2314363002: extensions: Change ScopedTempDir::path() to GetPath() (Closed)
Patch Set: Comment addressed Created 4 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
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/base64.h" 5 #include "base/base64.h"
6 #include "base/files/file_path.h" 6 #include "base/files/file_path.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "crypto/sha2.h" 8 #include "crypto/sha2.h"
9 #include "extensions/browser/computed_hashes.h" 9 #include "extensions/browser/computed_hashes.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 namespace { 12 namespace {
13 13
14 // Helper to return base64 encode result by value. 14 // Helper to return base64 encode result by value.
15 std::string Base64Encode(const std::string& data) { 15 std::string Base64Encode(const std::string& data) {
16 std::string result; 16 std::string result;
17 base::Base64Encode(data, &result); 17 base::Base64Encode(data, &result);
18 return result; 18 return result;
19 } 19 }
20 20
21 } // namespace 21 } // namespace
22 22
23 namespace extensions { 23 namespace extensions {
24 24
25 TEST(ComputedHashes, ComputedHashes) { 25 TEST(ComputedHashes, ComputedHashes) {
26 base::ScopedTempDir scoped_dir; 26 base::ScopedTempDir scoped_dir;
27 ASSERT_TRUE(scoped_dir.CreateUniqueTempDir()); 27 ASSERT_TRUE(scoped_dir.CreateUniqueTempDir());
28 base::FilePath computed_hashes = 28 base::FilePath computed_hashes =
29 scoped_dir.path().AppendASCII("computed_hashes.json"); 29 scoped_dir.GetPath().AppendASCII("computed_hashes.json");
30 30
31 // We'll add hashes for 2 files, one of which uses a subdirectory 31 // We'll add hashes for 2 files, one of which uses a subdirectory
32 // path. The first file will have a list of 1 block hash, and the 32 // path. The first file will have a list of 1 block hash, and the
33 // second file will have 2 block hashes. 33 // second file will have 2 block hashes.
34 base::FilePath path1(FILE_PATH_LITERAL("foo.txt")); 34 base::FilePath path1(FILE_PATH_LITERAL("foo.txt"));
35 base::FilePath path2 = 35 base::FilePath path2 =
36 base::FilePath(FILE_PATH_LITERAL("foo")).AppendASCII("bar.txt"); 36 base::FilePath(FILE_PATH_LITERAL("foo")).AppendASCII("bar.txt");
37 std::vector<std::string> hashes1; 37 std::vector<std::string> hashes1;
38 std::vector<std::string> hashes2; 38 std::vector<std::string> hashes2;
39 hashes1.push_back(crypto::SHA256HashString("first")); 39 hashes1.push_back(crypto::SHA256HashString("first"));
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 // Now an empty input. 116 // Now an empty input.
117 std::string content3; 117 std::string content3;
118 std::vector<std::string> hashes3; 118 std::vector<std::string> hashes3;
119 ComputedHashes::ComputeHashesForContent(content3, block_size, &hashes3); 119 ComputedHashes::ComputeHashesForContent(content3, block_size, &hashes3);
120 ASSERT_EQ(1u, hashes3.size()); 120 ASSERT_EQ(1u, hashes3.size());
121 ASSERT_EQ(std::string("47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="), 121 ASSERT_EQ(std::string("47DEQpj8HBSa+/TImW+5JCeuQeRkm5NMpJWZG3hSuFU="),
122 Base64Encode(hashes3[0])); 122 Base64Encode(hashes3[0]));
123 } 123 }
124 124
125 } // namespace extensions 125 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/storage/storage_frontend_unittest.cc ('k') | extensions/browser/sandboxed_unpacker.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698