Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / infobars / infobars_browsertest.cc
blobdb81e6e48176e3569fab341483fe6afe8de35eb5
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
3 // found in the LICENSE file.
5 #include "base/command_line.h"
6 #include "chrome/browser/chrome_notification_types.h"
7 #include "chrome/browser/extensions/crx_installer.h"
8 #include "chrome/browser/extensions/extension_install_prompt.h"
9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/infobars/infobar_service.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/themes/theme_service.h"
13 #include "chrome/browser/themes/theme_service_factory.h"
14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/browser/ui/tabs/tab_strip_model.h"
16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/test/base/in_process_browser_test.h"
18 #include "chrome/test/base/test_switches.h"
19 #include "chrome/test/base/ui_test_utils.h"
20 #include "content/public/browser/notification_service.h"
21 #include "extensions/browser/extension_dialog_auto_confirm.h"
22 #include "extensions/browser/extension_system.h"
23 #include "net/test/embedded_test_server/embedded_test_server.h"
25 class InfoBarsTest : public InProcessBrowserTest {
26 public:
27 InfoBarsTest() {}
29 void InstallExtension(const char* filename) {
30 base::FilePath path = ui_test_utils::GetTestFilePath(
31 base::FilePath().AppendASCII("extensions"),
32 base::FilePath().AppendASCII(filename));
33 ExtensionService* service = extensions::ExtensionSystem::Get(
34 browser()->profile())->extension_service();
36 content::WindowedNotificationObserver observer(
37 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
38 content::NotificationService::AllSources());
40 scoped_ptr<ExtensionInstallPrompt> client(new ExtensionInstallPrompt(
41 browser()->tab_strip_model()->GetActiveWebContents()));
42 scoped_refptr<extensions::CrxInstaller> installer(
43 extensions::CrxInstaller::Create(service, client.Pass()));
44 installer->set_install_cause(extension_misc::INSTALL_CAUSE_AUTOMATION);
45 installer->InstallCrx(path);
47 observer.Wait();
51 IN_PROC_BROWSER_TEST_F(InfoBarsTest, TestInfoBarsCloseOnNewTheme) {
52 extensions::ScopedTestDialogAutoConfirm auto_confirm(
53 extensions::ScopedTestDialogAutoConfirm::ACCEPT);
55 #if defined(OS_WIN) && defined(USE_ASH)
56 // Disable this test in Metro+Ash for now (http://crbug.com/262796).
57 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
58 switches::kAshBrowserTests))
59 return;
60 #endif
62 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
64 ui_test_utils::NavigateToURL(
65 browser(), embedded_test_server()->GetURL("/simple.html"));
67 content::WindowedNotificationObserver infobar_added_1(
68 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
69 content::NotificationService::AllSources());
70 InstallExtension("theme.crx");
71 infobar_added_1.Wait();
73 ui_test_utils::NavigateToURLWithDisposition(
74 browser(), embedded_test_server()->GetURL("/simple.html"),
75 NEW_FOREGROUND_TAB, ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
76 content::WindowedNotificationObserver infobar_added_2(
77 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_ADDED,
78 content::NotificationService::AllSources());
79 content::WindowedNotificationObserver infobar_removed_1(
80 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
81 content::NotificationService::AllSources());
82 InstallExtension("theme2.crx");
83 infobar_added_2.Wait();
84 infobar_removed_1.Wait();
85 EXPECT_EQ(
86 0u,
87 InfoBarService::FromWebContents(
88 browser()->tab_strip_model()->GetWebContentsAt(0))->infobar_count());
90 content::WindowedNotificationObserver infobar_removed_2(
91 chrome::NOTIFICATION_TAB_CONTENTS_INFOBAR_REMOVED,
92 content::NotificationService::AllSources());
93 ThemeServiceFactory::GetForProfile(browser()->profile())->UseDefaultTheme();
94 infobar_removed_2.Wait();
95 EXPECT_EQ(0u,
96 InfoBarService::FromWebContents(
97 browser()->tab_strip_model()->GetActiveWebContents())->
98 infobar_count());