OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/browser/extensions/extension_service_unittest.h" | 5 #include "chrome/browser/extensions/extension_service_unittest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 #include "sync/api/syncable_service.h" | 103 #include "sync/api/syncable_service.h" |
104 #include "sync/protocol/app_specifics.pb.h" | 104 #include "sync/protocol/app_specifics.pb.h" |
105 #include "sync/protocol/extension_specifics.pb.h" | 105 #include "sync/protocol/extension_specifics.pb.h" |
106 #include "sync/protocol/sync.pb.h" | 106 #include "sync/protocol/sync.pb.h" |
107 #include "testing/gtest/include/gtest/gtest.h" | 107 #include "testing/gtest/include/gtest/gtest.h" |
108 #include "testing/platform_test.h" | 108 #include "testing/platform_test.h" |
109 #include "url/gurl.h" | 109 #include "url/gurl.h" |
110 #include "webkit/browser/database/database_tracker.h" | 110 #include "webkit/browser/database/database_tracker.h" |
111 #include "webkit/browser/quota/quota_manager.h" | 111 #include "webkit/browser/quota/quota_manager.h" |
112 #include "webkit/common/database/database_identifier.h" | 112 #include "webkit/common/database/database_identifier.h" |
113 #include "webkit/plugins/npapi/mock_plugin_list.h" | |
114 | 113 |
115 #if defined(OS_CHROMEOS) | 114 #if defined(OS_CHROMEOS) |
116 #include "chrome/browser/chromeos/extensions/install_limiter.h" | 115 #include "chrome/browser/chromeos/extensions/install_limiter.h" |
117 #include "chrome/browser/chromeos/login/user_manager.h" | 116 #include "chrome/browser/chromeos/login/user_manager.h" |
118 #include "chrome/browser/chromeos/settings/cros_settings.h" | 117 #include "chrome/browser/chromeos/settings/cros_settings.h" |
119 #include "chrome/browser/chromeos/settings/device_settings_service.h" | 118 #include "chrome/browser/chromeos/settings/device_settings_service.h" |
120 #endif | 119 #endif |
121 | 120 |
122 using base::DictionaryValue; | 121 using base::DictionaryValue; |
123 using base::ListValue; | 122 using base::ListValue; |
(...skipping 4713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4837 | 4836 |
4838 // Test that we get enabled/disabled correctly for all the pref/command-line | 4837 // Test that we get enabled/disabled correctly for all the pref/command-line |
4839 // combinations. We don't want to derive from the ExtensionServiceTest class | 4838 // combinations. We don't want to derive from the ExtensionServiceTest class |
4840 // for this test, so we use ExtensionServiceTestSimple. | 4839 // for this test, so we use ExtensionServiceTestSimple. |
4841 // | 4840 // |
4842 // Also tests that we always fire EXTENSIONS_READY, no matter whether we are | 4841 // Also tests that we always fire EXTENSIONS_READY, no matter whether we are |
4843 // enabled or not. | 4842 // enabled or not. |
4844 TEST(ExtensionServiceTestSimple, Enabledness) { | 4843 TEST(ExtensionServiceTestSimple, Enabledness) { |
4845 // Make sure the PluginService singleton is destroyed at the end of the test. | 4844 // Make sure the PluginService singleton is destroyed at the end of the test. |
4846 base::ShadowingAtExitManager at_exit_manager; | 4845 base::ShadowingAtExitManager at_exit_manager; |
| 4846 #if defined(ENABLE_PLUGINS) |
| 4847 content::PluginService::GetInstance()->Init(); |
| 4848 content::PluginService::GetInstance()->DisablePluginsDiscoveryForTesting(); |
| 4849 #endif |
4847 | 4850 |
4848 ExtensionErrorReporter::Init(false); // no noisy errors | 4851 ExtensionErrorReporter::Init(false); // no noisy errors |
4849 ExtensionsReadyRecorder recorder; | 4852 ExtensionsReadyRecorder recorder; |
4850 scoped_ptr<TestingProfile> profile(new TestingProfile()); | 4853 scoped_ptr<TestingProfile> profile(new TestingProfile()); |
4851 base::MessageLoop loop; | 4854 base::MessageLoop loop; |
4852 content::TestBrowserThread ui_thread(BrowserThread::UI, &loop); | 4855 content::TestBrowserThread ui_thread(BrowserThread::UI, &loop); |
4853 content::TestBrowserThread file_thread(BrowserThread::FILE, &loop); | 4856 content::TestBrowserThread file_thread(BrowserThread::FILE, &loop); |
4854 #if defined OS_CHROMEOS | 4857 #if defined OS_CHROMEOS |
4855 chromeos::ScopedTestDeviceSettingsService device_settings_service; | 4858 chromeos::ScopedTestDeviceSettingsService device_settings_service; |
4856 chromeos::ScopedTestCrosSettings cros_settings; | 4859 chromeos::ScopedTestCrosSettings cros_settings; |
4857 scoped_ptr<chromeos::ScopedTestUserManager> user_manager( | 4860 scoped_ptr<chromeos::ScopedTestUserManager> user_manager( |
4858 new chromeos::ScopedTestUserManager); | 4861 new chromeos::ScopedTestUserManager); |
4859 #endif | 4862 #endif |
4860 scoped_ptr<CommandLine> command_line; | 4863 scoped_ptr<CommandLine> command_line; |
4861 base::FilePath install_dir = profile->GetPath() | 4864 base::FilePath install_dir = profile->GetPath() |
4862 .AppendASCII(extensions::kInstallDirectoryName); | 4865 .AppendASCII(extensions::kInstallDirectoryName); |
4863 | 4866 |
4864 #if defined(ENABLE_PLUGINS) | |
4865 webkit::npapi::MockPluginList plugin_list; | |
4866 PluginService::GetInstance()->SetPluginListForTesting(&plugin_list); | |
4867 #endif | |
4868 | |
4869 // By default, we are enabled. | 4867 // By default, we are enabled. |
4870 command_line.reset(new CommandLine(CommandLine::NO_PROGRAM)); | 4868 command_line.reset(new CommandLine(CommandLine::NO_PROGRAM)); |
4871 ExtensionService* service = static_cast<extensions::TestExtensionSystem*>( | 4869 ExtensionService* service = static_cast<extensions::TestExtensionSystem*>( |
4872 ExtensionSystem::Get(profile.get()))-> | 4870 ExtensionSystem::Get(profile.get()))-> |
4873 CreateExtensionService( | 4871 CreateExtensionService( |
4874 command_line.get(), | 4872 command_line.get(), |
4875 install_dir, | 4873 install_dir, |
4876 false); | 4874 false); |
4877 EXPECT_TRUE(service->extensions_enabled()); | 4875 EXPECT_TRUE(service->extensions_enabled()); |
4878 service->Init(); | 4876 service->Init(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4924 EXPECT_FALSE(service->extensions_enabled()); | 4922 EXPECT_FALSE(service->extensions_enabled()); |
4925 service->Init(); | 4923 service->Init(); |
4926 loop.RunUntilIdle(); | 4924 loop.RunUntilIdle(); |
4927 EXPECT_TRUE(recorder.ready()); | 4925 EXPECT_TRUE(recorder.ready()); |
4928 | 4926 |
4929 // Explicitly delete all the resources used in this test. | 4927 // Explicitly delete all the resources used in this test. |
4930 profile.reset(); | 4928 profile.reset(); |
4931 service = NULL; | 4929 service = NULL; |
4932 // Execute any pending deletion tasks. | 4930 // Execute any pending deletion tasks. |
4933 loop.RunUntilIdle(); | 4931 loop.RunUntilIdle(); |
4934 | |
4935 #if defined(ENABLE_PLUGINS) | |
4936 // Ensure that even if the PluginService is re-used for a later test, it | |
4937 // won't still hold a reference to the stack position of our MockPluginList. | |
4938 // See crbug.com/159754. | |
4939 PluginService::GetInstance()->SetPluginListForTesting(NULL); | |
4940 #endif | |
4941 } | 4932 } |
4942 | 4933 |
4943 // Test loading extensions that require limited and unlimited storage quotas. | 4934 // Test loading extensions that require limited and unlimited storage quotas. |
4944 TEST_F(ExtensionServiceTest, StorageQuota) { | 4935 TEST_F(ExtensionServiceTest, StorageQuota) { |
4945 InitializeEmptyExtensionService(); | 4936 InitializeEmptyExtensionService(); |
4946 | 4937 |
4947 base::FilePath extensions_path = data_dir_ | 4938 base::FilePath extensions_path = data_dir_ |
4948 .AppendASCII("storage_quota"); | 4939 .AppendASCII("storage_quota"); |
4949 | 4940 |
4950 base::FilePath limited_quota_ext = | 4941 base::FilePath limited_quota_ext = |
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6272 provider->UpdateOrAddExtension(updates_from_webstore, "1", crx_path); | 6263 provider->UpdateOrAddExtension(updates_from_webstore, "1", crx_path); |
6273 | 6264 |
6274 service_->CheckForExternalUpdates(); | 6265 service_->CheckForExternalUpdates(); |
6275 content::WindowedNotificationObserver( | 6266 content::WindowedNotificationObserver( |
6276 chrome::NOTIFICATION_CRX_INSTALLER_DONE, | 6267 chrome::NOTIFICATION_CRX_INSTALLER_DONE, |
6277 content::NotificationService::AllSources()).Wait(); | 6268 content::NotificationService::AllSources()).Wait(); |
6278 EXPECT_TRUE(extensions::HasExternalInstallError(service_)); | 6269 EXPECT_TRUE(extensions::HasExternalInstallError(service_)); |
6279 EXPECT_FALSE(extensions::HasExternalInstallBubble(service_)); | 6270 EXPECT_FALSE(extensions::HasExternalInstallBubble(service_)); |
6280 EXPECT_FALSE(service_->IsExtensionEnabled(updates_from_webstore)); | 6271 EXPECT_FALSE(service_->IsExtensionEnabled(updates_from_webstore)); |
6281 } | 6272 } |
OLD | NEW |