| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" | 5 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "ash/aura/wm_window_aura.h" | 9 #include "ash/aura/wm_window_aura.h" |
| 10 #include "ash/common/shelf/shelf.h" | 10 #include "ash/common/shelf/wm_shelf.h" |
| 11 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 11 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
| 12 #include "ash/common/wm/mru_window_tracker.h" | 12 #include "ash/common/wm/mru_window_tracker.h" |
| 13 #include "ash/common/wm/overview/window_selector_controller.h" | 13 #include "ash/common/wm/overview/window_selector_controller.h" |
| 14 #include "ash/common/wm/switchable_windows.h" | 14 #include "ash/common/wm/switchable_windows.h" |
| 15 #include "ash/common/wm/window_state.h" | 15 #include "ash/common/wm/window_state.h" |
| 16 #include "ash/common/wm/window_state_observer.h" | 16 #include "ash/common/wm/window_state_observer.h" |
| 17 #include "ash/common/wm/wm_event.h" | 17 #include "ash/common/wm/wm_event.h" |
| 18 #include "ash/common/wm_shell.h" | 18 #include "ash/common/wm_shell.h" |
| 19 #include "ash/root_window_controller.h" | 19 #include "ash/root_window_controller.h" |
| 20 #include "ash/screen_util.h" | 20 #include "ash/screen_util.h" |
| 21 #include "ash/shell.h" | 21 #include "ash/shell.h" |
| 22 #include "ash/test/ash_test_base.h" | 22 #include "ash/test/ash_test_base.h" |
| 23 #include "ash/test/shell_test_api.h" | 23 #include "ash/test/shell_test_api.h" |
| 24 #include "ash/wm/window_properties.h" | 24 #include "ash/wm/window_properties.h" |
| 25 #include "ash/wm/window_state_aura.h" | 25 #include "ash/wm/window_state_aura.h" |
| 26 #include "ash/wm/window_util.h" | 26 #include "ash/wm/window_util.h" |
| 27 #include "base/strings/stringprintf.h" | 27 #include "base/strings/stringprintf.h" |
| 28 #include "base/strings/utf_string_conversions.h" | 28 #include "base/strings/utf_string_conversions.h" |
| 29 #include "base/values.h" | 29 #include "base/values.h" |
| 30 #include "ui/aura/client/aura_constants.h" | 30 #include "ui/aura/client/aura_constants.h" |
| 31 #include "ui/aura/test/test_window_delegate.h" | 31 #include "ui/aura/test/test_window_delegate.h" |
| 32 #include "ui/aura/test/test_windows.h" | 32 #include "ui/aura/test/test_windows.h" |
| 33 #include "ui/aura/window.h" | 33 #include "ui/aura/window.h" |
| 34 #include "ui/base/hit_test.h" | 34 #include "ui/base/hit_test.h" |
| 35 #include "ui/events/test/event_generator.h" | 35 #include "ui/events/test/event_generator.h" |
| 36 #include "ui/views/widget/widget.h" |
| 36 | 37 |
| 37 namespace ash { | 38 namespace ash { |
| 38 | 39 |
| 39 class MaximizeModeWindowManagerTest : public test::AshTestBase { | 40 class MaximizeModeWindowManagerTest : public test::AshTestBase { |
| 40 public: | 41 public: |
| 41 MaximizeModeWindowManagerTest() {} | 42 MaximizeModeWindowManagerTest() {} |
| 42 ~MaximizeModeWindowManagerTest() override {} | 43 ~MaximizeModeWindowManagerTest() override {} |
| 43 | 44 |
| 44 // Creates a window which has a fixed size. | 45 // Creates a window which has a fixed size. |
| 45 aura::Window* CreateFixedSizeNonMaximizableWindow(ui::wm::WindowType type, | 46 aura::Window* CreateFixedSizeNonMaximizableWindow(ui::wm::WindowType type, |
| (...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 853 | 854 |
| 854 // Check that a full screen window remains full screen upon entering maximize | 855 // Check that a full screen window remains full screen upon entering maximize |
| 855 // mode. Furthermore, checks that this window is not full screen upon exiting | 856 // mode. Furthermore, checks that this window is not full screen upon exiting |
| 856 // maximize mode if it was un-full-screened while in maximize mode. | 857 // maximize mode if it was un-full-screened while in maximize mode. |
| 857 TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) { | 858 TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) { |
| 858 gfx::Rect rect(20, 140, 100, 100); | 859 gfx::Rect rect(20, 140, 100, 100); |
| 859 std::unique_ptr<aura::Window> w1( | 860 std::unique_ptr<aura::Window> w1( |
| 860 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 861 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 861 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 862 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
| 862 | 863 |
| 863 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 864 WmShelf* shelf = GetPrimaryShelf(); |
| 864 | 865 |
| 865 // Allow the shelf to hide. | 866 // Allow the shelf to hide. |
| 866 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 867 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 867 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 868 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 868 | 869 |
| 869 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 870 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 870 window_state->OnWMEvent(&event); | 871 window_state->OnWMEvent(&event); |
| 871 | 872 |
| 872 // With full screen, the shelf should get hidden. | 873 // With full screen, the shelf should get hidden. |
| 873 EXPECT_TRUE(window_state->IsFullscreen()); | 874 EXPECT_TRUE(window_state->IsFullscreen()); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1048 | 1049 |
| 1049 // Verifies that if a window is un-full-screened while in maximize mode, | 1050 // Verifies that if a window is un-full-screened while in maximize mode, |
| 1050 // other changes to that window's state (such as minimizing it) are | 1051 // other changes to that window's state (such as minimizing it) are |
| 1051 // preserved upon exiting maximize mode. | 1052 // preserved upon exiting maximize mode. |
| 1052 TEST_F(MaximizeModeWindowManagerTest, MinimizePreservedAfterLeavingFullscreen) { | 1053 TEST_F(MaximizeModeWindowManagerTest, MinimizePreservedAfterLeavingFullscreen) { |
| 1053 gfx::Rect rect(20, 140, 100, 100); | 1054 gfx::Rect rect(20, 140, 100, 100); |
| 1054 std::unique_ptr<aura::Window> w1( | 1055 std::unique_ptr<aura::Window> w1( |
| 1055 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 1056 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 1056 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 1057 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
| 1057 | 1058 |
| 1058 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 1059 WmShelf* shelf = GetPrimaryShelf(); |
| 1059 | 1060 |
| 1060 // Allow the shelf to hide and enter full screen. | 1061 // Allow the shelf to hide and enter full screen. |
| 1061 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1062 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1062 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 1063 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 1063 window_state->OnWMEvent(&event); | 1064 window_state->OnWMEvent(&event); |
| 1064 ASSERT_FALSE(window_state->IsMinimized()); | 1065 ASSERT_FALSE(window_state->IsMinimized()); |
| 1065 | 1066 |
| 1066 // Enter maximize mode, exit full screen, and then minimize the window. | 1067 // Enter maximize mode, exit full screen, and then minimize the window. |
| 1067 CreateMaximizeModeWindowManager(); | 1068 CreateMaximizeModeWindowManager(); |
| 1068 window_state->OnWMEvent(&event); | 1069 window_state->OnWMEvent(&event); |
| 1069 window_state->Minimize(); | 1070 window_state->Minimize(); |
| 1070 ASSERT_TRUE(window_state->IsMinimized()); | 1071 ASSERT_TRUE(window_state->IsMinimized()); |
| 1071 | 1072 |
| 1072 // The window should remain minimized when exiting maximize mode. | 1073 // The window should remain minimized when exiting maximize mode. |
| 1073 DestroyMaximizeModeWindowManager(); | 1074 DestroyMaximizeModeWindowManager(); |
| 1074 EXPECT_TRUE(window_state->IsMinimized()); | 1075 EXPECT_TRUE(window_state->IsMinimized()); |
| 1075 } | 1076 } |
| 1076 | 1077 |
| 1077 // Check that full screen mode can be turned on in maximized mode and remains | 1078 // Check that full screen mode can be turned on in maximized mode and remains |
| 1078 // upon coming back. | 1079 // upon coming back. |
| 1079 TEST_F(MaximizeModeWindowManagerTest, AllowFullScreenMode) { | 1080 TEST_F(MaximizeModeWindowManagerTest, AllowFullScreenMode) { |
| 1080 gfx::Rect rect(20, 140, 100, 100); | 1081 gfx::Rect rect(20, 140, 100, 100); |
| 1081 std::unique_ptr<aura::Window> w1( | 1082 std::unique_ptr<aura::Window> w1( |
| 1082 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 1083 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 1083 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 1084 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
| 1084 | 1085 |
| 1085 Shelf* shelf = Shelf::ForPrimaryDisplay(); | 1086 WmShelf* shelf = GetPrimaryShelf(); |
| 1086 | 1087 |
| 1087 // Allow the shelf to hide. | 1088 // Allow the shelf to hide. |
| 1088 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 1089 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 1089 | 1090 |
| 1090 EXPECT_FALSE(window_state->IsFullscreen()); | 1091 EXPECT_FALSE(window_state->IsFullscreen()); |
| 1091 EXPECT_FALSE(window_state->IsMaximized()); | 1092 EXPECT_FALSE(window_state->IsMaximized()); |
| 1092 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); | 1093 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); |
| 1093 | 1094 |
| 1094 CreateMaximizeModeWindowManager(); | 1095 CreateMaximizeModeWindowManager(); |
| 1095 | 1096 |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1693 EXPECT_EQ(1, observer.GetPostCountAndReset()); | 1694 EXPECT_EQ(1, observer.GetPostCountAndReset()); |
| 1694 EXPECT_EQ(wm::WINDOW_STATE_TYPE_MINIMIZED, | 1695 EXPECT_EQ(wm::WINDOW_STATE_TYPE_MINIMIZED, |
| 1695 observer.GetLastOldStateAndReset()); | 1696 observer.GetLastOldStateAndReset()); |
| 1696 | 1697 |
| 1697 window_state->RemoveObserver(&observer); | 1698 window_state->RemoveObserver(&observer); |
| 1698 | 1699 |
| 1699 DestroyMaximizeModeWindowManager(); | 1700 DestroyMaximizeModeWindowManager(); |
| 1700 } | 1701 } |
| 1701 | 1702 |
| 1702 } // namespace ash | 1703 } // namespace ash |
| OLD | NEW |