Index: ui/views/widget/widget_unittest.cc |
diff --git a/ui/views/widget/widget_unittest.cc b/ui/views/widget/widget_unittest.cc |
index 1ca9e88b8737a441cb7da5cd4fa9e88e7bfcad7c..a677ee7184ff9a024d3aea8f00b93c22a30d424c 100644 |
--- a/ui/views/widget/widget_unittest.cc |
+++ b/ui/views/widget/widget_unittest.cc |
@@ -3391,6 +3391,56 @@ TEST_F(WidgetTest, DestroyInSysCommandNCLButtonDownOnCaption) { |
widget.CloseNow(); |
} |
+// On Windows if we create a fullscreen window on a thread, then it affects the |
+// way other windows on the thread interact with the taskbar. To workaround |
+// this we reduce the bounds of a fullscreen window by 1px when it loses |
+// activation. This test verifies the same. |
+TEST_F(WidgetTest, FullscreenBoundsReducedOnActivationLoss) { |
+ Widget widget1; |
+ Widget::InitParams params = |
+ CreateParams(Widget::InitParams::TYPE_WINDOW); |
+ params.native_widget = new PlatformDesktopNativeWidget(&widget1); |
+ params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
+ widget1.Init(params); |
+ widget1.SetBounds(gfx::Rect(0, 0, 200, 200)); |
+ widget1.Show(); |
+ |
+ Widget widget2; |
+ params.native_widget = new PlatformDesktopNativeWidget(&widget2); |
+ params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
+ widget2.Init(params); |
+ widget2.SetBounds(gfx::Rect(0, 0, 200, 200)); |
+ widget2.Show(); |
+ |
+ widget1.SetFullscreen(true); |
+ EXPECT_TRUE(widget1.IsFullscreen()); |
+ // Ensure that the StopIgnoringPosChanges task in HWNDMessageHandler runs. |
+ // This task is queued when a widget becomes fullscreen. |
+ RunPendingMessages(); |
+ |
+ gfx::Rect fullscreen_bounds = widget1.GetWindowBoundsInScreen(); |
+ |
+ widget2.Activate(); |
+ |
+ gfx::Rect fullscreen_bounds_after_activation_loss = |
+ widget1.GetWindowBoundsInScreen(); |
+ |
+ // After deactivation loss the bounds of the fullscreen widget should be |
+ // reduced by 1px. |
+ EXPECT_EQ(fullscreen_bounds.height() - |
+ fullscreen_bounds_after_activation_loss.height(), 1); |
+ |
+ widget1.Activate(); |
+ |
+ gfx::Rect fullscreen_bounds_after_activate = |
+ widget1.GetWindowBoundsInScreen(); |
+ |
+ // After activation the bounds of the fullscreen widget should be restored. |
+ EXPECT_EQ(fullscreen_bounds, fullscreen_bounds_after_activate); |
+ |
+ widget1.CloseNow(); |
+ widget2.CloseNow(); |
+} |
#endif |
// Test that SetAlwaysOnTop and IsAlwaysOnTop are consistent. |