| 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 "chrome/common/extensions/extension_file_util.h" | 5 #include "chrome/common/extensions/extension_file_util.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/stringprintf.h" | 11 #include "base/stringprintf.h" |
| 12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
| 13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
| 14 #include "chrome/common/extensions/api/extension_action/browser_action_handler.h
" | 14 #include "chrome/common/extensions/api/extension_action/browser_action_handler.h
" |
| 15 #include "chrome/common/extensions/api/extension_action/page_action_handler.h" | 15 #include "chrome/common/extensions/api/extension_action/page_action_handler.h" |
| 16 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" | 16 #include "chrome/common/extensions/api/i18n/default_locale_handler.h" |
| 17 #include "chrome/common/extensions/api/icons/icons_handler.h" | 17 #include "chrome/common/extensions/api/icons/icons_handler.h" |
| 18 #include "chrome/common/extensions/background_info.h" |
| 18 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
| 19 #include "chrome/common/extensions/extension_manifest_constants.h" | 20 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 20 #include "chrome/common/extensions/manifest.h" | 21 #include "chrome/common/extensions/manifest.h" |
| 21 #include "chrome/common/extensions/manifest_handler.h" | 22 #include "chrome/common/extensions/manifest_handler.h" |
| 22 #include "grit/generated_resources.h" | 23 #include "grit/generated_resources.h" |
| 23 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 25 #include "testing/gtest/include/gtest/gtest.h" |
| 25 #include "ui/base/l10n/l10n_util.h" | 26 #include "ui/base/l10n/l10n_util.h" |
| 26 | 27 |
| 27 using extensions::Extension; | 28 using extensions::Extension; |
| 28 using extensions::Manifest; | 29 using extensions::Manifest; |
| 29 | 30 |
| 30 namespace keys = extension_manifest_keys; | 31 namespace keys = extension_manifest_keys; |
| 31 | 32 |
| 32 class ExtensionFileUtilTest : public testing::Test { | 33 class ExtensionFileUtilTest : public testing::Test { |
| 33 protected: | 34 protected: |
| 34 virtual void SetUp() OVERRIDE { | 35 virtual void SetUp() OVERRIDE { |
| 35 testing::Test::SetUp(); | 36 testing::Test::SetUp(); |
| 36 extensions::ManifestHandler::Register( | 37 (new extensions::BackgroundManifestHandler)->Register(); |
| 37 extension_manifest_keys::kIcons, | 38 (new extensions::BrowserActionHandler)->Register(); |
| 38 make_linked_ptr(new extensions::IconsHandler)); | 39 (new extensions::DefaultLocaleHandler)->Register(); |
| 39 extensions::ManifestHandler::Register( | 40 (new extensions::IconsHandler)->Register(); |
| 40 keys::kBrowserAction, | 41 (new extensions::PageActionHandler)->Register(); |
| 41 make_linked_ptr(new extensions::BrowserActionHandler)); | 42 } |
| 42 linked_ptr<extensions::PageActionHandler> page_action_handler( | 43 |
| 43 new extensions::PageActionHandler); | 44 virtual void TearDown() OVERRIDE { |
| 44 extensions::ManifestHandler::Register(keys::kPageAction, | 45 extensions::ManifestHandler::ClearRegistryForTesting(); |
| 45 page_action_handler); | |
| 46 extensions::ManifestHandler::Register(keys::kPageActions, | |
| 47 page_action_handler); | |
| 48 extensions::ManifestHandler::Register( | |
| 49 keys::kDefaultLocale, | |
| 50 make_linked_ptr(new extensions::DefaultLocaleHandler)); | |
| 51 } | 46 } |
| 52 }; | 47 }; |
| 53 | 48 |
| 54 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
| 55 // http://crbug.com/106381 | 50 // http://crbug.com/106381 |
| 56 #define InstallUninstallGarbageCollect DISABLED_InstallUninstallGarbageCollect | 51 #define InstallUninstallGarbageCollect DISABLED_InstallUninstallGarbageCollect |
| 57 #endif | 52 #endif |
| 58 TEST_F(ExtensionFileUtilTest, InstallUninstallGarbageCollect) { | 53 TEST_F(ExtensionFileUtilTest, InstallUninstallGarbageCollect) { |
| 59 base::ScopedTempDir temp; | 54 base::ScopedTempDir temp; |
| 60 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 55 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
| (...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension( | 614 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension( |
| 620 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); | 615 ext_dir, Manifest::UNPACKED, Extension::NO_FLAGS, &error)); |
| 621 ASSERT_TRUE(extension3 == NULL); | 616 ASSERT_TRUE(extension3 == NULL); |
| 622 ASSERT_STREQ("Could not load icon 'icon.png' for page action.", | 617 ASSERT_STREQ("Could not load icon 'icon.png' for page action.", |
| 623 error.c_str()); | 618 error.c_str()); |
| 624 } | 619 } |
| 625 | 620 |
| 626 // TODO(aa): More tests as motivation allows. Maybe steal some from | 621 // TODO(aa): More tests as motivation allows. Maybe steal some from |
| 627 // ExtensionService? Many of them could probably be tested here without the | 622 // ExtensionService? Many of them could probably be tested here without the |
| 628 // MessageLoop shenanigans. | 623 // MessageLoop shenanigans. |
| OLD | NEW |