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

Side by Side Diff: ui/views/widget/widget_interactive_uitest.cc

Issue 1859283003: Avoid restoring maximized window down when going fullscreen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months 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 | « no previous file | ui/views/win/fullscreen_handler.h » ('j') | 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 835
836 gfx::Rect fullscreen_bounds_after_activate = 836 gfx::Rect fullscreen_bounds_after_activate =
837 widget1.GetWindowBoundsInScreen(); 837 widget1.GetWindowBoundsInScreen();
838 838
839 // After activation the bounds of the fullscreen widget should be restored. 839 // After activation the bounds of the fullscreen widget should be restored.
840 EXPECT_EQ(fullscreen_bounds, fullscreen_bounds_after_activate); 840 EXPECT_EQ(fullscreen_bounds, fullscreen_bounds_after_activate);
841 841
842 widget1.CloseNow(); 842 widget1.CloseNow();
843 widget2.CloseNow(); 843 widget2.CloseNow();
844 } 844 }
845
846 // Ensure the window rect and client rects are correct with a window that was
847 // maximized.
848 TEST_F(WidgetTestInteractive, FullscreenMaximizedWindowBounds) {
849 Widget widget;
850 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW);
851 params.native_widget = new DesktopNativeWidgetAura(&widget);
852 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET;
853 widget.set_frame_type(Widget::FRAME_TYPE_FORCE_CUSTOM);
854 widget.Init(params);
855 widget.SetBounds(gfx::Rect(0, 0, 200, 200));
856 widget.Show();
857
858 widget.Maximize();
859 EXPECT_TRUE(widget.IsMaximized());
860
861 widget.SetFullscreen(true);
862 EXPECT_TRUE(widget.IsFullscreen());
863 EXPECT_FALSE(widget.IsMaximized());
864 // Ensure that the StopIgnoringPosChanges task in HWNDMessageHandler runs.
865 // This task is queued when a widget becomes fullscreen.
866 RunPendingMessages();
867
868 aura::WindowTreeHost* host = widget.GetNativeWindow()->GetHost();
869 HWND hwnd = host->GetAcceleratedWidget();
870
871 HMONITOR monitor = ::MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
872 ASSERT_TRUE(!!monitor);
873 MONITORINFO monitor_info;
874 monitor_info.cbSize = sizeof(monitor_info);
875 ASSERT_TRUE(::GetMonitorInfo(monitor, &monitor_info));
876
877 gfx::Rect monitor_bounds(monitor_info.rcMonitor);
878 gfx::Rect window_bounds = widget.GetWindowBoundsInScreen();
879 gfx::Rect client_area_bounds = host->GetBounds();
880
881 EXPECT_EQ(window_bounds, monitor_bounds);
882 EXPECT_EQ(monitor_bounds, client_area_bounds);
883
884 // Setting not fullscreen should return it to maximized.
885 widget.SetFullscreen(false);
886 EXPECT_FALSE(widget.IsFullscreen());
887 EXPECT_TRUE(widget.IsMaximized());
888
889 client_area_bounds = host->GetBounds();
890 EXPECT_TRUE(monitor_bounds.Contains(client_area_bounds));
891 EXPECT_NE(monitor_bounds, client_area_bounds);
892
893 widget.CloseNow();
894 }
845 #endif // defined(OS_WIN) 895 #endif // defined(OS_WIN)
846 896
847 #if !defined(OS_CHROMEOS) 897 #if !defined(OS_CHROMEOS)
848 // Provides functionality to create a window modal dialog. 898 // Provides functionality to create a window modal dialog.
849 class ModalDialogDelegate : public DialogDelegateView { 899 class ModalDialogDelegate : public DialogDelegateView {
850 public: 900 public:
851 explicit ModalDialogDelegate(ui::ModalType type) : type_(type) {} 901 explicit ModalDialogDelegate(ui::ModalType type) : type_(type) {}
852 ~ModalDialogDelegate() override {} 902 ~ModalDialogDelegate() override {}
853 903
854 // WidgetDelegate overrides. 904 // WidgetDelegate overrides.
(...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 1794
1745 ui::KeyEvent key_event2(key_event); 1795 ui::KeyEvent key_event2(key_event);
1746 widget->OnKeyEvent(&key_event2); 1796 widget->OnKeyEvent(&key_event2);
1747 EXPECT_FALSE(key_event2.stopped_propagation()); 1797 EXPECT_FALSE(key_event2.stopped_propagation());
1748 1798
1749 widget->CloseNow(); 1799 widget->CloseNow();
1750 } 1800 }
1751 1801
1752 } // namespace test 1802 } // namespace test
1753 } // namespace views 1803 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | ui/views/win/fullscreen_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698