| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/scoped_temp_dir.h" | 8 #include "base/scoped_temp_dir.h" |
| 9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 ASSERT_TRUE(file_util::PathExists(original_path)) << original_path.value(); | 83 ASSERT_TRUE(file_util::PathExists(original_path)) << original_path.value(); |
| 84 | 84 |
| 85 // Try bots won't let us write into DIR_TEST_DATA, so we have to write the | 85 // Try bots won't let us write into DIR_TEST_DATA, so we have to write the |
| 86 // CRX to the temp directory, and create a subdirectory into which to | 86 // CRX to the temp directory, and create a subdirectory into which to |
| 87 // unpack it. | 87 // unpack it. |
| 88 FilePath crx_path = temp_dir_.path().AppendASCII(crx_name); | 88 FilePath crx_path = temp_dir_.path().AppendASCII(crx_name); |
| 89 ASSERT_TRUE(file_util::CopyFile(original_path, crx_path)) << | 89 ASSERT_TRUE(file_util::CopyFile(original_path, crx_path)) << |
| 90 "Original path: " << original_path.value() << | 90 "Original path: " << original_path.value() << |
| 91 ", Crx path: " << crx_path.value(); | 91 ", Crx path: " << crx_path.value(); |
| 92 | 92 |
| 93 unpacker_.reset(new ExtensionUnpacker(crx_path)); | 93 unpacker_.reset(new ExtensionUnpacker( |
| 94 crx_path, Extension::INTERNAL, Extension::NO_FLAGS)); |
| 94 | 95 |
| 95 // Build a temp area where the extension will be unpacked. | 96 // Build a temp area where the extension will be unpacked. |
| 96 temp_path_ = | 97 temp_path_ = |
| 97 temp_dir_.path().AppendASCII("sandboxed_extension_unpacker_test_Temp"); | 98 temp_dir_.path().AppendASCII("sandboxed_extension_unpacker_test_Temp"); |
| 98 ASSERT_TRUE(file_util::CreateDirectory(temp_path_)); | 99 ASSERT_TRUE(file_util::CreateDirectory(temp_path_)); |
| 99 | 100 |
| 100 sandboxed_unpacker_ = | 101 sandboxed_unpacker_ = |
| 101 new SandboxedExtensionUnpacker(crx_path, NULL, Extension::NO_FLAGS, | 102 new SandboxedExtensionUnpacker(crx_path, NULL, Extension::INTERNAL, |
| 102 client_); | 103 Extension::NO_FLAGS, client_); |
| 103 | 104 |
| 104 // Hack since SandboxedExtensionUnpacker gets its background thread id from | 105 // Hack since SandboxedExtensionUnpacker gets its background thread id from |
| 105 // the Start call, but we don't call it here. | 106 // the Start call, but we don't call it here. |
| 106 sandboxed_unpacker_->thread_identifier_ = BrowserThread::FILE; | 107 sandboxed_unpacker_->thread_identifier_ = BrowserThread::FILE; |
| 107 EXPECT_TRUE(PrepareUnpackerEnv()); | 108 EXPECT_TRUE(PrepareUnpackerEnv()); |
| 108 } | 109 } |
| 109 | 110 |
| 110 bool PrepareUnpackerEnv() { | 111 bool PrepareUnpackerEnv() { |
| 111 sandboxed_unpacker_->extension_root_ = | 112 sandboxed_unpacker_->extension_root_ = |
| 112 temp_dir_.path().AppendASCII(extension_filenames::kTempExtensionName); | 113 temp_dir_.path().AppendASCII(extension_filenames::kTempExtensionName); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 OnUnpackSucceeded(); | 210 OnUnpackSucceeded(); |
| 210 | 211 |
| 211 // Check that there is newer _locales/en_US/messages.json file. | 212 // Check that there is newer _locales/en_US/messages.json file. |
| 212 base::PlatformFileInfo new_info; | 213 base::PlatformFileInfo new_info; |
| 213 EXPECT_TRUE(file_util::GetFileInfo(messages_file, &new_info)); | 214 EXPECT_TRUE(file_util::GetFileInfo(messages_file, &new_info)); |
| 214 | 215 |
| 215 EXPECT_TRUE(new_info.last_modified > old_info.last_modified); | 216 EXPECT_TRUE(new_info.last_modified > old_info.last_modified); |
| 216 | 217 |
| 217 ASSERT_TRUE(TempFilesRemoved()); | 218 ASSERT_TRUE(TempFilesRemoved()); |
| 218 } | 219 } |
| OLD | NEW |