From a5d24d34fa7917464367bcf216ec3c8f8dedfb97 Mon Sep 17 00:00:00 2001 From: "skerner@chromium.org" Date: Thu, 1 Jul 2010 15:32:19 +0000 Subject: Revert 51362 - Un-flake and enable test. Ran tests for a few hours on windows without seeing a failure. BUG=44026 TEST=BrowserAppRefocusTest.* Review URL: http://codereview.chromium.org/2870036 TBR=skerner@chromium.org Review URL: http://codereview.chromium.org/2865031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51365 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/browser_browsertest.cc | 55 ++++++++++++----------------------- 1 file changed, 18 insertions(+), 37 deletions(-) (limited to 'chrome/browser/browser_browsertest.cc') diff --git a/chrome/browser/browser_browsertest.cc b/chrome/browser/browser_browsertest.cc index b80ba65..a4bfaf9 100644 --- a/chrome/browser/browser_browsertest.cc +++ b/chrome/browser/browser_browsertest.cc @@ -5,7 +5,6 @@ #include #include "app/l10n_util.h" -#include "base/compiler_specific.h" #include "base/i18n/rtl.h" #include "base/file_path.h" #include "base/sys_info.h" @@ -638,11 +637,10 @@ class BrowserAppRefocusTest : public ExtensionBrowserTest { // 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 . server_ = StartHTTPServer(); ASSERT_TRUE(server_); host_resolver()->AddRule("www.example.com", "127.0.0.1"); + url_ = GURL(server_->TestServerPage("empty.html")); profile_ = browser()->profile(); ASSERT_TRUE(profile_); @@ -660,29 +658,14 @@ class BrowserAppRefocusTest : public ExtensionBrowserTest { 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; - } - HTTPTestServer* server_; Extension* extension_app_; Profile* profile_; + GURL url_; }; #if defined(OS_WIN) || (defined(OS_LINUX) && !defined(TOOLKIT_VIEWS)) -#define MAYBE_OpenTab OpenTab #define MAYBE_OpenPanel OpenPanel #define MAYBE_OpenWindow OpenWindow #define MAYBE_WindowBeforeTab WindowBeforeTab @@ -693,9 +676,8 @@ class BrowserAppRefocusTest : public ExtensionBrowserTest { // Crashes on mac involving app panels: http://crbug.com/42865 -// Tests fail on Chrome OS: http://crbug.com/43061 - -#define MAYBE_OpenTab DISABLED_OpenTab +// ChromeOS doesn't open extension based app windows correctly yet: +// http://crbug.com/43061 #define MAYBE_OpenPanel DISABLED_OpenPanel #define MAYBE_OpenWindow DISABLED_OpenWindow #define MAYBE_WindowBeforeTab DISABLED_WindowBeforeTab @@ -705,28 +687,26 @@ class BrowserAppRefocusTest : public ExtensionBrowserTest { #endif // Test that launching an app refocuses a tab already hosting the app. -IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenTab) { +// Hangs flakily, http://crbug.com/44026. +IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, DISABLED_OpenTab) { SetUpExtensionApp(); + ui_test_utils::NavigateToURL(browser(), url_); 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_); - ASSERT_TRUE(WaitForTab(tab)); + Browser::OpenApplicationTab(profile_, extension_app_); + ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); 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."; ASSERT_EQ(browser()->GetTabContentsAt(0), Browser::FindAppTab(browser(), extension_app_)); // 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); + Browser::OpenApplication(profile_, extension_app_->id()); + ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); ASSERT_EQ(2, browser()->tab_count()); ASSERT_EQ(app_tab_index, browser()->selected_index()); @@ -734,10 +714,6 @@ IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenTab) { // be refocused. browser()->SelectTabContentsAt(1, false); Browser::OpenApplication(profile_, extension_app_->id()); - - tab = Browser::OpenApplication(profile_, extension_app_->id()); - ASSERT_TRUE(WaitForTab(tab)); - ASSERT_EQ(2, browser()->tab_count()); ASSERT_EQ(app_tab_index, browser()->selected_index()); @@ -764,6 +740,7 @@ IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenTab) { IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenPanel) { SetUpExtensionApp(); + ui_test_utils::NavigateToURL(browser(), url_); ASSERT_EQ(1, browser()->tab_count()); ASSERT_EQ(NULL, Browser::FindAppWindowOrPanel(profile_, extension_app_)); @@ -797,6 +774,7 @@ IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenPanel) { IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenWindow) { SetUpExtensionApp(); + ui_test_utils::NavigateToURL(browser(), url_); ASSERT_EQ(1, browser()->tab_count()); ASSERT_EQ(NULL, Browser::FindAppWindowOrPanel(profile_, extension_app_)); @@ -827,6 +805,7 @@ IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_OpenWindow) { IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_WindowBeforeTab) { SetUpExtensionApp(); + ui_test_utils::NavigateToURL(browser(), url_); ASSERT_EQ(1, browser()->tab_count()); // Open a tab with the app. @@ -856,11 +835,12 @@ IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_WindowBeforeTab) { IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_PanelBeforeTab) { SetUpExtensionApp(); + ui_test_utils::NavigateToURL(browser(), url_); ASSERT_EQ(1, browser()->tab_count()); // Open a tab with the app. - TabContents* tab = Browser::OpenApplicationTab(profile_, extension_app_); - ASSERT_TRUE(WaitForTab(tab)); + Browser::OpenApplicationTab(profile_, extension_app_); + ASSERT_TRUE(ui_test_utils::WaitForNavigationInCurrentTab(browser())); 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."; @@ -885,6 +865,7 @@ IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_PanelBeforeTab) { IN_PROC_BROWSER_TEST_F(BrowserAppRefocusTest, MAYBE_TabInFocusedWindow) { SetUpExtensionApp(); + ui_test_utils::NavigateToURL(browser(), url_); ASSERT_EQ(1, browser()->tab_count()); Browser::OpenApplicationTab(profile_, extension_app_); -- cgit v1.1