OLD | NEW |
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/files/scoped_temp_dir.h" | 6 #include "base/files/scoped_temp_dir.h" |
7 #include "base/memory/ref_counted.h" | 7 #include "base/memory/ref_counted.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 | 89 |
90 // Try bots won't let us write into DIR_TEST_DATA, so we have to write the | 90 // Try bots won't let us write into DIR_TEST_DATA, so we have to write the |
91 // CRX to the temp directory, and create a subdirectory into which to | 91 // CRX to the temp directory, and create a subdirectory into which to |
92 // unpack it. | 92 // unpack it. |
93 FilePath crx_path = temp_dir_.path().AppendASCII(crx_name); | 93 FilePath crx_path = temp_dir_.path().AppendASCII(crx_name); |
94 ASSERT_TRUE(file_util::CopyFile(original_path, crx_path)) << | 94 ASSERT_TRUE(file_util::CopyFile(original_path, crx_path)) << |
95 "Original path: " << original_path.value() << | 95 "Original path: " << original_path.value() << |
96 ", Crx path: " << crx_path.value(); | 96 ", Crx path: " << crx_path.value(); |
97 | 97 |
98 unpacker_.reset(new Unpacker( | 98 unpacker_.reset(new Unpacker( |
99 crx_path, std::string(), Extension::INTERNAL, Extension::NO_FLAGS)); | 99 crx_path, std::string(), Manifest::INTERNAL, Extension::NO_FLAGS)); |
100 | 100 |
101 // Build a temp area where the extension will be unpacked. | 101 // Build a temp area where the extension will be unpacked. |
102 temp_path_ = | 102 temp_path_ = |
103 temp_dir_.path().AppendASCII("sandboxed_unpacker_test_Temp"); | 103 temp_dir_.path().AppendASCII("sandboxed_unpacker_test_Temp"); |
104 ASSERT_TRUE(file_util::CreateDirectory(temp_path_)); | 104 ASSERT_TRUE(file_util::CreateDirectory(temp_path_)); |
105 | 105 |
106 sandboxed_unpacker_ = | 106 sandboxed_unpacker_ = |
107 new SandboxedUnpacker( | 107 new SandboxedUnpacker( |
108 crx_path, false, Extension::INTERNAL, Extension::NO_FLAGS, | 108 crx_path, false, Manifest::INTERNAL, Extension::NO_FLAGS, |
109 extensions_dir_.path(), | 109 extensions_dir_.path(), |
110 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 110 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
111 client_); | 111 client_); |
112 | 112 |
113 EXPECT_TRUE(PrepareUnpackerEnv()); | 113 EXPECT_TRUE(PrepareUnpackerEnv()); |
114 } | 114 } |
115 | 115 |
116 bool PrepareUnpackerEnv() { | 116 bool PrepareUnpackerEnv() { |
117 sandboxed_unpacker_->extension_root_ = | 117 sandboxed_unpacker_->extension_root_ = |
118 temp_dir_.path().AppendASCII(extension_filenames::kTempExtensionName); | 118 temp_dir_.path().AppendASCII(extension_filenames::kTempExtensionName); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
OLD | NEW |