summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_browsertest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/browser_browsertest.cc')
-rw-r--r--chrome/browser/browser_browsertest.cc167
1 files changed, 0 insertions, 167 deletions
diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc
index 2ccc444..fa60fef 100644
--- a/chrome/browser/browser_browsertest.cc
+++ b/chrome/browser/browser_browsertest.cc
@@ -608,173 +608,6 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, RestorePinnedTabs) {
}
#endif // !defined(OS_CHROMEOS)
-class BrowserAppRefocusTest : public ExtensionBrowserTest {
- public:
- BrowserAppRefocusTest()
- : extension_app_(NULL),
- profile_(NULL) {}
-
- protected:
- // Common setup for all tests. Can't use SetUpInProcessBrowserTestFixture
- // because starting the http server crashes if called from that function.
- // The IO thread is not set up at that point.
- virtual void SetUpExtensionApp() {
- // The web URL of the example app we load has a host of
- // www.example.com .
- ASSERT_TRUE(test_server()->Start());
- host_resolver()->AddRule("www.example.com", "127.0.0.1");
-
- profile_ = browser()->profile();
- ASSERT_TRUE(profile_);
-
- ASSERT_TRUE(LoadExtension(test_data_dir_.AppendASCII("app/")));
-
- // Save a pointer to the loaded extension in |extension_app_|.
- const ExtensionList* extensions =
- profile_->GetExtensionsService()->extensions();
-
- for (size_t i = 0; i < extensions->size(); ++i) {
- if ((*extensions)[i]->name() == "App Test")
- extension_app_ =(*extensions)[i];
- }
- ASSERT_TRUE(extension_app_) << "App Test extension not loaded.";
- }
-
- // Given a tab, wait for navigation in the tab, then test that it is
- // selected. If this function returns false, an error was logged.
- bool WaitForTab(TabContents* tab) WARN_UNUSED_RESULT {
- if (!tab) {
- LOG(ERROR) << "|tab| should not be NULL.";
- return false;
- }
- ui_test_utils::WaitForNavigation(&(tab->controller()));
- if (tab != browser()->GetSelectedTabContents()) {
- LOG(ERROR) << "Tab was not selected.";
- return false;
- }
- return true;
- }
-
- Extension* extension_app_;
- Profile* profile_;
-};
-
-#if (defined(OS_LINUX) && defined(TOOLKIT_VIEWS)) || defined(OS_WIN)
-
-// Tests fail on Chrome OS: http://crbug.com/43061
-#define MAYBE_OpenTab DISABLED_OpenTab
-#define MAYBE_OpenPanel DISABLED_OpenPanel
-#define MAYBE_PanelBeforeTab DISABLED_PanelBeforeTab
-
-#else
-
-#define MAYBE_OpenTab OpenTab
-#define MAYBE_OpenPanel OpenPanel
-#define MAYBE_PanelBeforeTab PanelBeforeTab
-
-#endif
-
-// Test that launching an app refocuses a tab already hosting the app.
-IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenTab) {
- SetUpExtensionApp();
-
- ASSERT_EQ(1, browser()->tab_count());
- ASSERT_EQ(NULL, Browser::FindAppTab(browser(), extension_app_));
-
- // Open a tab with the app.
- TabContents* tab = Browser::OpenApplicationTab(profile_,
- extension_app_,
- NULL);
- ASSERT_TRUE(WaitForTab(tab));
- ASSERT_EQ(2, browser()->tab_count());
-
- int app_tab_index = browser()->selected_index();
- ASSERT_EQ(0, app_tab_index) << "App tab should be the left most tab.";
-
- // Open the same app. The existing tab should stay focused.
- tab = Browser::OpenApplication(profile_, extension_app_->id());
-
- // No need to wait for navigation, because the tab already exists,
- // and no navigation should take place.
- ASSERT_TRUE(tab != NULL);
- ASSERT_EQ(3, browser()->tab_count());
- ASSERT_EQ(app_tab_index + 1, browser()->selected_index());
-
- // Open a second browser window, and open the app in a tab.
- Browser* second_browser = CreateBrowser(profile_);
- second_browser->window()->Show();
-
- Browser::OpenApplication(profile_, extension_app_,
- extension_misc::LAUNCH_TAB);
- ASSERT_EQ(2, second_browser->tab_count()) <<
- "Expect the app to open in a tab under |second_browser|.";
- int second_app_tab_index = second_browser->selected_index();
- ASSERT_EQ(0, second_app_tab_index) <<
- "Second app tab should be the left most tab.";
-}
-
-// Test that launching an app refocuses a panel running the app.
-IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenPanel) {
- SetUpExtensionApp();
-
- ASSERT_EQ(1, browser()->tab_count());
- ASSERT_EQ(NULL, Browser::FindAppWindowOrPanel(profile_, extension_app_));
-
- // Open the app in a panel.
- Browser::OpenApplicationWindow(profile_, extension_app_,
- extension_misc::LAUNCH_PANEL, GURL(), NULL);
- Browser* app_panel = BrowserList::GetLastActive();
- ASSERT_TRUE(app_panel);
- ASSERT_NE(app_panel, browser()) << "New browser should have opened.";
- ASSERT_EQ(app_panel, BrowserList::GetLastActive());
- ASSERT_EQ(app_panel,
- Browser::FindAppWindowOrPanel(profile_, extension_app_));
-
- // Focus the initial browser.
- browser()->window()->Show();
- ASSERT_EQ(browser(), BrowserList::GetLastActive());
-
- // Open the app.
- Browser::OpenApplication(profile_, extension_app_->id());
-
- // Focus should move to the panel.
- ASSERT_EQ(app_panel, BrowserList::GetLastActive());
- ASSERT_EQ(app_panel,
- Browser::FindAppWindowOrPanel(profile_, extension_app_));
-
- // No new tab should have been created in the initial browser.
- ASSERT_EQ(1, browser()->tab_count());
-}
-
-// Test that if an app is opened while running in a panel and a tab,
-// the panel is focused.
-IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_PanelBeforeTab) {
- SetUpExtensionApp();
-
- ASSERT_EQ(1, browser()->tab_count());
-
- // Open a tab with the app.
- TabContents* tab = Browser::OpenApplicationTab(profile_, extension_app_,
- NULL);
- ASSERT_TRUE(WaitForTab(tab));
- ASSERT_EQ(2, browser()->tab_count());
- int app_tab_index = browser()->selected_index();
- ASSERT_EQ(0, app_tab_index) << "App tab should be the left most tab.";
-
- // Open a panel with the app.
- Browser::OpenApplicationWindow(profile_, extension_app_,
- extension_misc::LAUNCH_PANEL, GURL(), NULL);
- Browser* app_panel = BrowserList::GetLastActive();
- ASSERT_TRUE(app_panel);
- ASSERT_NE(app_panel, browser()) << "New browser should have opened.";
-
- // Focus the initial browser.
- browser()->window()->Show();
-
- // Open the app. Focus should move to the panel.
- Browser::OpenApplication(profile_, extension_app_->id());
- ASSERT_EQ(app_panel, BrowserList::GetLastActive());
-}
// TODO(ben): this test was never enabled. It has bit-rotted since being added.
// It originally lived in browser_unittest.cc, but has been moved here to make