| 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 |
| 10 namespace { | 16 namespace { |
| 11 | 17 |
| 12 bool WaitForURLDisplayedForTab(BrowserProxy* browser, int tab_index, | 18 bool WaitForURLDisplayedForTab(BrowserProxy* browser, int tab_index, |
| 13 GURL url) { | 19 GURL url) { |
| 14 int i = 0; | 20 int i = 0; |
| 15 while (i < 10) { | 21 while (i < 10) { |
| 16 scoped_refptr<TabProxy> tab(browser->GetTab(tab_index)); | 22 scoped_refptr<TabProxy> tab(browser->GetTab(tab_index)); |
| 17 GURL tab_url; | 23 GURL tab_url; |
| 18 if (tab->GetCurrentURL(&tab_url)) | 24 if (tab->GetCurrentURL(&tab_url)) |
| 19 if (tab_url == url) | 25 if (tab_url == url) |
| 20 return true; | 26 return true; |
| 21 i++; | 27 i++; |
| 22 PlatformThread::Sleep(automation::kSleepTime); | 28 PlatformThread::Sleep(automation::kSleepTime); |
| 23 } | 29 } |
| 24 return false; | 30 return false; |
| 25 } | 31 } |
| 26 | 32 |
| 27 } | 33 } // namespace |
| 28 | 34 |
| 29 TEST_F(AutomatedUITestBase, DragOut) { | 35 TEST_F(AutomatedUITestBase, MAYBE(DragOut)) { |
| 30 int tab_count; | 36 int tab_count; |
| 31 active_browser()->GetTabCount(&tab_count); | 37 active_browser()->GetTabCount(&tab_count); |
| 32 ASSERT_EQ(1, tab_count); | 38 ASSERT_EQ(1, tab_count); |
| 33 ASSERT_FALSE(DragTabOut()); | 39 ASSERT_FALSE(DragTabOut()); |
| 34 NewTab(); | 40 NewTab(); |
| 35 Navigate(GURL(L"about:")); | 41 Navigate(GURL("about:")); |
| 36 active_browser()->GetTabCount(&tab_count); | 42 active_browser()->GetTabCount(&tab_count); |
| 37 ASSERT_EQ(2, tab_count); | 43 ASSERT_EQ(2, tab_count); |
| 38 NewTab(); | 44 NewTab(); |
| 39 active_browser()->GetTabCount(&tab_count); | 45 active_browser()->GetTabCount(&tab_count); |
| 40 ASSERT_EQ(3, tab_count); | 46 ASSERT_EQ(3, tab_count); |
| 41 GURL chrome_downloads_url(L"chrome://downloads/"); | 47 GURL chrome_downloads_url("chrome://downloads/"); |
| 42 Navigate(chrome_downloads_url); | 48 Navigate(chrome_downloads_url); |
| 43 ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 2, | 49 ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 2, |
| 44 chrome_downloads_url)); | 50 chrome_downloads_url)); |
| 45 ASSERT_TRUE(DragTabOut()); | 51 ASSERT_TRUE(DragTabOut()); |
| 46 int window_count; | 52 int window_count; |
| 47 automation()->GetBrowserWindowCount(&window_count); | 53 automation()->GetBrowserWindowCount(&window_count); |
| 48 ASSERT_EQ(2, window_count); | 54 ASSERT_EQ(2, window_count); |
| 49 } | 55 } |
| 50 | 56 |
| 51 TEST_F(AutomatedUITestBase, DragLeftRight) { | 57 TEST_F(AutomatedUITestBase, MAYBE(DragLeftRight)) { |
| 52 int tab_count; | 58 int tab_count; |
| 53 active_browser()->GetTabCount(&tab_count); | 59 active_browser()->GetTabCount(&tab_count); |
| 54 ASSERT_EQ(1, tab_count); | 60 ASSERT_EQ(1, tab_count); |
| 55 ASSERT_FALSE(DragActiveTab(false)); | 61 ASSERT_FALSE(DragActiveTab(false)); |
| 56 | 62 |
| 57 NewTab(); | 63 NewTab(); |
| 58 active_browser()->GetTabCount(&tab_count); | 64 active_browser()->GetTabCount(&tab_count); |
| 59 ASSERT_EQ(2, tab_count); | 65 ASSERT_EQ(2, tab_count); |
| 60 GURL about_url(L"about:"); | 66 GURL about_url("about:"); |
| 61 Navigate(about_url); | 67 Navigate(about_url); |
| 62 | 68 |
| 63 NewTab(); | 69 NewTab(); |
| 64 active_browser()->GetTabCount(&tab_count); | 70 active_browser()->GetTabCount(&tab_count); |
| 65 ASSERT_EQ(3, tab_count); | 71 ASSERT_EQ(3, tab_count); |
| 66 GURL chrome_downloads_url(L"chrome://downloads/"); | 72 GURL chrome_downloads_url("chrome://downloads/"); |
| 67 Navigate(chrome_downloads_url); | 73 Navigate(chrome_downloads_url); |
| 68 ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 2, | 74 ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 2, |
| 69 chrome_downloads_url)); | 75 chrome_downloads_url)); |
| 70 | 76 |
| 71 // Drag the active tab to left. Now download tab should be the middle tab. | 77 // Drag the active tab to left. Now download tab should be the middle tab. |
| 72 ASSERT_TRUE(DragActiveTab(false)); | 78 ASSERT_TRUE(DragActiveTab(false)); |
| 73 ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 1, | 79 ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 1, |
| 74 chrome_downloads_url)); | 80 chrome_downloads_url)); |
| 75 | 81 |
| 76 // Drag the active tab to left. Now download tab should be the leftmost | 82 // Drag the active tab to left. Now download tab should be the leftmost |
| (...skipping 14 matching lines...) Expand all Loading... |
| 91 // Drag the active tab to right. Now download tab should be the rightmost | 97 // Drag the active tab to right. Now download tab should be the rightmost |
| 92 // tab. | 98 // tab. |
| 93 ASSERT_TRUE(DragActiveTab(true)); | 99 ASSERT_TRUE(DragActiveTab(true)); |
| 94 ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 2, | 100 ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 2, |
| 95 chrome_downloads_url)); | 101 chrome_downloads_url)); |
| 96 | 102 |
| 97 // Drag the active tab to right. It should fail since the active tab is | 103 // Drag the active tab to right. It should fail since the active tab is |
| 98 // already the rightmost tab. | 104 // already the rightmost tab. |
| 99 ASSERT_FALSE(DragActiveTab(true)); | 105 ASSERT_FALSE(DragActiveTab(true)); |
| 100 } | 106 } |
| OLD | NEW |