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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "chrome/browser/chrome_notification_types.h" | 6 #include "chrome/browser/chrome_notification_types.h" |
7 #include "chrome/browser/extensions/crx_installer.h" | 7 #include "chrome/browser/extensions/crx_installer.h" |
8 #include "chrome/browser/extensions/extension_install_prompt.h" | 8 #include "chrome/browser/extensions/extension_install_prompt.h" |
9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
11 #include "chrome/browser/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/themes/theme_service.h" | 12 #include "chrome/browser/themes/theme_service.h" |
13 #include "chrome/browser/themes/theme_service_factory.h" | 13 #include "chrome/browser/themes/theme_service_factory.h" |
14 #include "chrome/browser/ui/browser.h" | 14 #include "chrome/browser/ui/browser.h" |
15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/test/base/in_process_browser_test.h" | 17 #include "chrome/test/base/in_process_browser_test.h" |
18 #include "chrome/test/base/test_switches.h" | 18 #include "chrome/test/base/test_switches.h" |
19 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
20 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
21 #include "extensions/browser/extension_system.h" | 21 #include "extensions/browser/extension_system.h" |
22 #include "net/test/embedded_test_server/embedded_test_server.h" | 22 #include "net/test/embedded_test_server/embedded_test_server.h" |
23 | 23 |
24 class InfoBarsTest : public InProcessBrowserTest { | 24 class InfoBarsTest : public InProcessBrowserTest { |
25 public: | 25 public: |
26 InfoBarsTest() {} | 26 InfoBarsTest() {} |
27 | 27 |
28 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | |
29 command_line->AppendSwitchASCII( | |
30 switches::kAppsGalleryInstallAutoConfirmForTests, "accept"); | |
31 } | |
32 | |
33 void InstallExtension(const char* filename) { | 28 void InstallExtension(const char* filename) { |
34 base::FilePath path = ui_test_utils::GetTestFilePath( | 29 base::FilePath path = ui_test_utils::GetTestFilePath( |
35 base::FilePath().AppendASCII("extensions"), | 30 base::FilePath().AppendASCII("extensions"), |
36 base::FilePath().AppendASCII(filename)); | 31 base::FilePath().AppendASCII(filename)); |
37 ExtensionService* service = extensions::ExtensionSystem::Get( | 32 ExtensionService* service = extensions::ExtensionSystem::Get( |
38 browser()->profile())->extension_service(); | 33 browser()->profile())->extension_service(); |
39 | 34 |
40 content::WindowedNotificationObserver observer( | 35 content::WindowedNotificationObserver observer( |
41 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | 36 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
42 content::NotificationService::AllSources()); | 37 content::NotificationService::AllSources()); |
43 | 38 |
44 scoped_ptr<ExtensionInstallPrompt> client(new ExtensionInstallPrompt( | 39 scoped_ptr<ExtensionInstallPrompt> client(new ExtensionInstallPrompt( |
45 browser()->tab_strip_model()->GetActiveWebContents())); | 40 browser()->tab_strip_model()->GetActiveWebContents())); |
46 scoped_refptr<extensions::CrxInstaller> installer( | 41 scoped_refptr<extensions::CrxInstaller> installer( |
47 extensions::CrxInstaller::Create(service, client.Pass())); | 42 extensions::CrxInstaller::Create(service, client.Pass())); |
48 installer->set_install_cause(extension_misc::INSTALL_CAUSE_AUTOMATION); | 43 installer->set_install_cause(extension_misc::INSTALL_CAUSE_AUTOMATION); |
49 installer->InstallCrx(path); | 44 installer->InstallCrx(path); |
50 | 45 |
51 observer.Wait(); | 46 observer.Wait(); |
52 } | 47 } |
53 }; | 48 }; |
54 | 49 |
55 IN_PROC_BROWSER_TEST_F(InfoBarsTest, TestInfoBarsCloseOnNewTheme) { | 50 IN_PROC_BROWSER_TEST_F(InfoBarsTest, TestInfoBarsCloseOnNewTheme) { |
| 51 ExtensionInstallPrompt::g_auto_confirm_for_tests = |
| 52 ExtensionInstallPrompt::ACCEPT; |
| 53 |
56 #if defined(OS_WIN) && defined(USE_ASH) | 54 #if defined(OS_WIN) && defined(USE_ASH) |
57 // Disable this test in Metro+Ash for now (http://crbug.com/262796). | 55 // Disable this test in Metro+Ash for now (http://crbug.com/262796). |
58 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) | 56 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kAshBrowserTests)) |
59 return; | 57 return; |
60 #endif | 58 #endif |
61 | 59 |
62 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); | 60 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
63 | 61 |
64 ui_test_utils::NavigateToURL( | 62 ui_test_utils::NavigateToURL( |
65 browser(), embedded_test_server()->GetURL("/simple.html")); | 63 browser(), embedded_test_server()->GetURL("/simple.html")); |
(...skipping 24 matching lines...) Expand all Loading... |
90 content::WindowedNotificationObserver infobar_removed_2( | 88 content::WindowedNotificationObserver infobar_removed_2( |
91 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, | 89 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED, |
92 content::NotificationService::AllSources()); | 90 content::NotificationService::AllSources()); |
93 ThemeServiceFactory::GetForProfile(browser()->profile())->UseDefaultTheme(); | 91 ThemeServiceFactory::GetForProfile(browser()->profile())->UseDefaultTheme(); |
94 infobar_removed_2.Wait(); | 92 infobar_removed_2.Wait(); |
95 EXPECT_EQ(0u, | 93 EXPECT_EQ(0u, |
96 InfoBarService::FromWebContents( | 94 InfoBarService::FromWebContents( |
97 browser()->tab_strip_model()->GetActiveWebContents())-> | 95 browser()->tab_strip_model()->GetActiveWebContents())-> |
98 infobar_count()); | 96 infobar_count()); |
99 } | 97 } |
OLD | NEW |