Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 410683008: Remove kAppsGalleryInstallAutoConfirmForTests switch (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <algorithm> 5 #include <algorithm>
6 #include <set> 6 #include <set>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/at_exit.h" 9 #include "base/at_exit.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 2778 matching lines...) Expand 10 before | Expand all | Expand 10 after
2789 TEST_F(ExtensionServiceTest, LoadExtensionsWithPlugins) { 2789 TEST_F(ExtensionServiceTest, LoadExtensionsWithPlugins) {
2790 base::FilePath extension_with_plugin_path = good1_path(); 2790 base::FilePath extension_with_plugin_path = good1_path();
2791 base::FilePath extension_no_plugin_path = good2_path(); 2791 base::FilePath extension_no_plugin_path = good2_path();
2792 2792
2793 InitPluginService(); 2793 InitPluginService();
2794 InitializeEmptyExtensionService(); 2794 InitializeEmptyExtensionService();
2795 InitializeProcessManager(); 2795 InitializeProcessManager();
2796 service()->set_show_extensions_prompts(true); 2796 service()->set_show_extensions_prompts(true);
2797 2797
2798 // Start by canceling any install prompts. 2798 // Start by canceling any install prompts.
2799 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 2799 ExtensionInstallPrompt::g_auto_confirm_for_tests =
2800 switches::kAppsGalleryInstallAutoConfirmForTests, 2800 ExtensionInstallPrompt::CANCEL;
2801 "cancel");
2802 2801
2803 // The extension that has a plugin should not install. 2802 // The extension that has a plugin should not install.
2804 extensions::UnpackedInstaller::Create(service()) 2803 extensions::UnpackedInstaller::Create(service())
2805 ->Load(extension_with_plugin_path); 2804 ->Load(extension_with_plugin_path);
2806 base::RunLoop().RunUntilIdle(); 2805 base::RunLoop().RunUntilIdle();
2807 EXPECT_EQ(0u, GetErrors().size()); 2806 EXPECT_EQ(0u, GetErrors().size());
2808 EXPECT_EQ(0u, loaded_.size()); 2807 EXPECT_EQ(0u, loaded_.size());
2809 EXPECT_EQ(0u, registry()->enabled_extensions().size()); 2808 EXPECT_EQ(0u, registry()->enabled_extensions().size());
2810 EXPECT_EQ(0u, registry()->disabled_extensions().size()); 2809 EXPECT_EQ(0u, registry()->disabled_extensions().size());
2811 2810
2812 // But the extension with no plugin should since there's no prompt. 2811 // But the extension with no plugin should since there's no prompt.
2813 ExtensionErrorReporter::GetInstance()->ClearErrors(); 2812 ExtensionErrorReporter::GetInstance()->ClearErrors();
2814 extensions::UnpackedInstaller::Create(service()) 2813 extensions::UnpackedInstaller::Create(service())
2815 ->Load(extension_no_plugin_path); 2814 ->Load(extension_no_plugin_path);
2816 base::RunLoop().RunUntilIdle(); 2815 base::RunLoop().RunUntilIdle();
2817 EXPECT_EQ(0u, GetErrors().size()); 2816 EXPECT_EQ(0u, GetErrors().size());
2818 EXPECT_EQ(1u, loaded_.size()); 2817 EXPECT_EQ(1u, loaded_.size());
2819 EXPECT_EQ(1u, registry()->enabled_extensions().size()); 2818 EXPECT_EQ(1u, registry()->enabled_extensions().size());
2820 EXPECT_EQ(0u, registry()->disabled_extensions().size()); 2819 EXPECT_EQ(0u, registry()->disabled_extensions().size());
2821 EXPECT_TRUE(registry()->enabled_extensions().Contains(good2)); 2820 EXPECT_TRUE(registry()->enabled_extensions().Contains(good2));
2822 2821
2823 // The plugin extension should install if we accept the dialog. 2822 // The plugin extension should install if we accept the dialog.
2824 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 2823 ExtensionInstallPrompt::g_auto_confirm_for_tests =
2825 switches::kAppsGalleryInstallAutoConfirmForTests, 2824 ExtensionInstallPrompt::ACCEPT;
2826 "accept");
2827 2825
2828 ExtensionErrorReporter::GetInstance()->ClearErrors(); 2826 ExtensionErrorReporter::GetInstance()->ClearErrors();
2829 extensions::UnpackedInstaller::Create(service()) 2827 extensions::UnpackedInstaller::Create(service())
2830 ->Load(extension_with_plugin_path); 2828 ->Load(extension_with_plugin_path);
2831 base::RunLoop().RunUntilIdle(); 2829 base::RunLoop().RunUntilIdle();
2832 EXPECT_EQ(0u, GetErrors().size()); 2830 EXPECT_EQ(0u, GetErrors().size());
2833 EXPECT_EQ(2u, loaded_.size()); 2831 EXPECT_EQ(2u, loaded_.size());
2834 EXPECT_EQ(2u, registry()->enabled_extensions().size()); 2832 EXPECT_EQ(2u, registry()->enabled_extensions().size());
2835 EXPECT_EQ(0u, registry()->disabled_extensions().size()); 2833 EXPECT_EQ(0u, registry()->disabled_extensions().size());
2836 EXPECT_TRUE(registry()->enabled_extensions().Contains(good1)); 2834 EXPECT_TRUE(registry()->enabled_extensions().Contains(good1));
2837 EXPECT_TRUE(registry()->enabled_extensions().Contains(good2)); 2835 EXPECT_TRUE(registry()->enabled_extensions().Contains(good2));
2838 2836
2839 // Make sure the granted permissions have been setup. 2837 // Make sure the granted permissions have been setup.
2840 scoped_refptr<PermissionSet> permissions( 2838 scoped_refptr<PermissionSet> permissions(
2841 ExtensionPrefs::Get(profile())->GetGrantedPermissions(good1)); 2839 ExtensionPrefs::Get(profile())->GetGrantedPermissions(good1));
2842 EXPECT_FALSE(permissions->IsEmpty()); 2840 EXPECT_FALSE(permissions->IsEmpty());
2843 EXPECT_TRUE(permissions->HasEffectiveFullAccess()); 2841 EXPECT_TRUE(permissions->HasEffectiveFullAccess());
2844 EXPECT_FALSE(permissions->apis().empty()); 2842 EXPECT_FALSE(permissions->apis().empty());
2845 EXPECT_TRUE(permissions->HasAPIPermission(APIPermission::kPlugin)); 2843 EXPECT_TRUE(permissions->HasAPIPermission(APIPermission::kPlugin));
2846 2844
2847 // We should be able to reload the extension without getting another prompt. 2845 // We should be able to reload the extension without getting another prompt.
2848 loaded_.clear(); 2846 loaded_.clear();
2849 CommandLine::ForCurrentProcess()->AppendSwitchASCII( 2847 ExtensionInstallPrompt::g_auto_confirm_for_tests =
2850 switches::kAppsGalleryInstallAutoConfirmForTests, 2848 ExtensionInstallPrompt::CANCEL;
2851 "cancel");
2852 2849
2853 service()->ReloadExtension(good1); 2850 service()->ReloadExtension(good1);
2854 base::RunLoop().RunUntilIdle(); 2851 base::RunLoop().RunUntilIdle();
2855 EXPECT_EQ(1u, loaded_.size()); 2852 EXPECT_EQ(1u, loaded_.size());
2856 EXPECT_EQ(2u, registry()->enabled_extensions().size()); 2853 EXPECT_EQ(2u, registry()->enabled_extensions().size());
2857 EXPECT_EQ(0u, registry()->disabled_extensions().size()); 2854 EXPECT_EQ(0u, registry()->disabled_extensions().size());
2858 } 2855 }
2859 #endif // !defined(OS_POSIX) || defined(OS_MACOSX) 2856 #endif // !defined(OS_POSIX) || defined(OS_MACOSX)
2860 2857
2861 namespace { 2858 namespace {
(...skipping 4100 matching lines...) Expand 10 before | Expand all | Expand 10 after
6962 6959
6963 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED, 6960 service()->Observe(chrome::NOTIFICATION_PROFILE_DESTRUCTION_STARTED,
6964 content::Source<Profile>(profile()), 6961 content::Source<Profile>(profile()),
6965 content::NotificationService::NoDetails()); 6962 content::NotificationService::NoDetails());
6966 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_); 6963 EXPECT_EQ(UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN, unloaded_reason_);
6967 EXPECT_EQ(0u, registry()->enabled_extensions().size()); 6964 EXPECT_EQ(0u, registry()->enabled_extensions().size());
6968 EXPECT_EQ(0u, registry()->disabled_extensions().size()); 6965 EXPECT_EQ(0u, registry()->disabled_extensions().size());
6969 EXPECT_EQ(0u, registry()->terminated_extensions().size()); 6966 EXPECT_EQ(0u, registry()->terminated_extensions().size());
6970 EXPECT_EQ(0u, registry()->blacklisted_extensions().size()); 6967 EXPECT_EQ(0u, registry()->blacklisted_extensions().size());
6971 } 6968 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_prompt.cc ('k') | chrome/browser/extensions/unpacked_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698