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

Side by Side Diff: extensions/utility/unpacker_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
« no previous file with comments | « extensions/common/file_util_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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <memory> 5 #include <memory>
6 6
7 #include "base/files/file_util.h" 7 #include "base/files/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/pattern.h" 10 #include "base/strings/pattern.h"
(...skipping 15 matching lines...) Expand all
26 using base::ASCIIToUTF16; 26 using base::ASCIIToUTF16;
27 27
28 namespace extensions { 28 namespace extensions {
29 29
30 namespace errors = manifest_errors; 30 namespace errors = manifest_errors;
31 namespace keys = manifest_keys; 31 namespace keys = manifest_keys;
32 32
33 class UnpackerTest : public testing::Test { 33 class UnpackerTest : public testing::Test {
34 public: 34 public:
35 ~UnpackerTest() override { 35 ~UnpackerTest() override {
36 VLOG(1) << "Deleting temp dir: " << temp_dir_.path().LossyDisplayName(); 36 VLOG(1) << "Deleting temp dir: " << temp_dir_.GetPath().LossyDisplayName();
37 VLOG(1) << temp_dir_.Delete(); 37 VLOG(1) << temp_dir_.Delete();
38 } 38 }
39 39
40 void SetupUnpacker(const std::string& crx_name) { 40 void SetupUnpacker(const std::string& crx_name) {
41 base::FilePath crx_path; 41 base::FilePath crx_path;
42 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &crx_path)); 42 ASSERT_TRUE(PathService::Get(DIR_TEST_DATA, &crx_path));
43 crx_path = crx_path.AppendASCII("unpacker").AppendASCII(crx_name); 43 crx_path = crx_path.AppendASCII("unpacker").AppendASCII(crx_name);
44 ASSERT_TRUE(base::PathExists(crx_path)) << crx_path.value(); 44 ASSERT_TRUE(base::PathExists(crx_path)) << crx_path.value();
45 45
46 // Try bots won't let us write into DIR_TEST_DATA, so we have to create 46 // Try bots won't let us write into DIR_TEST_DATA, so we have to create
47 // a temp folder to play in. 47 // a temp folder to play in.
48 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 48 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
49 49
50 base::FilePath unzipped_dir = temp_dir_.path().AppendASCII("unzipped"); 50 base::FilePath unzipped_dir = temp_dir_.GetPath().AppendASCII("unzipped");
51 ASSERT_TRUE(zip::Unzip(crx_path, unzipped_dir)) 51 ASSERT_TRUE(zip::Unzip(crx_path, unzipped_dir))
52 << "Failed to unzip " << crx_path.value() << " to " 52 << "Failed to unzip " << crx_path.value() << " to "
53 << unzipped_dir.value(); 53 << unzipped_dir.value();
54 54
55 unpacker_.reset(new Unpacker(temp_dir_.path(), unzipped_dir, std::string(), 55 unpacker_.reset(new Unpacker(temp_dir_.GetPath(), unzipped_dir,
56 Manifest::INTERNAL, Extension::NO_FLAGS)); 56 std::string(), Manifest::INTERNAL,
57 Extension::NO_FLAGS));
57 } 58 }
58 59
59 protected: 60 protected:
60 base::ScopedTempDir temp_dir_; 61 base::ScopedTempDir temp_dir_;
61 std::unique_ptr<Unpacker> unpacker_; 62 std::unique_ptr<Unpacker> unpacker_;
62 }; 63 };
63 64
64 TEST_F(UnpackerTest, EmptyDefaultLocale) { 65 TEST_F(UnpackerTest, EmptyDefaultLocale) {
65 SetupUnpacker("empty_default_locale.crx"); 66 SetupUnpacker("empty_default_locale.crx");
66 EXPECT_FALSE(unpacker_->Run()); 67 EXPECT_FALSE(unpacker_->Run());
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 SetupUnpacker("bad_image.crx"); 190 SetupUnpacker("bad_image.crx");
190 EXPECT_FALSE(unpacker_->Run()); 191 EXPECT_FALSE(unpacker_->Run());
191 EXPECT_TRUE(base::StartsWith(unpacker_->error_message(), 192 EXPECT_TRUE(base::StartsWith(unpacker_->error_message(),
192 ASCIIToUTF16(kExpected), 193 ASCIIToUTF16(kExpected),
193 base::CompareCase::INSENSITIVE_ASCII)) 194 base::CompareCase::INSENSITIVE_ASCII))
194 << "Expected prefix: \"" << kExpected << "\", actual error: \"" 195 << "Expected prefix: \"" << kExpected << "\", actual error: \""
195 << unpacker_->error_message() << "\""; 196 << unpacker_->error_message() << "\"";
196 } 197 }
197 198
198 } // namespace extensions 199 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/common/file_util_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698