Chromium Code Reviews| Index: chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc |
| diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc |
| index 10d80815a0cfdcafb4aebf88a3522c4285ead267..0ad10041b43391843787936645eed8dc795f2cf0 100644 |
| --- a/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc |
| +++ b/chrome/browser/ui/views/tabs/tab_drag_controller_interactive_uitest.cc |
| @@ -9,7 +9,9 @@ |
| #include <algorithm> |
| #include "base/bind.h" |
| +#include "base/bind_helpers.h" |
| #include "base/callback.h" |
| +#include "base/callback_helpers.h" |
| #include "base/command_line.h" |
| #include "base/location.h" |
| #include "base/macros.h" |
| @@ -796,18 +798,55 @@ bool HasUserChangedWindowPositionOrSize(gfx::NativeWindow window) { |
| } |
| #endif |
| +// Encapsulates waiting for the browser window to become maximized. This is |
| +// needed for example on Chrome desktop linux, where window maximization is done |
| +// asynchronously as an event received from a different process. |
| +class MaximizedBrowserWindowWaiter { |
| + public: |
| + explicit MaximizedBrowserWindowWaiter(BrowserWindow* window) |
| + : window_(window) {} |
| + ~MaximizedBrowserWindowWaiter() = default; |
| + |
| + // Blocks until the browser window becomes maximized. |
| + void Wait() { |
| + if (CheckMaximized()) |
| + return; |
| + |
| + base::RunLoop run_loop; |
| + quit_ = run_loop.QuitClosure(); |
| + run_loop.Run(); |
| + } |
| + |
| + private: |
| + bool CheckMaximized() { |
| + if (!window_->IsMaximized()) { |
| + base::MessageLoop::current()->task_runner()->PostTask( |
|
sky
2016/11/28 21:31:50
It's generally preferable to install a listener th
afakhry
2016/11/28 22:54:25
Yes, that's the first thing I tried. I wasn't howe
|
| + FROM_HERE, base::Bind( |
| + base::IgnoreResult(&MaximizedBrowserWindowWaiter::CheckMaximized), |
| + base::Unretained(this))); |
| + return false; |
| + } |
| + |
| + // Quit the run_loop to end the wait. |
| + if (!quit_.is_null()) |
| + base::ResetAndReturn(&quit_).Run(); |
| + return true; |
| + } |
| + |
| + // The browser window observed by this waiter. |
| + BrowserWindow* window_; |
| + |
| + // The waiter's RunLoop quit closure. |
| + base::Closure quit_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(MaximizedBrowserWindowWaiter); |
| +}; |
| + |
| } // namespace |
| -#if defined(OS_CHROMEOS) || defined(OS_LINUX) |
| -// TODO(sky,sad): Disabled as it fails due to resize locks with a real |
| -// compositor. crbug.com/331924 |
| -#define MAYBE_DetachToOwnWindow DISABLED_DetachToOwnWindow |
| -#else |
| -#define MAYBE_DetachToOwnWindow DetachToOwnWindow |
| -#endif |
| // Drags from browser to separate window and releases mouse. |
| IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| - MAYBE_DetachToOwnWindow) { |
| + DetachToOwnWindow) { |
| const gfx::Rect initial_bounds(browser()->window()->GetBounds()); |
| // Add another tab. |
| AddTabAndResetBrowser(browser()); |
| @@ -860,9 +899,13 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture()); |
| } |
| -#if defined(OS_CHROMEOS) || defined(OS_LINUX) || defined(OS_MACOSX) |
| -// TODO(sky,sad): Disabled as it fails due to resize locks with a real |
| -// compositor. crbug.com/331924 |
| +#if defined(OS_LINUX) || defined(OS_MACOSX) |
| +// TODO(afakhry,varkha): Disabled on Linux as it fails on the bot because |
| +// setting the window bounds to the work area bounds in |
| +// DesktopWindowTreeHostX11::SetBounds() always insets it by one pixel in both |
| +// width and height. This results in considering the source browser window not |
| +// being full size, and the test is not as expected. |
| +// crbug.com/626761, crbug.com/331924. |
| // TODO(tapted,mblsha): Disabled as the Mac IsMaximized() behavior is not |
| // consistent with other platforms. crbug.com/603562 |
| #define MAYBE_DetachFromFullsizeWindow DISABLED_DetachFromFullsizeWindow |
| @@ -923,6 +966,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| // Only second window should be maximized. |
| EXPECT_FALSE(browser()->window()->IsMaximized()); |
| + MaximizedBrowserWindowWaiter(new_browser->window()).Wait(); |
| EXPECT_TRUE(new_browser->window()->IsMaximized()); |
| // The tab strip should no longer have capture because the drag was ended and |
| @@ -931,9 +975,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| EXPECT_FALSE(tab_strip2->GetWidget()->HasCapture()); |
| } |
| -#if defined(OS_CHROMEOS) || defined(OS_LINUX) || defined(OS_MACOSX) |
| -// TODO(sky,sad): Disabled as it fails due to resize locks with a real |
| -// compositor. crbug.com/331924 |
| +#if defined(OS_MACOSX) |
| // TODO(tapted,mblsha): Disabled as the Mac IsMaximized() behavior is not |
| // consistent with other platforms. crbug.com/603562 |
| #define MAYBE_DetachToOwnWindowFromMaximizedWindow \ |
| @@ -947,6 +989,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| MAYBE_DetachToOwnWindowFromMaximizedWindow) { |
| // Maximize the initial browser window. |
| browser()->window()->Maximize(); |
| + MaximizedBrowserWindowWaiter(browser()->window()).Wait(); |
| ASSERT_TRUE(browser()->window()->IsMaximized()); |
| // Add another tab. |
| @@ -990,6 +1033,7 @@ IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| new_browser->window()->GetNativeWindow())); |
| // The new window should be maximized. |
| + MaximizedBrowserWindowWaiter(new_browser->window()).Wait(); |
| EXPECT_TRUE(new_browser->window()->IsMaximized()); |
| } |
| @@ -2429,7 +2473,7 @@ void DetachToDockedWindowNextStep( |
| // Drags from browser to separate window, docks that window and releases mouse. |
| IN_PROC_BROWSER_TEST_P(DetachToBrowserTabDragControllerTest, |
| - DISABLED_DetachToDockedWindowFromMaximizedWindow) { |
| + DetachToDockedWindowFromMaximizedWindow) { |
| // Maximize the initial browser window. |
| browser()->window()->Maximize(); |
| ASSERT_TRUE(browser()->window()->IsMaximized()); |