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

Side by Side Diff: ash/wm/maximize_mode/maximize_mode_window_manager_unittest.cc

Issue 308683002: Move MaximizeModeWindowManager to the controller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 6 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
OLDNEW
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/wm/maximize_mode/maximize_mode_window_manager.h" 5 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h"
6 6
7 #include <string>
8
7 #include "ash/root_window_controller.h" 9 #include "ash/root_window_controller.h"
8 #include "ash/screen_util.h" 10 #include "ash/screen_util.h"
9 #include "ash/shelf/shelf_layout_manager.h" 11 #include "ash/shelf/shelf_layout_manager.h"
10 #include "ash/shell.h" 12 #include "ash/shell.h"
11 #include "ash/switchable_windows.h" 13 #include "ash/switchable_windows.h"
12 #include "ash/test/ash_test_base.h" 14 #include "ash/test/ash_test_base.h"
13 #include "ash/test/shell_test_api.h" 15 #include "ash/test/shell_test_api.h"
16 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
14 #include "ash/wm/mru_window_tracker.h" 17 #include "ash/wm/mru_window_tracker.h"
15 #include "ash/wm/overview/window_selector_controller.h" 18 #include "ash/wm/overview/window_selector_controller.h"
16 #include "ash/wm/window_properties.h" 19 #include "ash/wm/window_properties.h"
17 #include "ash/wm/window_state.h" 20 #include "ash/wm/window_state.h"
18 #include "ash/wm/window_util.h" 21 #include "ash/wm/window_util.h"
19 #include "ash/wm/wm_event.h" 22 #include "ash/wm/wm_event.h"
20 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
22 #include "base/values.h" 25 #include "base/values.h"
23 #include "ui/aura/client/aura_constants.h" 26 #include "ui/aura/client/aura_constants.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 aura::Window* window = widget->GetNativeWindow(); 75 aura::Window* window = widget->GetNativeWindow();
73 window->SetBounds(bounds); 76 window->SetBounds(bounds);
74 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 77 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
75 78
76 return window; 79 return window;
77 } 80 }
78 81
79 // Create the Maximized mode window manager. 82 // Create the Maximized mode window manager.
80 ash::MaximizeModeWindowManager* CreateMaximizeModeWindowManager() { 83 ash::MaximizeModeWindowManager* CreateMaximizeModeWindowManager() {
81 EXPECT_FALSE(maximize_mode_window_manager()); 84 EXPECT_FALSE(maximize_mode_window_manager());
82 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); 85 Shell::GetInstance()->maximize_mode_controller()->
86 EnableMaximizeModeWindowManager(true);
83 return maximize_mode_window_manager(); 87 return maximize_mode_window_manager();
84 } 88 }
85 89
86 // Destroy the maximized mode window manager. 90 // Destroy the maximized mode window manager.
87 void DestroyMaximizeModeWindowManager() { 91 void DestroyMaximizeModeWindowManager() {
88 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); 92 Shell::GetInstance()->maximize_mode_controller()->
93 EnableMaximizeModeWindowManager(false);
89 EXPECT_FALSE(maximize_mode_window_manager()); 94 EXPECT_FALSE(maximize_mode_window_manager());
90 } 95 }
91 96
92 // Get the maximze window manager. 97 // Get the maximze window manager.
93 ash::MaximizeModeWindowManager* maximize_mode_window_manager() { 98 ash::MaximizeModeWindowManager* maximize_mode_window_manager() {
94 test::ShellTestApi test_api(Shell::GetInstance()); 99 return Shell::GetInstance()->maximize_mode_controller()->
95 return test_api.maximize_mode_window_manager(); 100 maximize_mode_window_manager_.get();
96 } 101 }
97 102
98 // Resize our desktop. 103 // Resize our desktop.
99 void ResizeDesktop(int width_delta) { 104 void ResizeDesktop(int width_delta) {
100 gfx::Size size = Shell::GetScreen()->GetDisplayNearestWindow( 105 gfx::Size size = Shell::GetScreen()->GetDisplayNearestWindow(
101 Shell::GetPrimaryRootWindow()).size(); 106 Shell::GetPrimaryRootWindow()).size();
102 size.Enlarge(0, width_delta); 107 size.Enlarge(0, width_delta);
103 UpdateDisplay(size.ToString()); 108 UpdateDisplay(size.ToString());
104 } 109 }
105 110
(...skipping 622 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 DestroyMaximizeModeWindowManager(); 733 DestroyMaximizeModeWindowManager();
729 } 734 }
730 735
731 // Check that minimize and restore do the right thing. 736 // Check that minimize and restore do the right thing.
732 TEST_F(MaximizeModeWindowManagerTest, TestMinimize) { 737 TEST_F(MaximizeModeWindowManagerTest, TestMinimize) {
733 gfx::Rect rect(10, 10, 100, 100); 738 gfx::Rect rect(10, 10, 100, 100);
734 scoped_ptr<aura::Window> window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, 739 scoped_ptr<aura::Window> window(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL,
735 rect)); 740 rect));
736 wm::WindowState* window_state = wm::GetWindowState(window.get()); 741 wm::WindowState* window_state = wm::GetWindowState(window.get());
737 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); 742 EXPECT_EQ(rect.ToString(), window->bounds().ToString());
738 ash::Shell::GetInstance()->EnableMaximizeModeWindowManager(true); 743 ash::Shell::GetInstance()->maximize_mode_controller()->
744 EnableMaximizeModeWindowManager(true);
739 EXPECT_TRUE(window_state->IsMaximized()); 745 EXPECT_TRUE(window_state->IsMaximized());
740 EXPECT_FALSE(window_state->IsMinimized()); 746 EXPECT_FALSE(window_state->IsMinimized());
741 EXPECT_TRUE(window->IsVisible()); 747 EXPECT_TRUE(window->IsVisible());
742 748
743 window_state->Minimize(); 749 window_state->Minimize();
744 EXPECT_FALSE(window_state->IsMaximized()); 750 EXPECT_FALSE(window_state->IsMaximized());
745 EXPECT_TRUE(window_state->IsMinimized()); 751 EXPECT_TRUE(window_state->IsMinimized());
746 EXPECT_FALSE(window->IsVisible()); 752 EXPECT_FALSE(window->IsVisible());
747 753
748 window_state->Maximize(); 754 window_state->Maximize();
749 EXPECT_TRUE(window_state->IsMaximized()); 755 EXPECT_TRUE(window_state->IsMaximized());
750 EXPECT_FALSE(window_state->IsMinimized()); 756 EXPECT_FALSE(window_state->IsMinimized());
751 EXPECT_TRUE(window->IsVisible()); 757 EXPECT_TRUE(window->IsVisible());
752 758
753 ash::Shell::GetInstance()->EnableMaximizeModeWindowManager(false); 759 ash::Shell::GetInstance()->maximize_mode_controller()->
760 EnableMaximizeModeWindowManager(false);
754 EXPECT_FALSE(window_state->IsMaximized()); 761 EXPECT_FALSE(window_state->IsMaximized());
755 EXPECT_FALSE(window_state->IsMinimized()); 762 EXPECT_FALSE(window_state->IsMinimized());
756 EXPECT_TRUE(window->IsVisible()); 763 EXPECT_TRUE(window->IsVisible());
757 } 764 }
758 765
759 // Check that a full screen window is staying full screen in maximize mode, 766 // Check that a full screen window is staying full screen in maximize mode,
760 // and that it returns to full screen thereafter (if left). 767 // and that it returns to full screen thereafter (if left).
761 TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) { 768 TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) {
762 gfx::Rect rect(20, 140, 100, 100); 769 gfx::Rect rect(20, 140, 100, 100);
763 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 770 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
943 generator.PressLeftButton(); 950 generator.PressLeftButton();
944 generator.MoveMouseBy(10, 5); 951 generator.MoveMouseBy(10, 5);
945 RunAllPendingInMessageLoop(); 952 RunAllPendingInMessageLoop();
946 generator.ReleaseLeftButton(); 953 generator.ReleaseLeftButton();
947 gfx::Point first_dragged_origin = window->bounds().origin(); 954 gfx::Point first_dragged_origin = window->bounds().origin();
948 EXPECT_EQ(rect.x() + 10, first_dragged_origin.x()); 955 EXPECT_EQ(rect.x() + 10, first_dragged_origin.x());
949 EXPECT_EQ(rect.y() + 5, first_dragged_origin.y()); 956 EXPECT_EQ(rect.y() + 5, first_dragged_origin.y());
950 957
951 // 2. Check that turning on the manager will stop allowing the window from 958 // 2. Check that turning on the manager will stop allowing the window from
952 // dragging. 959 // dragging.
953 ash::Shell::GetInstance()->EnableMaximizeModeWindowManager(true); 960 ash::Shell::GetInstance()->maximize_mode_controller()->
961 EnableMaximizeModeWindowManager(true);
954 gfx::Rect center_bounds(window->bounds()); 962 gfx::Rect center_bounds(window->bounds());
955 EXPECT_NE(rect.origin().ToString(), center_bounds.origin().ToString()); 963 EXPECT_NE(rect.origin().ToString(), center_bounds.origin().ToString());
956 generator.MoveMouseTo(gfx::Point(center_bounds.x() + 1, 964 generator.MoveMouseTo(gfx::Point(center_bounds.x() + 1,
957 center_bounds.y() + 1)); 965 center_bounds.y() + 1));
958 generator.PressLeftButton(); 966 generator.PressLeftButton();
959 generator.MoveMouseBy(10, 5); 967 generator.MoveMouseBy(10, 5);
960 RunAllPendingInMessageLoop(); 968 RunAllPendingInMessageLoop();
961 generator.ReleaseLeftButton(); 969 generator.ReleaseLeftButton();
962 EXPECT_EQ(center_bounds.x(), window->bounds().x()); 970 EXPECT_EQ(center_bounds.x(), window->bounds().x());
963 EXPECT_EQ(center_bounds.y(), window->bounds().y()); 971 EXPECT_EQ(center_bounds.y(), window->bounds().y());
964 ash::Shell::GetInstance()->EnableMaximizeModeWindowManager(false); 972 ash::Shell::GetInstance()->maximize_mode_controller()->
973 EnableMaximizeModeWindowManager(false);
965 974
966 // 3. Releasing the mazimize manager again will restore the window to its 975 // 3. Releasing the mazimize manager again will restore the window to its
967 // previous bounds and 976 // previous bounds and
968 generator.MoveMouseTo(gfx::Point(first_dragged_origin.x() + 1, 977 generator.MoveMouseTo(gfx::Point(first_dragged_origin.x() + 1,
969 first_dragged_origin.y() + 1)); 978 first_dragged_origin.y() + 1));
970 generator.PressLeftButton(); 979 generator.PressLeftButton();
971 generator.MoveMouseBy(10, 5); 980 generator.MoveMouseBy(10, 5);
972 RunAllPendingInMessageLoop(); 981 RunAllPendingInMessageLoop();
973 generator.ReleaseLeftButton(); 982 generator.ReleaseLeftButton();
974 EXPECT_EQ(first_dragged_origin.x() + 10, window->bounds().x()); 983 EXPECT_EQ(first_dragged_origin.x() + 10, window->bounds().x());
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 // The window should still be full screen and immersive. 1225 // The window should still be full screen and immersive.
1217 EXPECT_TRUE(window_state->IsFullscreen()); 1226 EXPECT_TRUE(window_state->IsFullscreen());
1218 EXPECT_TRUE(window_state->in_immersive_fullscreen()); 1227 EXPECT_TRUE(window_state->in_immersive_fullscreen());
1219 1228
1220 DestroyMaximizeModeWindowManager(); 1229 DestroyMaximizeModeWindowManager();
1221 } 1230 }
1222 1231
1223 #endif // OS_WIN 1232 #endif // OS_WIN
1224 1233
1225 } // namespace ash 1234 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/maximize_mode/maximize_mode_window_manager.cc ('k') | chrome/browser/chromeos/display/display_preferences_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698