Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc

Issue 2550533002: Revert of Reenable Tabdragging tests failing because of IsWindowPositionManaged() (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_drag_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h"
13 #include "base/callback.h" 12 #include "base/callback.h"
14 #include "base/callback_helpers.h"
15 #include "base/command_line.h" 13 #include "base/command_line.h"
16 #include "base/location.h" 14 #include "base/location.h"
17 #include "base/macros.h" 15 #include "base/macros.h"
18 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
19 #include "base/run_loop.h" 17 #include "base/run_loop.h"
20 #include "base/single_thread_task_runner.h" 18 #include "base/single_thread_task_runner.h"
21 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
22 #include "base/threading/thread_task_runner_handle.h" 20 #include "base/threading/thread_task_runner_handle.h"
23 #include "build/build_config.h" 21 #include "build/build_config.h"
24 #include "chrome/browser/chrome_notification_types.h" 22 #include "chrome/browser/chrome_notification_types.h"
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 } 789 }
792 #else 790 #else
793 bool IsWindowPositionManaged(gfx::NativeWindow window) { 791 bool IsWindowPositionManaged(gfx::NativeWindow window) {
794 return true; 792 return true;
795 } 793 }
796 bool HasUserChangedWindowPositionOrSize(gfx::NativeWindow window) { 794 bool HasUserChangedWindowPositionOrSize(gfx::NativeWindow window) {
797 return false; 795 return false;
798 } 796 }
799 #endif 797 #endif
800 798
801 // Encapsulates waiting for the browser window to become maximized. This is
802 // needed for example on Chrome desktop linux, where window maximization is done
803 // asynchronously as an event received from a different process.
804 class MaximizedBrowserWindowWaiter {
805 public:
806 explicit MaximizedBrowserWindowWaiter(BrowserWindow* window)
807 : window_(window) {}
808 ~MaximizedBrowserWindowWaiter() = default;
809
810 // Blocks until the browser window becomes maximized.
811 void Wait() {
812 if (CheckMaximized())
813 return;
814
815 base::RunLoop run_loop;
816 quit_ = run_loop.QuitClosure();
817 run_loop.Run();
818 }
819
820 private:
821 bool CheckMaximized() {
822 if (!window_->IsMaximized()) {
823 base::MessageLoop::current()->task_runner()->PostTask(
824 FROM_HERE, base::Bind(
825 base::IgnoreResult(&MaximizedBrowserWindowWaiter::CheckMaximized),
826 base::Unretained(this)));
827 return false;
828 }
829
830 // Quit the run_loop to end the wait.
831 if (!quit_.is_null())
832 base::ResetAndReturn(&quit_).Run();
833 return true;
834 }
835
836 // The browser window observed by this waiter.
837 BrowserWindow* window_;
838
839 // The waiter's RunLoop quit closure.
840 base::Closure quit_;
841
842 DISALLOW_COPY_AND_ASSIGN(MaximizedBrowserWindowWaiter);
843 };
844
845 } // namespace 799 } // namespace
846 800
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
847 // Drags from browser to separate window and releases mouse. 808 // Drags from browser to separate window and releases mouse.
848 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, 809 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
849 DetachToOwnWindow) { 810 MAYBE_DetachToOwnWindow) {
850 const gfx::Rect initial_bounds(browser()->window()->GetBounds()); 811 const gfx::Rect initial_bounds(browser()->window()->GetBounds());
851 // Add another tab. 812 // Add another tab.
852 AddTabAndResetBrowser(browser()); 813 AddTabAndResetBrowser(browser());
853 TabStrip* tab_strip = GetTabStripForBrowser(browser()); 814 TabStrip* tab_strip = GetTabStripForBrowser(browser());
854 815
855 // Move to the first tab and drag it enough so that it detaches. 816 // Move to the first tab and drag it enough so that it detaches.
856 gfx::Point tab_0_center( 817 gfx::Point tab_0_center(
857 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); 818 GetCenterInScreenCoordinates(tab_strip->tab_at(0)));
858 ASSERT_TRUE(PressInput(tab_0_center)); 819 ASSERT_TRUE(PressInput(tab_0_center));
859 ASSERT_TRUE(DragInputToNotifyWhenDone( 820 ASSERT_TRUE(DragInputToNotifyWhenDone(
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 // Both windows should not be maximized 853 // Both windows should not be maximized
893 EXPECT_FALSE(browser()->window()->IsMaximized()); 854 EXPECT_FALSE(browser()->window()->IsMaximized());
894 EXPECT_FALSE(new_browser->window()->IsMaximized()); 855 EXPECT_FALSE(new_browser->window()->IsMaximized());
895 856
896 // The tab strip should no longer have capture because the drag was ended and 857 // The tab strip should no longer have capture because the drag was ended and
897 // mouse/touch was released. 858 // mouse/touch was released.
898 EXPECT_FALSE(tab_strip->GetWidget()->HasCapture()); 859 EXPECT_FALSE(tab_strip->GetWidget()->HasCapture());
899 EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture()); 860 EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture());
900 } 861 }
901 862
902 #if defined(OS_LINUX) || defined(OS_MACOSX) 863 #if defined(OS_CHROMEOS) || defined(OS_LINUX) || defined(OS_MACOSX)
903 // TODO(afakhry,varkha): Disabled on Linux as it fails on the bot because 864 // TODO(sky,sad): Disabled as it fails due to resize locks with a real
904 // setting the window bounds to the work area bounds in 865 // compositor. crbug.com/331924
905 // DesktopWindowTreeHostX11::SetBounds() always insets it by one pixel in both
906 // width and height. This results in considering the source browser window not
907 // being full size, and the test is not as expected.
908 // crbug.com/626761, crbug.com/331924.
909 // TODO(tapted,mblsha): Disabled as the Mac IsMaximized() behavior is not 866 // TODO(tapted,mblsha): Disabled as the Mac IsMaximized() behavior is not
910 // consistent with other platforms. crbug.com/603562 867 // consistent with other platforms. crbug.com/603562
911 #define MAYBE_DetachFromFullsizeWindow DISABLED_DetachFromFullsizeWindow 868 #define MAYBE_DetachFromFullsizeWindow DISABLED_DetachFromFullsizeWindow
912 #else 869 #else
913 #define MAYBE_DetachFromFullsizeWindow DetachFromFullsizeWindow 870 #define MAYBE_DetachFromFullsizeWindow DetachFromFullsizeWindow
914 #endif 871 #endif
915 // Tests that a tab can be dragged from a browser window that is resized to full 872 // Tests that a tab can be dragged from a browser window that is resized to full
916 // screen. 873 // screen.
917 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, 874 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
918 MAYBE_DetachFromFullsizeWindow) { 875 MAYBE_DetachFromFullsizeWindow) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 916
960 EXPECT_FALSE(GetIsDragged(browser())); 917 EXPECT_FALSE(GetIsDragged(browser()));
961 EXPECT_FALSE(GetIsDragged(new_browser)); 918 EXPECT_FALSE(GetIsDragged(new_browser));
962 // After this both windows should still be manageable. 919 // After this both windows should still be manageable.
963 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); 920 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow()));
964 EXPECT_TRUE( 921 EXPECT_TRUE(
965 IsWindowPositionManaged(new_browser->window()->GetNativeWindow())); 922 IsWindowPositionManaged(new_browser->window()->GetNativeWindow()));
966 923
967 // Only second window should be maximized. 924 // Only second window should be maximized.
968 EXPECT_FALSE(browser()->window()->IsMaximized()); 925 EXPECT_FALSE(browser()->window()->IsMaximized());
969 MaximizedBrowserWindowWaiter(new_browser->window()).Wait();
970 EXPECT_TRUE(new_browser->window()->IsMaximized()); 926 EXPECT_TRUE(new_browser->window()->IsMaximized());
971 927
972 // The tab strip should no longer have capture because the drag was ended and 928 // The tab strip should no longer have capture because the drag was ended and
973 // mouse/touch was released. 929 // mouse/touch was released.
974 EXPECT_FALSE(tab_strip->GetWidget()->HasCapture()); 930 EXPECT_FALSE(tab_strip->GetWidget()->HasCapture());
975 EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture()); 931 EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture());
976 } 932 }
977 933
978 #if defined(OS_MACOSX) 934 #if defined(OS_CHROMEOS) || defined(OS_LINUX) || defined(OS_MACOSX)
935 // TODO(sky,sad): Disabled as it fails due to resize locks with a real
936 // compositor. crbug.com/331924
979 // TODO(tapted,mblsha): Disabled as the Mac IsMaximized() behavior is not 937 // TODO(tapted,mblsha): Disabled as the Mac IsMaximized() behavior is not
980 // consistent with other platforms. crbug.com/603562 938 // consistent with other platforms. crbug.com/603562
981 #define MAYBE_DetachToOwnWindowFromMaximizedWindow \ 939 #define MAYBE_DetachToOwnWindowFromMaximizedWindow \
982 DISABLED_DetachToOwnWindowFromMaximizedWindow 940 DISABLED_DetachToOwnWindowFromMaximizedWindow
983 #else 941 #else
984 #define MAYBE_DetachToOwnWindowFromMaximizedWindow \ 942 #define MAYBE_DetachToOwnWindowFromMaximizedWindow \
985 DetachToOwnWindowFromMaximizedWindow 943 DetachToOwnWindowFromMaximizedWindow
986 #endif 944 #endif
987 // Drags from browser to a separate window and releases mouse. 945 // Drags from browser to a separate window and releases mouse.
988 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, 946 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
989 MAYBE_DetachToOwnWindowFromMaximizedWindow) { 947 MAYBE_DetachToOwnWindowFromMaximizedWindow) {
990 // Maximize the initial browser window. 948 // Maximize the initial browser window.
991 browser()->window()->Maximize(); 949 browser()->window()->Maximize();
992 MaximizedBrowserWindowWaiter(browser()->window()).Wait();
993 ASSERT_TRUE(browser()->window()->IsMaximized()); 950 ASSERT_TRUE(browser()->window()->IsMaximized());
994 951
995 // Add another tab. 952 // Add another tab.
996 AddTabAndResetBrowser(browser()); 953 AddTabAndResetBrowser(browser());
997 TabStrip* tab_strip = GetTabStripForBrowser(browser()); 954 TabStrip* tab_strip = GetTabStripForBrowser(browser());
998 955
999 // Move to the first tab and drag it enough so that it detaches. 956 // Move to the first tab and drag it enough so that it detaches.
1000 gfx::Point tab_0_center( 957 gfx::Point tab_0_center(
1001 GetCenterInScreenCoordinates(tab_strip->tab_at(0))); 958 GetCenterInScreenCoordinates(tab_strip->tab_at(0)));
1002 ASSERT_TRUE(PressInput(tab_0_center)); 959 ASSERT_TRUE(PressInput(tab_0_center));
(...skipping 23 matching lines...) Expand all
1026 EXPECT_TRUE(browser()->window()->IsMaximized()); 983 EXPECT_TRUE(browser()->window()->IsMaximized());
1027 984
1028 EXPECT_FALSE(GetIsDragged(browser())); 985 EXPECT_FALSE(GetIsDragged(browser()));
1029 EXPECT_FALSE(GetIsDragged(new_browser)); 986 EXPECT_FALSE(GetIsDragged(new_browser));
1030 // After this both windows should still be manageable. 987 // After this both windows should still be manageable.
1031 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow())); 988 EXPECT_TRUE(IsWindowPositionManaged(browser()->window()->GetNativeWindow()));
1032 EXPECT_TRUE(IsWindowPositionManaged( 989 EXPECT_TRUE(IsWindowPositionManaged(
1033 new_browser->window()->GetNativeWindow())); 990 new_browser->window()->GetNativeWindow()));
1034 991
1035 // The new window should be maximized. 992 // The new window should be maximized.
1036 MaximizedBrowserWindowWaiter(new_browser->window()).Wait();
1037 EXPECT_TRUE(new_browser->window()->IsMaximized()); 993 EXPECT_TRUE(new_browser->window()->IsMaximized());
1038 } 994 }
1039 995
1040 // Deletes a tab being dragged before the user moved enough to start a drag. 996 // Deletes a tab being dragged before the user moved enough to start a drag.
1041 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, 997 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
1042 DeleteBeforeStartedDragging) { 998 DeleteBeforeStartedDragging) {
1043 // Add another tab. 999 // Add another tab.
1044 AddTabAndResetBrowser(browser()); 1000 AddTabAndResetBrowser(browser());
1045 TabStrip* tab_strip = GetTabStripForBrowser(browser()); 1001 TabStrip* tab_strip = GetTabStripForBrowser(browser());
1046 1002
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after
2466 base::Bind(&DetachToDockedWindowNextStep, 2422 base::Bind(&DetachToDockedWindowNextStep,
2467 test, 2423 test,
2468 gfx::Point(target_point.x(), 1 + target_point.y()), 2424 gfx::Point(target_point.x(), 1 + target_point.y()),
2469 iteration - 1))); 2425 iteration - 1)));
2470 } 2426 }
2471 2427
2472 } // namespace 2428 } // namespace
2473 2429
2474 // Drags from browser to separate window, docks that window and releases mouse. 2430 // Drags from browser to separate window, docks that window and releases mouse.
2475 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, 2431 IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest,
2476 DetachToDockedWindowFromMaximizedWindow) { 2432 DISABLED_DetachToDockedWindowFromMaximizedWindow) {
2477 // Maximize the initial browser window. 2433 // Maximize the initial browser window.
2478 browser()->window()->Maximize(); 2434 browser()->window()->Maximize();
2479 ASSERT_TRUE(browser()->window()->IsMaximized()); 2435 ASSERT_TRUE(browser()->window()->IsMaximized());
2480 2436
2481 // Add another tab. 2437 // Add another tab.
2482 AddTabAndResetBrowser(browser()); 2438 AddTabAndResetBrowser(browser());
2483 TabStrip* tab_strip = GetTabStripForBrowser(browser()); 2439 TabStrip* tab_strip = GetTabStripForBrowser(browser());
2484 2440
2485 // Move to the first tab and drag it enough so that it detaches. 2441 // Move to the first tab and drag it enough so that it detaches.
2486 gfx::Point tab_0_center( 2442 gfx::Point tab_0_center(
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
2543 DetachToBrowserTabDragControllerTest, 2499 DetachToBrowserTabDragControllerTest,
2544 ::testing::Values("mouse", "touch")); 2500 ::testing::Values("mouse", "touch"));
2545 INSTANTIATE_TEST_CASE_P(TabDragging, 2501 INSTANTIATE_TEST_CASE_P(TabDragging,
2546 DetachToBrowserTabDragControllerTestTouch, 2502 DetachToBrowserTabDragControllerTestTouch,
2547 ::testing::Values("touch")); 2503 ::testing::Values("touch"));
2548 #else 2504 #else
2549 INSTANTIATE_TEST_CASE_P(TabDragging, 2505 INSTANTIATE_TEST_CASE_P(TabDragging,
2550 DetachToBrowserTabDragControllerTest, 2506 DetachToBrowserTabDragControllerTest,
2551 ::testing::Values("mouse")); 2507 ::testing::Values("mouse"));
2552 #endif 2508 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_drag_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698