| 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/i18n/default_locale_handler.h" |
| 15 #include "chrome/common/extensions/extension.h" | 16 #include "chrome/common/extensions/extension.h" |
| 16 #include "chrome/common/extensions/extension_manifest_constants.h" | 17 #include "chrome/common/extensions/extension_manifest_constants.h" |
| 17 #include "chrome/common/extensions/manifest_handler.h" | 18 #include "chrome/common/extensions/manifest_handler.h" |
| 18 #include "grit/generated_resources.h" | 19 #include "grit/generated_resources.h" |
| 19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
| 20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
| 21 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
| 22 | 23 |
| 23 using extensions::Extension; | 24 using extensions::Extension; |
| 24 | 25 |
| 25 namespace keys = extension_manifest_keys; | 26 namespace keys = extension_manifest_keys; |
| 26 | 27 |
| 27 class ExtensionFileUtilTest : public testing::Test { | 28 class ExtensionFileUtilTest : public testing::Test { |
| 28 protected: | 29 protected: |
| 29 virtual void SetUp() OVERRIDE { | 30 virtual void SetUp() OVERRIDE { |
| 30 testing::Test::SetUp(); | 31 testing::Test::SetUp(); |
| 31 extensions::ManifestHandler::Register( | 32 extensions::ManifestHandler::Register( |
| 32 extension_manifest_keys::kBrowserAction, | 33 extension_manifest_keys::kBrowserAction, |
| 33 new extensions::BrowserActionHandler); | 34 new extensions::BrowserActionHandler); |
| 35 extensions::ManifestHandler::Register( |
| 36 keys::kDefaultLocale, |
| 37 new extensions::DefaultLocaleHandler); |
| 34 } | 38 } |
| 35 }; | 39 }; |
| 36 | 40 |
| 37 #if defined(OS_WIN) | 41 #if defined(OS_WIN) |
| 38 // http://crbug.com/106381 | 42 // http://crbug.com/106381 |
| 39 #define InstallUninstallGarbageCollect DISABLED_InstallUninstallGarbageCollect | 43 #define InstallUninstallGarbageCollect DISABLED_InstallUninstallGarbageCollect |
| 40 #endif | 44 #endif |
| 41 TEST_F(ExtensionFileUtilTest, InstallUninstallGarbageCollect) { | 45 TEST_F(ExtensionFileUtilTest, InstallUninstallGarbageCollect) { |
| 42 base::ScopedTempDir temp; | 46 base::ScopedTempDir temp; |
| 43 ASSERT_TRUE(temp.CreateUniqueTempDir()); | 47 ASSERT_TRUE(temp.CreateUniqueTempDir()); |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 597 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension( | 601 scoped_refptr<Extension> extension3(extension_file_util::LoadExtension( |
| 598 ext_dir, Extension::LOAD, Extension::NO_FLAGS, &error)); | 602 ext_dir, Extension::LOAD, Extension::NO_FLAGS, &error)); |
| 599 ASSERT_TRUE(extension3 == NULL); | 603 ASSERT_TRUE(extension3 == NULL); |
| 600 ASSERT_STREQ("Could not load icon 'icon.png' for page action.", | 604 ASSERT_STREQ("Could not load icon 'icon.png' for page action.", |
| 601 error.c_str()); | 605 error.c_str()); |
| 602 } | 606 } |
| 603 | 607 |
| 604 // TODO(aa): More tests as motivation allows. Maybe steal some from | 608 // TODO(aa): More tests as motivation allows. Maybe steal some from |
| 605 // ExtensionService? Many of them could probably be tested here without the | 609 // ExtensionService? Many of them could probably be tested here without the |
| 606 // MessageLoop shenanigans. | 610 // MessageLoop shenanigans. |
| OLD | NEW |