| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/threading/platform_thread.h" |
| 5 #include "chrome/test/automated_ui_tests/automated_ui_test_base.h" | 6 #include "chrome/test/automated_ui_tests/automated_ui_test_base.h" |
| 6 #include "chrome/test/automation/browser_proxy.h" | 7 #include "chrome/test/automation/browser_proxy.h" |
| 7 #include "chrome/test/automation/tab_proxy.h" | 8 #include "chrome/test/automation/tab_proxy.h" |
| 8 #include "chrome/test/ui/ui_test.h" | 9 #include "chrome/test/ui/ui_test.h" |
| 9 | 10 |
| 10 TEST_F(AutomatedUITestBase, DragOut) { | 11 TEST_F(AutomatedUITestBase, DragOut) { |
| 11 NewTab(); | 12 NewTab(); |
| 12 NewTab(); | 13 NewTab(); |
| 13 ASSERT_TRUE(active_browser()->WaitForTabCountToBecome(3)); | 14 ASSERT_TRUE(active_browser()->WaitForTabCountToBecome(3)); |
| 14 PlatformThread::Sleep(sleep_timeout_ms()); | 15 base::PlatformThread::Sleep(sleep_timeout_ms()); |
| 15 ASSERT_TRUE(DragTabOut()); | 16 ASSERT_TRUE(DragTabOut()); |
| 16 int window_count; | 17 int window_count; |
| 17 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); | 18 ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count)); |
| 18 ASSERT_EQ(2, window_count); | 19 ASSERT_EQ(2, window_count); |
| 19 } | 20 } |
| 20 | 21 |
| 21 TEST_F(AutomatedUITestBase, DragLeftRight) { | 22 TEST_F(AutomatedUITestBase, DragLeftRight) { |
| 22 NewTab(); | 23 NewTab(); |
| 23 NewTab(); | 24 NewTab(); |
| 24 ASSERT_TRUE(active_browser()->WaitForTabCountToBecome(3)); | 25 ASSERT_TRUE(active_browser()->WaitForTabCountToBecome(3)); |
| 25 // TODO(phajdan.jr): We need a WaitForTabstripAnimationsToEnd() function. | 26 // TODO(phajdan.jr): We need a WaitForTabstripAnimationsToEnd() function. |
| 26 // Every sleep in this file should be replaced with it. | 27 // Every sleep in this file should be replaced with it. |
| 27 PlatformThread::Sleep(sleep_timeout_ms()); | 28 base::PlatformThread::Sleep(sleep_timeout_ms()); |
| 28 | 29 |
| 29 scoped_refptr<TabProxy> dragged_tab(active_browser()->GetActiveTab()); | 30 scoped_refptr<TabProxy> dragged_tab(active_browser()->GetActiveTab()); |
| 30 int tab_index; | 31 int tab_index; |
| 31 ASSERT_TRUE(dragged_tab->GetTabIndex(&tab_index)); | 32 ASSERT_TRUE(dragged_tab->GetTabIndex(&tab_index)); |
| 32 EXPECT_EQ(2, tab_index); | 33 EXPECT_EQ(2, tab_index); |
| 33 | 34 |
| 34 // Drag the active tab to left. Now it should be the middle tab. | 35 // Drag the active tab to left. Now it should be the middle tab. |
| 35 ASSERT_TRUE(DragActiveTab(false)); | 36 ASSERT_TRUE(DragActiveTab(false)); |
| 36 // We wait for the animation to be over. | 37 // We wait for the animation to be over. |
| 37 PlatformThread::Sleep(sleep_timeout_ms()); | 38 base::PlatformThread::Sleep(sleep_timeout_ms()); |
| 38 ASSERT_TRUE(dragged_tab->GetTabIndex(&tab_index)); | 39 ASSERT_TRUE(dragged_tab->GetTabIndex(&tab_index)); |
| 39 EXPECT_EQ(1, tab_index); | 40 EXPECT_EQ(1, tab_index); |
| 40 | 41 |
| 41 // Drag the active tab to left. Now it should be the leftmost tab. | 42 // Drag the active tab to left. Now it should be the leftmost tab. |
| 42 ASSERT_TRUE(DragActiveTab(false)); | 43 ASSERT_TRUE(DragActiveTab(false)); |
| 43 PlatformThread::Sleep(sleep_timeout_ms()); | 44 base::PlatformThread::Sleep(sleep_timeout_ms()); |
| 44 ASSERT_TRUE(dragged_tab->GetTabIndex(&tab_index)); | 45 ASSERT_TRUE(dragged_tab->GetTabIndex(&tab_index)); |
| 45 EXPECT_EQ(0, tab_index); | 46 EXPECT_EQ(0, tab_index); |
| 46 | 47 |
| 47 // Drag the active tab to left. It should fail since the active tab is | 48 // Drag the active tab to left. It should fail since the active tab is |
| 48 // already the leftmost tab. | 49 // already the leftmost tab. |
| 49 ASSERT_FALSE(DragActiveTab(false)); | 50 ASSERT_FALSE(DragActiveTab(false)); |
| 50 | 51 |
| 51 // Drag the active tab to right. Now it should be the middle tab. | 52 // Drag the active tab to right. Now it should be the middle tab. |
| 52 ASSERT_TRUE(DragActiveTab(true)); | 53 ASSERT_TRUE(DragActiveTab(true)); |
| 53 PlatformThread::Sleep(sleep_timeout_ms()); | 54 base::PlatformThread::Sleep(sleep_timeout_ms()); |
| 54 ASSERT_TRUE(dragged_tab->GetTabIndex(&tab_index)); | 55 ASSERT_TRUE(dragged_tab->GetTabIndex(&tab_index)); |
| 55 EXPECT_EQ(1, tab_index); | 56 EXPECT_EQ(1, tab_index); |
| 56 | 57 |
| 57 // Drag the active tab to right. Now it should be the rightmost tab. | 58 // Drag the active tab to right. Now it should be the rightmost tab. |
| 58 ASSERT_TRUE(DragActiveTab(true)); | 59 ASSERT_TRUE(DragActiveTab(true)); |
| 59 PlatformThread::Sleep(sleep_timeout_ms()); | 60 base::PlatformThread::Sleep(sleep_timeout_ms()); |
| 60 ASSERT_TRUE(dragged_tab->GetTabIndex(&tab_index)); | 61 ASSERT_TRUE(dragged_tab->GetTabIndex(&tab_index)); |
| 61 EXPECT_EQ(2, tab_index); | 62 EXPECT_EQ(2, tab_index); |
| 62 | 63 |
| 63 // Drag the active tab to right. It should fail since the active tab is | 64 // Drag the active tab to right. It should fail since the active tab is |
| 64 // already the rightmost tab. | 65 // already the rightmost tab. |
| 65 ASSERT_FALSE(DragActiveTab(true)); | 66 ASSERT_FALSE(DragActiveTab(true)); |
| 66 } | 67 } |
| OLD | NEW |