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