summaryrefslogtreecommitdiffstats
path: root/chrome/test/automated_ui_tests
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/test/automated_ui_tests')
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_test_interactive_test.cc92
1 files changed, 30 insertions, 62 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 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.