OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "chrome/app/chrome_dll_resource.h" | 7 #include "chrome/app/chrome_dll_resource.h" |
8 #include "chrome/browser/view_ids.h" | 8 #include "chrome/browser/view_ids.h" |
9 #include "chrome/common/chrome_paths.h" | 9 #include "chrome/common/chrome_paths.h" |
10 #include "chrome/common/chrome_switches.h" | 10 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
12 #include "chrome/test/automation/tab_proxy.h" | 12 #include "chrome/test/automation/tab_proxy.h" |
13 #include "chrome/test/automation/browser_proxy.h" | 13 #include "chrome/test/automation/browser_proxy.h" |
14 #include "chrome/test/automation/window_proxy.h" | 14 #include "chrome/test/automation/window_proxy.h" |
15 #include "chrome/test/ui/ui_test.h" | 15 #include "chrome/test/ui/ui_test.h" |
16 #include "gfx/rect.h" | 16 #include "gfx/rect.h" |
17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
18 #include "net/base/net_util.h" | 18 #include "net/base/net_util.h" |
19 #include "views/event.h" | 19 #include "views/event.h" |
20 | 20 |
| 21 #if defined(OS_CHROMEOS) |
| 22 // Disabled, see http://crbug.com/40043. |
| 23 #define MAYBE_Tab2OutOfTabStrip DISABLED_Tab2OutOfTabStrip |
| 24 #define MAYBE_Tab1Tab3Escape DISABLED_Tab1Tab3Escape |
| 25 |
| 26 #else |
| 27 #define MAYBE_Tab2OutOfTabStrip Tab2OutOfTabStrip |
| 28 |
| 29 // Flaky, see http://crbug.com/21092. |
| 30 #define MAYBE_Tab1Tab3Escape FLAKY_Tab1Tab3Escape |
| 31 |
| 32 #endif |
| 33 |
21 | 34 |
22 class TabDraggingTest : public UITest { | 35 class TabDraggingTest : public UITest { |
23 protected: | 36 protected: |
24 TabDraggingTest() { | 37 TabDraggingTest() { |
25 show_window_ = true; | 38 show_window_ = true; |
26 } | 39 } |
27 }; | 40 }; |
28 | 41 |
29 // Automated UI test to open three tabs in a new window, and drag Tab_1 into | 42 // Automated UI test to open three tabs in a new window, and drag Tab_1 into |
30 // the position of Tab_2. | 43 // the position of Tab_2. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 98 |
86 // Get url Bar bounds. | 99 // Get url Bar bounds. |
87 gfx::Rect urlbar_bounds; | 100 gfx::Rect urlbar_bounds; |
88 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_LOCATION_BAR, &urlbar_bounds, | 101 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_LOCATION_BAR, &urlbar_bounds, |
89 false)); | 102 false)); |
90 EXPECT_LT(0, urlbar_bounds.x()); | 103 EXPECT_LT(0, urlbar_bounds.x()); |
91 EXPECT_LT(0, urlbar_bounds.y()); | 104 EXPECT_LT(0, urlbar_bounds.y()); |
92 EXPECT_LT(0, urlbar_bounds.width()); | 105 EXPECT_LT(0, urlbar_bounds.width()); |
93 EXPECT_LT(0, urlbar_bounds.height()); | 106 EXPECT_LT(0, urlbar_bounds.height()); |
94 | 107 |
95 // TEST: Move Tab_1 to the position of Tab_2 | 108 /* |
96 // ____________ ____________ ____________ | 109 TEST: Move Tab_1 to the position of Tab_2 |
97 // / \ / \ / \ | 110 ____________ ____________ ____________ |
98 // | Tab_1 | Tab_2 | Tab_3 | | 111 / \ / \ / \ |
99 // ---- ---- ---- ---- ---- ---- ---- ---- ---- | 112 | Tab_1 | Tab_2 | Tab_3 | |
100 // x---- ----> | 113 ---- ---- ---- ---- ---- ---- ---- ---- ---- |
101 // ____________ | 114 x---- ----> |
102 // / X \ | 115 ____________ |
103 // | Tab_1 | | 116 / X \ |
104 // ---- ---- ---- | 117 | Tab_1 | |
| 118 ---- ---- ---- |
| 119 */ |
105 | 120 |
106 gfx::Point start(bounds1.x() + bounds1.width() / 2, | 121 gfx::Point start(bounds1.x() + bounds1.width() / 2, |
107 bounds1.y() + bounds1.height() / 2); | 122 bounds1.y() + bounds1.height() / 2); |
108 gfx::Point end(start.x() + 2 * bounds1.width() / 3, start.y()); | 123 gfx::Point end(start.x() + 2 * bounds1.width() / 3, start.y()); |
109 ASSERT_TRUE(browser->SimulateDrag(start, end, | 124 ASSERT_TRUE(browser->SimulateDrag(start, end, |
110 views::Event::EF_LEFT_BUTTON_DOWN, | 125 views::Event::EF_LEFT_BUTTON_DOWN, |
111 false)); | 126 false)); |
112 | 127 |
113 // Now check for expected results. | 128 // Now check for expected results. |
114 tab1 = browser->GetTab(0); | 129 tab1 = browser->GetTab(0); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 | 198 |
184 // Get url Bar bounds. | 199 // Get url Bar bounds. |
185 gfx::Rect urlbar_bounds; | 200 gfx::Rect urlbar_bounds; |
186 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_LOCATION_BAR, &urlbar_bounds, | 201 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_LOCATION_BAR, &urlbar_bounds, |
187 false)); | 202 false)); |
188 EXPECT_LT(0, urlbar_bounds.x()); | 203 EXPECT_LT(0, urlbar_bounds.x()); |
189 EXPECT_LT(0, urlbar_bounds.y()); | 204 EXPECT_LT(0, urlbar_bounds.y()); |
190 EXPECT_LT(0, urlbar_bounds.width()); | 205 EXPECT_LT(0, urlbar_bounds.width()); |
191 EXPECT_LT(0, urlbar_bounds.height()); | 206 EXPECT_LT(0, urlbar_bounds.height()); |
192 | 207 |
193 // TEST: Move Tab_1 to the middle position of Tab_3 | 208 /* |
194 // ____________ ____________ ____________ | 209 TEST: Move Tab_1 to the middle position of Tab_3 |
195 // / \ / \ / \ | 210 ____________ ____________ ____________ |
196 // | Tab_1 | Tab_2 | Tab_3 | | 211 / \ / \ / \ |
197 // ---- ---- ---- ---- ---- ---- ---- ---- ---- | 212 | Tab_1 | Tab_2 | Tab_3 | |
198 // x---- ---- ---- ---- ---- ----> | 213 ---- ---- ---- ---- ---- ---- ---- ---- ---- |
199 // ____________ | 214 x---- ---- ---- ---- ---- ----> |
200 // / X \ | 215 ____________ |
201 // | Tab_1 | | 216 / X \ |
202 // ---- ---- ---- | 217 | Tab_1 | |
| 218 ---- ---- ---- |
| 219 */ |
203 | 220 |
204 gfx::Point start(bounds1.x() + bounds1.width() / 2, | 221 gfx::Point start(bounds1.x() + bounds1.width() / 2, |
205 bounds1.y() + bounds1.height() / 2); | 222 bounds1.y() + bounds1.height() / 2); |
206 gfx::Point end(start.x() + bounds1.width() / 2 + bounds2.width() + | 223 gfx::Point end(start.x() + bounds1.width() / 2 + bounds2.width() + |
207 bounds3.width() / 2, | 224 bounds3.width() / 2, |
208 start.y()); | 225 start.y()); |
209 ASSERT_TRUE(browser->SimulateDrag(start, end, | 226 ASSERT_TRUE(browser->SimulateDrag(start, end, |
210 views::Event::EF_LEFT_BUTTON_DOWN, | 227 views::Event::EF_LEFT_BUTTON_DOWN, |
211 false)); | 228 false)); |
212 | 229 |
(...skipping 13 matching lines...) Expand all Loading... |
226 GURL tab3_new_url; | 243 GURL tab3_new_url; |
227 ASSERT_TRUE(tab3->GetCurrentURL(&tab3_new_url)); | 244 ASSERT_TRUE(tab3->GetCurrentURL(&tab3_new_url)); |
228 | 245 |
229 EXPECT_EQ(tab1_new_url.spec(), tab2_url.spec()); | 246 EXPECT_EQ(tab1_new_url.spec(), tab2_url.spec()); |
230 EXPECT_EQ(tab2_new_url.spec(), tab3_url.spec()); | 247 EXPECT_EQ(tab2_new_url.spec(), tab3_url.spec()); |
231 EXPECT_EQ(tab3_new_url.spec(), tab1_url.spec()); | 248 EXPECT_EQ(tab3_new_url.spec(), tab1_url.spec()); |
232 } | 249 } |
233 | 250 |
234 // Drag Tab_1 into the position of Tab_3, and press ESCAPE before releasing the | 251 // Drag Tab_1 into the position of Tab_3, and press ESCAPE before releasing the |
235 // left mouse button. | 252 // left mouse button. |
236 // Flaky, see http://crbug.com/21092. | 253 TEST_F(TabDraggingTest, MAYBE_Tab1Tab3Escape) { |
237 TEST_F(TabDraggingTest, FLAKY_Tab1Tab3Escape) { | |
238 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 254 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
239 ASSERT_TRUE(browser.get()); | 255 ASSERT_TRUE(browser.get()); |
240 scoped_refptr<WindowProxy> window(browser->GetWindow()); | 256 scoped_refptr<WindowProxy> window(browser->GetWindow()); |
241 ASSERT_TRUE(window.get()); | 257 ASSERT_TRUE(window.get()); |
242 | 258 |
243 // Get initial tab count. | 259 // Get initial tab count. |
244 int initial_tab_count = 0; | 260 int initial_tab_count = 0; |
245 ASSERT_TRUE(browser->GetTabCount(&initial_tab_count)); | 261 ASSERT_TRUE(browser->GetTabCount(&initial_tab_count)); |
246 ASSERT_TRUE(1 == initial_tab_count); | 262 ASSERT_TRUE(1 == initial_tab_count); |
247 | 263 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
290 | 306 |
291 // Get url Bar bounds. | 307 // Get url Bar bounds. |
292 gfx::Rect urlbar_bounds; | 308 gfx::Rect urlbar_bounds; |
293 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_LOCATION_BAR, &urlbar_bounds, | 309 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_LOCATION_BAR, &urlbar_bounds, |
294 false)); | 310 false)); |
295 EXPECT_LT(0, urlbar_bounds.x()); | 311 EXPECT_LT(0, urlbar_bounds.x()); |
296 EXPECT_LT(0, urlbar_bounds.y()); | 312 EXPECT_LT(0, urlbar_bounds.y()); |
297 EXPECT_LT(0, urlbar_bounds.width()); | 313 EXPECT_LT(0, urlbar_bounds.width()); |
298 EXPECT_LT(0, urlbar_bounds.height()); | 314 EXPECT_LT(0, urlbar_bounds.height()); |
299 | 315 |
300 // TEST: Move Tab_1 to the middle position of Tab_3 | 316 /* |
301 // ____________ ____________ ____________ | 317 TEST: Move Tab_1 to the middle position of Tab_3 |
302 // / \ / \ / \ | 318 ____________ ____________ ____________ |
303 // | Tab_1 | Tab_2 | Tab_3 | | 319 / \ / \ / \ |
304 // ---- ---- ---- ---- ---- ---- ---- ---- ---- | 320 | Tab_1 | Tab_2 | Tab_3 | |
305 // x---- ---- ---- ---- ---- ----> + ESCAPE | 321 ---- ---- ---- ---- ---- ---- ---- ---- ---- |
306 // ____________ | 322 x---- ---- ---- ---- ---- ----> + ESCAPE |
307 // / X \ | 323 ____________ |
308 // | Tab_1 | | 324 / X \ |
309 // ---- ---- ---- | 325 | Tab_1 | |
| 326 ---- ---- ---- |
| 327 */ |
310 | 328 |
311 gfx::Point start(bounds1.x() + bounds1.width() / 2, | 329 gfx::Point start(bounds1.x() + bounds1.width() / 2, |
312 bounds1.y() + bounds1.height() / 2); | 330 bounds1.y() + bounds1.height() / 2); |
313 gfx::Point end(start.x() + bounds1.width() / 2 + bounds2.width() + | 331 gfx::Point end(start.x() + bounds1.width() / 2 + bounds2.width() + |
314 bounds3.width() / 2, | 332 bounds3.width() / 2, |
315 start.y()); | 333 start.y()); |
316 | 334 |
317 // Simulate drag with 'true' as the last parameter. This will interrupt | 335 // Simulate drag with 'true' as the last parameter. This will interrupt |
318 // in-flight with Escape. | 336 // in-flight with Escape. |
319 ASSERT_TRUE(browser->SimulateDrag(start, end, | 337 ASSERT_TRUE(browser->SimulateDrag(start, end, |
(...skipping 16 matching lines...) Expand all Loading... |
336 GURL tab3_new_url; | 354 GURL tab3_new_url; |
337 ASSERT_TRUE(tab3->GetCurrentURL(&tab3_new_url)); | 355 ASSERT_TRUE(tab3->GetCurrentURL(&tab3_new_url)); |
338 | 356 |
339 // The tabs should be in their original positions. | 357 // The tabs should be in their original positions. |
340 EXPECT_EQ(tab1_new_url.spec(), tab1_url.spec()); | 358 EXPECT_EQ(tab1_new_url.spec(), tab1_url.spec()); |
341 EXPECT_EQ(tab2_new_url.spec(), tab2_url.spec()); | 359 EXPECT_EQ(tab2_new_url.spec(), tab2_url.spec()); |
342 EXPECT_EQ(tab3_new_url.spec(), tab3_url.spec()); | 360 EXPECT_EQ(tab3_new_url.spec(), tab3_url.spec()); |
343 } | 361 } |
344 | 362 |
345 // Drag Tab_2 out of the Tab strip. A new window should open with this tab. | 363 // Drag Tab_2 out of the Tab strip. A new window should open with this tab. |
346 TEST_F(TabDraggingTest, Tab2OutOfTabStrip) { | 364 TEST_F(TabDraggingTest, MAYBE_Tab2OutOfTabStrip) { |
347 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 365 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
348 ASSERT_TRUE(browser.get()); | 366 ASSERT_TRUE(browser.get()); |
349 scoped_refptr<WindowProxy> window(browser->GetWindow()); | 367 scoped_refptr<WindowProxy> window(browser->GetWindow()); |
350 ASSERT_TRUE(window.get()); | 368 ASSERT_TRUE(window.get()); |
351 | 369 |
352 // Get initial tab count. | 370 // Get initial tab count. |
353 int initial_tab_count = 0; | 371 int initial_tab_count = 0; |
354 ASSERT_TRUE(browser->GetTabCount(&initial_tab_count)); | 372 ASSERT_TRUE(browser->GetTabCount(&initial_tab_count)); |
355 ASSERT_TRUE(1 == initial_tab_count); | 373 ASSERT_TRUE(1 == initial_tab_count); |
356 | 374 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 | 422 |
405 // Get url Bar bounds. | 423 // Get url Bar bounds. |
406 gfx::Rect urlbar_bounds; | 424 gfx::Rect urlbar_bounds; |
407 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_LOCATION_BAR, &urlbar_bounds, | 425 ASSERT_TRUE(window->GetViewBounds(VIEW_ID_LOCATION_BAR, &urlbar_bounds, |
408 false)); | 426 false)); |
409 EXPECT_LT(0, urlbar_bounds.x()); | 427 EXPECT_LT(0, urlbar_bounds.x()); |
410 EXPECT_LT(0, urlbar_bounds.y()); | 428 EXPECT_LT(0, urlbar_bounds.y()); |
411 EXPECT_LT(0, urlbar_bounds.width()); | 429 EXPECT_LT(0, urlbar_bounds.width()); |
412 EXPECT_LT(0, urlbar_bounds.height()); | 430 EXPECT_LT(0, urlbar_bounds.height()); |
413 | 431 |
414 // TEST: Move Tab_2 down, out of the tab strip. | 432 /* |
415 // This should result in the following: | 433 TEST: Move Tab_2 down, out of the tab strip. |
416 // 1- Tab_3 shift left in place of Tab_2 in Window 1 | 434 This should result in the following: |
417 // 2- Tab_1 to remain in its place | 435 1- Tab_3 shift left in place of Tab_2 in Window 1 |
418 // 3- Tab_2 openes in a new window | 436 2- Tab_1 to remain in its place |
419 // | 437 3- Tab_2 openes in a new window |
420 // ____________ ____________ ____________ | 438 |
421 // / \ / \ / \ | 439 ____________ ____________ ____________ |
422 // | Tab_1 | Tab_2 | Tab_3 | | 440 / \ / \ / \ |
423 // ---- ---- ---- ---- ---- ---- ---- ---- ---- | 441 | Tab_1 | Tab_2 | Tab_3 | |
424 // x | 442 ---- ---- ---- ---- ---- ---- ---- ---- ---- |
425 // | | 443 x |
426 // | (Drag this below, out of tab strip) | 444 | |
427 // V | 445 | (Drag this below, out of tab strip) |
428 // ____________ | 446 V |
429 // / X \ | 447 ____________ |
430 // | Tab_2 | (New Window) | 448 / X \ |
431 // ---- ---- ---- ---- ---- ---- ---- | 449 | Tab_2 | (New Window) |
| 450 ---- ---- ---- ---- ---- ---- ---- |
| 451 */ |
432 | 452 |
433 gfx::Point start(bounds2.x() + bounds2.width() / 2, | 453 gfx::Point start(bounds2.x() + bounds2.width() / 2, |
434 bounds2.y() + bounds2.height() / 2); | 454 bounds2.y() + bounds2.height() / 2); |
435 gfx::Point end(start.x(), | 455 gfx::Point end(start.x(), |
436 start.y() + 3 * urlbar_bounds.height()); | 456 start.y() + 3 * urlbar_bounds.height()); |
437 | 457 |
438 // Simulate tab drag. | 458 // Simulate tab drag. |
439 ASSERT_TRUE(browser->SimulateDrag(start, end, | 459 ASSERT_TRUE(browser->SimulateDrag(start, end, |
440 views::Event::EF_LEFT_BUTTON_DOWN, | 460 views::Event::EF_LEFT_BUTTON_DOWN, |
441 false)); | 461 false)); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 scoped_refptr<TabProxy> tab1_2(browser2->GetTab(0)); | 496 scoped_refptr<TabProxy> tab1_2(browser2->GetTab(0)); |
477 ASSERT_TRUE(tab1_2.get()); | 497 ASSERT_TRUE(tab1_2.get()); |
478 GURL tab1_2_url; | 498 GURL tab1_2_url; |
479 ASSERT_TRUE(tab1_2->GetCurrentURL(&tab1_2_url)); | 499 ASSERT_TRUE(tab1_2->GetCurrentURL(&tab1_2_url)); |
480 | 500 |
481 // Tab_1_2 of Window 2 should essentially be Tab_2 of Window 1. | 501 // Tab_1_2 of Window 2 should essentially be Tab_2 of Window 1. |
482 EXPECT_EQ(tab1_2_url.spec(), tab2_url.spec()); | 502 EXPECT_EQ(tab1_2_url.spec(), tab2_url.spec()); |
483 EXPECT_NE(tab1_2_url.spec(), tab1_url.spec()); | 503 EXPECT_NE(tab1_2_url.spec(), tab1_url.spec()); |
484 EXPECT_NE(tab1_2_url.spec(), tab3_url.spec()); | 504 EXPECT_NE(tab1_2_url.spec(), tab3_url.spec()); |
485 } | 505 } |
OLD | NEW |