OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome/test/automated_ui_tests/automated_ui_test_base.h" | 5 #include "chrome/test/automated_ui_tests/automated_ui_test_base.h" |
6 #include "chrome/test/automation/browser_proxy.h" | 6 #include "chrome/test/automation/browser_proxy.h" |
7 #include "chrome/test/automation/tab_proxy.h" | 7 #include "chrome/test/automation/tab_proxy.h" |
8 #include "chrome/test/ui/ui_test.h" | 8 #include "chrome/test/ui/ui_test.h" |
9 | 9 |
10 #if defined(OS_WINDOWS) | |
11 #define MAYBE(x) x | |
12 #else | |
13 #define MAYBE(x) DISABLED_##x | |
14 #endif | |
15 | |
16 namespace { | 10 namespace { |
17 | 11 |
18 bool WaitForURLDisplayedForTab(BrowserProxy* browser, int tab_index, | 12 bool WaitForURLDisplayedForTab(BrowserProxy* browser, int tab_index, |
19 GURL url) { | 13 GURL url) { |
20 int i = 0; | 14 int i = 0; |
21 while (i < 10) { | 15 while (i < 10) { |
22 scoped_refptr<TabProxy> tab(browser->GetTab(tab_index)); | 16 scoped_refptr<TabProxy> tab(browser->GetTab(tab_index)); |
23 GURL tab_url; | 17 GURL tab_url; |
24 if (tab->GetCurrentURL(&tab_url)) | 18 if (tab->GetCurrentURL(&tab_url)) |
25 if (tab_url == url) | 19 if (tab_url == url) |
26 return true; | 20 return true; |
27 i++; | 21 i++; |
28 PlatformThread::Sleep(automation::kSleepTime); | 22 PlatformThread::Sleep(automation::kSleepTime); |
29 } | 23 } |
30 return false; | 24 return false; |
31 } | 25 } |
32 | 26 |
33 } // namespace | 27 } // namespace |
34 | 28 |
35 TEST_F(AutomatedUITestBase, MAYBE(DragOut)) { | 29 TEST_F(AutomatedUITestBase, DragOut) { |
36 int tab_count; | 30 int tab_count; |
37 active_browser()->GetTabCount(&tab_count); | 31 active_browser()->GetTabCount(&tab_count); |
38 ASSERT_EQ(1, tab_count); | 32 ASSERT_EQ(1, tab_count); |
39 ASSERT_FALSE(DragTabOut()); | 33 ASSERT_FALSE(DragTabOut()); |
40 NewTab(); | 34 NewTab(); |
41 Navigate(GURL("about:")); | 35 Navigate(GURL("about:")); |
42 active_browser()->GetTabCount(&tab_count); | 36 active_browser()->GetTabCount(&tab_count); |
43 ASSERT_EQ(2, tab_count); | 37 ASSERT_EQ(2, tab_count); |
44 NewTab(); | 38 NewTab(); |
45 active_browser()->GetTabCount(&tab_count); | 39 active_browser()->GetTabCount(&tab_count); |
46 ASSERT_EQ(3, tab_count); | 40 ASSERT_EQ(3, tab_count); |
47 GURL chrome_downloads_url("chrome://downloads/"); | 41 GURL chrome_downloads_url("chrome://downloads/"); |
48 Navigate(chrome_downloads_url); | 42 Navigate(chrome_downloads_url); |
49 ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 2, | 43 ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 2, |
50 chrome_downloads_url)); | 44 chrome_downloads_url)); |
51 ASSERT_TRUE(DragTabOut()); | 45 ASSERT_TRUE(DragTabOut()); |
52 int window_count; | 46 int window_count; |
53 automation()->GetBrowserWindowCount(&window_count); | 47 automation()->GetBrowserWindowCount(&window_count); |
54 ASSERT_EQ(2, window_count); | 48 ASSERT_EQ(2, window_count); |
55 } | 49 } |
56 | 50 |
57 TEST_F(AutomatedUITestBase, MAYBE(DragLeftRight)) { | 51 TEST_F(AutomatedUITestBase, DragLeftRight) { |
58 int tab_count; | 52 int tab_count; |
59 active_browser()->GetTabCount(&tab_count); | 53 active_browser()->GetTabCount(&tab_count); |
60 ASSERT_EQ(1, tab_count); | 54 ASSERT_EQ(1, tab_count); |
61 ASSERT_FALSE(DragActiveTab(false)); | 55 ASSERT_FALSE(DragActiveTab(false)); |
62 | 56 |
63 NewTab(); | 57 NewTab(); |
64 active_browser()->GetTabCount(&tab_count); | 58 active_browser()->GetTabCount(&tab_count); |
65 ASSERT_EQ(2, tab_count); | 59 ASSERT_EQ(2, tab_count); |
66 GURL about_url("about:"); | 60 GURL about_url("about:"); |
67 Navigate(about_url); | 61 Navigate(about_url); |
(...skipping 29 matching lines...) Expand all Loading... |
97 // Drag the active tab to right. Now download tab should be the rightmost | 91 // Drag the active tab to right. Now download tab should be the rightmost |
98 // tab. | 92 // tab. |
99 ASSERT_TRUE(DragActiveTab(true)); | 93 ASSERT_TRUE(DragActiveTab(true)); |
100 ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 2, | 94 ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 2, |
101 chrome_downloads_url)); | 95 chrome_downloads_url)); |
102 | 96 |
103 // Drag the active tab to right. It should fail since the active tab is | 97 // Drag the active tab to right. It should fail since the active tab is |
104 // already the rightmost tab. | 98 // already the rightmost tab. |
105 ASSERT_FALSE(DragActiveTab(true)); | 99 ASSERT_FALSE(DragActiveTab(true)); |
106 } | 100 } |
OLD | NEW |