| 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 2432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2443 // The drag should have been reverted. | 2443 // The drag should have been reverted. |
| 2444 ASSERT_EQ(1u, browser_list->size()); | 2444 ASSERT_EQ(1u, browser_list->size()); |
| 2445 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | 2445 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 2446 ASSERT_FALSE(TabDragController::IsActive()); | 2446 ASSERT_FALSE(TabDragController::IsActive()); |
| 2447 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); | 2447 EXPECT_EQ("0 1", IDString(browser()->tab_strip_model())); |
| 2448 | 2448 |
| 2449 ASSERT_TRUE(ReleaseInput()); | 2449 ASSERT_TRUE(ReleaseInput()); |
| 2450 ASSERT_TRUE(ReleaseInput2()); | 2450 ASSERT_TRUE(ReleaseInput2()); |
| 2451 } | 2451 } |
| 2452 | 2452 |
| 2453 namespace { | |
| 2454 | |
| 2455 void DetachToDockedWindowNextStep( | |
| 2456 DetachToBrowserTabDragControllerTest* test, | |
| 2457 const gfx::Point& target_point, | |
| 2458 int iteration) { | |
| 2459 ASSERT_EQ(2u, test->browser_list->size()); | |
| 2460 Browser* new_browser = test->browser_list->get(1); | |
| 2461 ASSERT_TRUE(new_browser->window()->IsActive()); | |
| 2462 | |
| 2463 if (!iteration) { | |
| 2464 ASSERT_TRUE(test->ReleaseInput()); | |
| 2465 return; | |
| 2466 } | |
| 2467 ASSERT_TRUE(test->DragInputToNotifyWhenDone( | |
| 2468 target_point.x(), target_point.y(), | |
| 2469 base::Bind(&DetachToDockedWindowNextStep, | |
| 2470 test, | |
| 2471 gfx::Point(target_point.x(), 1 + target_point.y()), | |
| 2472 iteration - 1))); | |
| 2473 } | |
| 2474 | |
| 2475 } // namespace | |
| 2476 | |
| 2477 // Drags from browser to separate window, docks that window and releases mouse. | |
| 2478 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | |
| 2479 DetachToDockedWindowFromMaximizedWindow) { | |
| 2480 // Enable docked windows for this test. | |
| 2481 base::CommandLine::ForCurrentProcess()->AppendSwitch( | |
| 2482 ash::switches::kAshEnableDockedWindows); | |
| 2483 | |
| 2484 // Maximize the initial browser window. | |
| 2485 browser()->window()->Maximize(); | |
| 2486 ASSERT_TRUE(browser()->window()->IsMaximized()); | |
| 2487 | |
| 2488 // Add another tab. | |
| 2489 AddTabAndResetBrowser(browser()); | |
| 2490 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | |
| 2491 | |
| 2492 // Move to the first tab and drag it enough so that it detaches. | |
| 2493 gfx::Point tab_0_center( | |
| 2494 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | |
| 2495 ASSERT_TRUE(PressInput(tab_0_center)); | |
| 2496 | |
| 2497 // The following matches kMovesBeforeAdjust in snap_sizer.cc | |
| 2498 const int kNumIterations = 25 * 5 + 10; | |
| 2499 ASSERT_TRUE(DragInputToNotifyWhenDone( | |
| 2500 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), | |
| 2501 base::Bind(&DetachToDockedWindowNextStep, this, | |
| 2502 gfx::Point(0, tab_0_center.y() + GetDetachY(tab_strip)), | |
| 2503 kNumIterations))); | |
| 2504 // Continue dragging enough times to go through snapping sequence and dock | |
| 2505 // the window. | |
| 2506 QuitWhenNotDragging(); | |
| 2507 // Should no longer be dragging. | |
| 2508 ASSERT_FALSE(tab_strip->IsDragSessionActive()); | |
| 2509 ASSERT_FALSE(TabDragController::IsActive()); | |
| 2510 | |
| 2511 // There should now be another browser. | |
| 2512 ASSERT_EQ(2u, browser_list->size()); | |
| 2513 Browser* new_browser = browser_list->get(1); | |
| 2514 ASSERT_TRUE(new_browser->window()->IsActive()); | |
| 2515 TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser); | |
| 2516 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); | |
| 2517 | |
| 2518 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); | |
| 2519 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); | |
| 2520 | |
| 2521 // The bounds of the initial window should not have changed. | |
| 2522 EXPECT_TRUE(browser()->window()->IsMaximized()); | |
| 2523 | |
| 2524 EXPECT_FALSE(GetIsDragged(browser())); | |
| 2525 EXPECT_FALSE(GetIsDragged(new_browser)); | |
| 2526 // After this both windows should still be manageable. | |
| 2527 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); | |
| 2528 EXPECT_TRUE(IsWindowPositionManaged( | |
| 2529 new_browser->window()->GetNativeWindow())); | |
| 2530 | |
| 2531 ash::wm::WindowState* window_state = | |
| 2532 ash::wm::GetWindowState(new_browser->window()->GetNativeWindow()); | |
| 2533 // The new window should not be maximized because it gets docked or snapped. | |
| 2534 EXPECT_FALSE(new_browser->window()->IsMaximized()); | |
| 2535 // The new window should be docked and not snapped. | |
| 2536 EXPECT_TRUE(window_state->IsDocked()); | |
| 2537 EXPECT_FALSE(window_state->IsSnapped()); | |
| 2538 } | |
| 2539 | |
| 2540 #endif // OS_CHROMEOS | 2453 #endif // OS_CHROMEOS |
| 2541 | 2454 |
| 2542 #if defined(USE_ASH) | 2455 #if defined(USE_ASH) |
| 2543 INSTANTIATE_TEST_CASE_P(TabDragging, | 2456 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 2544 DetachToBrowserInSeparateDisplayTabDragControllerTest, | 2457 DetachToBrowserInSeparateDisplayTabDragControllerTest, |
| 2545 ::testing::Values("mouse", "touch")); | 2458 ::testing::Values("mouse", "touch")); |
| 2546 INSTANTIATE_TEST_CASE_P(TabDragging, | 2459 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 2547 DifferentDeviceScaleFactorDisplayTabDragControllerTest, | 2460 DifferentDeviceScaleFactorDisplayTabDragControllerTest, |
| 2548 ::testing::Values("mouse")); | 2461 ::testing::Values("mouse")); |
| 2549 INSTANTIATE_TEST_CASE_P(TabDragging, | 2462 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 2550 DetachToBrowserTabDragControllerTest, | 2463 DetachToBrowserTabDragControllerTest, |
| 2551 ::testing::Values("mouse", "touch")); | 2464 ::testing::Values("mouse", "touch")); |
| 2552 INSTANTIATE_TEST_CASE_P(TabDragging, | 2465 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 2553 DetachToBrowserTabDragControllerTestTouch, | 2466 DetachToBrowserTabDragControllerTestTouch, |
| 2554 ::testing::Values("touch")); | 2467 ::testing::Values("touch")); |
| 2555 #else | 2468 #else |
| 2556 INSTANTIATE_TEST_CASE_P(TabDragging, | 2469 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 2557 DetachToBrowserTabDragControllerTest, | 2470 DetachToBrowserTabDragControllerTest, |
| 2558 ::testing::Values("mouse")); | 2471 ::testing::Values("mouse")); |
| 2559 #endif | 2472 #endif |
| OLD | NEW |