diff options
author | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-03 23:55:15 +0000 |
---|---|---|
committer | phajdan.jr@chromium.org <phajdan.jr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-03 23:55:15 +0000 |
commit | 54cea0fd87a8ad562d6ad403b22c5a9b4722ff3b (patch) | |
tree | 1591db9bbe04b443feb1c0fc385b68130e08b6b6 /chrome/test | |
parent | f9ff629f7e67baf59700abceacbdfb0c6014211a (diff) | |
download | chromium_src-54cea0fd87a8ad562d6ad403b22c5a9b4722ff3b.zip chromium_src-54cea0fd87a8ad562d6ad403b22c5a9b4722ff3b.tar.gz chromium_src-54cea0fd87a8ad562d6ad403b22c5a9b4722ff3b.tar.bz2 |
GTTF: Make WaitForTabCountToBecome automation call not Sleep.
Sleeping is an unreliable method to wait for things.
Instead, we set up an observer.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/3300011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58563 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r-- | chrome/test/automated_ui_tests/automated_ui_test_interactive_test.cc | 6 | ||||
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 6 | ||||
-rw-r--r-- | chrome/test/automation/browser_proxy.cc | 19 | ||||
-rw-r--r-- | chrome/test/automation/browser_proxy.h | 3 | ||||
-rw-r--r-- | chrome/test/interactive_ui/keyboard_access_uitest.cc | 4 | ||||
-rw-r--r-- | chrome/test/tab_switching/tab_switching_test.cc | 2 | ||||
-rw-r--r-- | chrome/test/ui/fast_shutdown_uitest.cc | 2 |
7 files changed, 20 insertions, 22 deletions
diff --git a/chrome/test/automated_ui_tests/automated_ui_test_interactive_test.cc b/chrome/test/automated_ui_tests/automated_ui_test_interactive_test.cc index b3952b2..c4c1eec 100644 --- a/chrome/test/automated_ui_tests/automated_ui_test_interactive_test.cc +++ b/chrome/test/automated_ui_tests/automated_ui_test_interactive_test.cc @@ -10,8 +10,7 @@ TEST_F(AutomatedUITestBase, DragOut) { NewTab(); NewTab(); - ASSERT_TRUE(active_browser()-> - WaitForTabCountToBecome(3, action_max_timeout_ms())); + ASSERT_TRUE(active_browser()->WaitForTabCountToBecome(3)); PlatformThread::Sleep(sleep_timeout_ms()); ASSERT_TRUE(DragTabOut()); int window_count; @@ -22,8 +21,7 @@ TEST_F(AutomatedUITestBase, DragOut) { TEST_F(AutomatedUITestBase, DragLeftRight) { NewTab(); NewTab(); - ASSERT_TRUE(active_browser()-> - WaitForTabCountToBecome(3, action_max_timeout_ms())); + ASSERT_TRUE(active_browser()->WaitForTabCountToBecome(3)); // TODO(phajdan.jr): We need a WaitForTabstripAnimationsToEnd() function. // Every sleep in this file should be replaced with it. PlatformThread::Sleep(sleep_timeout_ms()); diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index 0ef68ad..196fe0f 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -1428,4 +1428,10 @@ IPC_BEGIN_MESSAGES(Automation) // None expected IPC_MESSAGE_ROUTED2(AutomationMsg_SetZoomLevel, int, int) + // Waits for tab count to reach target value. + IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_WaitForTabCountToBecome, + int /* browser handle */, + int /* target tab count */, + bool /* success */) + IPC_END_MESSAGES(Automation) diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc index df3929a..b5a89eb 100644 --- a/chrome/test/automation/browser_proxy.cc +++ b/chrome/test/automation/browser_proxy.cc @@ -192,19 +192,14 @@ bool BrowserProxy::SimulateDrag(const gfx::Point& start, return result; } -bool BrowserProxy::WaitForTabCountToBecome(int count, int wait_timeout) { - const TimeTicks start = TimeTicks::Now(); - const TimeDelta timeout = TimeDelta::FromMilliseconds(wait_timeout); - while (TimeTicks::Now() - start < timeout) { - PlatformThread::Sleep(automation::kSleepTime); - int new_count; - if (!GetTabCount(&new_count)) - return false; - if (count == new_count) - return true; +bool BrowserProxy::WaitForTabCountToBecome(int count) { + bool success = false; + if (!sender_->Send(new AutomationMsg_WaitForTabCountToBecome( + 0, handle_, count, &success))) { + return false; } - // If we get here, the tab count doesn't match. - return false; + + return success; } bool BrowserProxy::WaitForTabToBecomeActive(int tab, diff --git a/chrome/test/automation/browser_proxy.h b/chrome/test/automation/browser_proxy.h index 7dd2671..3fb06d4 100644 --- a/chrome/test/automation/browser_proxy.h +++ b/chrome/test/automation/browser_proxy.h @@ -115,9 +115,8 @@ class BrowserProxy : public AutomationResourceProxy { bool press_escape_en_route) WARN_UNUSED_RESULT; // Block the thread until the tab count is |count|. - // |wait_timeout| is the timeout, in milliseconds, for waiting. // Returns true on success. - bool WaitForTabCountToBecome(int count, int wait_timeout) WARN_UNUSED_RESULT; + bool WaitForTabCountToBecome(int count) WARN_UNUSED_RESULT; // Block the thread until the specified tab is the active tab. // |wait_timeout| is the timeout, in milliseconds, for waiting. diff --git a/chrome/test/interactive_ui/keyboard_access_uitest.cc b/chrome/test/interactive_ui/keyboard_access_uitest.cc index d002a3e..a8ee85d 100644 --- a/chrome/test/interactive_ui/keyboard_access_uitest.cc +++ b/chrome/test/interactive_ui/keyboard_access_uitest.cc @@ -87,7 +87,7 @@ void KeyboardAccessTest::TestMenuKeyboardAccess(bool alternate_key_sequence) { ASSERT_TRUE(window->SimulateOSKeyPress(app::VKEY_RETURN, 0)); // Wait for the new tab to appear. - ASSERT_TRUE(browser->WaitForTabCountToBecome(2, action_timeout_ms())); + ASSERT_TRUE(browser->WaitForTabCountToBecome(2)); // Make sure that the new tab index is 1. ASSERT_TRUE(browser->GetActiveTabIndex(&tab_index)); @@ -132,7 +132,7 @@ TEST_F(KeyboardAccessTest, FAILS_ReserveKeyboardAccelerators) { ASSERT_TRUE(browser->ActivateTab(1)); ASSERT_TRUE(window->SimulateOSKeyPress( app::VKEY_F4, views::Event::EF_CONTROL_DOWN)); - ASSERT_TRUE(browser->WaitForTabCountToBecome(1, action_max_timeout_ms())); + ASSERT_TRUE(browser->WaitForTabCountToBecome(1)); #endif } diff --git a/chrome/test/tab_switching/tab_switching_test.cc b/chrome/test/tab_switching/tab_switching_test.cc index ba72e7e..8544167 100644 --- a/chrome/test/tab_switching/tab_switching_test.cc +++ b/chrome/test/tab_switching/tab_switching_test.cc @@ -87,7 +87,7 @@ class TabSwitchingUITest : public UIPerfTest { ASSERT_TRUE(browser_proxy_->GetTabCount(&initial_tab_count)); int new_tab_count = OpenTabs(); ASSERT_TRUE(browser_proxy_->WaitForTabCountToBecome( - initial_tab_count + new_tab_count, 10000)); + initial_tab_count + new_tab_count)); // Switch linearly between tabs. ASSERT_TRUE(browser_proxy_->ActivateTab(0)); diff --git a/chrome/test/ui/fast_shutdown_uitest.cc b/chrome/test/ui/fast_shutdown_uitest.cc index 758ca156f..f3215d4 100644 --- a/chrome/test/ui/fast_shutdown_uitest.cc +++ b/chrome/test/ui/fast_shutdown_uitest.cc @@ -47,7 +47,7 @@ TEST_F(FastShutdown, MAYBE_SlowTermination) { // This click will launch a popup which has a before unload handler. ASSERT_TRUE(window->SimulateOSClick(bounds.CenterPoint(), views::Event::EF_LEFT_BUTTON_DOWN)); - ASSERT_TRUE(browser->WaitForTabCountToBecome(2, action_max_timeout_ms())); + ASSERT_TRUE(browser->WaitForTabCountToBecome(2)); // Close the tab, removing the one and only before unload handler. scoped_refptr<TabProxy> tab(browser->GetTab(1)); ASSERT_TRUE(tab->Close(true)); |