Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 787 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 798 | 798 |
| 799 gfx::Rect fullscreen_bounds_after_activate = | 799 gfx::Rect fullscreen_bounds_after_activate = |
| 800 widget1.GetWindowBoundsInScreen(); | 800 widget1.GetWindowBoundsInScreen(); |
| 801 | 801 |
| 802 // After activation the bounds of the fullscreen widget should be restored. | 802 // After activation the bounds of the fullscreen widget should be restored. |
| 803 EXPECT_EQ(fullscreen_bounds, fullscreen_bounds_after_activate); | 803 EXPECT_EQ(fullscreen_bounds, fullscreen_bounds_after_activate); |
| 804 | 804 |
| 805 widget1.CloseNow(); | 805 widget1.CloseNow(); |
| 806 widget2.CloseNow(); | 806 widget2.CloseNow(); |
| 807 } | 807 } |
| 808 | |
| 809 // Ensure the window rect and client rects are correct with a window that was | |
| 810 // maximized. | |
| 811 TEST_F(WidgetTestInteractive, FullscreenMaximizedWindowBounds) { | |
| 812 Widget widget; | |
| 813 Widget::InitParams params = CreateParams(Widget::InitParams::TYPE_WINDOW); | |
| 814 params.native_widget = new DesktopNativeWidgetAura(&widget); | |
| 815 params.ownership = Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | |
| 816 widget.set_frame_type(Widget::FRAME_TYPE_FORCE_CUSTOM); | |
| 817 widget.Init(params); | |
| 818 widget.SetBounds(gfx::Rect(0, 0, 200, 200)); | |
| 819 widget.Show(); | |
| 820 | |
| 821 widget.Maximize(); | |
| 822 EXPECT_TRUE(widget.IsMaximized()); | |
| 823 | |
| 824 widget.SetFullscreen(true); | |
| 825 EXPECT_TRUE(widget.IsFullscreen()); | |
| 826 EXPECT_FALSE(widget.IsMaximized()); | |
| 827 // Ensure that the StopIgnoringPosChanges task in HWNDMessageHandler runs. | |
| 828 // This task is queued when a widget becomes fullscreen. | |
| 829 RunPendingMessages(); | |
| 830 | |
| 831 aura::WindowTreeHost* host = widget.GetNativeWindow()->GetHost(); | |
| 832 HWND hwnd = host->GetAcceleratedWidget(); | |
| 833 | |
| 834 HMONITOR monitor = ::MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST); | |
| 835 ASSERT_TRUE(!!monitor); | |
| 836 MONITORINFO monitor_info; | |
| 837 monitor_info.cbSize = sizeof(monitor_info); | |
| 838 ::GetMonitorInfo(monitor, &monitor_info); | |
|
sky
2016/04/12 13:34:02
ASSERT on return value?
| |
| 839 | |
| 840 gfx::Rect monitor_bounds(monitor_info.rcMonitor); | |
| 841 gfx::Rect window_bounds = widget.GetWindowBoundsInScreen(); | |
| 842 gfx::Rect client_area_bounds = host->GetBounds(); | |
| 843 | |
| 844 EXPECT_EQ(window_bounds, monitor_bounds); | |
| 845 EXPECT_EQ(monitor_bounds, client_area_bounds); | |
| 846 | |
| 847 // Setting not fullscreen should return it to maximized. | |
| 848 widget.SetFullscreen(false); | |
| 849 EXPECT_FALSE(widget.IsFullscreen()); | |
| 850 EXPECT_TRUE(widget.IsMaximized()); | |
| 851 | |
| 852 client_area_bounds = host->GetBounds(); | |
| 853 EXPECT_TRUE(monitor_bounds.Contains(client_area_bounds)); | |
| 854 EXPECT_NE(monitor_bounds, client_area_bounds); | |
| 855 | |
| 856 widget.CloseNow(); | |
| 857 } | |
| 808 #endif // defined(OS_WIN) | 858 #endif // defined(OS_WIN) |
| 809 | 859 |
| 810 #if !defined(OS_CHROMEOS) | 860 #if !defined(OS_CHROMEOS) |
| 811 // Provides functionality to create a window modal dialog. | 861 // Provides functionality to create a window modal dialog. |
| 812 class ModalDialogDelegate : public DialogDelegateView { | 862 class ModalDialogDelegate : public DialogDelegateView { |
| 813 public: | 863 public: |
| 814 explicit ModalDialogDelegate(ui::ModalType type) : type_(type) {} | 864 explicit ModalDialogDelegate(ui::ModalType type) : type_(type) {} |
| 815 ~ModalDialogDelegate() override {} | 865 ~ModalDialogDelegate() override {} |
| 816 | 866 |
| 817 // WidgetDelegate overrides. | 867 // WidgetDelegate overrides. |
| (...skipping 889 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1707 | 1757 |
| 1708 ui::KeyEvent key_event2(key_event); | 1758 ui::KeyEvent key_event2(key_event); |
| 1709 widget->OnKeyEvent(&key_event2); | 1759 widget->OnKeyEvent(&key_event2); |
| 1710 EXPECT_FALSE(key_event2.stopped_propagation()); | 1760 EXPECT_FALSE(key_event2.stopped_propagation()); |
| 1711 | 1761 |
| 1712 widget->CloseNow(); | 1762 widget->CloseNow(); |
| 1713 } | 1763 } |
| 1714 | 1764 |
| 1715 } // namespace test | 1765 } // namespace test |
| 1716 } // namespace views | 1766 } // namespace views |
| OLD | NEW |