| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h" | 5 #include "chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 467 return ui_controls::SendMouseMoveNotifyWhenDone(x, y, task); | 467 return ui_controls::SendMouseMoveNotifyWhenDone(x, y, task); |
| 468 #if defined(OS_CHROMEOS) | 468 #if defined(OS_CHROMEOS) |
| 469 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); | 469 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); |
| 470 event_generator_->MoveTouch(gfx::Point(x, y)); | 470 event_generator_->MoveTouch(gfx::Point(x, y)); |
| 471 #else | 471 #else |
| 472 NOTREACHED(); | 472 NOTREACHED(); |
| 473 #endif | 473 #endif |
| 474 return true; | 474 return true; |
| 475 } | 475 } |
| 476 | 476 |
| 477 bool DragInputToDelayedNotifyWhenDone(int x, | |
| 478 int y, | |
| 479 const base::Closure& task, | |
| 480 base::TimeDelta delay) { | |
| 481 if (input_source() == INPUT_SOURCE_MOUSE) | |
| 482 return ui_controls::SendMouseMoveNotifyWhenDone(x, y, task); | |
| 483 #if defined(OS_CHROMEOS) | |
| 484 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(FROM_HERE, task, | |
| 485 delay); | |
| 486 event_generator_->MoveTouch(gfx::Point(x, y)); | |
| 487 #else | |
| 488 NOTREACHED(); | |
| 489 #endif | |
| 490 return true; | |
| 491 } | |
| 492 | |
| 493 bool DragInput2ToNotifyWhenDone(int x, | 477 bool DragInput2ToNotifyWhenDone(int x, |
| 494 int y, | 478 int y, |
| 495 const base::Closure& task) { | 479 const base::Closure& task) { |
| 496 if (input_source() == INPUT_SOURCE_MOUSE) | 480 if (input_source() == INPUT_SOURCE_MOUSE) |
| 497 return ui_controls::SendMouseMoveNotifyWhenDone(x, y, task); | 481 return ui_controls::SendMouseMoveNotifyWhenDone(x, y, task); |
| 498 #if defined(OS_CHROMEOS) | 482 #if defined(OS_CHROMEOS) |
| 499 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); | 483 base::ThreadTaskRunnerHandle::Get()->PostTask(FROM_HERE, task); |
| 500 event_generator_->MoveTouchId(gfx::Point(x, y), 1); | 484 event_generator_->MoveTouchId(gfx::Point(x, y), 1); |
| 501 #else | 485 #else |
| 502 NOTREACHED(); | 486 NOTREACHED(); |
| (...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2354 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); | 2338 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); |
| 2355 | 2339 |
| 2356 // Release the mouse | 2340 // Release the mouse |
| 2357 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( | 2341 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( |
| 2358 ui_controls::LEFT, ui_controls::UP)); | 2342 ui_controls::LEFT, ui_controls::UP)); |
| 2359 } | 2343 } |
| 2360 | 2344 |
| 2361 // Drags from browser from a second display to primary and releases input. | 2345 // Drags from browser from a second display to primary and releases input. |
| 2362 IN_PROC_BROWSER_TEST_F( | 2346 IN_PROC_BROWSER_TEST_F( |
| 2363 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest, | 2347 DetachToBrowserInSeparateDisplayAndCancelTabDragControllerTest, |
| 2364 DISABLED_CancelDragTabToWindowIn1stDisplay) { | 2348 CancelDragTabToWindowIn1stDisplay) { |
| 2365 aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); | 2349 aura::Window::Windows roots = ash::Shell::GetAllRootWindows(); |
| 2366 ASSERT_EQ(2u, roots.size()); | 2350 ASSERT_EQ(2u, roots.size()); |
| 2367 | 2351 |
| 2368 // Add another tab. | 2352 // Add another tab. |
| 2369 AddTabAndResetBrowser(browser()); | 2353 AddTabAndResetBrowser(browser()); |
| 2370 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 2354 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 2371 | 2355 |
| 2372 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); | 2356 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); |
| 2373 EXPECT_EQ(roots[0], browser()->window()->GetNativeWindow()->GetRootWindow()); | 2357 EXPECT_EQ(roots[0], browser()->window()->GetNativeWindow()->GetRootWindow()); |
| 2374 | 2358 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2399 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 2383 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 2400 ASSERT_FALSE(TabDragController::IsActive()); | 2384 ASSERT_FALSE(TabDragController::IsActive()); |
| 2401 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); | 2385 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); |
| 2402 | 2386 |
| 2403 // Release the mouse | 2387 // Release the mouse |
| 2404 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( | 2388 ASSERT_TRUE(ui_test_utils::SendMouseEventsSync( |
| 2405 ui_controls::LEFT, ui_controls::UP)); | 2389 ui_controls::LEFT, ui_controls::UP)); |
| 2406 } | 2390 } |
| 2407 | 2391 |
| 2408 namespace { | 2392 namespace { |
| 2409 | 2393 void PressSecondFingerWhileDetachedStep3( |
| 2410 void PressSecondFingerWhileDetachedStep2( | |
| 2411 DetachToBrowserTabDragControllerTest* test) { | 2394 DetachToBrowserTabDragControllerTest* test) { |
| 2412 ASSERT_TRUE(TabDragController::IsActive()); | 2395 ASSERT_TRUE(TabDragController::IsActive()); |
| 2413 ASSERT_EQ(2u, test->browser_list->size()); | 2396 ASSERT_EQ(2u, test->browser_list->size()); |
| 2414 Browser* new_browser = test->browser_list->get(1); | 2397 ASSERT_TRUE(test->browser_list->get(1)->window()->IsActive()); |
| 2415 ASSERT_TRUE(new_browser->window()->IsActive()); | |
| 2416 | 2398 |
| 2399 ASSERT_TRUE(test->ReleaseInput()); |
| 2400 ASSERT_TRUE(test->ReleaseInput2()); |
| 2401 } |
| 2402 |
| 2403 void PressSecondFingerWhileDetachedStep2( |
| 2404 DetachToBrowserTabDragControllerTest* test, |
| 2405 const gfx::Point& target_point) { |
| 2406 ASSERT_TRUE(TabDragController::IsActive()); |
| 2407 ASSERT_EQ(2u, test->browser_list->size()); |
| 2408 ASSERT_TRUE(test->browser_list->get(1)->window()->IsActive()); |
| 2409 |
| 2410 // Continue dragging after adding a second finger. |
| 2417 ASSERT_TRUE(test->PressInput2()); | 2411 ASSERT_TRUE(test->PressInput2()); |
| 2412 ASSERT_TRUE(test->DragInputToNotifyWhenDone( |
| 2413 target_point.x(), target_point.y(), |
| 2414 base::Bind(&PressSecondFingerWhileDetachedStep3, test))); |
| 2418 } | 2415 } |
| 2419 | 2416 |
| 2420 } // namespace | 2417 } // namespace |
| 2421 | 2418 |
| 2422 // Detaches a tab and while detached presses a second finger. | 2419 // Detaches a tab and while detached presses a second finger. |
| 2423 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTestTouch, | 2420 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTestTouch, |
| 2424 DISABLED_PressSecondFingerWhileDetached) { | 2421 PressSecondFingerWhileDetached) { |
| 2425 // Add another tab. | 2422 // Add another tab. |
| 2426 AddTabAndResetBrowser(browser()); | 2423 AddTabAndResetBrowser(browser()); |
| 2427 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 2424 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 2428 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); | 2425 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); |
| 2429 | 2426 |
| 2430 // Move to the first tab and drag it enough so that it detaches. | 2427 // Move to the first tab and drag it enough so that it detaches. |
| 2431 gfx::Point tab_0_center( | 2428 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 2432 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | |
| 2433 ASSERT_TRUE(PressInput(tab_0_center)); | 2429 ASSERT_TRUE(PressInput(tab_0_center)); |
| 2434 ASSERT_TRUE(DragInputToDelayedNotifyWhenDone( | 2430 ASSERT_TRUE(DragInputToNotifyWhenDone( |
| 2435 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), | 2431 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), |
| 2436 base::Bind(&PressSecondFingerWhileDetachedStep2, this), | 2432 base::Bind(&PressSecondFingerWhileDetachedStep2, this, |
| 2437 base::TimeDelta::FromMilliseconds(60))); | 2433 gfx::Point(tab_0_center.x(), |
| 2434 tab_0_center.y() + 2 * GetDetachY(tab_strip))))); |
| 2438 QuitWhenNotDragging(); | 2435 QuitWhenNotDragging(); |
| 2439 | 2436 |
| 2440 // The drag should have been reverted. | 2437 // Should no longer be dragging. |
| 2441 ASSERT_EQ(1u, browser_list->size()); | |
| 2442 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 2438 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 2443 ASSERT_FALSE(TabDragController::IsActive()); | 2439 ASSERT_FALSE(TabDragController::IsActive()); |
| 2444 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); | |
| 2445 | 2440 |
| 2446 ASSERT_TRUE(ReleaseInput()); | 2441 // There should now be another browser. |
| 2447 ASSERT_TRUE(ReleaseInput2()); | 2442 ASSERT_EQ(2u, browser_list->size()); |
| 2443 Browser* new_browser = browser_list->get(1); |
| 2444 ASSERT_TRUE(new_browser->window()->IsActive()); |
| 2445 TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser); |
| 2446 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); |
| 2447 |
| 2448 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); |
| 2449 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); |
| 2448 } | 2450 } |
| 2449 | 2451 |
| 2450 #endif // OS_CHROMEOS | 2452 #endif // OS_CHROMEOS |
| 2451 | 2453 |
| 2452 #if defined(USE_ASH) | 2454 #if defined(USE_ASH) |
| 2453 INSTANTIATE_TEST_CASE_P(TabDragging, | 2455 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 2454 DetachToBrowserInSeparateDisplayTabDragControllerTest, | 2456 DetachToBrowserInSeparateDisplayTabDragControllerTest, |
| 2455 ::testing::Values("mouse", "touch")); | 2457 ::testing::Values("mouse", "touch")); |
| 2456 INSTANTIATE_TEST_CASE_P(TabDragging, | 2458 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 2457 DifferentDeviceScaleFactorDisplayTabDragControllerTest, | 2459 DifferentDeviceScaleFactorDisplayTabDragControllerTest, |
| 2458 ::testing::Values("mouse")); | 2460 ::testing::Values("mouse")); |
| 2459 INSTANTIATE_TEST_CASE_P(TabDragging, | 2461 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 2460 DetachToBrowserTabDragControllerTest, | 2462 DetachToBrowserTabDragControllerTest, |
| 2461 ::testing::Values("mouse", "touch")); | 2463 ::testing::Values("mouse", "touch")); |
| 2462 INSTANTIATE_TEST_CASE_P(TabDragging, | 2464 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 2463 DetachToBrowserTabDragControllerTestTouch, | 2465 DetachToBrowserTabDragControllerTestTouch, |
| 2464 ::testing::Values("touch")); | 2466 ::testing::Values("touch")); |
| 2465 #else | 2467 #else |
| 2466 INSTANTIATE_TEST_CASE_P(TabDragging, | 2468 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 2467 DetachToBrowserTabDragControllerTest, | 2469 DetachToBrowserTabDragControllerTest, |
| 2468 ::testing::Values("mouse")); | 2470 ::testing::Values("mouse")); |
| 2469 #endif | 2471 #endif |
| OLD | NEW |