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

Side by Side Diff: chrome/browser/extensions/sandboxed_unpacker_unittest.cc

Issue 10704060: Move ExtensionUnpacker into extensions:: namespace, rename it to Unpacker (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Even later master Created 8 years, 5 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 | « chrome/browser/extensions/sandboxed_unpacker.cc ('k') | chrome/chrome_common.gypi » ('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 (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 "base/file_util.h" 5 #include "base/file_util.h"
6 #include "base/memory/ref_counted.h" 6 #include "base/memory/ref_counted.h"
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/scoped_temp_dir.h" 9 #include "base/scoped_temp_dir.h"
10 #include "base/scoped_temp_dir.h" 10 #include "base/scoped_temp_dir.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/extensions/sandboxed_unpacker.h" 13 #include "chrome/browser/extensions/sandboxed_unpacker.h"
14 #include "chrome/common/chrome_paths.h" 14 #include "chrome/common/chrome_paths.h"
15 #include "chrome/common/extensions/extension.h" 15 #include "chrome/common/extensions/extension.h"
16 #include "chrome/common/extensions/extension_manifest_constants.h" 16 #include "chrome/common/extensions/extension_manifest_constants.h"
17 #include "chrome/common/extensions/extension_unpacker.h" 17 #include "chrome/common/extensions/unpacker.h"
18 #include "content/public/test/test_browser_thread.h" 18 #include "content/public/test/test_browser_thread.h"
19 #include "testing/gmock/include/gmock/gmock.h" 19 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 #include "third_party/skia/include/core/SkBitmap.h" 21 #include "third_party/skia/include/core/SkBitmap.h"
22 22
23 namespace errors = extension_manifest_errors; 23 namespace errors = extension_manifest_errors;
24 namespace keys = extension_manifest_keys; 24 namespace keys = extension_manifest_keys;
25 25
26 using content::BrowserThread; 26 using content::BrowserThread;
27 using testing::_; 27 using testing::_;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 ASSERT_TRUE(file_util::PathExists(original_path)) << original_path.value(); 87 ASSERT_TRUE(file_util::PathExists(original_path)) << original_path.value();
88 88
89 // Try bots won't let us write into DIR_TEST_DATA, so we have to write the 89 // Try bots won't let us write into DIR_TEST_DATA, so we have to write the
90 // CRX to the temp directory, and create a subdirectory into which to 90 // CRX to the temp directory, and create a subdirectory into which to
91 // unpack it. 91 // unpack it.
92 FilePath crx_path = temp_dir_.path().AppendASCII(crx_name); 92 FilePath crx_path = temp_dir_.path().AppendASCII(crx_name);
93 ASSERT_TRUE(file_util::CopyFile(original_path, crx_path)) << 93 ASSERT_TRUE(file_util::CopyFile(original_path, crx_path)) <<
94 "Original path: " << original_path.value() << 94 "Original path: " << original_path.value() <<
95 ", Crx path: " << crx_path.value(); 95 ", Crx path: " << crx_path.value();
96 96
97 unpacker_.reset(new ExtensionUnpacker( 97 unpacker_.reset(new Unpacker(
98 crx_path, std::string(), Extension::INTERNAL, Extension::NO_FLAGS)); 98 crx_path, std::string(), Extension::INTERNAL, Extension::NO_FLAGS));
99 99
100 // Build a temp area where the extension will be unpacked. 100 // Build a temp area where the extension will be unpacked.
101 temp_path_ = 101 temp_path_ =
102 temp_dir_.path().AppendASCII("sandboxed_unpacker_test_Temp"); 102 temp_dir_.path().AppendASCII("sandboxed_unpacker_test_Temp");
103 ASSERT_TRUE(file_util::CreateDirectory(temp_path_)); 103 ASSERT_TRUE(file_util::CreateDirectory(temp_path_));
104 104
105 sandboxed_unpacker_ = 105 sandboxed_unpacker_ =
106 new SandboxedUnpacker(crx_path, false, Extension::INTERNAL, 106 new SandboxedUnpacker(crx_path, false, Extension::INTERNAL,
107 Extension::NO_FLAGS, client_); 107 Extension::NO_FLAGS, client_);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 << "File was not removed on success."; 154 << "File was not removed on success.";
155 item_in_temp = temp_iterator.Next(); 155 item_in_temp = temp_iterator.Next();
156 } 156 }
157 return (items_not_removed == 0); 157 return (items_not_removed == 0);
158 } 158 }
159 159
160 protected: 160 protected:
161 ScopedTempDir temp_dir_; 161 ScopedTempDir temp_dir_;
162 FilePath temp_path_; 162 FilePath temp_path_;
163 MockSandboxedUnpackerClient* client_; 163 MockSandboxedUnpackerClient* client_;
164 scoped_ptr<ExtensionUnpacker> unpacker_; 164 scoped_ptr<Unpacker> unpacker_;
165 scoped_refptr<SandboxedUnpacker> sandboxed_unpacker_; 165 scoped_refptr<SandboxedUnpacker> sandboxed_unpacker_;
166 MessageLoop loop_; 166 MessageLoop loop_;
167 scoped_ptr<content::TestBrowserThread> file_thread_; 167 scoped_ptr<content::TestBrowserThread> file_thread_;
168 }; 168 };
169 169
170 TEST_F(SandboxedUnpackerTest, NoCatalogsSuccess) { 170 TEST_F(SandboxedUnpackerTest, NoCatalogsSuccess) {
171 EXPECT_CALL(*client_, OnUnpackSuccess(_, _, _, _)); 171 EXPECT_CALL(*client_, OnUnpackSuccess(_, _, _, _));
172 EXPECT_CALL(*client_, OnUnpackFailure(_)).Times(0); 172 EXPECT_CALL(*client_, OnUnpackFailure(_)).Times(0);
173 173
174 SetupUnpacker("no_l10n.crx"); 174 SetupUnpacker("no_l10n.crx");
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // Check that there is newer _locales/en_US/messages.json file. 216 // Check that there is newer _locales/en_US/messages.json file.
217 base::PlatformFileInfo new_info; 217 base::PlatformFileInfo new_info;
218 EXPECT_TRUE(file_util::GetFileInfo(messages_file, &new_info)); 218 EXPECT_TRUE(file_util::GetFileInfo(messages_file, &new_info));
219 219
220 EXPECT_TRUE(new_info.last_modified > old_info.last_modified); 220 EXPECT_TRUE(new_info.last_modified > old_info.last_modified);
221 221
222 ASSERT_TRUE(TempFilesRemoved()); 222 ASSERT_TRUE(TempFilesRemoved());
223 } 223 }
224 224
225 } // namespace extensions 225 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/sandboxed_unpacker.cc ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698