| 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/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| 11 #include "chrome/common/chrome_paths.h" | 11 #include "chrome/common/chrome_paths.h" |
| 12 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" | 12 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" |
| 13 #include "chrome/common/extensions/api/themes/theme_handler.h" |
| 13 #include "chrome/common/extensions/extension.h" | 14 #include "chrome/common/extensions/extension.h" |
| 14 #include "chrome/common/extensions/extension_constants.h" | 15 #include "chrome/common/extensions/extension_constants.h" |
| 15 #include "chrome/common/extensions/extension_manifest_constants.h" | 16 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 16 #include "chrome/common/extensions/manifest_handler.h" | 17 #include "chrome/common/extensions/manifest_handler.h" |
| 17 #include "chrome/common/extensions/unpacker.h" | 18 #include "chrome/common/extensions/unpacker.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "third_party/skia/include/core/SkBitmap.h" | 20 #include "third_party/skia/include/core/SkBitmap.h" |
| 20 | 21 |
| 21 namespace errors = extension_manifest_errors; | 22 namespace errors = extension_manifest_errors; |
| 22 namespace filenames = extension_filenames; | 23 namespace filenames = extension_filenames; |
| 23 namespace keys = extension_manifest_keys; | 24 namespace keys = extension_manifest_keys; |
| 24 | 25 |
| 25 namespace extensions { | 26 namespace extensions { |
| 26 | 27 |
| 27 class UnpackerTest : public testing::Test { | 28 class UnpackerTest : public testing::Test { |
| 28 public: | 29 public: |
| 29 virtual ~UnpackerTest() { | 30 virtual ~UnpackerTest() { |
| 30 LOG(WARNING) << "Deleting temp dir: " | 31 LOG(WARNING) << "Deleting temp dir: " |
| 31 << temp_dir_.path().LossyDisplayName(); | 32 << temp_dir_.path().LossyDisplayName(); |
| 32 LOG(WARNING) << temp_dir_.Delete(); | 33 LOG(WARNING) << temp_dir_.Delete(); |
| 33 } | 34 } |
| 34 | 35 |
| 35 virtual void SetUp() OVERRIDE { | 36 virtual void SetUp() OVERRIDE { |
| 36 testing::Test::SetUp(); | 37 testing::Test::SetUp(); |
| 37 extensions::ManifestHandler::Register( | 38 extensions::ManifestHandler::Register( |
| 38 keys::kDefaultLocale, | 39 keys::kDefaultLocale, |
| 39 make_linked_ptr(new extensions::DefaultLocaleHandler)); | 40 make_linked_ptr(new extensions::DefaultLocaleHandler)); |
| 41 extensions::ManifestHandler::Register( |
| 42 keys::kTheme, |
| 43 make_linked_ptr(new extensions::ThemeHandler)); |
| 40 } | 44 } |
| 41 | 45 |
| 42 void SetupUnpacker(const std::string& crx_name) { | 46 void SetupUnpacker(const std::string& crx_name) { |
| 43 base::FilePath original_path; | 47 base::FilePath original_path; |
| 44 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path)); | 48 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &original_path)); |
| 45 original_path = original_path.AppendASCII("extensions") | 49 original_path = original_path.AppendASCII("extensions") |
| 46 .AppendASCII("unpacker") | 50 .AppendASCII("unpacker") |
| 47 .AppendASCII(crx_name); | 51 .AppendASCII(crx_name); |
| 48 ASSERT_TRUE(file_util::PathExists(original_path)) << original_path.value(); | 52 ASSERT_TRUE(file_util::PathExists(original_path)) << original_path.value(); |
| 49 | 53 |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 SetupUnpacker("bad_image.crx"); | 277 SetupUnpacker("bad_image.crx"); |
| 274 EXPECT_FALSE(unpacker_->Run()); | 278 EXPECT_FALSE(unpacker_->Run()); |
| 275 EXPECT_TRUE(StartsWith(unpacker_->error_message(), | 279 EXPECT_TRUE(StartsWith(unpacker_->error_message(), |
| 276 ASCIIToUTF16(kExpected), | 280 ASCIIToUTF16(kExpected), |
| 277 false)) << "Expected prefix: \"" << kExpected | 281 false)) << "Expected prefix: \"" << kExpected |
| 278 << "\", actual error: \"" << unpacker_->error_message() | 282 << "\", actual error: \"" << unpacker_->error_message() |
| 279 << "\""; | 283 << "\""; |
| 280 } | 284 } |
| 281 | 285 |
| 282 } // namespace extensions | 286 } // namespace extensions |
| OLD | NEW |