| 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/string_util.h" | 5 #include "base/string_util.h" |
| 6 #include "chrome/browser/extensions/extension_browsertest.h" | 6 #include "chrome/browser/extensions/extension_browsertest.h" |
| 7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" | 8 #include "chrome/browser/extensions/theme_installed_infobar_delegate.h" |
| 9 #include "chrome/browser/infobars/infobar_tab_helper.h" | 9 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
| 12 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
| 13 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 13 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 14 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" | 14 #include "chrome/browser/ui/webui/ntp/new_tab_ui.h" |
| 15 #include "chrome/browser/themes/theme_service_factory.h" | 15 #include "chrome/browser/themes/theme_service_factory.h" |
| 16 #include "chrome/test/base/ui_test_utils.h" | 16 #include "chrome/test/base/ui_test_utils.h" |
| 17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
| 18 | 18 |
| 19 using content::WebContents; | 19 using content::WebContents; |
| 20 using extensions::Extension; | 20 using extensions::Extension; |
| 21 | 21 |
| 22 class ExtensionInstallUIBrowserTest : public ExtensionBrowserTest { | 22 class ExtensionInstallUIBrowserTest : public ExtensionBrowserTest { |
| 23 public: | 23 public: |
| 24 // Checks that a theme info bar is currently visible and issues an undo to | 24 // Checks that a theme info bar is currently visible and issues an undo to |
| 25 // revert to the previous theme. | 25 // revert to the previous theme. |
| 26 void VerifyThemeInfoBarAndUndoInstall() { | 26 void VerifyThemeInfoBarAndUndoInstall() { |
| 27 TabContentsWrapper* tab = browser()->GetSelectedTabContentsWrapper(); | 27 TabContents* tab = browser()->GetActiveTabContents(); |
| 28 ASSERT_TRUE(tab); | 28 ASSERT_TRUE(tab); |
| 29 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); | 29 InfoBarTabHelper* infobar_helper = tab->infobar_tab_helper(); |
| 30 ASSERT_EQ(1U, infobar_helper->infobar_count()); | 30 ASSERT_EQ(1U, infobar_helper->infobar_count()); |
| 31 ConfirmInfoBarDelegate* delegate = infobar_helper-> | 31 ConfirmInfoBarDelegate* delegate = infobar_helper-> |
| 32 GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); | 32 GetInfoBarDelegateAt(0)->AsConfirmInfoBarDelegate(); |
| 33 ASSERT_TRUE(delegate); | 33 ASSERT_TRUE(delegate); |
| 34 delegate->Cancel(); | 34 delegate->Cancel(); |
| 35 ASSERT_EQ(0U, infobar_helper->infobar_count()); | 35 ASSERT_EQ(0U, infobar_helper->infobar_count()); |
| 36 } | 36 } |
| 37 | 37 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, | 104 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, |
| 105 AppInstallConfirmation) { | 105 AppInstallConfirmation) { |
| 106 int num_tabs = browser()->tab_count(); | 106 int num_tabs = browser()->tab_count(); |
| 107 | 107 |
| 108 FilePath app_dir = test_data_dir_.AppendASCII("app"); | 108 FilePath app_dir = test_data_dir_.AppendASCII("app"); |
| 109 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(app_dir, 1, | 109 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(app_dir, 1, |
| 110 browser()->profile())); | 110 browser()->profile())); |
| 111 | 111 |
| 112 if (NewTabUI::ShouldShowApps()) { | 112 if (NewTabUI::ShouldShowApps()) { |
| 113 EXPECT_EQ(num_tabs + 1, browser()->tab_count()); | 113 EXPECT_EQ(num_tabs + 1, browser()->tab_count()); |
| 114 WebContents* web_contents = browser()->GetSelectedWebContents(); | 114 WebContents* web_contents = browser()->GetActiveWebContents(); |
| 115 ASSERT_TRUE(web_contents); | 115 ASSERT_TRUE(web_contents); |
| 116 EXPECT_TRUE(StartsWithASCII(web_contents->GetURL().spec(), | 116 EXPECT_TRUE(StartsWithASCII(web_contents->GetURL().spec(), |
| 117 "chrome://newtab/", false)); | 117 "chrome://newtab/", false)); |
| 118 } else { | 118 } else { |
| 119 // TODO(xiyuan): Figure out how to test extension installed bubble? | 119 // TODO(xiyuan): Figure out how to test extension installed bubble? |
| 120 } | 120 } |
| 121 } | 121 } |
| 122 | 122 |
| 123 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, | 123 IN_PROC_BROWSER_TEST_F(ExtensionInstallUIBrowserTest, |
| 124 AppInstallConfirmation_Incognito) { | 124 AppInstallConfirmation_Incognito) { |
| 125 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); | 125 Profile* incognito_profile = browser()->profile()->GetOffTheRecordProfile(); |
| 126 Browser* incognito_browser = browser::FindOrCreateTabbedBrowser( | 126 Browser* incognito_browser = browser::FindOrCreateTabbedBrowser( |
| 127 incognito_profile); | 127 incognito_profile); |
| 128 | 128 |
| 129 int num_incognito_tabs = incognito_browser->tab_count(); | 129 int num_incognito_tabs = incognito_browser->tab_count(); |
| 130 int num_normal_tabs = browser()->tab_count(); | 130 int num_normal_tabs = browser()->tab_count(); |
| 131 | 131 |
| 132 FilePath app_dir = test_data_dir_.AppendASCII("app"); | 132 FilePath app_dir = test_data_dir_.AppendASCII("app"); |
| 133 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(app_dir, 1, | 133 ASSERT_TRUE(InstallExtensionWithUIAutoConfirm(app_dir, 1, |
| 134 incognito_profile)); | 134 incognito_profile)); |
| 135 | 135 |
| 136 EXPECT_EQ(num_incognito_tabs, incognito_browser->tab_count()); | 136 EXPECT_EQ(num_incognito_tabs, incognito_browser->tab_count()); |
| 137 if (NewTabUI::ShouldShowApps()) { | 137 if (NewTabUI::ShouldShowApps()) { |
| 138 EXPECT_EQ(num_normal_tabs + 1, browser()->tab_count()); | 138 EXPECT_EQ(num_normal_tabs + 1, browser()->tab_count()); |
| 139 WebContents* web_contents = browser()->GetSelectedWebContents(); | 139 WebContents* web_contents = browser()->GetActiveWebContents(); |
| 140 ASSERT_TRUE(web_contents); | 140 ASSERT_TRUE(web_contents); |
| 141 EXPECT_TRUE(StartsWithASCII(web_contents->GetURL().spec(), | 141 EXPECT_TRUE(StartsWithASCII(web_contents->GetURL().spec(), |
| 142 "chrome://newtab/", false)); | 142 "chrome://newtab/", false)); |
| 143 } else { | 143 } else { |
| 144 // TODO(xiyuan): Figure out how to test extension installed bubble? | 144 // TODO(xiyuan): Figure out how to test extension installed bubble? |
| 145 } | 145 } |
| 146 } | 146 } |
| OLD | NEW |