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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/wm/window_state.h" | 9 #include "ash/wm/window_state.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
788 | 788 |
789 // The tab strip should no longer have capture because the drag was ended and | 789 // The tab strip should no longer have capture because the drag was ended and |
790 // mouse/touch was released. | 790 // mouse/touch was released. |
791 EXPECT_FALSE(tab_strip->GetWidget()->HasCapture()); | 791 EXPECT_FALSE(tab_strip->GetWidget()->HasCapture()); |
792 EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture()); | 792 EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture()); |
793 } | 793 } |
794 | 794 |
795 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | 795 #if defined(OS_CHROMEOS) || defined(OS_LINUX) |
796 // TODO(sky,sad): Disabled as it fails due to resize locks with a real | 796 // TODO(sky,sad): Disabled as it fails due to resize locks with a real |
797 // compositor. crbug.com/331924 | 797 // compositor. crbug.com/331924 |
| 798 #define MAYBE_DetachFromFullsizeWindow DISABLED_DetachFromFullsizeWindow |
| 799 #else |
| 800 #define MAYBE_DetachFromFullsizeWindow DetachFromFullsizeWindow |
| 801 #endif |
| 802 // Tests that a tab can be dragged from a browser window that is resized to full |
| 803 // screen. |
| 804 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| 805 MAYBE_DetachFromFullsizeWindow) { |
| 806 // Resize the browser window so that it is as big as the work area. |
| 807 gfx::Rect work_area = |
| 808 gfx::Screen::GetNativeScreen() |
| 809 ->GetDisplayNearestWindow(browser()->window()->GetNativeWindow()) |
| 810 .work_area(); |
| 811 browser()->window()->SetBounds(work_area); |
| 812 const gfx::Rect initial_bounds(browser()->window()->GetBounds()); |
| 813 // Add another tab. |
| 814 AddTabAndResetBrowser(browser()); |
| 815 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 816 |
| 817 // Move to the first tab and drag it enough so that it detaches. |
| 818 gfx::Point tab_0_center(GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 819 ASSERT_TRUE(PressInput(tab_0_center)); |
| 820 ASSERT_TRUE(DragInputToNotifyWhenDone( |
| 821 tab_0_center.x(), tab_0_center.y() + GetDetachY(tab_strip), |
| 822 base::Bind(&DetachToOwnWindowStep2, this))); |
| 823 if (input_source() == INPUT_SOURCE_MOUSE) { |
| 824 ASSERT_TRUE(ReleaseMouseAsync()); |
| 825 QuitWhenNotDragging(); |
| 826 } |
| 827 |
| 828 // Should no longer be dragging. |
| 829 ASSERT_FALSE(tab_strip->IsDragSessionActive()); |
| 830 ASSERT_FALSE(TabDragController::IsActive()); |
| 831 |
| 832 // There should now be another browser. |
| 833 ASSERT_EQ(2u, native_browser_list->size()); |
| 834 Browser* new_browser = native_browser_list->get(1); |
| 835 ASSERT_TRUE(new_browser->window()->IsActive()); |
| 836 TabStrip* tab_strip2 = GetTabStripForBrowser(new_browser); |
| 837 ASSERT_FALSE(tab_strip2->IsDragSessionActive()); |
| 838 |
| 839 EXPECT_EQ("0", IDString(new_browser->tab_strip_model())); |
| 840 EXPECT_EQ("1", IDString(browser()->tab_strip_model())); |
| 841 |
| 842 // The bounds of the initial window should not have changed. |
| 843 EXPECT_EQ(initial_bounds.ToString(), |
| 844 browser()->window()->GetBounds().ToString()); |
| 845 |
| 846 EXPECT_FALSE(GetIsDragged(browser())); |
| 847 EXPECT_FALSE(GetIsDragged(new_browser)); |
| 848 // After this both windows should still be manageable. |
| 849 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); |
| 850 EXPECT_TRUE( |
| 851 IsWindowPositionManaged(new_browser->window()->GetNativeWindow())); |
| 852 |
| 853 // Only second window should be maximized. |
| 854 EXPECT_FALSE(browser()->window()->IsMaximized()); |
| 855 EXPECT_TRUE(new_browser->window()->IsMaximized()); |
| 856 |
| 857 // The tab strip should no longer have capture because the drag was ended and |
| 858 // mouse/touch was released. |
| 859 EXPECT_FALSE(tab_strip->GetWidget()->HasCapture()); |
| 860 EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture()); |
| 861 } |
| 862 |
| 863 #if defined(OS_CHROMEOS) || defined(OS_LINUX) |
| 864 // TODO(sky,sad): Disabled as it fails due to resize locks with a real |
| 865 // compositor. crbug.com/331924 |
798 #define MAYBE_DetachToOwnWindowFromMaximizedWindow \ | 866 #define MAYBE_DetachToOwnWindowFromMaximizedWindow \ |
799 DISABLED_DetachToOwnWindowFromMaximizedWindow | 867 DISABLED_DetachToOwnWindowFromMaximizedWindow |
800 #else | 868 #else |
801 #define MAYBE_DetachToOwnWindowFromMaximizedWindow \ | 869 #define MAYBE_DetachToOwnWindowFromMaximizedWindow \ |
802 DetachToOwnWindowFromMaximizedWindow | 870 DetachToOwnWindowFromMaximizedWindow |
803 #endif | 871 #endif |
804 // Drags from browser to a separate window and releases mouse. | 872 // Drags from browser to a separate window and releases mouse. |
805 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 873 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
806 MAYBE_DetachToOwnWindowFromMaximizedWindow) { | 874 MAYBE_DetachToOwnWindowFromMaximizedWindow) { |
807 // Maximize the initial browser window. | 875 // Maximize the initial browser window. |
(...skipping 1478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2286 DetachToBrowserTabDragControllerTest, | 2354 DetachToBrowserTabDragControllerTest, |
2287 ::testing::Values("mouse", "touch")); | 2355 ::testing::Values("mouse", "touch")); |
2288 INSTANTIATE_TEST_CASE_P(TabDragging, | 2356 INSTANTIATE_TEST_CASE_P(TabDragging, |
2289 DetachToBrowserTabDragControllerTestTouch, | 2357 DetachToBrowserTabDragControllerTestTouch, |
2290 ::testing::Values("touch")); | 2358 ::testing::Values("touch")); |
2291 #elif defined(USE_ASH) | 2359 #elif defined(USE_ASH) |
2292 INSTANTIATE_TEST_CASE_P(TabDragging, | 2360 INSTANTIATE_TEST_CASE_P(TabDragging, |
2293 DetachToBrowserTabDragControllerTest, | 2361 DetachToBrowserTabDragControllerTest, |
2294 ::testing::Values("mouse")); | 2362 ::testing::Values("mouse")); |
2295 #endif | 2363 #endif |
OLD | NEW |