summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-25 20:04:25 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-25 20:04:25 +0000
commit5fa7acd439a4de7afa3d16b34cd95751639c20d1 (patch)
tree635183ef627a07ec49002aaee1ec4c7068b6fbb8
parente5497e9a893a780d13b93ed1ea4aeed6addd6e6e (diff)
downloadchromium_src-5fa7acd439a4de7afa3d16b34cd95751639c20d1.zip
chromium_src-5fa7acd439a4de7afa3d16b34cd95751639c20d1.tar.gz
chromium_src-5fa7acd439a4de7afa3d16b34cd95751639c20d1.tar.bz2
Cut down on flakiness of automated ui tests by changing message sending/waiting logic.
BUG=none TEST=a lot less flaky on linux Review URL: http://codereview.chromium.org/235019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27232 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/automation_provider.cc6
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_test_interactive_test.cc92
2 files changed, 32 insertions, 66 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 65dae1d..7f0998e 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -1761,11 +1761,9 @@ void AutomationProvider::GetLastNavigationTime(int handle,
void AutomationProvider::WaitForNavigation(int handle,
int64 last_navigation_time,
IPC::Message* reply_message) {
- NavigationController* controller = NULL;
- if (tab_tracker_->ContainsHandle(handle))
- controller = tab_tracker_->GetResource(handle);
-
+ NavigationController* controller = tab_tracker_->GetResource(handle);
Time time = tab_tracker_->GetLastNavigationTime(handle);
+
if (time.ToInternalValue() > last_navigation_time || !controller) {
AutomationMsg_WaitForNavigation::WriteReplyParams(reply_message,
controller == NULL ? AUTOMATION_MSG_NAVIGATION_ERROR :
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 e1d2e64..328ec13 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
@@ -7,41 +7,12 @@
#include "chrome/test/automation/tab_proxy.h"
#include "chrome/test/ui/ui_test.h"
-namespace {
-
-bool WaitForURLDisplayedForTab(BrowserProxy* browser, int tab_index,
- GURL url) {
- int i = 0;
- while (i < 10) {
- scoped_refptr<TabProxy> tab(browser->GetTab(tab_index));
- GURL tab_url;
- if (tab->GetCurrentURL(&tab_url))
- if (tab_url == url)
- return true;
- i++;
- PlatformThread::Sleep(automation::kSleepTime);
- }
- return false;
-}
-
-} // namespace
-
TEST_F(AutomatedUITestBase, DragOut) {
- int tab_count;
- active_browser()->GetTabCount(&tab_count);
- ASSERT_EQ(1, tab_count);
- ASSERT_FALSE(DragTabOut());
NewTab();
- Navigate(GURL("about:"));
- active_browser()->GetTabCount(&tab_count);
- ASSERT_EQ(2, tab_count);
NewTab();
- active_browser()->GetTabCount(&tab_count);
- ASSERT_EQ(3, tab_count);
- GURL chrome_downloads_url("chrome://downloads/");
- Navigate(chrome_downloads_url);
- ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 2,
- chrome_downloads_url));
+ ASSERT_TRUE(active_browser()->
+ WaitForTabCountToBecome(3, action_max_timeout_ms()));
+ PlatformThread::Sleep(sleep_timeout_ms());
ASSERT_TRUE(DragTabOut());
int window_count;
automation()->GetBrowserWindowCount(&window_count);
@@ -49,50 +20,47 @@ TEST_F(AutomatedUITestBase, DragOut) {
}
TEST_F(AutomatedUITestBase, DragLeftRight) {
- int tab_count;
- active_browser()->GetTabCount(&tab_count);
- ASSERT_EQ(1, tab_count);
- ASSERT_FALSE(DragActiveTab(false));
-
NewTab();
- active_browser()->GetTabCount(&tab_count);
- ASSERT_EQ(2, tab_count);
- GURL about_url("about:");
- Navigate(about_url);
-
NewTab();
- active_browser()->GetTabCount(&tab_count);
- ASSERT_EQ(3, tab_count);
- GURL chrome_downloads_url("chrome://downloads/");
- Navigate(chrome_downloads_url);
- ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 2,
- chrome_downloads_url));
+ ASSERT_TRUE(active_browser()->
+ WaitForTabCountToBecome(3, action_max_timeout_ms()));
+ // TODO(phajdan.jr): We need a WaitForTabstripAnimationsToEnd() function.
+ // Every sleep in this file should be replaced with it.
+ PlatformThread::Sleep(sleep_timeout_ms());
+
+ scoped_refptr<TabProxy> dragged_tab(active_browser()->GetActiveTab());
+ int tab_index;
+ ASSERT_TRUE(dragged_tab->GetTabIndex(&tab_index));
+ EXPECT_EQ(2, tab_index);
- // Drag the active tab to left. Now download tab should be the middle tab.
+ // Drag the active tab to left. Now it should be the middle tab.
ASSERT_TRUE(DragActiveTab(false));
- ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 1,
- chrome_downloads_url));
+ // We wait for the animation to be over.
+ PlatformThread::Sleep(sleep_timeout_ms());
+ ASSERT_TRUE(dragged_tab->GetTabIndex(&tab_index));
+ EXPECT_EQ(1, tab_index);
- // Drag the active tab to left. Now download tab should be the leftmost
- // tab.
+ // Drag the active tab to left. Now it should be the leftmost tab.
ASSERT_TRUE(DragActiveTab(false));
- ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 0,
- chrome_downloads_url));
+ PlatformThread::Sleep(sleep_timeout_ms());
+ ASSERT_TRUE(dragged_tab->GetTabIndex(&tab_index));
+ EXPECT_EQ(0, tab_index);
// Drag the active tab to left. It should fail since the active tab is
// already the leftmost tab.
ASSERT_FALSE(DragActiveTab(false));
- // Drag the active tab to right. Now download tab should be the middle tab.
+ // Drag the active tab to right. Now it should be the middle tab.
ASSERT_TRUE(DragActiveTab(true));
- ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 1,
- chrome_downloads_url));
+ PlatformThread::Sleep(sleep_timeout_ms());
+ ASSERT_TRUE(dragged_tab->GetTabIndex(&tab_index));
+ EXPECT_EQ(1, tab_index);
- // Drag the active tab to right. Now download tab should be the rightmost
- // tab.
+ // Drag the active tab to right. Now it should be the rightmost tab.
ASSERT_TRUE(DragActiveTab(true));
- ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 2,
- chrome_downloads_url));
+ PlatformThread::Sleep(sleep_timeout_ms());
+ ASSERT_TRUE(dragged_tab->GetTabIndex(&tab_index));
+ EXPECT_EQ(2, tab_index);
// Drag the active tab to right. It should fail since the active tab is
// already the rightmost tab.