| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
| 10 #include "chrome/common/extensions/extension_constants.h" | 10 #include "chrome/common/extensions/extension_constants.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path)); | 22 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path)); |
| 23 original_path = original_path.AppendASCII("extensions") | 23 original_path = original_path.AppendASCII("extensions") |
| 24 .AppendASCII("unpacker") | 24 .AppendASCII("unpacker") |
| 25 .AppendASCII(crx_name); | 25 .AppendASCII(crx_name); |
| 26 ASSERT_TRUE(file_util::PathExists(original_path)) << original_path.value(); | 26 ASSERT_TRUE(file_util::PathExists(original_path)) << original_path.value(); |
| 27 | 27 |
| 28 // Try bots won't let us write into DIR_TEST_DATA, so we have to create | 28 // Try bots won't let us write into DIR_TEST_DATA, so we have to create |
| 29 // a temp folder to play in. | 29 // a temp folder to play in. |
| 30 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &install_dir_)); | 30 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &install_dir_)); |
| 31 install_dir_ = install_dir_.AppendASCII("extension_unpacker_test"); | 31 install_dir_ = install_dir_.AppendASCII("extension_unpacker_test"); |
| 32 ASSERT_TRUE(file_util::Delete(install_dir_, true)) << | 32 file_util::Delete(install_dir_, true); |
| 33 install_dir_.value(); | 33 file_util::CreateDirectory(install_dir_); |
| 34 ASSERT_TRUE(file_util::CreateDirectory(install_dir_)) << | |
| 35 install_dir_.value(); | |
| 36 | 34 |
| 37 FilePath crx_path = install_dir_.AppendASCII(crx_name); | 35 FilePath crx_path = install_dir_.AppendASCII(crx_name); |
| 38 ASSERT_TRUE(file_util::CopyFile(original_path, crx_path)) << | 36 ASSERT_TRUE(file_util::CopyFile(original_path, crx_path)) << |
| 39 "Original path " << original_path.value() << | 37 "Original path " << original_path.value() << |
| 40 ", Crx path " << crx_path.value(); | 38 ", Crx path " << crx_path.value(); |
| 41 | 39 |
| 42 unpacker_.reset(new ExtensionUnpacker(crx_path)); | 40 unpacker_.reset(new ExtensionUnpacker(crx_path)); |
| 43 } | 41 } |
| 44 | 42 |
| 45 virtual void TearDown() { | 43 virtual void TearDown() { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 EXPECT_TRUE(unpacker_->error_message().empty()); | 109 EXPECT_TRUE(unpacker_->error_message().empty()); |
| 112 ASSERT_EQ(2U, unpacker_->parsed_catalogs()->GetSize()); | 110 ASSERT_EQ(2U, unpacker_->parsed_catalogs()->GetSize()); |
| 113 } | 111 } |
| 114 | 112 |
| 115 TEST_F(ExtensionUnpackerTest, NoL10n) { | 113 TEST_F(ExtensionUnpackerTest, NoL10n) { |
| 116 SetupUnpacker("no_l10n.crx"); | 114 SetupUnpacker("no_l10n.crx"); |
| 117 EXPECT_TRUE(unpacker_->Run()); | 115 EXPECT_TRUE(unpacker_->Run()); |
| 118 EXPECT_TRUE(unpacker_->error_message().empty()); | 116 EXPECT_TRUE(unpacker_->error_message().empty()); |
| 119 EXPECT_EQ(0U, unpacker_->parsed_catalogs()->GetSize()); | 117 EXPECT_EQ(0U, unpacker_->parsed_catalogs()->GetSize()); |
| 120 } | 118 } |
| OLD | NEW |