Chromium Code Reviews| 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 778 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 789 } | 789 } |
| 790 #else | 790 #else |
| 791 bool IsWindowPositionManaged(gfx::NativeWindow window) { | 791 bool IsWindowPositionManaged(gfx::NativeWindow window) { |
| 792 return true; | 792 return true; |
| 793 } | 793 } |
| 794 bool HasUserChangedWindowPositionOrSize(gfx::NativeWindow window) { | 794 bool HasUserChangedWindowPositionOrSize(gfx::NativeWindow window) { |
| 795 return false; | 795 return false; |
| 796 } | 796 } |
| 797 #endif | 797 #endif |
| 798 | 798 |
| 799 // Encapsulates waiting for the browser window to become maximized. This is | |
| 800 // needed for example on Chrome desktop linux, where window maximization is done | |
| 801 // asynchronously as an event received from a different process. | |
| 802 class MaximizedBrowserWindowWaiter { | |
| 803 public: | |
| 804 explicit MaximizedBrowserWindowWaiter(BrowserWindow* window) | |
| 805 : window_(window) {} | |
| 806 ~MaximizedBrowserWindowWaiter() = default; | |
| 807 | |
| 808 // Blocks until the browser window becomes maximized. | |
| 809 void Wait() { | |
| 810 base::RunLoop run_loop; | |
| 811 quit_ = run_loop.QuitClosure(); | |
| 812 base::MessageLoop::current()->task_runner()->PostTask( | |
| 813 FROM_HERE, base::Bind(&MaximizedBrowserWindowWaiter::CheckMaximized, | |
| 814 base::Unretained(this))); | |
|
Peter Kasting
2016/11/17 01:32:49
Optional nit: We can save the repeated ugly PostTa
afakhry
2016/11/17 22:51:05
This is a great suggestion! Thanks!
Done.
I'm no
Peter Kasting
2016/11/17 23:05:24
After the first Wait(), |quit_| will remain initia
afakhry
2016/11/18 16:45:36
Yes, I also thought that's what you meant. I attem
| |
| 815 run_loop.Run(); | |
| 816 CHECK(window_->IsMaximized()); | |
|
Peter Kasting
2016/11/17 01:32:49
Nit: CHECK in test code can causes tests to shut d
afakhry
2016/11/17 22:51:05
Done. Removed.
| |
| 817 } | |
| 818 | |
| 819 private: | |
| 820 void CheckMaximized() { | |
| 821 if (!window_->IsMaximized()) { | |
| 822 base::MessageLoop::current()->task_runner()->PostTask( | |
| 823 FROM_HERE, base::Bind(&MaximizedBrowserWindowWaiter::CheckMaximized, | |
| 824 base::Unretained(this))); | |
| 825 return; | |
| 826 } | |
| 827 | |
| 828 // Quit the run_loop to end the wait. | |
| 829 if (!quit_.is_null()) | |
| 830 quit_.Run(); | |
| 831 } | |
| 832 | |
| 833 // The browser window observed by this waiter. | |
| 834 BrowserWindow* window_; | |
| 835 | |
| 836 // The waiter's RunLoop quit closure. | |
| 837 base::Closure quit_; | |
| 838 | |
| 839 DISALLOW_COPY_AND_ASSIGN(MaximizedBrowserWindowWaiter); | |
| 840 }; | |
| 841 | |
| 799 } // namespace | 842 } // namespace |
| 800 | 843 |
| 801 #if defined(OS_CHROMEOS) || defined(OS_LINUX) | |
| 802 // TODO(sky,sad): Disabled as it fails due to resize locks with a real | |
| 803 // compositor. crbug.com/331924 | |
| 804 #define MAYBE_DetachToOwnWindow DISABLED_DetachToOwnWindow | |
| 805 #else | |
| 806 #define MAYBE_DetachToOwnWindow DetachToOwnWindow | |
| 807 #endif | |
| 808 // Drags from browser to separate window and releases mouse. | 844 // Drags from browser to separate window and releases mouse. |
| 809 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 845 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| 810 MAYBE_DetachToOwnWindow) { | 846 DetachToOwnWindow) { |
| 811 const gfx::Rect initial_bounds(browser()->window()->GetBounds()); | 847 const gfx::Rect initial_bounds(browser()->window()->GetBounds()); |
| 812 // Add another tab. | 848 // Add another tab. |
| 813 AddTabAndResetBrowser(browser()); | 849 AddTabAndResetBrowser(browser()); |
| 814 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 850 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 815 | 851 |
| 816 // Move to the first tab and drag it enough so that it detaches. | 852 // Move to the first tab and drag it enough so that it detaches. |
| 817 gfx::Point tab_0_center( | 853 gfx::Point tab_0_center( |
| 818 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 854 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 819 ASSERT_TRUE(PressInput(tab_0_center)); | 855 ASSERT_TRUE(PressInput(tab_0_center)); |
| 820 ASSERT_TRUE(DragInputToNotifyWhenDone( | 856 ASSERT_TRUE(DragInputToNotifyWhenDone( |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 853 // Both windows should not be maximized | 889 // Both windows should not be maximized |
| 854 EXPECT_FALSE(browser()->window()->IsMaximized()); | 890 EXPECT_FALSE(browser()->window()->IsMaximized()); |
| 855 EXPECT_FALSE(new_browser->window()->IsMaximized()); | 891 EXPECT_FALSE(new_browser->window()->IsMaximized()); |
| 856 | 892 |
| 857 // The tab strip should no longer have capture because the drag was ended and | 893 // The tab strip should no longer have capture because the drag was ended and |
| 858 // mouse/touch was released. | 894 // mouse/touch was released. |
| 859 EXPECT_FALSE(tab_strip->GetWidget()->HasCapture()); | 895 EXPECT_FALSE(tab_strip->GetWidget()->HasCapture()); |
| 860 EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture()); | 896 EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture()); |
| 861 } | 897 } |
| 862 | 898 |
| 863 #if defined(OS_CHROMEOS) || defined(OS_LINUX) || defined(OS_MACOSX) | 899 #if defined(OS_LINUX) || defined(OS_MACOSX) |
| 864 // TODO(sky,sad): Disabled as it fails due to resize locks with a real | 900 // TODO(afakhry,varkha): Disabled on Linux as it fails on the bot because |
| 865 // compositor. crbug.com/331924 | 901 // setting the window bounds to the work area bounds in |
| 902 // DesktopWindowTreeHostX11::SetBounds() always insets it by one pixel in both | |
| 903 // width and height. This results in considering the source browser window not | |
| 904 // being full size, and the test is not as expected. | |
| 905 // crbug.com/626761, crbug.com/331924. | |
| 866 // TODO(tapted,mblsha): Disabled as the Mac IsMaximized() behavior is not | 906 // TODO(tapted,mblsha): Disabled as the Mac IsMaximized() behavior is not |
| 867 // consistent with other platforms. crbug.com/603562 | 907 // consistent with other platforms. crbug.com/603562 |
| 868 #define MAYBE_DetachFromFullsizeWindow DISABLED_DetachFromFullsizeWindow | 908 #define MAYBE_DetachFromFullsizeWindow DISABLED_DetachFromFullsizeWindow |
| 869 #else | 909 #else |
| 870 #define MAYBE_DetachFromFullsizeWindow DetachFromFullsizeWindow | 910 #define MAYBE_DetachFromFullsizeWindow DetachFromFullsizeWindow |
| 871 #endif | 911 #endif |
| 872 // Tests that a tab can be dragged from a browser window that is resized to full | 912 // Tests that a tab can be dragged from a browser window that is resized to full |
| 873 // screen. | 913 // screen. |
| 874 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 914 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| 875 MAYBE_DetachFromFullsizeWindow) { | 915 MAYBE_DetachFromFullsizeWindow) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 916 | 956 |
| 917 EXPECT_FALSE(GetIsDragged(browser())); | 957 EXPECT_FALSE(GetIsDragged(browser())); |
| 918 EXPECT_FALSE(GetIsDragged(new_browser)); | 958 EXPECT_FALSE(GetIsDragged(new_browser)); |
| 919 // After this both windows should still be manageable. | 959 // After this both windows should still be manageable. |
| 920 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); | 960 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); |
| 921 EXPECT_TRUE( | 961 EXPECT_TRUE( |
| 922 IsWindowPositionManaged(new_browser->window()->GetNativeWindow())); | 962 IsWindowPositionManaged(new_browser->window()->GetNativeWindow())); |
| 923 | 963 |
| 924 // Only second window should be maximized. | 964 // Only second window should be maximized. |
| 925 EXPECT_FALSE(browser()->window()->IsMaximized()); | 965 EXPECT_FALSE(browser()->window()->IsMaximized()); |
| 966 MaximizedBrowserWindowWaiter(new_browser->window()).Wait(); | |
| 926 EXPECT_TRUE(new_browser->window()->IsMaximized()); | 967 EXPECT_TRUE(new_browser->window()->IsMaximized()); |
| 927 | 968 |
| 928 // The tab strip should no longer have capture because the drag was ended and | 969 // The tab strip should no longer have capture because the drag was ended and |
| 929 // mouse/touch was released. | 970 // mouse/touch was released. |
| 930 EXPECT_FALSE(tab_strip->GetWidget()->HasCapture()); | 971 EXPECT_FALSE(tab_strip->GetWidget()->HasCapture()); |
| 931 EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture()); | 972 EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture()); |
| 932 } | 973 } |
| 933 | 974 |
| 934 #if defined(OS_CHROMEOS) || defined(OS_LINUX) || defined(OS_MACOSX) | 975 #if defined(OS_MACOSX) |
| 935 // TODO(sky,sad): Disabled as it fails due to resize locks with a real | |
| 936 // compositor. crbug.com/331924 | |
| 937 // TODO(tapted,mblsha): Disabled as the Mac IsMaximized() behavior is not | 976 // TODO(tapted,mblsha): Disabled as the Mac IsMaximized() behavior is not |
| 938 // consistent with other platforms. crbug.com/603562 | 977 // consistent with other platforms. crbug.com/603562 |
| 939 #define MAYBE_DetachToOwnWindowFromMaximizedWindow \ | 978 #define MAYBE_DetachToOwnWindowFromMaximizedWindow \ |
| 940 DISABLED_DetachToOwnWindowFromMaximizedWindow | 979 DISABLED_DetachToOwnWindowFromMaximizedWindow |
| 941 #else | 980 #else |
| 942 #define MAYBE_DetachToOwnWindowFromMaximizedWindow \ | 981 #define MAYBE_DetachToOwnWindowFromMaximizedWindow \ |
| 943 DetachToOwnWindowFromMaximizedWindow | 982 DetachToOwnWindowFromMaximizedWindow |
| 944 #endif | 983 #endif |
| 945 // Drags from browser to a separate window and releases mouse. | 984 // Drags from browser to a separate window and releases mouse. |
| 946 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 985 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| 947 MAYBE_DetachToOwnWindowFromMaximizedWindow) { | 986 MAYBE_DetachToOwnWindowFromMaximizedWindow) { |
| 948 // Maximize the initial browser window. | 987 // Maximize the initial browser window. |
| 949 browser()->window()->Maximize(); | 988 browser()->window()->Maximize(); |
| 989 MaximizedBrowserWindowWaiter(browser()->window()).Wait(); | |
| 950 ASSERT_TRUE(browser()->window()->IsMaximized()); | 990 ASSERT_TRUE(browser()->window()->IsMaximized()); |
| 951 | 991 |
| 952 // Add another tab. | 992 // Add another tab. |
| 953 AddTabAndResetBrowser(browser()); | 993 AddTabAndResetBrowser(browser()); |
| 954 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 994 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 955 | 995 |
| 956 // Move to the first tab and drag it enough so that it detaches. | 996 // Move to the first tab and drag it enough so that it detaches. |
| 957 gfx::Point tab_0_center( | 997 gfx::Point tab_0_center( |
| 958 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); | 998 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); |
| 959 ASSERT_TRUE(PressInput(tab_0_center)); | 999 ASSERT_TRUE(PressInput(tab_0_center)); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 983 EXPECT_TRUE(browser()->window()->IsMaximized()); | 1023 EXPECT_TRUE(browser()->window()->IsMaximized()); |
| 984 | 1024 |
| 985 EXPECT_FALSE(GetIsDragged(browser())); | 1025 EXPECT_FALSE(GetIsDragged(browser())); |
| 986 EXPECT_FALSE(GetIsDragged(new_browser)); | 1026 EXPECT_FALSE(GetIsDragged(new_browser)); |
| 987 // After this both windows should still be manageable. | 1027 // After this both windows should still be manageable. |
| 988 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); | 1028 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); |
| 989 EXPECT_TRUE(IsWindowPositionManaged( | 1029 EXPECT_TRUE(IsWindowPositionManaged( |
| 990 new_browser->window()->GetNativeWindow())); | 1030 new_browser->window()->GetNativeWindow())); |
| 991 | 1031 |
| 992 // The new window should be maximized. | 1032 // The new window should be maximized. |
| 1033 MaximizedBrowserWindowWaiter(new_browser->window()).Wait(); | |
| 993 EXPECT_TRUE(new_browser->window()->IsMaximized()); | 1034 EXPECT_TRUE(new_browser->window()->IsMaximized()); |
| 994 } | 1035 } |
| 995 | 1036 |
| 996 // Deletes a tab being dragged before the user moved enough to start a drag. | 1037 // Deletes a tab being dragged before the user moved enough to start a drag. |
| 997 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 1038 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| 998 DeleteBeforeStartedDragging) { | 1039 DeleteBeforeStartedDragging) { |
| 999 // Add another tab. | 1040 // Add another tab. |
| 1000 AddTabAndResetBrowser(browser()); | 1041 AddTabAndResetBrowser(browser()); |
| 1001 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 1042 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 1002 | 1043 |
| (...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2422 base::Bind(&DetachToDockedWindowNextStep, | 2463 base::Bind(&DetachToDockedWindowNextStep, |
| 2423 test, | 2464 test, |
| 2424 gfx::Point(target_point.x(), 1 + target_point.y()), | 2465 gfx::Point(target_point.x(), 1 + target_point.y()), |
| 2425 iteration - 1))); | 2466 iteration - 1))); |
| 2426 } | 2467 } |
| 2427 | 2468 |
| 2428 } // namespace | 2469 } // namespace |
| 2429 | 2470 |
| 2430 // Drags from browser to separate window, docks that window and releases mouse. | 2471 // Drags from browser to separate window, docks that window and releases mouse. |
| 2431 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, | 2472 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| 2432 DISABLED_DetachToDockedWindowFromMaximizedWindow) { | 2473 DetachToDockedWindowFromMaximizedWindow) { |
| 2433 // Maximize the initial browser window. | 2474 // Maximize the initial browser window. |
| 2434 browser()->window()->Maximize(); | 2475 browser()->window()->Maximize(); |
| 2435 ASSERT_TRUE(browser()->window()->IsMaximized()); | 2476 ASSERT_TRUE(browser()->window()->IsMaximized()); |
| 2436 | 2477 |
| 2437 // Add another tab. | 2478 // Add another tab. |
| 2438 AddTabAndResetBrowser(browser()); | 2479 AddTabAndResetBrowser(browser()); |
| 2439 TabStrip* tab_strip = GetTabStripForBrowser(browser()); | 2480 TabStrip* tab_strip = GetTabStripForBrowser(browser()); |
| 2440 | 2481 |
| 2441 // Move to the first tab and drag it enough so that it detaches. | 2482 // Move to the first tab and drag it enough so that it detaches. |
| 2442 gfx::Point tab_0_center( | 2483 gfx::Point tab_0_center( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2499 DetachToBrowserTabDragControllerTest, | 2540 DetachToBrowserTabDragControllerTest, |
| 2500 ::testing::Values("mouse", "touch")); | 2541 ::testing::Values("mouse", "touch")); |
| 2501 INSTANTIATE_TEST_CASE_P(TabDragging, | 2542 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 2502 DetachToBrowserTabDragControllerTestTouch, | 2543 DetachToBrowserTabDragControllerTestTouch, |
| 2503 ::testing::Values("touch")); | 2544 ::testing::Values("touch")); |
| 2504 #else | 2545 #else |
| 2505 INSTANTIATE_TEST_CASE_P(TabDragging, | 2546 INSTANTIATE_TEST_CASE_P(TabDragging, |
| 2506 DetachToBrowserTabDragControllerTest, | 2547 DetachToBrowserTabDragControllerTest, |
| 2507 ::testing::Values("mouse")); | 2548 ::testing::Values("mouse")); |
| 2508 #endif | 2549 #endif |
| OLD | NEW |