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

Side by Side Diff: ash/wm/tablet_mode/tablet_mode_window_manager_unittest.cc

Issue 2906803002: Rename MaximizeMode to TabletMode (Closed)
Patch Set: updated filter Created 3 years, 7 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/tablet_mode/tablet_mode_window_manager.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "ash/ash_switches.h" 9 #include "ash/ash_switches.h"
10 #include "ash/public/cpp/config.h" 10 #include "ash/public/cpp/config.h"
11 #include "ash/root_window_controller.h" 11 #include "ash/root_window_controller.h"
12 #include "ash/screen_util.h" 12 #include "ash/screen_util.h"
13 #include "ash/shelf/shelf.h" 13 #include "ash/shelf/shelf.h"
14 #include "ash/shell.h" 14 #include "ash/shell.h"
15 #include "ash/shell_port.h" 15 #include "ash/shell_port.h"
16 #include "ash/test/ash_test_base.h" 16 #include "ash/test/ash_test_base.h"
17 #include "ash/test/shell_test_api.h" 17 #include "ash/test/shell_test_api.h"
18 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
19 #include "ash/wm/mru_window_tracker.h" 18 #include "ash/wm/mru_window_tracker.h"
20 #include "ash/wm/overview/window_selector_controller.h" 19 #include "ash/wm/overview/window_selector_controller.h"
21 #include "ash/wm/switchable_windows.h" 20 #include "ash/wm/switchable_windows.h"
21 #include "ash/wm/tablet_mode/tablet_mode_controller.h"
22 #include "ash/wm/window_properties.h" 22 #include "ash/wm/window_properties.h"
23 #include "ash/wm/window_state.h" 23 #include "ash/wm/window_state.h"
24 #include "ash/wm/window_state_observer.h" 24 #include "ash/wm/window_state_observer.h"
25 #include "ash/wm/window_util.h" 25 #include "ash/wm/window_util.h"
26 #include "ash/wm/wm_event.h" 26 #include "ash/wm/wm_event.h"
27 #include "ash/wm_window.h" 27 #include "ash/wm_window.h"
28 #include "base/command_line.h" 28 #include "base/command_line.h"
29 #include "base/strings/stringprintf.h" 29 #include "base/strings/stringprintf.h"
30 #include "base/strings/utf_string_conversions.h" 30 #include "base/strings/utf_string_conversions.h"
31 #include "base/values.h" 31 #include "base/values.h"
32 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" 32 #include "services/ui/public/interfaces/window_manager_constants.mojom.h"
33 #include "ui/aura/client/aura_constants.h" 33 #include "ui/aura/client/aura_constants.h"
34 #include "ui/aura/test/test_window_delegate.h" 34 #include "ui/aura/test/test_window_delegate.h"
35 #include "ui/aura/test/test_windows.h" 35 #include "ui/aura/test/test_windows.h"
36 #include "ui/aura/window.h" 36 #include "ui/aura/window.h"
37 #include "ui/base/hit_test.h" 37 #include "ui/base/hit_test.h"
38 #include "ui/events/test/event_generator.h" 38 #include "ui/events/test/event_generator.h"
39 #include "ui/views/widget/widget.h" 39 #include "ui/views/widget/widget.h"
40 40
41 namespace ash { 41 namespace ash {
42 42
43 class MaximizeModeWindowManagerTest : public test::AshTestBase { 43 class TabletModeWindowManagerTest : public test::AshTestBase {
44 public: 44 public:
45 MaximizeModeWindowManagerTest() {} 45 TabletModeWindowManagerTest() {}
46 ~MaximizeModeWindowManagerTest() override {} 46 ~TabletModeWindowManagerTest() override {}
47 47
48 // Creates a window which has a fixed size. 48 // Creates a window which has a fixed size.
49 aura::Window* CreateFixedSizeNonMaximizableWindow( 49 aura::Window* CreateFixedSizeNonMaximizableWindow(
50 aura::client::WindowType type, 50 aura::client::WindowType type,
51 const gfx::Rect& bounds) { 51 const gfx::Rect& bounds) {
52 return CreateWindowInWatchedContainer(type, bounds, gfx::Size(), false, 52 return CreateWindowInWatchedContainer(type, bounds, gfx::Size(), false,
53 false); 53 false);
54 } 54 }
55 55
56 // Creates a window which can not be maximized, but resized. |max_size| 56 // Creates a window which can not be maximized, but resized. |max_size|
(...skipping 21 matching lines...) Expand all
78 widget->Init(params); 78 widget->Init(params);
79 widget->Show(); 79 widget->Show();
80 aura::Window* window = widget->GetNativeWindow(); 80 aura::Window* window = widget->GetNativeWindow();
81 window->SetBounds(bounds); 81 window->SetBounds(bounds);
82 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 82 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
83 83
84 return window; 84 return window;
85 } 85 }
86 86
87 // Create the Maximized mode window manager. 87 // Create the Maximized mode window manager.
88 MaximizeModeWindowManager* CreateMaximizeModeWindowManager() { 88 TabletModeWindowManager* CreateTabletModeWindowManager() {
89 EXPECT_FALSE(maximize_mode_window_manager()); 89 EXPECT_FALSE(tablet_mode_window_manager());
90 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 90 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
91 true); 91 return tablet_mode_window_manager();
92 return maximize_mode_window_manager();
93 } 92 }
94 93
95 // Destroy the maximized mode window manager. 94 // Destroy the tablet mode window manager.
96 void DestroyMaximizeModeWindowManager() { 95 void DestroyTabletModeWindowManager() {
97 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 96 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(
98 false); 97 false);
99 EXPECT_FALSE(maximize_mode_window_manager()); 98 EXPECT_FALSE(tablet_mode_window_manager());
100 } 99 }
101 100
102 // Get the maximze window manager. 101 // Get the maximze window manager.
103 MaximizeModeWindowManager* maximize_mode_window_manager() { 102 TabletModeWindowManager* tablet_mode_window_manager() {
104 return Shell::Get() 103 return Shell::Get()
105 ->maximize_mode_controller() 104 ->tablet_mode_controller()
106 ->maximize_mode_window_manager_.get(); 105 ->tablet_mode_window_manager_.get();
107 } 106 }
108 107
109 // Resize our desktop. 108 // Resize our desktop.
110 void ResizeDesktop(int width_delta) { 109 void ResizeDesktop(int width_delta) {
111 gfx::Size size = 110 gfx::Size size =
112 display::Screen::GetScreen() 111 display::Screen::GetScreen()
113 ->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()) 112 ->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow())
114 .size(); 113 .size();
115 size.Enlarge(0, width_delta); 114 size.Enlarge(0, width_delta);
116 UpdateDisplay(size.ToString()); 115 UpdateDisplay(size.ToString());
117 } 116 }
118 117
119 private: 118 private:
120 // Create a window in one of the containers which are watched by the 119 // Create a window in one of the containers which are watched by the
121 // MaximizeModeWindowManager. Note that this only works with one root window. 120 // TabletModeWindowManager. Note that this only works with one root window.
122 // If |can_maximize| is not set, |max_size| is the upper limiting size for 121 // If |can_maximize| is not set, |max_size| is the upper limiting size for
123 // the window, whereas an empty size means that there is no limit. 122 // the window, whereas an empty size means that there is no limit.
124 aura::Window* CreateWindowInWatchedContainer(aura::client::WindowType type, 123 aura::Window* CreateWindowInWatchedContainer(aura::client::WindowType type,
125 const gfx::Rect& bounds, 124 const gfx::Rect& bounds,
126 const gfx::Size& max_size, 125 const gfx::Size& max_size,
127 bool can_maximize, 126 bool can_maximize,
128 bool can_resize) { 127 bool can_resize) {
129 aura::test::TestWindowDelegate* delegate = NULL; 128 aura::test::TestWindowDelegate* delegate = NULL;
130 if (!can_maximize) { 129 if (!can_maximize) {
131 delegate = aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate(); 130 delegate = aura::test::TestWindowDelegate::CreateSelfDestroyingDelegate();
132 delegate->set_window_component(HTCAPTION); 131 delegate->set_window_component(HTCAPTION);
133 if (!max_size.IsEmpty()) 132 if (!max_size.IsEmpty())
134 delegate->set_maximum_size(max_size); 133 delegate->set_maximum_size(max_size);
135 } 134 }
136 aura::Window* window = aura::test::CreateTestWindowWithDelegateAndType( 135 aura::Window* window = aura::test::CreateTestWindowWithDelegateAndType(
137 delegate, type, 0, bounds, NULL); 136 delegate, type, 0, bounds, NULL);
138 int32_t behavior = ui::mojom::kResizeBehaviorNone; 137 int32_t behavior = ui::mojom::kResizeBehaviorNone;
139 behavior |= can_resize ? ui::mojom::kResizeBehaviorCanResize : 0; 138 behavior |= can_resize ? ui::mojom::kResizeBehaviorCanResize : 0;
140 behavior |= can_maximize ? ui::mojom::kResizeBehaviorCanMaximize : 0; 139 behavior |= can_maximize ? ui::mojom::kResizeBehaviorCanMaximize : 0;
141 window->SetProperty(aura::client::kResizeBehaviorKey, behavior); 140 window->SetProperty(aura::client::kResizeBehaviorKey, behavior);
142 aura::Window* container = Shell::GetContainer( 141 aura::Window* container = Shell::GetContainer(
143 Shell::GetPrimaryRootWindow(), wm::kSwitchableWindowContainerIds[0]); 142 Shell::GetPrimaryRootWindow(), wm::kSwitchableWindowContainerIds[0]);
144 container->AddChild(window); 143 container->AddChild(window);
145 return window; 144 return window;
146 } 145 }
147 146
148 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManagerTest); 147 DISALLOW_COPY_AND_ASSIGN(TabletModeWindowManagerTest);
149 }; 148 };
150 149
151 // Test that creating the object and destroying it without any windows should 150 // Test that creating the object and destroying it without any windows should
152 // not cause any problems. 151 // not cause any problems.
153 TEST_F(MaximizeModeWindowManagerTest, SimpleStart) { 152 TEST_F(TabletModeWindowManagerTest, SimpleStart) {
154 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 153 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
155 ASSERT_TRUE(manager); 154 ASSERT_TRUE(manager);
156 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 155 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
157 DestroyMaximizeModeWindowManager(); 156 DestroyTabletModeWindowManager();
158 } 157 }
159 158
160 // Test that existing windows will handled properly when going into maximized 159 // Test that existing windows will handled properly when going into maximized
161 // mode. 160 // mode.
162 TEST_F(MaximizeModeWindowManagerTest, PreCreateWindows) { 161 TEST_F(TabletModeWindowManagerTest, PreCreateWindows) {
163 // Bounds for windows we know can be controlled. 162 // Bounds for windows we know can be controlled.
164 gfx::Rect rect1(10, 10, 200, 50); 163 gfx::Rect rect1(10, 10, 200, 50);
165 gfx::Rect rect2(10, 60, 200, 50); 164 gfx::Rect rect2(10, 60, 200, 50);
166 gfx::Rect rect3(20, 140, 100, 100); 165 gfx::Rect rect3(20, 140, 100, 100);
167 // Bounds for anything else. 166 // Bounds for anything else.
168 gfx::Rect rect(80, 90, 100, 110); 167 gfx::Rect rect(80, 90, 100, 110);
169 std::unique_ptr<aura::Window> w1( 168 std::unique_ptr<aura::Window> w1(
170 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect1)); 169 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect1));
171 std::unique_ptr<aura::Window> w2( 170 std::unique_ptr<aura::Window> w2(
172 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect2)); 171 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect2));
(...skipping 11 matching lines...) Expand all
184 CreateWindow(aura::client::WINDOW_TYPE_TOOLTIP, rect)); 183 CreateWindow(aura::client::WINDOW_TYPE_TOOLTIP, rect));
185 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); 184 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized());
186 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); 185 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized());
187 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); 186 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
188 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); 187 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
189 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); 188 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
190 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString()); 189 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString());
191 190
192 // Create the manager and make sure that all qualifying windows were detected 191 // Create the manager and make sure that all qualifying windows were detected
193 // and changed. 192 // and changed.
194 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 193 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
195 ASSERT_TRUE(manager); 194 ASSERT_TRUE(manager);
196 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 195 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
197 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized()); 196 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized());
198 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); 197 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized());
199 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); 198 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
200 EXPECT_NE(rect3.origin().ToString(), w3->bounds().origin().ToString()); 199 EXPECT_NE(rect3.origin().ToString(), w3->bounds().origin().ToString());
201 EXPECT_EQ(rect3.size().ToString(), w3->bounds().size().ToString()); 200 EXPECT_EQ(rect3.size().ToString(), w3->bounds().size().ToString());
202 201
203 // All other windows should not have been touched. 202 // All other windows should not have been touched.
204 EXPECT_FALSE(wm::GetWindowState(w4.get())->IsMaximized()); 203 EXPECT_FALSE(wm::GetWindowState(w4.get())->IsMaximized());
205 EXPECT_FALSE(wm::GetWindowState(w5.get())->IsMaximized()); 204 EXPECT_FALSE(wm::GetWindowState(w5.get())->IsMaximized());
206 EXPECT_FALSE(wm::GetWindowState(w6.get())->IsMaximized()); 205 EXPECT_FALSE(wm::GetWindowState(w6.get())->IsMaximized());
207 EXPECT_FALSE(wm::GetWindowState(w7.get())->IsMaximized()); 206 EXPECT_FALSE(wm::GetWindowState(w7.get())->IsMaximized());
208 EXPECT_FALSE(wm::GetWindowState(w8.get())->IsMaximized()); 207 EXPECT_FALSE(wm::GetWindowState(w8.get())->IsMaximized());
209 EXPECT_EQ(rect.ToString(), w4->bounds().ToString()); 208 EXPECT_EQ(rect.ToString(), w4->bounds().ToString());
210 EXPECT_EQ(rect.ToString(), w5->bounds().ToString()); 209 EXPECT_EQ(rect.ToString(), w5->bounds().ToString());
211 EXPECT_EQ(rect.ToString(), w6->bounds().ToString()); 210 EXPECT_EQ(rect.ToString(), w6->bounds().ToString());
212 EXPECT_EQ(rect.ToString(), w7->bounds().ToString()); 211 EXPECT_EQ(rect.ToString(), w7->bounds().ToString());
213 EXPECT_EQ(rect.ToString(), w8->bounds().ToString()); 212 EXPECT_EQ(rect.ToString(), w8->bounds().ToString());
214 213
215 // Destroy the manager again and check that the windows return to their 214 // Destroy the manager again and check that the windows return to their
216 // previous state. 215 // previous state.
217 DestroyMaximizeModeWindowManager(); 216 DestroyTabletModeWindowManager();
218 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); 217 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized());
219 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); 218 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized());
220 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); 219 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
221 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); 220 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
222 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); 221 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
223 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString()); 222 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString());
224 EXPECT_EQ(rect.ToString(), w4->bounds().ToString()); 223 EXPECT_EQ(rect.ToString(), w4->bounds().ToString());
225 EXPECT_EQ(rect.ToString(), w5->bounds().ToString()); 224 EXPECT_EQ(rect.ToString(), w5->bounds().ToString());
226 EXPECT_EQ(rect.ToString(), w6->bounds().ToString()); 225 EXPECT_EQ(rect.ToString(), w6->bounds().ToString());
227 EXPECT_EQ(rect.ToString(), w7->bounds().ToString()); 226 EXPECT_EQ(rect.ToString(), w7->bounds().ToString());
228 EXPECT_EQ(rect.ToString(), w8->bounds().ToString()); 227 EXPECT_EQ(rect.ToString(), w8->bounds().ToString());
229 } 228 }
230 229
231 // The same test as the above but while a system modal dialog is shown. 230 // The same test as the above but while a system modal dialog is shown.
232 TEST_F(MaximizeModeWindowManagerTest, GoingToMaximizedWithModalDialogPresent) { 231 TEST_F(TabletModeWindowManagerTest, GoingToMaximizedWithModalDialogPresent) {
233 // Bounds for windows we know can be controlled. 232 // Bounds for windows we know can be controlled.
234 gfx::Rect rect1(10, 10, 200, 50); 233 gfx::Rect rect1(10, 10, 200, 50);
235 gfx::Rect rect2(10, 60, 200, 50); 234 gfx::Rect rect2(10, 60, 200, 50);
236 gfx::Rect rect3(20, 140, 100, 100); 235 gfx::Rect rect3(20, 140, 100, 100);
237 // Bounds for anything else. 236 // Bounds for anything else.
238 gfx::Rect rect(80, 90, 100, 110); 237 gfx::Rect rect(80, 90, 100, 110);
239 std::unique_ptr<aura::Window> w1( 238 std::unique_ptr<aura::Window> w1(
240 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect1)); 239 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect1));
241 std::unique_ptr<aura::Window> w2( 240 std::unique_ptr<aura::Window> w2(
242 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect2)); 241 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect2));
(...skipping 15 matching lines...) Expand all
258 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); 257 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
259 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); 258 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
260 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString()); 259 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString());
261 260
262 // Enable system modal dialog, and make sure both shelves are still hidden. 261 // Enable system modal dialog, and make sure both shelves are still hidden.
263 ShellPort::Get()->SimulateModalWindowOpenForTesting(true); 262 ShellPort::Get()->SimulateModalWindowOpenForTesting(true);
264 EXPECT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen()); 263 EXPECT_TRUE(ShellPort::Get()->IsSystemModalWindowOpen());
265 264
266 // Create the manager and make sure that all qualifying windows were detected 265 // Create the manager and make sure that all qualifying windows were detected
267 // and changed. 266 // and changed.
268 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 267 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
269 ASSERT_TRUE(manager); 268 ASSERT_TRUE(manager);
270 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 269 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
271 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized()); 270 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized());
272 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); 271 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized());
273 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); 272 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
274 EXPECT_NE(rect3.origin().ToString(), w3->bounds().origin().ToString()); 273 EXPECT_NE(rect3.origin().ToString(), w3->bounds().origin().ToString());
275 EXPECT_EQ(rect3.size().ToString(), w3->bounds().size().ToString()); 274 EXPECT_EQ(rect3.size().ToString(), w3->bounds().size().ToString());
276 275
277 // All other windows should not have been touched. 276 // All other windows should not have been touched.
278 EXPECT_FALSE(wm::GetWindowState(w4.get())->IsMaximized()); 277 EXPECT_FALSE(wm::GetWindowState(w4.get())->IsMaximized());
279 EXPECT_FALSE(wm::GetWindowState(w5.get())->IsMaximized()); 278 EXPECT_FALSE(wm::GetWindowState(w5.get())->IsMaximized());
280 EXPECT_FALSE(wm::GetWindowState(w6.get())->IsMaximized()); 279 EXPECT_FALSE(wm::GetWindowState(w6.get())->IsMaximized());
281 EXPECT_FALSE(wm::GetWindowState(w7.get())->IsMaximized()); 280 EXPECT_FALSE(wm::GetWindowState(w7.get())->IsMaximized());
282 EXPECT_FALSE(wm::GetWindowState(w8.get())->IsMaximized()); 281 EXPECT_FALSE(wm::GetWindowState(w8.get())->IsMaximized());
283 EXPECT_EQ(rect.ToString(), w4->bounds().ToString()); 282 EXPECT_EQ(rect.ToString(), w4->bounds().ToString());
284 EXPECT_EQ(rect.ToString(), w5->bounds().ToString()); 283 EXPECT_EQ(rect.ToString(), w5->bounds().ToString());
285 EXPECT_EQ(rect.ToString(), w6->bounds().ToString()); 284 EXPECT_EQ(rect.ToString(), w6->bounds().ToString());
286 EXPECT_EQ(rect.ToString(), w7->bounds().ToString()); 285 EXPECT_EQ(rect.ToString(), w7->bounds().ToString());
287 EXPECT_EQ(rect.ToString(), w8->bounds().ToString()); 286 EXPECT_EQ(rect.ToString(), w8->bounds().ToString());
288 287
289 // Destroy the manager again and check that the windows return to their 288 // Destroy the manager again and check that the windows return to their
290 // previous state. 289 // previous state.
291 DestroyMaximizeModeWindowManager(); 290 DestroyTabletModeWindowManager();
292 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); 291 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized());
293 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); 292 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized());
294 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); 293 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
295 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); 294 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
296 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); 295 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
297 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString()); 296 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString());
298 EXPECT_EQ(rect.ToString(), w4->bounds().ToString()); 297 EXPECT_EQ(rect.ToString(), w4->bounds().ToString());
299 EXPECT_EQ(rect.ToString(), w5->bounds().ToString()); 298 EXPECT_EQ(rect.ToString(), w5->bounds().ToString());
300 EXPECT_EQ(rect.ToString(), w6->bounds().ToString()); 299 EXPECT_EQ(rect.ToString(), w6->bounds().ToString());
301 EXPECT_EQ(rect.ToString(), w7->bounds().ToString()); 300 EXPECT_EQ(rect.ToString(), w7->bounds().ToString());
302 EXPECT_EQ(rect.ToString(), w8->bounds().ToString()); 301 EXPECT_EQ(rect.ToString(), w8->bounds().ToString());
303 } 302 }
304 303
305 // Test that non-maximizable windows get properly handled when going into 304 // Test that non-maximizable windows get properly handled when going into
306 // maximized mode. 305 // tablet mode.
307 TEST_F(MaximizeModeWindowManagerTest, 306 TEST_F(TabletModeWindowManagerTest,
308 PreCreateNonMaximizableButResizableWindows) { 307 PreCreateNonMaximizableButResizableWindows) {
309 // The window bounds. 308 // The window bounds.
310 gfx::Rect rect(10, 10, 200, 50); 309 gfx::Rect rect(10, 10, 200, 50);
311 gfx::Size max_size(300, 200); 310 gfx::Size max_size(300, 200);
312 gfx::Size empty_size; 311 gfx::Size empty_size;
313 std::unique_ptr<aura::Window> unlimited_window(CreateNonMaximizableWindow( 312 std::unique_ptr<aura::Window> unlimited_window(CreateNonMaximizableWindow(
314 aura::client::WINDOW_TYPE_NORMAL, rect, empty_size)); 313 aura::client::WINDOW_TYPE_NORMAL, rect, empty_size));
315 std::unique_ptr<aura::Window> limited_window(CreateNonMaximizableWindow( 314 std::unique_ptr<aura::Window> limited_window(CreateNonMaximizableWindow(
316 aura::client::WINDOW_TYPE_NORMAL, rect, max_size)); 315 aura::client::WINDOW_TYPE_NORMAL, rect, max_size));
317 std::unique_ptr<aura::Window> fixed_window( 316 std::unique_ptr<aura::Window> fixed_window(
318 CreateFixedSizeNonMaximizableWindow(aura::client::WINDOW_TYPE_NORMAL, 317 CreateFixedSizeNonMaximizableWindow(aura::client::WINDOW_TYPE_NORMAL,
319 rect)); 318 rect));
320 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized()); 319 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized());
321 EXPECT_EQ(rect.ToString(), unlimited_window->bounds().ToString()); 320 EXPECT_EQ(rect.ToString(), unlimited_window->bounds().ToString());
322 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized()); 321 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized());
323 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString()); 322 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString());
324 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized()); 323 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized());
325 EXPECT_EQ(rect.ToString(), fixed_window->bounds().ToString()); 324 EXPECT_EQ(rect.ToString(), fixed_window->bounds().ToString());
326 325
327 gfx::Size workspace_size = 326 gfx::Size workspace_size =
328 ScreenUtil::GetMaximizedWindowBoundsInParent(unlimited_window.get()) 327 ScreenUtil::GetMaximizedWindowBoundsInParent(unlimited_window.get())
329 .size(); 328 .size();
330 329
331 // Create the manager and make sure that all qualifying windows were detected 330 // Create the manager and make sure that all qualifying windows were detected
332 // and changed. 331 // and changed.
333 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 332 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
334 ASSERT_TRUE(manager); 333 ASSERT_TRUE(manager);
335 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 334 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
336 // The unlimited window should have the size of the workspace / parent window. 335 // The unlimited window should have the size of the workspace / parent window.
337 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized()); 336 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized());
338 EXPECT_EQ("0,0", unlimited_window->bounds().origin().ToString()); 337 EXPECT_EQ("0,0", unlimited_window->bounds().origin().ToString());
339 EXPECT_EQ(workspace_size.ToString(), 338 EXPECT_EQ(workspace_size.ToString(),
340 unlimited_window->bounds().size().ToString()); 339 unlimited_window->bounds().size().ToString());
341 // The limited window should have the size of the upper possible bounds. 340 // The limited window should have the size of the upper possible bounds.
342 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized()); 341 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized());
343 EXPECT_NE(rect.origin().ToString(), 342 EXPECT_NE(rect.origin().ToString(),
344 limited_window->bounds().origin().ToString()); 343 limited_window->bounds().origin().ToString());
345 EXPECT_EQ(max_size.ToString(), limited_window->bounds().size().ToString()); 344 EXPECT_EQ(max_size.ToString(), limited_window->bounds().size().ToString());
346 // The fixed size window should have the size of the original window. 345 // The fixed size window should have the size of the original window.
347 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized()); 346 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized());
348 EXPECT_NE(rect.origin().ToString(), 347 EXPECT_NE(rect.origin().ToString(),
349 fixed_window->bounds().origin().ToString()); 348 fixed_window->bounds().origin().ToString());
350 EXPECT_EQ(rect.size().ToString(), fixed_window->bounds().size().ToString()); 349 EXPECT_EQ(rect.size().ToString(), fixed_window->bounds().size().ToString());
351 350
352 // Destroy the manager again and check that the windows return to their 351 // Destroy the manager again and check that the windows return to their
353 // previous state. 352 // previous state.
354 DestroyMaximizeModeWindowManager(); 353 DestroyTabletModeWindowManager();
355 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized()); 354 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized());
356 EXPECT_EQ(rect.ToString(), unlimited_window->bounds().ToString()); 355 EXPECT_EQ(rect.ToString(), unlimited_window->bounds().ToString());
357 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized()); 356 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized());
358 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString()); 357 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString());
359 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized()); 358 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized());
360 EXPECT_EQ(rect.ToString(), fixed_window->bounds().ToString()); 359 EXPECT_EQ(rect.ToString(), fixed_window->bounds().ToString());
361 } 360 }
362 361
363 // Test that creating windows while a maximizer exists picks them properly up. 362 // Test that creating windows while a maximizer exists picks them properly up.
364 TEST_F(MaximizeModeWindowManagerTest, CreateWindows) { 363 TEST_F(TabletModeWindowManagerTest, CreateWindows) {
365 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 364 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
366 ASSERT_TRUE(manager); 365 ASSERT_TRUE(manager);
367 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 366 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
368 367
369 // Create the windows and see that the window manager picks them up. 368 // Create the windows and see that the window manager picks them up.
370 // Rects for windows we know can be controlled. 369 // Rects for windows we know can be controlled.
371 gfx::Rect rect1(10, 10, 200, 50); 370 gfx::Rect rect1(10, 10, 200, 50);
372 gfx::Rect rect2(10, 60, 200, 50); 371 gfx::Rect rect2(10, 60, 200, 50);
373 gfx::Rect rect3(20, 140, 100, 100); 372 gfx::Rect rect3(20, 140, 100, 100);
374 // One rect for anything else. 373 // One rect for anything else.
375 gfx::Rect rect(80, 90, 100, 110); 374 gfx::Rect rect(80, 90, 100, 110);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 EXPECT_FALSE(wm::GetWindowState(w5.get())->IsMaximized()); 408 EXPECT_FALSE(wm::GetWindowState(w5.get())->IsMaximized());
410 EXPECT_FALSE(wm::GetWindowState(w6.get())->IsMaximized()); 409 EXPECT_FALSE(wm::GetWindowState(w6.get())->IsMaximized());
411 EXPECT_FALSE(wm::GetWindowState(w7.get())->IsMaximized()); 410 EXPECT_FALSE(wm::GetWindowState(w7.get())->IsMaximized());
412 EXPECT_FALSE(wm::GetWindowState(w8.get())->IsMaximized()); 411 EXPECT_FALSE(wm::GetWindowState(w8.get())->IsMaximized());
413 EXPECT_EQ(rect.ToString(), w4->bounds().ToString()); 412 EXPECT_EQ(rect.ToString(), w4->bounds().ToString());
414 EXPECT_EQ(rect.ToString(), w5->bounds().ToString()); 413 EXPECT_EQ(rect.ToString(), w5->bounds().ToString());
415 EXPECT_EQ(rect.ToString(), w6->bounds().ToString()); 414 EXPECT_EQ(rect.ToString(), w6->bounds().ToString());
416 EXPECT_EQ(rect.ToString(), w7->bounds().ToString()); 415 EXPECT_EQ(rect.ToString(), w7->bounds().ToString());
417 EXPECT_EQ(rect.ToString(), w8->bounds().ToString()); 416 EXPECT_EQ(rect.ToString(), w8->bounds().ToString());
418 417
419 // After the maximize mode was disabled all windows fall back into the mode 418 // After the tablet mode was disabled all windows fall back into the mode
420 // they were created for. 419 // they were created for.
421 DestroyMaximizeModeWindowManager(); 420 DestroyTabletModeWindowManager();
422 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); 421 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized());
423 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); 422 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized());
424 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); 423 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
425 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); 424 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
426 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); 425 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
427 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString()); 426 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString());
428 EXPECT_EQ(rect.ToString(), w4->bounds().ToString()); 427 EXPECT_EQ(rect.ToString(), w4->bounds().ToString());
429 EXPECT_EQ(rect.ToString(), w5->bounds().ToString()); 428 EXPECT_EQ(rect.ToString(), w5->bounds().ToString());
430 EXPECT_EQ(rect.ToString(), w6->bounds().ToString()); 429 EXPECT_EQ(rect.ToString(), w6->bounds().ToString());
431 EXPECT_EQ(rect.ToString(), w7->bounds().ToString()); 430 EXPECT_EQ(rect.ToString(), w7->bounds().ToString());
432 EXPECT_EQ(rect.ToString(), w8->bounds().ToString()); 431 EXPECT_EQ(rect.ToString(), w8->bounds().ToString());
433 } 432 }
434 433
435 // Test that a window which got created while the maximize mode window manager 434 // Test that a window which got created while the tablet mode window manager
436 // is active gets restored to a usable (non tiny) size upon switching back. 435 // is active gets restored to a usable (non tiny) size upon switching back.
437 TEST_F(MaximizeModeWindowManagerTest, 436 TEST_F(TabletModeWindowManagerTest,
438 CreateWindowInMaximizedModeRestoresToUsefulSize) { 437 CreateWindowInMaximizedModeRestoresToUsefulSize) {
439 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 438 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
440 ASSERT_TRUE(manager); 439 ASSERT_TRUE(manager);
441 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 440 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
442 441
443 // We pass in an empty rectangle to simulate a window creation with no 442 // We pass in an empty rectangle to simulate a window creation with no
444 // particular size. 443 // particular size.
445 gfx::Rect empty_rect(0, 0, 0, 0); 444 gfx::Rect empty_rect(0, 0, 0, 0);
446 std::unique_ptr<aura::Window> window( 445 std::unique_ptr<aura::Window> window(
447 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, empty_rect)); 446 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, empty_rect));
448 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized()); 447 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized());
449 EXPECT_NE(empty_rect.ToString(), window->bounds().ToString()); 448 EXPECT_NE(empty_rect.ToString(), window->bounds().ToString());
450 gfx::Rect maximized_size = window->bounds(); 449 gfx::Rect maximized_size = window->bounds();
451 450
452 // Destroy the maximize mode and check that the resulting size of the window 451 // Destroy the tablet mode and check that the resulting size of the window
453 // is remaining as it is (but not maximized). 452 // is remaining as it is (but not maximized).
454 DestroyMaximizeModeWindowManager(); 453 DestroyTabletModeWindowManager();
455 454
456 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); 455 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized());
457 EXPECT_EQ(maximized_size.ToString(), window->bounds().ToString()); 456 EXPECT_EQ(maximized_size.ToString(), window->bounds().ToString());
458 } 457 }
459 458
460 // Test that non-maximizable windows get properly handled when created in 459 // Test that non-maximizable windows get properly handled when created in
461 // maximized mode. 460 // tablet mode.
462 TEST_F(MaximizeModeWindowManagerTest, CreateNonMaximizableButResizableWindows) { 461 TEST_F(TabletModeWindowManagerTest, CreateNonMaximizableButResizableWindows) {
463 // Create the manager and make sure that all qualifying windows were detected 462 // Create the manager and make sure that all qualifying windows were detected
464 // and changed. 463 // and changed.
465 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 464 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
466 ASSERT_TRUE(manager); 465 ASSERT_TRUE(manager);
467 466
468 gfx::Rect rect(10, 10, 200, 50); 467 gfx::Rect rect(10, 10, 200, 50);
469 gfx::Size max_size(300, 200); 468 gfx::Size max_size(300, 200);
470 gfx::Size empty_size; 469 gfx::Size empty_size;
471 std::unique_ptr<aura::Window> unlimited_window(CreateNonMaximizableWindow( 470 std::unique_ptr<aura::Window> unlimited_window(CreateNonMaximizableWindow(
472 aura::client::WINDOW_TYPE_NORMAL, rect, empty_size)); 471 aura::client::WINDOW_TYPE_NORMAL, rect, empty_size));
473 std::unique_ptr<aura::Window> limited_window(CreateNonMaximizableWindow( 472 std::unique_ptr<aura::Window> limited_window(CreateNonMaximizableWindow(
474 aura::client::WINDOW_TYPE_NORMAL, rect, max_size)); 473 aura::client::WINDOW_TYPE_NORMAL, rect, max_size));
475 std::unique_ptr<aura::Window> fixed_window( 474 std::unique_ptr<aura::Window> fixed_window(
(...skipping 17 matching lines...) Expand all
493 limited_window->bounds().origin().ToString()); 492 limited_window->bounds().origin().ToString());
494 EXPECT_EQ(max_size.ToString(), limited_window->bounds().size().ToString()); 493 EXPECT_EQ(max_size.ToString(), limited_window->bounds().size().ToString());
495 // The fixed size window should have the size of the original window. 494 // The fixed size window should have the size of the original window.
496 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized()); 495 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized());
497 EXPECT_NE(rect.origin().ToString(), 496 EXPECT_NE(rect.origin().ToString(),
498 fixed_window->bounds().origin().ToString()); 497 fixed_window->bounds().origin().ToString());
499 EXPECT_EQ(rect.size().ToString(), fixed_window->bounds().size().ToString()); 498 EXPECT_EQ(rect.size().ToString(), fixed_window->bounds().size().ToString());
500 499
501 // Destroy the manager again and check that the windows return to their 500 // Destroy the manager again and check that the windows return to their
502 // creation state. 501 // creation state.
503 DestroyMaximizeModeWindowManager(); 502 DestroyTabletModeWindowManager();
504 503
505 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized()); 504 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized());
506 EXPECT_EQ(rect.ToString(), unlimited_window->bounds().ToString()); 505 EXPECT_EQ(rect.ToString(), unlimited_window->bounds().ToString());
507 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized()); 506 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized());
508 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString()); 507 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString());
509 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized()); 508 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized());
510 EXPECT_EQ(rect.ToString(), fixed_window->bounds().ToString()); 509 EXPECT_EQ(rect.ToString(), fixed_window->bounds().ToString());
511 } 510 }
512 511
513 // Create a string which consists of the bounds and the state for comparison. 512 // Create a string which consists of the bounds and the state for comparison.
(...skipping 10 matching lines...) Expand all
524 gfx::Rect restore_bounds = *bounds; 523 gfx::Rect restore_bounds = *bounds;
525 ui::WindowShowState restore_state = 524 ui::WindowShowState restore_state =
526 window->GetProperty(kRestoreShowStateOverrideKey); 525 window->GetProperty(kRestoreShowStateOverrideKey);
527 return GetPlacementString(restore_bounds, restore_state); 526 return GetPlacementString(restore_bounds, restore_state);
528 } 527 }
529 return std::string(); 528 return std::string();
530 } 529 }
531 530
532 // Test that the restore state will be kept at its original value for 531 // Test that the restore state will be kept at its original value for
533 // session restauration purposes. 532 // session restauration purposes.
534 TEST_F(MaximizeModeWindowManagerTest, TestRestoreIntegrety) { 533 TEST_F(TabletModeWindowManagerTest, TestRestoreIntegrety) {
535 gfx::Rect bounds(10, 10, 200, 50); 534 gfx::Rect bounds(10, 10, 200, 50);
536 gfx::Size empty_size; 535 gfx::Size empty_size;
537 gfx::Rect empty_bounds; 536 gfx::Rect empty_bounds;
538 std::unique_ptr<aura::Window> normal_window(CreateWindowWithWidget(bounds)); 537 std::unique_ptr<aura::Window> normal_window(CreateWindowWithWidget(bounds));
539 std::unique_ptr<aura::Window> maximized_window( 538 std::unique_ptr<aura::Window> maximized_window(
540 CreateWindowWithWidget(bounds)); 539 CreateWindowWithWidget(bounds));
541 wm::GetWindowState(maximized_window.get())->Maximize(); 540 wm::GetWindowState(maximized_window.get())->Maximize();
542 541
543 EXPECT_EQ(std::string(), GetPlacementOverride(normal_window.get())); 542 EXPECT_EQ(std::string(), GetPlacementOverride(normal_window.get()));
544 EXPECT_EQ(std::string(), GetPlacementOverride(maximized_window.get())); 543 EXPECT_EQ(std::string(), GetPlacementOverride(maximized_window.get()));
545 544
546 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 545 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
547 ASSERT_TRUE(manager); 546 ASSERT_TRUE(manager);
548 547
549 // With the maximization the override states should be returned in its 548 // With the maximization the override states should be returned in its
550 // pre-maximized state. 549 // pre-maximized state.
551 EXPECT_EQ(GetPlacementString(bounds, ui::SHOW_STATE_NORMAL), 550 EXPECT_EQ(GetPlacementString(bounds, ui::SHOW_STATE_NORMAL),
552 GetPlacementOverride(normal_window.get())); 551 GetPlacementOverride(normal_window.get()));
553 EXPECT_EQ(GetPlacementString(bounds, ui::SHOW_STATE_MAXIMIZED), 552 EXPECT_EQ(GetPlacementString(bounds, ui::SHOW_STATE_MAXIMIZED),
554 GetPlacementOverride(maximized_window.get())); 553 GetPlacementOverride(maximized_window.get()));
555 554
556 // Changing a window's state now does not change the returned result. 555 // Changing a window's state now does not change the returned result.
557 wm::GetWindowState(maximized_window.get())->Minimize(); 556 wm::GetWindowState(maximized_window.get())->Minimize();
558 EXPECT_EQ(GetPlacementString(bounds, ui::SHOW_STATE_MAXIMIZED), 557 EXPECT_EQ(GetPlacementString(bounds, ui::SHOW_STATE_MAXIMIZED),
559 GetPlacementOverride(maximized_window.get())); 558 GetPlacementOverride(maximized_window.get()));
560 559
561 // Destroy the manager again and check that the overrides get reset. 560 // Destroy the manager again and check that the overrides get reset.
562 DestroyMaximizeModeWindowManager(); 561 DestroyTabletModeWindowManager();
563 EXPECT_EQ(std::string(), GetPlacementOverride(normal_window.get())); 562 EXPECT_EQ(std::string(), GetPlacementOverride(normal_window.get()));
564 EXPECT_EQ(std::string(), GetPlacementOverride(maximized_window.get())); 563 EXPECT_EQ(std::string(), GetPlacementOverride(maximized_window.get()));
565 564
566 // Changing a window's state now does not bring the overrides back. 565 // Changing a window's state now does not bring the overrides back.
567 wm::GetWindowState(maximized_window.get())->Restore(); 566 wm::GetWindowState(maximized_window.get())->Restore();
568 gfx::Rect new_bounds(10, 10, 200, 50); 567 gfx::Rect new_bounds(10, 10, 200, 50);
569 maximized_window->SetBounds(new_bounds); 568 maximized_window->SetBounds(new_bounds);
570 569
571 EXPECT_EQ(std::string(), GetPlacementOverride(maximized_window.get())); 570 EXPECT_EQ(std::string(), GetPlacementOverride(maximized_window.get()));
572 } 571 }
573 572
574 // Test that windows which got created before the maximizer was created can be 573 // Test that windows which got created before the maximizer was created can be
575 // destroyed while the maximizer is still running. 574 // destroyed while the maximizer is still running.
576 TEST_F(MaximizeModeWindowManagerTest, PreCreateWindowsDeleteWhileActive) { 575 TEST_F(TabletModeWindowManagerTest, PreCreateWindowsDeleteWhileActive) {
577 MaximizeModeWindowManager* manager = NULL; 576 TabletModeWindowManager* manager = NULL;
578 { 577 {
579 // Bounds for windows we know can be controlled. 578 // Bounds for windows we know can be controlled.
580 gfx::Rect rect1(10, 10, 200, 50); 579 gfx::Rect rect1(10, 10, 200, 50);
581 gfx::Rect rect2(10, 60, 200, 50); 580 gfx::Rect rect2(10, 60, 200, 50);
582 gfx::Rect rect3(20, 140, 100, 100); 581 gfx::Rect rect3(20, 140, 100, 100);
583 // Bounds for anything else. 582 // Bounds for anything else.
584 gfx::Rect rect(80, 90, 100, 110); 583 gfx::Rect rect(80, 90, 100, 110);
585 std::unique_ptr<aura::Window> w1( 584 std::unique_ptr<aura::Window> w1(
586 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect1)); 585 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect1));
587 std::unique_ptr<aura::Window> w2( 586 std::unique_ptr<aura::Window> w2(
588 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect2)); 587 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect2));
589 std::unique_ptr<aura::Window> w3(CreateFixedSizeNonMaximizableWindow( 588 std::unique_ptr<aura::Window> w3(CreateFixedSizeNonMaximizableWindow(
590 aura::client::WINDOW_TYPE_NORMAL, rect3)); 589 aura::client::WINDOW_TYPE_NORMAL, rect3));
591 590
592 // Create the manager and make sure that all qualifying windows were 591 // Create the manager and make sure that all qualifying windows were
593 // detected and changed. 592 // detected and changed.
594 manager = CreateMaximizeModeWindowManager(); 593 manager = CreateTabletModeWindowManager();
595 ASSERT_TRUE(manager); 594 ASSERT_TRUE(manager);
596 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 595 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
597 } 596 }
598 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 597 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
599 DestroyMaximizeModeWindowManager(); 598 DestroyTabletModeWindowManager();
600 } 599 }
601 600
602 // Test that windows which got created while the maximizer was running can get 601 // Test that windows which got created while the maximizer was running can get
603 // destroyed before the maximizer gets destroyed. 602 // destroyed before the maximizer gets destroyed.
604 TEST_F(MaximizeModeWindowManagerTest, CreateWindowsAndDeleteWhileActive) { 603 TEST_F(TabletModeWindowManagerTest, CreateWindowsAndDeleteWhileActive) {
605 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 604 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
606 ASSERT_TRUE(manager); 605 ASSERT_TRUE(manager);
607 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 606 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
608 { 607 {
609 // Bounds for windows we know can be controlled. 608 // Bounds for windows we know can be controlled.
610 gfx::Rect rect1(10, 10, 200, 50); 609 gfx::Rect rect1(10, 10, 200, 50);
611 gfx::Rect rect2(10, 60, 200, 50); 610 gfx::Rect rect2(10, 60, 200, 50);
612 gfx::Rect rect3(20, 140, 100, 100); 611 gfx::Rect rect3(20, 140, 100, 100);
613 std::unique_ptr<aura::Window> w1(CreateWindow( 612 std::unique_ptr<aura::Window> w1(CreateWindow(
614 aura::client::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50))); 613 aura::client::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50)));
615 std::unique_ptr<aura::Window> w2(CreateWindow( 614 std::unique_ptr<aura::Window> w2(CreateWindow(
616 aura::client::WINDOW_TYPE_NORMAL, gfx::Rect(10, 60, 200, 50))); 615 aura::client::WINDOW_TYPE_NORMAL, gfx::Rect(10, 60, 200, 50)));
617 std::unique_ptr<aura::Window> w3(CreateFixedSizeNonMaximizableWindow( 616 std::unique_ptr<aura::Window> w3(CreateFixedSizeNonMaximizableWindow(
618 aura::client::WINDOW_TYPE_NORMAL, gfx::Rect(20, 140, 100, 100))); 617 aura::client::WINDOW_TYPE_NORMAL, gfx::Rect(20, 140, 100, 100)));
619 // Check that the windows got automatically maximized as well. 618 // Check that the windows got automatically maximized as well.
620 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 619 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
621 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized()); 620 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized());
622 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); 621 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized());
623 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); 622 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
624 } 623 }
625 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 624 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
626 DestroyMaximizeModeWindowManager(); 625 DestroyTabletModeWindowManager();
627 } 626 }
628 627
629 // Test that windows which were maximized stay maximized. 628 // Test that windows which were maximized stay maximized.
630 TEST_F(MaximizeModeWindowManagerTest, MaximizedShouldRemainMaximized) { 629 TEST_F(TabletModeWindowManagerTest, MaximizedShouldRemainMaximized) {
631 // Bounds for windows we know can be controlled. 630 // Bounds for windows we know can be controlled.
632 gfx::Rect rect(10, 10, 200, 50); 631 gfx::Rect rect(10, 10, 200, 50);
633 std::unique_ptr<aura::Window> window( 632 std::unique_ptr<aura::Window> window(
634 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 633 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
635 wm::GetWindowState(window.get())->Maximize(); 634 wm::GetWindowState(window.get())->Maximize();
636 635
637 // Create the manager and make sure that the window gets detected. 636 // Create the manager and make sure that the window gets detected.
638 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 637 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
639 ASSERT_TRUE(manager); 638 ASSERT_TRUE(manager);
640 EXPECT_EQ(1, manager->GetNumberOfManagedWindows()); 639 EXPECT_EQ(1, manager->GetNumberOfManagedWindows());
641 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized()); 640 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized());
642 641
643 // Destroy the manager again and check that the window will remain maximized. 642 // Destroy the manager again and check that the window will remain maximized.
644 DestroyMaximizeModeWindowManager(); 643 DestroyTabletModeWindowManager();
645 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized()); 644 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized());
646 wm::GetWindowState(window.get())->Restore(); 645 wm::GetWindowState(window.get())->Restore();
647 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); 646 EXPECT_EQ(rect.ToString(), window->bounds().ToString());
648 } 647 }
649 648
650 // Test that minimized windows do neither get maximized nor restored upon 649 // Test that minimized windows do neither get maximized nor restored upon
651 // entering maximized mode and get restored to their previous state after 650 // entering tablet mode and get restored to their previous state after
652 // leaving. 651 // leaving.
653 TEST_F(MaximizeModeWindowManagerTest, MinimizedWindowBehavior) { 652 TEST_F(TabletModeWindowManagerTest, MinimizedWindowBehavior) {
654 // Bounds for windows we know can be controlled. 653 // Bounds for windows we know can be controlled.
655 gfx::Rect rect(10, 10, 200, 50); 654 gfx::Rect rect(10, 10, 200, 50);
656 std::unique_ptr<aura::Window> initially_minimized_window( 655 std::unique_ptr<aura::Window> initially_minimized_window(
657 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 656 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
658 std::unique_ptr<aura::Window> initially_normal_window( 657 std::unique_ptr<aura::Window> initially_normal_window(
659 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 658 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
660 std::unique_ptr<aura::Window> initially_maximized_window( 659 std::unique_ptr<aura::Window> initially_maximized_window(
661 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 660 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
662 wm::GetWindowState(initially_minimized_window.get())->Minimize(); 661 wm::GetWindowState(initially_minimized_window.get())->Minimize();
663 wm::GetWindowState(initially_maximized_window.get())->Maximize(); 662 wm::GetWindowState(initially_maximized_window.get())->Maximize();
664 663
665 // Create the manager and make sure that the window gets detected. 664 // Create the manager and make sure that the window gets detected.
666 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 665 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
667 ASSERT_TRUE(manager); 666 ASSERT_TRUE(manager);
668 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 667 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
669 EXPECT_TRUE( 668 EXPECT_TRUE(
670 wm::GetWindowState(initially_minimized_window.get())->IsMinimized()); 669 wm::GetWindowState(initially_minimized_window.get())->IsMinimized());
671 EXPECT_TRUE(wm::GetWindowState(initially_normal_window.get())->IsMaximized()); 670 EXPECT_TRUE(wm::GetWindowState(initially_normal_window.get())->IsMaximized());
672 EXPECT_TRUE( 671 EXPECT_TRUE(
673 wm::GetWindowState(initially_maximized_window.get())->IsMaximized()); 672 wm::GetWindowState(initially_maximized_window.get())->IsMaximized());
674 // Now minimize the second window to check that upon leaving the window 673 // Now minimize the second window to check that upon leaving the window
675 // will get restored to its minimized state. 674 // will get restored to its minimized state.
676 wm::GetWindowState(initially_normal_window.get())->Minimize(); 675 wm::GetWindowState(initially_normal_window.get())->Minimize();
677 wm::GetWindowState(initially_maximized_window.get())->Minimize(); 676 wm::GetWindowState(initially_maximized_window.get())->Minimize();
678 EXPECT_TRUE( 677 EXPECT_TRUE(
679 wm::GetWindowState(initially_minimized_window.get())->IsMinimized()); 678 wm::GetWindowState(initially_minimized_window.get())->IsMinimized());
680 EXPECT_TRUE(wm::GetWindowState(initially_normal_window.get())->IsMinimized()); 679 EXPECT_TRUE(wm::GetWindowState(initially_normal_window.get())->IsMinimized());
681 EXPECT_TRUE( 680 EXPECT_TRUE(
682 wm::GetWindowState(initially_maximized_window.get())->IsMinimized()); 681 wm::GetWindowState(initially_maximized_window.get())->IsMinimized());
683 682
684 // Destroy the manager again and check that the window will get minimized. 683 // Destroy the manager again and check that the window will get minimized.
685 DestroyMaximizeModeWindowManager(); 684 DestroyTabletModeWindowManager();
686 EXPECT_TRUE( 685 EXPECT_TRUE(
687 wm::GetWindowState(initially_minimized_window.get())->IsMinimized()); 686 wm::GetWindowState(initially_minimized_window.get())->IsMinimized());
688 EXPECT_FALSE( 687 EXPECT_FALSE(
689 wm::GetWindowState(initially_normal_window.get())->IsMinimized()); 688 wm::GetWindowState(initially_normal_window.get())->IsMinimized());
690 EXPECT_TRUE( 689 EXPECT_TRUE(
691 wm::GetWindowState(initially_maximized_window.get())->IsMaximized()); 690 wm::GetWindowState(initially_maximized_window.get())->IsMaximized());
692 } 691 }
693 692
694 // Check that resizing the desktop does reposition unmaximizable, unresizable & 693 // Check that resizing the desktop does reposition unmaximizable, unresizable &
695 // managed windows. 694 // managed windows.
696 TEST_F(MaximizeModeWindowManagerTest, DesktopSizeChangeMovesUnmaximizable) { 695 TEST_F(TabletModeWindowManagerTest, DesktopSizeChangeMovesUnmaximizable) {
697 UpdateDisplay("400x400"); 696 UpdateDisplay("400x400");
698 // This window will move because it does not fit the new bounds. 697 // This window will move because it does not fit the new bounds.
699 gfx::Rect rect(20, 300, 100, 100); 698 gfx::Rect rect(20, 300, 100, 100);
700 std::unique_ptr<aura::Window> window1(CreateFixedSizeNonMaximizableWindow( 699 std::unique_ptr<aura::Window> window1(CreateFixedSizeNonMaximizableWindow(
701 aura::client::WINDOW_TYPE_NORMAL, rect)); 700 aura::client::WINDOW_TYPE_NORMAL, rect));
702 EXPECT_EQ(rect.ToString(), window1->bounds().ToString()); 701 EXPECT_EQ(rect.ToString(), window1->bounds().ToString());
703 702
704 // This window will not move because it does fit the new bounds. 703 // This window will not move because it does fit the new bounds.
705 gfx::Rect rect2(20, 140, 100, 100); 704 gfx::Rect rect2(20, 140, 100, 100);
706 std::unique_ptr<aura::Window> window2(CreateFixedSizeNonMaximizableWindow( 705 std::unique_ptr<aura::Window> window2(CreateFixedSizeNonMaximizableWindow(
707 aura::client::WINDOW_TYPE_NORMAL, rect2)); 706 aura::client::WINDOW_TYPE_NORMAL, rect2));
708 707
709 // Turning on the manager will reposition (but not resize) the window. 708 // Turning on the manager will reposition (but not resize) the window.
710 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 709 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
711 ASSERT_TRUE(manager); 710 ASSERT_TRUE(manager);
712 EXPECT_EQ(2, manager->GetNumberOfManagedWindows()); 711 EXPECT_EQ(2, manager->GetNumberOfManagedWindows());
713 gfx::Rect moved_bounds(window1->bounds()); 712 gfx::Rect moved_bounds(window1->bounds());
714 EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString()); 713 EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString());
715 EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString()); 714 EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString());
716 715
717 // Simulating a desktop resize should move the window again. 716 // Simulating a desktop resize should move the window again.
718 UpdateDisplay("300x300"); 717 UpdateDisplay("300x300");
719 gfx::Rect new_moved_bounds(window1->bounds()); 718 gfx::Rect new_moved_bounds(window1->bounds());
720 EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString()); 719 EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString());
721 EXPECT_EQ(rect.size().ToString(), new_moved_bounds.size().ToString()); 720 EXPECT_EQ(rect.size().ToString(), new_moved_bounds.size().ToString());
722 EXPECT_NE(moved_bounds.origin().ToString(), new_moved_bounds.ToString()); 721 EXPECT_NE(moved_bounds.origin().ToString(), new_moved_bounds.ToString());
723 722
724 // Turning off the mode should not restore to the initial coordinates since 723 // Turning off the mode should not restore to the initial coordinates since
725 // the new resolution is smaller and the window was on the edge. 724 // the new resolution is smaller and the window was on the edge.
726 DestroyMaximizeModeWindowManager(); 725 DestroyTabletModeWindowManager();
727 EXPECT_NE(rect.ToString(), window1->bounds().ToString()); 726 EXPECT_NE(rect.ToString(), window1->bounds().ToString());
728 EXPECT_EQ(rect2.ToString(), window2->bounds().ToString()); 727 EXPECT_EQ(rect2.ToString(), window2->bounds().ToString());
729 } 728 }
730 729
731 // Check that windows return to original location if desktop size changes to 730 // Check that windows return to original location if desktop size changes to
732 // something else and back while in maximize mode. 731 // something else and back while in tablet mode.
733 TEST_F(MaximizeModeWindowManagerTest, SizeChangeReturnWindowToOriginalPos) { 732 TEST_F(TabletModeWindowManagerTest, SizeChangeReturnWindowToOriginalPos) {
734 gfx::Rect rect(20, 140, 100, 100); 733 gfx::Rect rect(20, 140, 100, 100);
735 std::unique_ptr<aura::Window> window(CreateFixedSizeNonMaximizableWindow( 734 std::unique_ptr<aura::Window> window(CreateFixedSizeNonMaximizableWindow(
736 aura::client::WINDOW_TYPE_NORMAL, rect)); 735 aura::client::WINDOW_TYPE_NORMAL, rect));
737 736
738 // Turning on the manager will reposition (but not resize) the window. 737 // Turning on the manager will reposition (but not resize) the window.
739 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 738 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
740 ASSERT_TRUE(manager); 739 ASSERT_TRUE(manager);
741 EXPECT_EQ(1, manager->GetNumberOfManagedWindows()); 740 EXPECT_EQ(1, manager->GetNumberOfManagedWindows());
742 gfx::Rect moved_bounds(window->bounds()); 741 gfx::Rect moved_bounds(window->bounds());
743 EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString()); 742 EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString());
744 EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString()); 743 EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString());
745 744
746 // Simulating a desktop resize should move the window again. 745 // Simulating a desktop resize should move the window again.
747 ResizeDesktop(-10); 746 ResizeDesktop(-10);
748 gfx::Rect new_moved_bounds(window->bounds()); 747 gfx::Rect new_moved_bounds(window->bounds());
749 EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString()); 748 EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString());
750 EXPECT_EQ(rect.size().ToString(), new_moved_bounds.size().ToString()); 749 EXPECT_EQ(rect.size().ToString(), new_moved_bounds.size().ToString());
751 EXPECT_NE(moved_bounds.origin().ToString(), new_moved_bounds.ToString()); 750 EXPECT_NE(moved_bounds.origin().ToString(), new_moved_bounds.ToString());
752 751
753 // Then resize back to the original desktop size which should move windows 752 // Then resize back to the original desktop size which should move windows
754 // to their original location after leaving the maximize mode. 753 // to their original location after leaving the tablet mode.
755 ResizeDesktop(10); 754 ResizeDesktop(10);
756 DestroyMaximizeModeWindowManager(); 755 DestroyTabletModeWindowManager();
757 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); 756 EXPECT_EQ(rect.ToString(), window->bounds().ToString());
758 } 757 }
759 758
760 // Check that enabling of the maximize mode does not have an impact on the MRU 759 // Check that enabling of the tablet mode does not have an impact on the MRU
761 // order of windows. 760 // order of windows.
762 TEST_F(MaximizeModeWindowManagerTest, ModeChangeKeepsMRUOrder) { 761 TEST_F(TabletModeWindowManagerTest, ModeChangeKeepsMRUOrder) {
763 gfx::Rect rect(20, 140, 100, 100); 762 gfx::Rect rect(20, 140, 100, 100);
764 std::unique_ptr<aura::Window> w1(CreateFixedSizeNonMaximizableWindow( 763 std::unique_ptr<aura::Window> w1(CreateFixedSizeNonMaximizableWindow(
765 aura::client::WINDOW_TYPE_NORMAL, rect)); 764 aura::client::WINDOW_TYPE_NORMAL, rect));
766 std::unique_ptr<aura::Window> w2( 765 std::unique_ptr<aura::Window> w2(
767 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 766 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
768 std::unique_ptr<aura::Window> w3( 767 std::unique_ptr<aura::Window> w3(
769 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 768 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
770 std::unique_ptr<aura::Window> w4(CreateFixedSizeNonMaximizableWindow( 769 std::unique_ptr<aura::Window> w4(CreateFixedSizeNonMaximizableWindow(
771 aura::client::WINDOW_TYPE_NORMAL, rect)); 770 aura::client::WINDOW_TYPE_NORMAL, rect));
772 std::unique_ptr<aura::Window> w5( 771 std::unique_ptr<aura::Window> w5(
773 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 772 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
774 773
775 // The windows should be in the reverse order of creation in the MRU list. 774 // The windows should be in the reverse order of creation in the MRU list.
776 { 775 {
777 aura::Window::Windows windows = 776 aura::Window::Windows windows =
778 Shell::Get()->mru_window_tracker()->BuildMruWindowList(); 777 Shell::Get()->mru_window_tracker()->BuildMruWindowList();
779 778
780 EXPECT_EQ(w1.get(), windows[4]); 779 EXPECT_EQ(w1.get(), windows[4]);
781 EXPECT_EQ(w2.get(), windows[3]); 780 EXPECT_EQ(w2.get(), windows[3]);
782 EXPECT_EQ(w3.get(), windows[2]); 781 EXPECT_EQ(w3.get(), windows[2]);
783 EXPECT_EQ(w4.get(), windows[1]); 782 EXPECT_EQ(w4.get(), windows[1]);
784 EXPECT_EQ(w5.get(), windows[0]); 783 EXPECT_EQ(w5.get(), windows[0]);
785 } 784 }
786 785
787 // Activating the window manager should keep the order. 786 // Activating the window manager should keep the order.
788 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 787 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
789 ASSERT_TRUE(manager); 788 ASSERT_TRUE(manager);
790 EXPECT_EQ(5, manager->GetNumberOfManagedWindows()); 789 EXPECT_EQ(5, manager->GetNumberOfManagedWindows());
791 { 790 {
792 aura::Window::Windows windows = 791 aura::Window::Windows windows =
793 Shell::Get()->mru_window_tracker()->BuildMruWindowList(); 792 Shell::Get()->mru_window_tracker()->BuildMruWindowList();
794 // We do not test maximization here again since that was done already. 793 // We do not test maximization here again since that was done already.
795 EXPECT_EQ(w1.get(), windows[4]); 794 EXPECT_EQ(w1.get(), windows[4]);
796 EXPECT_EQ(w2.get(), windows[3]); 795 EXPECT_EQ(w2.get(), windows[3]);
797 EXPECT_EQ(w3.get(), windows[2]); 796 EXPECT_EQ(w3.get(), windows[2]);
798 EXPECT_EQ(w4.get(), windows[1]); 797 EXPECT_EQ(w4.get(), windows[1]);
799 EXPECT_EQ(w5.get(), windows[0]); 798 EXPECT_EQ(w5.get(), windows[0]);
800 } 799 }
801 800
802 // Destroying should still keep the order. 801 // Destroying should still keep the order.
803 DestroyMaximizeModeWindowManager(); 802 DestroyTabletModeWindowManager();
804 { 803 {
805 aura::Window::Windows windows = 804 aura::Window::Windows windows =
806 Shell::Get()->mru_window_tracker()->BuildMruWindowList(); 805 Shell::Get()->mru_window_tracker()->BuildMruWindowList();
807 // We do not test maximization here again since that was done already. 806 // We do not test maximization here again since that was done already.
808 EXPECT_EQ(w1.get(), windows[4]); 807 EXPECT_EQ(w1.get(), windows[4]);
809 EXPECT_EQ(w2.get(), windows[3]); 808 EXPECT_EQ(w2.get(), windows[3]);
810 EXPECT_EQ(w3.get(), windows[2]); 809 EXPECT_EQ(w3.get(), windows[2]);
811 EXPECT_EQ(w4.get(), windows[1]); 810 EXPECT_EQ(w4.get(), windows[1]);
812 EXPECT_EQ(w5.get(), windows[0]); 811 EXPECT_EQ(w5.get(), windows[0]);
813 } 812 }
814 } 813 }
815 814
816 // Check that a restore state change does always restore to maximized. 815 // Check that a restore state change does always restore to maximized.
817 TEST_F(MaximizeModeWindowManagerTest, IgnoreRestoreStateChages) { 816 TEST_F(TabletModeWindowManagerTest, IgnoreRestoreStateChages) {
818 gfx::Rect rect(20, 140, 100, 100); 817 gfx::Rect rect(20, 140, 100, 100);
819 std::unique_ptr<aura::Window> w1( 818 std::unique_ptr<aura::Window> w1(
820 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 819 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
821 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 820 wm::WindowState* window_state = wm::GetWindowState(w1.get());
822 CreateMaximizeModeWindowManager(); 821 CreateTabletModeWindowManager();
823 EXPECT_TRUE(window_state->IsMaximized()); 822 EXPECT_TRUE(window_state->IsMaximized());
824 window_state->Minimize(); 823 window_state->Minimize();
825 EXPECT_TRUE(window_state->IsMinimized()); 824 EXPECT_TRUE(window_state->IsMinimized());
826 window_state->Restore(); 825 window_state->Restore();
827 EXPECT_TRUE(window_state->IsMaximized()); 826 EXPECT_TRUE(window_state->IsMaximized());
828 window_state->Restore(); 827 window_state->Restore();
829 EXPECT_TRUE(window_state->IsMaximized()); 828 EXPECT_TRUE(window_state->IsMaximized());
830 DestroyMaximizeModeWindowManager(); 829 DestroyTabletModeWindowManager();
831 } 830 }
832 831
833 // Check that minimize and restore do the right thing. 832 // Check that minimize and restore do the right thing.
834 TEST_F(MaximizeModeWindowManagerTest, TestMinimize) { 833 TEST_F(TabletModeWindowManagerTest, TestMinimize) {
835 gfx::Rect rect(10, 10, 100, 100); 834 gfx::Rect rect(10, 10, 100, 100);
836 std::unique_ptr<aura::Window> window( 835 std::unique_ptr<aura::Window> window(
837 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 836 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
838 wm::WindowState* window_state = wm::GetWindowState(window.get()); 837 wm::WindowState* window_state = wm::GetWindowState(window.get());
839 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); 838 EXPECT_EQ(rect.ToString(), window->bounds().ToString());
840 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 839 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
841 true);
842 EXPECT_TRUE(window_state->IsMaximized()); 840 EXPECT_TRUE(window_state->IsMaximized());
843 EXPECT_FALSE(window_state->IsMinimized()); 841 EXPECT_FALSE(window_state->IsMinimized());
844 EXPECT_TRUE(window->IsVisible()); 842 EXPECT_TRUE(window->IsVisible());
845 843
846 window_state->Minimize(); 844 window_state->Minimize();
847 EXPECT_FALSE(window_state->IsMaximized()); 845 EXPECT_FALSE(window_state->IsMaximized());
848 EXPECT_TRUE(window_state->IsMinimized()); 846 EXPECT_TRUE(window_state->IsMinimized());
849 EXPECT_FALSE(window->IsVisible()); 847 EXPECT_FALSE(window->IsVisible());
850 848
851 window_state->Maximize(); 849 window_state->Maximize();
852 EXPECT_TRUE(window_state->IsMaximized()); 850 EXPECT_TRUE(window_state->IsMaximized());
853 EXPECT_FALSE(window_state->IsMinimized()); 851 EXPECT_FALSE(window_state->IsMinimized());
854 EXPECT_TRUE(window->IsVisible()); 852 EXPECT_TRUE(window->IsVisible());
855 853
856 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 854 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false);
857 false);
858 EXPECT_FALSE(window_state->IsMaximized()); 855 EXPECT_FALSE(window_state->IsMaximized());
859 EXPECT_FALSE(window_state->IsMinimized()); 856 EXPECT_FALSE(window_state->IsMinimized());
860 EXPECT_TRUE(window->IsVisible()); 857 EXPECT_TRUE(window->IsVisible());
861 } 858 }
862 859
863 // Check that a full screen window remains full screen upon entering maximize 860 // Check that a full screen window remains full screen upon entering maximize
864 // mode. Furthermore, checks that this window is not full screen upon exiting 861 // mode. Furthermore, checks that this window is not full screen upon exiting
865 // maximize mode if it was un-full-screened while in maximize mode. 862 // tablet mode if it was un-full-screened while in tablet mode.
866 TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) { 863 TEST_F(TabletModeWindowManagerTest, KeepFullScreenModeOn) {
867 gfx::Rect rect(20, 140, 100, 100); 864 gfx::Rect rect(20, 140, 100, 100);
868 std::unique_ptr<aura::Window> w1( 865 std::unique_ptr<aura::Window> w1(
869 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 866 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
870 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 867 wm::WindowState* window_state = wm::GetWindowState(w1.get());
871 868
872 Shelf* shelf = GetPrimaryShelf(); 869 Shelf* shelf = GetPrimaryShelf();
873 870
874 // Allow the shelf to hide. 871 // Allow the shelf to hide.
875 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 872 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
876 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 873 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
877 874
878 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 875 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
879 window_state->OnWMEvent(&event); 876 window_state->OnWMEvent(&event);
880 877
881 // With full screen, the shelf should get hidden. 878 // With full screen, the shelf should get hidden.
882 EXPECT_TRUE(window_state->IsFullscreen()); 879 EXPECT_TRUE(window_state->IsFullscreen());
883 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); 880 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
884 881
885 CreateMaximizeModeWindowManager(); 882 CreateTabletModeWindowManager();
886 883
887 // The Full screen mode should continue to be on. 884 // The Full screen mode should continue to be on.
888 EXPECT_TRUE(window_state->IsFullscreen()); 885 EXPECT_TRUE(window_state->IsFullscreen());
889 EXPECT_FALSE(window_state->IsMaximized()); 886 EXPECT_FALSE(window_state->IsMaximized());
890 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); 887 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
891 888
892 // With leaving the fullscreen mode, the maximized mode should return and the 889 // With leaving the fullscreen mode, the tablet mode should return and the
893 // shelf should maintain its state from before maximize mode. 890 // shelf should maintain its state from before tablet mode.
894 window_state->OnWMEvent(&event); 891 window_state->OnWMEvent(&event);
895 EXPECT_FALSE(window_state->IsFullscreen()); 892 EXPECT_FALSE(window_state->IsFullscreen());
896 EXPECT_TRUE(window_state->IsMaximized()); 893 EXPECT_TRUE(window_state->IsMaximized());
897 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 894 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
898 895
899 // We left fullscreen mode while in maximize mode, so the window should 896 // We left fullscreen mode while in tablet mode, so the window should
900 // remain maximized and the shelf should not change state upon exiting 897 // remain maximized and the shelf should not change state upon exiting
901 // maximize mode. 898 // tablet mode.
902 DestroyMaximizeModeWindowManager(); 899 DestroyTabletModeWindowManager();
903 EXPECT_FALSE(window_state->IsFullscreen()); 900 EXPECT_FALSE(window_state->IsFullscreen());
904 EXPECT_TRUE(window_state->IsMaximized()); 901 EXPECT_TRUE(window_state->IsMaximized());
905 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 902 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
906 } 903 }
907 904
908 // Similar to the fullscreen mode, the pinned mode should be kept as well. 905 // Similar to the fullscreen mode, the pinned mode should be kept as well.
909 TEST_F(MaximizeModeWindowManagerTest, KeepPinnedModeOn_Case1) { 906 TEST_F(TabletModeWindowManagerTest, KeepPinnedModeOn_Case1) {
910 // Scenario: in the default state, pin a window, enter to the maximized mode, 907 // Scenario: in the default state, pin a window, enter to the tablet mode,
911 // then unpin. 908 // then unpin.
912 gfx::Rect rect(20, 140, 100, 100); 909 gfx::Rect rect(20, 140, 100, 100);
913 std::unique_ptr<aura::Window> w1( 910 std::unique_ptr<aura::Window> w1(
914 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 911 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
915 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 912 wm::WindowState* window_state = wm::GetWindowState(w1.get());
916 EXPECT_FALSE(window_state->IsPinned()); 913 EXPECT_FALSE(window_state->IsPinned());
917 914
918 // Pin the window. 915 // Pin the window.
919 { 916 {
920 wm::WMEvent event(wm::WM_EVENT_PIN); 917 wm::WMEvent event(wm::WM_EVENT_PIN);
921 window_state->OnWMEvent(&event); 918 window_state->OnWMEvent(&event);
922 } 919 }
923 EXPECT_TRUE(window_state->IsPinned()); 920 EXPECT_TRUE(window_state->IsPinned());
924 921
925 // Enter to Maximized mode. 922 // Enter to Maximized mode.
926 // The pinned mode should continue to be on. 923 // The pinned mode should continue to be on.
927 CreateMaximizeModeWindowManager(); 924 CreateTabletModeWindowManager();
928 EXPECT_TRUE(window_state->IsPinned()); 925 EXPECT_TRUE(window_state->IsPinned());
929 926
930 // Then unpin. 927 // Then unpin.
931 window_state->Restore(); 928 window_state->Restore();
932 EXPECT_FALSE(window_state->IsPinned()); 929 EXPECT_FALSE(window_state->IsPinned());
933 930
934 // Exit from Maximized mode. 931 // Exit from Maximized mode.
935 // The window should not be back to the pinned mode. 932 // The window should not be back to the pinned mode.
936 DestroyMaximizeModeWindowManager(); 933 DestroyTabletModeWindowManager();
937 EXPECT_FALSE(window_state->IsPinned()); 934 EXPECT_FALSE(window_state->IsPinned());
938 } 935 }
939 936
940 TEST_F(MaximizeModeWindowManagerTest, KeepPinnedModeOn_Case2) { 937 TEST_F(TabletModeWindowManagerTest, KeepPinnedModeOn_Case2) {
941 // Scenario: in the maximized mode, pin a window, exit from the maximized 938 // Scenario: in the tablet mode, pin a window, exit from the maximized
942 // mode, then unpin. 939 // mode, then unpin.
943 gfx::Rect rect(20, 140, 100, 100); 940 gfx::Rect rect(20, 140, 100, 100);
944 std::unique_ptr<aura::Window> w1( 941 std::unique_ptr<aura::Window> w1(
945 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 942 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
946 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 943 wm::WindowState* window_state = wm::GetWindowState(w1.get());
947 EXPECT_FALSE(window_state->IsPinned()); 944 EXPECT_FALSE(window_state->IsPinned());
948 945
949 // Enter to Maximized mode. 946 // Enter to Maximized mode.
950 CreateMaximizeModeWindowManager(); 947 CreateTabletModeWindowManager();
951 EXPECT_FALSE(window_state->IsPinned()); 948 EXPECT_FALSE(window_state->IsPinned());
952 949
953 // Pin the window. 950 // Pin the window.
954 { 951 {
955 wm::WMEvent event(wm::WM_EVENT_PIN); 952 wm::WMEvent event(wm::WM_EVENT_PIN);
956 window_state->OnWMEvent(&event); 953 window_state->OnWMEvent(&event);
957 } 954 }
958 EXPECT_TRUE(window_state->IsPinned()); 955 EXPECT_TRUE(window_state->IsPinned());
959 956
960 // Exit from Maximized mode. 957 // Exit from Maximized mode.
961 // The pinned mode should continue to be on. 958 // The pinned mode should continue to be on.
962 DestroyMaximizeModeWindowManager(); 959 DestroyTabletModeWindowManager();
963 EXPECT_TRUE(window_state->IsPinned()); 960 EXPECT_TRUE(window_state->IsPinned());
964 961
965 // Then unpin. 962 // Then unpin.
966 window_state->Restore(); 963 window_state->Restore();
967 EXPECT_FALSE(window_state->IsPinned()); 964 EXPECT_FALSE(window_state->IsPinned());
968 965
969 // Enter again to Maximized mode for verification. 966 // Enter again to Maximized mode for verification.
970 // The window should not be back to the pinned mode. 967 // The window should not be back to the pinned mode.
971 CreateMaximizeModeWindowManager(); 968 CreateTabletModeWindowManager();
972 EXPECT_FALSE(window_state->IsPinned()); 969 EXPECT_FALSE(window_state->IsPinned());
973 970
974 // Exit from Maximized mode. 971 // Exit from Maximized mode.
975 DestroyMaximizeModeWindowManager(); 972 DestroyTabletModeWindowManager();
976 EXPECT_FALSE(window_state->IsPinned()); 973 EXPECT_FALSE(window_state->IsPinned());
977 } 974 }
978 975
979 TEST_F(MaximizeModeWindowManagerTest, KeepPinnedModeOn_Case3) { 976 TEST_F(TabletModeWindowManagerTest, KeepPinnedModeOn_Case3) {
980 // Scenario: in the default state, pin a window, enter to the maximized mode, 977 // Scenario: in the default state, pin a window, enter to the tablet mode,
981 // exit from the maximized mode, then unpin. 978 // exit from the tablet mode, then unpin.
982 gfx::Rect rect(20, 140, 100, 100); 979 gfx::Rect rect(20, 140, 100, 100);
983 std::unique_ptr<aura::Window> w1( 980 std::unique_ptr<aura::Window> w1(
984 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 981 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
985 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 982 wm::WindowState* window_state = wm::GetWindowState(w1.get());
986 EXPECT_FALSE(window_state->IsPinned()); 983 EXPECT_FALSE(window_state->IsPinned());
987 984
988 // Pin the window. 985 // Pin the window.
989 { 986 {
990 wm::WMEvent event(wm::WM_EVENT_PIN); 987 wm::WMEvent event(wm::WM_EVENT_PIN);
991 window_state->OnWMEvent(&event); 988 window_state->OnWMEvent(&event);
992 } 989 }
993 EXPECT_TRUE(window_state->IsPinned()); 990 EXPECT_TRUE(window_state->IsPinned());
994 991
995 // Enter to Maximized mode. 992 // Enter to Maximized mode.
996 // The pinned mode should continue to be on. 993 // The pinned mode should continue to be on.
997 CreateMaximizeModeWindowManager(); 994 CreateTabletModeWindowManager();
998 EXPECT_TRUE(window_state->IsPinned()); 995 EXPECT_TRUE(window_state->IsPinned());
999 996
1000 // Exit from Maximized mode. 997 // Exit from Maximized mode.
1001 // The pinned mode should continue to be on, too. 998 // The pinned mode should continue to be on, too.
1002 DestroyMaximizeModeWindowManager(); 999 DestroyTabletModeWindowManager();
1003 EXPECT_TRUE(window_state->IsPinned()); 1000 EXPECT_TRUE(window_state->IsPinned());
1004 1001
1005 // Then unpin. 1002 // Then unpin.
1006 window_state->Restore(); 1003 window_state->Restore();
1007 EXPECT_FALSE(window_state->IsPinned()); 1004 EXPECT_FALSE(window_state->IsPinned());
1008 1005
1009 // Enter again to Maximized mode for verification. 1006 // Enter again to Maximized mode for verification.
1010 // The window should not be back to the pinned mode. 1007 // The window should not be back to the pinned mode.
1011 CreateMaximizeModeWindowManager(); 1008 CreateTabletModeWindowManager();
1012 EXPECT_FALSE(window_state->IsPinned()); 1009 EXPECT_FALSE(window_state->IsPinned());
1013 1010
1014 // Exit from Maximized mode. 1011 // Exit from Maximized mode.
1015 DestroyMaximizeModeWindowManager(); 1012 DestroyTabletModeWindowManager();
1016 } 1013 }
1017 1014
1018 TEST_F(MaximizeModeWindowManagerTest, KeepPinnedModeOn_Case4) { 1015 TEST_F(TabletModeWindowManagerTest, KeepPinnedModeOn_Case4) {
1019 // Scenario: in the maximized mode, pin a window, exit from the maximized 1016 // Scenario: in the tablet mode, pin a window, exit from the maximized
1020 // mode, enter back to the maximized mode, then unpin. 1017 // mode, enter back to the tablet mode, then unpin.
1021 gfx::Rect rect(20, 140, 100, 100); 1018 gfx::Rect rect(20, 140, 100, 100);
1022 std::unique_ptr<aura::Window> w1( 1019 std::unique_ptr<aura::Window> w1(
1023 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1020 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1024 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 1021 wm::WindowState* window_state = wm::GetWindowState(w1.get());
1025 EXPECT_FALSE(window_state->IsPinned()); 1022 EXPECT_FALSE(window_state->IsPinned());
1026 1023
1027 // Enter to Maximized mode. 1024 // Enter to Maximized mode.
1028 CreateMaximizeModeWindowManager(); 1025 CreateTabletModeWindowManager();
1029 EXPECT_FALSE(window_state->IsPinned()); 1026 EXPECT_FALSE(window_state->IsPinned());
1030 1027
1031 // Pin the window. 1028 // Pin the window.
1032 { 1029 {
1033 wm::WMEvent event(wm::WM_EVENT_PIN); 1030 wm::WMEvent event(wm::WM_EVENT_PIN);
1034 window_state->OnWMEvent(&event); 1031 window_state->OnWMEvent(&event);
1035 } 1032 }
1036 EXPECT_TRUE(window_state->IsPinned()); 1033 EXPECT_TRUE(window_state->IsPinned());
1037 1034
1038 // Exit from Maximized mode. 1035 // Exit from Maximized mode.
1039 // The pinned mode should continue to be on. 1036 // The pinned mode should continue to be on.
1040 DestroyMaximizeModeWindowManager(); 1037 DestroyTabletModeWindowManager();
1041 EXPECT_TRUE(window_state->IsPinned()); 1038 EXPECT_TRUE(window_state->IsPinned());
1042 1039
1043 // Enter again to Maximized mode. 1040 // Enter again to Maximized mode.
1044 // The pinned mode should continue to be on, too. 1041 // The pinned mode should continue to be on, too.
1045 CreateMaximizeModeWindowManager(); 1042 CreateTabletModeWindowManager();
1046 EXPECT_TRUE(window_state->IsPinned()); 1043 EXPECT_TRUE(window_state->IsPinned());
1047 1044
1048 // Then unpin. 1045 // Then unpin.
1049 window_state->Restore(); 1046 window_state->Restore();
1050 EXPECT_FALSE(window_state->IsPinned()); 1047 EXPECT_FALSE(window_state->IsPinned());
1051 1048
1052 // Exit from Maximized mode. 1049 // Exit from Maximized mode.
1053 // The window should not be back to the pinned mode. 1050 // The window should not be back to the pinned mode.
1054 DestroyMaximizeModeWindowManager(); 1051 DestroyTabletModeWindowManager();
1055 EXPECT_FALSE(window_state->IsPinned()); 1052 EXPECT_FALSE(window_state->IsPinned());
1056 } 1053 }
1057 1054
1058 // Verifies that if a window is un-full-screened while in maximize mode, 1055 // Verifies that if a window is un-full-screened while in tablet mode,
1059 // other changes to that window's state (such as minimizing it) are 1056 // other changes to that window's state (such as minimizing it) are
1060 // preserved upon exiting maximize mode. 1057 // preserved upon exiting tablet mode.
1061 TEST_F(MaximizeModeWindowManagerTest, MinimizePreservedAfterLeavingFullscreen) { 1058 TEST_F(TabletModeWindowManagerTest, MinimizePreservedAfterLeavingFullscreen) {
1062 gfx::Rect rect(20, 140, 100, 100); 1059 gfx::Rect rect(20, 140, 100, 100);
1063 std::unique_ptr<aura::Window> w1( 1060 std::unique_ptr<aura::Window> w1(
1064 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1061 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1065 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 1062 wm::WindowState* window_state = wm::GetWindowState(w1.get());
1066 1063
1067 Shelf* shelf = GetPrimaryShelf(); 1064 Shelf* shelf = GetPrimaryShelf();
1068 1065
1069 // Allow the shelf to hide and enter full screen. 1066 // Allow the shelf to hide and enter full screen.
1070 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1067 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1071 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 1068 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
1072 window_state->OnWMEvent(&event); 1069 window_state->OnWMEvent(&event);
1073 ASSERT_FALSE(window_state->IsMinimized()); 1070 ASSERT_FALSE(window_state->IsMinimized());
1074 1071
1075 // Enter maximize mode, exit full screen, and then minimize the window. 1072 // Enter tablet mode, exit full screen, and then minimize the window.
1076 CreateMaximizeModeWindowManager(); 1073 CreateTabletModeWindowManager();
1077 window_state->OnWMEvent(&event); 1074 window_state->OnWMEvent(&event);
1078 window_state->Minimize(); 1075 window_state->Minimize();
1079 ASSERT_TRUE(window_state->IsMinimized()); 1076 ASSERT_TRUE(window_state->IsMinimized());
1080 1077
1081 // The window should remain minimized when exiting maximize mode. 1078 // The window should remain minimized when exiting tablet mode.
1082 DestroyMaximizeModeWindowManager(); 1079 DestroyTabletModeWindowManager();
1083 EXPECT_TRUE(window_state->IsMinimized()); 1080 EXPECT_TRUE(window_state->IsMinimized());
1084 } 1081 }
1085 1082
1086 // Check that full screen mode can be turned on in maximized mode and remains 1083 // Check that full screen mode can be turned on in tablet mode and remains
1087 // upon coming back. 1084 // upon coming back.
1088 TEST_F(MaximizeModeWindowManagerTest, AllowFullScreenMode) { 1085 TEST_F(TabletModeWindowManagerTest, AllowFullScreenMode) {
1089 gfx::Rect rect(20, 140, 100, 100); 1086 gfx::Rect rect(20, 140, 100, 100);
1090 std::unique_ptr<aura::Window> w1( 1087 std::unique_ptr<aura::Window> w1(
1091 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1088 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1092 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 1089 wm::WindowState* window_state = wm::GetWindowState(w1.get());
1093 1090
1094 Shelf* shelf = GetPrimaryShelf(); 1091 Shelf* shelf = GetPrimaryShelf();
1095 1092
1096 // Allow the shelf to hide. 1093 // Allow the shelf to hide.
1097 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 1094 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
1098 1095
1099 EXPECT_FALSE(window_state->IsFullscreen()); 1096 EXPECT_FALSE(window_state->IsFullscreen());
1100 EXPECT_FALSE(window_state->IsMaximized()); 1097 EXPECT_FALSE(window_state->IsMaximized());
1101 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1098 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1102 1099
1103 CreateMaximizeModeWindowManager(); 1100 CreateTabletModeWindowManager();
1104 1101
1105 // Fullscreen mode should still be off and the shelf should maintain its 1102 // Fullscreen mode should still be off and the shelf should maintain its
1106 // state. 1103 // state.
1107 EXPECT_FALSE(window_state->IsFullscreen()); 1104 EXPECT_FALSE(window_state->IsFullscreen());
1108 EXPECT_TRUE(window_state->IsMaximized()); 1105 EXPECT_TRUE(window_state->IsMaximized());
1109 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState()); 1106 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
1110 1107
1111 // After going into fullscreen mode, the shelf should be hidden. 1108 // After going into fullscreen mode, the shelf should be hidden.
1112 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 1109 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
1113 window_state->OnWMEvent(&event); 1110 window_state->OnWMEvent(&event);
1114 EXPECT_TRUE(window_state->IsFullscreen()); 1111 EXPECT_TRUE(window_state->IsFullscreen());
1115 EXPECT_FALSE(window_state->IsMaximized()); 1112 EXPECT_FALSE(window_state->IsMaximized());
1116 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); 1113 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
1117 1114
1118 // With the destruction of the manager we should remain in full screen. 1115 // With the destruction of the manager we should remain in full screen.
1119 DestroyMaximizeModeWindowManager(); 1116 DestroyTabletModeWindowManager();
1120 EXPECT_TRUE(window_state->IsFullscreen()); 1117 EXPECT_TRUE(window_state->IsFullscreen());
1121 EXPECT_FALSE(window_state->IsMaximized()); 1118 EXPECT_FALSE(window_state->IsMaximized());
1122 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState()); 1119 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
1123 } 1120 }
1124 1121
1125 // Check that the full screen mode will stay active when the maximize mode is 1122 // Check that the full screen mode will stay active when the tablet mode is
1126 // ended. 1123 // ended.
1127 TEST_F(MaximizeModeWindowManagerTest, 1124 TEST_F(TabletModeWindowManagerTest,
1128 FullScreenModeRemainsWhenCreatedInMaximizedMode) { 1125 FullScreenModeRemainsWhenCreatedInMaximizedMode) {
1129 CreateMaximizeModeWindowManager(); 1126 CreateTabletModeWindowManager();
1130 1127
1131 gfx::Rect rect(20, 140, 100, 100); 1128 gfx::Rect rect(20, 140, 100, 100);
1132 std::unique_ptr<aura::Window> w1( 1129 std::unique_ptr<aura::Window> w1(
1133 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1130 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1134 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 1131 wm::WindowState* window_state = wm::GetWindowState(w1.get());
1135 wm::WMEvent event_full_screen(wm::WM_EVENT_TOGGLE_FULLSCREEN); 1132 wm::WMEvent event_full_screen(wm::WM_EVENT_TOGGLE_FULLSCREEN);
1136 window_state->OnWMEvent(&event_full_screen); 1133 window_state->OnWMEvent(&event_full_screen);
1137 EXPECT_TRUE(window_state->IsFullscreen()); 1134 EXPECT_TRUE(window_state->IsFullscreen());
1138 1135
1139 // After the maximize mode manager is ended, full screen will remain. 1136 // After the tablet mode manager is ended, full screen will remain.
1140 DestroyMaximizeModeWindowManager(); 1137 DestroyTabletModeWindowManager();
1141 EXPECT_TRUE(window_state->IsFullscreen()); 1138 EXPECT_TRUE(window_state->IsFullscreen());
1142 } 1139 }
1143 1140
1144 // Check that the full screen mode will stay active throughout a maximzied mode 1141 // Check that the full screen mode will stay active throughout a maximzied mode
1145 // session. 1142 // session.
1146 TEST_F(MaximizeModeWindowManagerTest, 1143 TEST_F(TabletModeWindowManagerTest,
1147 FullScreenModeRemainsThroughMaximizeModeSwitch) { 1144 FullScreenModeRemainsThroughTabletModeSwitch) {
1148 gfx::Rect rect(20, 140, 100, 100); 1145 gfx::Rect rect(20, 140, 100, 100);
1149 std::unique_ptr<aura::Window> w1( 1146 std::unique_ptr<aura::Window> w1(
1150 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1147 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1151 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 1148 wm::WindowState* window_state = wm::GetWindowState(w1.get());
1152 wm::WMEvent event_full_screen(wm::WM_EVENT_TOGGLE_FULLSCREEN); 1149 wm::WMEvent event_full_screen(wm::WM_EVENT_TOGGLE_FULLSCREEN);
1153 window_state->OnWMEvent(&event_full_screen); 1150 window_state->OnWMEvent(&event_full_screen);
1154 EXPECT_TRUE(window_state->IsFullscreen()); 1151 EXPECT_TRUE(window_state->IsFullscreen());
1155 1152
1156 CreateMaximizeModeWindowManager(); 1153 CreateTabletModeWindowManager();
1157 EXPECT_TRUE(window_state->IsFullscreen()); 1154 EXPECT_TRUE(window_state->IsFullscreen());
1158 DestroyMaximizeModeWindowManager(); 1155 DestroyTabletModeWindowManager();
1159 EXPECT_TRUE(window_state->IsFullscreen()); 1156 EXPECT_TRUE(window_state->IsFullscreen());
1160 } 1157 }
1161 1158
1162 // Check that an empty window does not get restored to a tiny size. 1159 // Check that an empty window does not get restored to a tiny size.
1163 TEST_F(MaximizeModeWindowManagerTest, 1160 TEST_F(TabletModeWindowManagerTest,
1164 CreateAndMaximizeInMaximizeModeShouldRetoreToGoodSizeGoingToDefault) { 1161 CreateAndMaximizeInTabletModeShouldRetoreToGoodSizeGoingToDefault) {
1165 CreateMaximizeModeWindowManager(); 1162 CreateTabletModeWindowManager();
1166 gfx::Rect rect; 1163 gfx::Rect rect;
1167 std::unique_ptr<aura::Window> w1( 1164 std::unique_ptr<aura::Window> w1(
1168 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1165 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1169 w1->Show(); 1166 w1->Show();
1170 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 1167 wm::WindowState* window_state = wm::GetWindowState(w1.get());
1171 EXPECT_TRUE(window_state->IsMaximized()); 1168 EXPECT_TRUE(window_state->IsMaximized());
1172 1169
1173 // There is a calling order in which the restore bounds can get set to an 1170 // There is a calling order in which the restore bounds can get set to an
1174 // empty rectangle. We simulate this here. 1171 // empty rectangle. We simulate this here.
1175 window_state->SetRestoreBoundsInScreen(rect); 1172 window_state->SetRestoreBoundsInScreen(rect);
1176 EXPECT_TRUE(window_state->GetRestoreBoundsInScreen().IsEmpty()); 1173 EXPECT_TRUE(window_state->GetRestoreBoundsInScreen().IsEmpty());
1177 1174
1178 // Setting the window to a new size will physically not change the window, 1175 // Setting the window to a new size will physically not change the window,
1179 // but the restore size should get updated so that a restore later on will 1176 // but the restore size should get updated so that a restore later on will
1180 // return to this size. 1177 // return to this size.
1181 gfx::Rect requested_bounds(10, 20, 50, 70); 1178 gfx::Rect requested_bounds(10, 20, 50, 70);
1182 w1->SetBounds(requested_bounds); 1179 w1->SetBounds(requested_bounds);
1183 EXPECT_TRUE(window_state->IsMaximized()); 1180 EXPECT_TRUE(window_state->IsMaximized());
1184 EXPECT_EQ(requested_bounds.ToString(), 1181 EXPECT_EQ(requested_bounds.ToString(),
1185 window_state->GetRestoreBoundsInScreen().ToString()); 1182 window_state->GetRestoreBoundsInScreen().ToString());
1186 1183
1187 DestroyMaximizeModeWindowManager(); 1184 DestroyTabletModeWindowManager();
1188 1185
1189 EXPECT_FALSE(window_state->IsMaximized()); 1186 EXPECT_FALSE(window_state->IsMaximized());
1190 EXPECT_EQ(w1->bounds().ToString(), requested_bounds.ToString()); 1187 EXPECT_EQ(w1->bounds().ToString(), requested_bounds.ToString());
1191 } 1188 }
1192 1189
1193 // Check that snapping operations get ignored. 1190 // Check that snapping operations get ignored.
1194 TEST_F(MaximizeModeWindowManagerTest, SnapModeTests) { 1191 TEST_F(TabletModeWindowManagerTest, SnapModeTests) {
1195 gfx::Rect rect(20, 140, 100, 100); 1192 gfx::Rect rect(20, 140, 100, 100);
1196 std::unique_ptr<aura::Window> w1( 1193 std::unique_ptr<aura::Window> w1(
1197 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1194 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1198 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 1195 wm::WindowState* window_state = wm::GetWindowState(w1.get());
1199 wm::WMEvent event_left(wm::WM_EVENT_SNAP_LEFT); 1196 wm::WMEvent event_left(wm::WM_EVENT_SNAP_LEFT);
1200 wm::WMEvent event_right(wm::WM_EVENT_SNAP_RIGHT); 1197 wm::WMEvent event_right(wm::WM_EVENT_SNAP_RIGHT);
1201 window_state->OnWMEvent(&event_left); 1198 window_state->OnWMEvent(&event_left);
1202 EXPECT_TRUE(window_state->IsSnapped()); 1199 EXPECT_TRUE(window_state->IsSnapped());
1203 1200
1204 CreateMaximizeModeWindowManager(); 1201 CreateTabletModeWindowManager();
1205 1202
1206 // Fullscreen mode should now be off and it should not come back while in 1203 // Fullscreen mode should now be off and it should not come back while in
1207 // maximize mode. 1204 // tablet mode.
1208 EXPECT_FALSE(window_state->IsSnapped()); 1205 EXPECT_FALSE(window_state->IsSnapped());
1209 EXPECT_TRUE(window_state->IsMaximized()); 1206 EXPECT_TRUE(window_state->IsMaximized());
1210 window_state->OnWMEvent(&event_left); 1207 window_state->OnWMEvent(&event_left);
1211 EXPECT_FALSE(window_state->IsSnapped()); 1208 EXPECT_FALSE(window_state->IsSnapped());
1212 EXPECT_TRUE(window_state->IsMaximized()); 1209 EXPECT_TRUE(window_state->IsMaximized());
1213 window_state->OnWMEvent(&event_right); 1210 window_state->OnWMEvent(&event_right);
1214 EXPECT_FALSE(window_state->IsSnapped()); 1211 EXPECT_FALSE(window_state->IsSnapped());
1215 EXPECT_TRUE(window_state->IsMaximized()); 1212 EXPECT_TRUE(window_state->IsMaximized());
1216 1213
1217 DestroyMaximizeModeWindowManager(); 1214 DestroyTabletModeWindowManager();
1218 EXPECT_TRUE(window_state->IsSnapped()); 1215 EXPECT_TRUE(window_state->IsSnapped());
1219 } 1216 }
1220 1217
1221 // Check that non maximizable windows cannot be dragged by the user. 1218 // Check that non maximizable windows cannot be dragged by the user.
1222 TEST_F(MaximizeModeWindowManagerTest, TryToDesktopSizeDragUnmaximizable) { 1219 TEST_F(TabletModeWindowManagerTest, TryToDesktopSizeDragUnmaximizable) {
1223 gfx::Rect rect(10, 10, 100, 100); 1220 gfx::Rect rect(10, 10, 100, 100);
1224 std::unique_ptr<aura::Window> window(CreateFixedSizeNonMaximizableWindow( 1221 std::unique_ptr<aura::Window> window(CreateFixedSizeNonMaximizableWindow(
1225 aura::client::WINDOW_TYPE_NORMAL, rect)); 1222 aura::client::WINDOW_TYPE_NORMAL, rect));
1226 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); 1223 EXPECT_EQ(rect.ToString(), window->bounds().ToString());
1227 1224
1228 // 1. Move the mouse over the caption and check that dragging the window does 1225 // 1. Move the mouse over the caption and check that dragging the window does
1229 // change the location. 1226 // change the location.
1230 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 1227 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
1231 generator.MoveMouseTo(gfx::Point(rect.x() + 2, rect.y() + 2)); 1228 generator.MoveMouseTo(gfx::Point(rect.x() + 2, rect.y() + 2));
1232 generator.PressLeftButton(); 1229 generator.PressLeftButton();
1233 generator.MoveMouseBy(10, 5); 1230 generator.MoveMouseBy(10, 5);
1234 RunAllPendingInMessageLoop(); 1231 RunAllPendingInMessageLoop();
1235 generator.ReleaseLeftButton(); 1232 generator.ReleaseLeftButton();
1236 gfx::Point first_dragged_origin = window->bounds().origin(); 1233 gfx::Point first_dragged_origin = window->bounds().origin();
1237 EXPECT_EQ(rect.x() + 10, first_dragged_origin.x()); 1234 EXPECT_EQ(rect.x() + 10, first_dragged_origin.x());
1238 EXPECT_EQ(rect.y() + 5, first_dragged_origin.y()); 1235 EXPECT_EQ(rect.y() + 5, first_dragged_origin.y());
1239 1236
1240 // 2. Check that turning on the manager will stop allowing the window from 1237 // 2. Check that turning on the manager will stop allowing the window from
1241 // dragging. 1238 // dragging.
1242 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 1239 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
1243 true);
1244 gfx::Rect center_bounds(window->bounds()); 1240 gfx::Rect center_bounds(window->bounds());
1245 EXPECT_NE(rect.origin().ToString(), center_bounds.origin().ToString()); 1241 EXPECT_NE(rect.origin().ToString(), center_bounds.origin().ToString());
1246 generator.MoveMouseTo( 1242 generator.MoveMouseTo(
1247 gfx::Point(center_bounds.x() + 1, center_bounds.y() + 1)); 1243 gfx::Point(center_bounds.x() + 1, center_bounds.y() + 1));
1248 generator.PressLeftButton(); 1244 generator.PressLeftButton();
1249 generator.MoveMouseBy(10, 5); 1245 generator.MoveMouseBy(10, 5);
1250 RunAllPendingInMessageLoop(); 1246 RunAllPendingInMessageLoop();
1251 generator.ReleaseLeftButton(); 1247 generator.ReleaseLeftButton();
1252 EXPECT_EQ(center_bounds.x(), window->bounds().x()); 1248 EXPECT_EQ(center_bounds.x(), window->bounds().x());
1253 EXPECT_EQ(center_bounds.y(), window->bounds().y()); 1249 EXPECT_EQ(center_bounds.y(), window->bounds().y());
1254 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 1250 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false);
1255 false);
1256 1251
1257 // 3. Releasing the mazimize manager again will restore the window to its 1252 // 3. Releasing the mazimize manager again will restore the window to its
1258 // previous bounds and 1253 // previous bounds and
1259 generator.MoveMouseTo( 1254 generator.MoveMouseTo(
1260 gfx::Point(first_dragged_origin.x() + 1, first_dragged_origin.y() + 1)); 1255 gfx::Point(first_dragged_origin.x() + 1, first_dragged_origin.y() + 1));
1261 generator.PressLeftButton(); 1256 generator.PressLeftButton();
1262 generator.MoveMouseBy(10, 5); 1257 generator.MoveMouseBy(10, 5);
1263 RunAllPendingInMessageLoop(); 1258 RunAllPendingInMessageLoop();
1264 generator.ReleaseLeftButton(); 1259 generator.ReleaseLeftButton();
1265 EXPECT_EQ(first_dragged_origin.x() + 10, window->bounds().x()); 1260 EXPECT_EQ(first_dragged_origin.x() + 10, window->bounds().x());
1266 EXPECT_EQ(first_dragged_origin.y() + 5, window->bounds().y()); 1261 EXPECT_EQ(first_dragged_origin.y() + 5, window->bounds().y());
1267 } 1262 }
1268 1263
1269 // Test that overview is exited before entering / exiting maximize mode so that 1264 // Test that overview is exited before entering / exiting tablet mode so that
1270 // the window changes made by MaximizeModeWindowManager do not conflict with 1265 // the window changes made by TabletModeWindowManager do not conflict with
1271 // those made in WindowOverview. 1266 // those made in WindowOverview.
1272 TEST_F(MaximizeModeWindowManagerTest, ExitsOverview) { 1267 TEST_F(TabletModeWindowManagerTest, ExitsOverview) {
1273 // Bounds for windows we know can be controlled. 1268 // Bounds for windows we know can be controlled.
1274 gfx::Rect rect1(10, 10, 200, 50); 1269 gfx::Rect rect1(10, 10, 200, 50);
1275 gfx::Rect rect2(10, 60, 200, 50); 1270 gfx::Rect rect2(10, 60, 200, 50);
1276 std::unique_ptr<aura::Window> w1( 1271 std::unique_ptr<aura::Window> w1(
1277 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect1)); 1272 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect1));
1278 std::unique_ptr<aura::Window> w2( 1273 std::unique_ptr<aura::Window> w2(
1279 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect2)); 1274 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect2));
1280 1275
1281 WindowSelectorController* window_selector_controller = 1276 WindowSelectorController* window_selector_controller =
1282 Shell::Get()->window_selector_controller(); 1277 Shell::Get()->window_selector_controller();
1283 ASSERT_TRUE(window_selector_controller->ToggleOverview()); 1278 ASSERT_TRUE(window_selector_controller->ToggleOverview());
1284 ASSERT_TRUE(window_selector_controller->IsSelecting()); 1279 ASSERT_TRUE(window_selector_controller->IsSelecting());
1285 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 1280 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
1286 ASSERT_TRUE(manager); 1281 ASSERT_TRUE(manager);
1287 EXPECT_FALSE(window_selector_controller->IsSelecting()); 1282 EXPECT_FALSE(window_selector_controller->IsSelecting());
1288 1283
1289 ASSERT_TRUE(window_selector_controller->ToggleOverview()); 1284 ASSERT_TRUE(window_selector_controller->ToggleOverview());
1290 ASSERT_TRUE(window_selector_controller->IsSelecting()); 1285 ASSERT_TRUE(window_selector_controller->IsSelecting());
1291 // Destroy the manager again and check that the windows return to their 1286 // Destroy the manager again and check that the windows return to their
1292 // previous state. 1287 // previous state.
1293 DestroyMaximizeModeWindowManager(); 1288 DestroyTabletModeWindowManager();
1294 EXPECT_FALSE(window_selector_controller->IsSelecting()); 1289 EXPECT_FALSE(window_selector_controller->IsSelecting());
1295 } 1290 }
1296 1291
1297 // Test that an edge swipe from the top will end full screen mode. 1292 // Test that an edge swipe from the top will end full screen mode.
1298 TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeSwipeFromTop) { 1293 TEST_F(TabletModeWindowManagerTest, ExitFullScreenWithEdgeSwipeFromTop) {
1299 // TODO: investigate failure. http://crbug.com/698093. 1294 // TODO: investigate failure. http://crbug.com/698093.
1300 if (Shell::GetAshConfig() == Config::MASH) 1295 if (Shell::GetAshConfig() == Config::MASH)
1301 return; 1296 return;
1302 1297
1303 gfx::Rect rect(10, 10, 200, 50); 1298 gfx::Rect rect(10, 10, 200, 50);
1304 std::unique_ptr<aura::Window> background_window( 1299 std::unique_ptr<aura::Window> background_window(
1305 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1300 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1306 std::unique_ptr<aura::Window> foreground_window( 1301 std::unique_ptr<aura::Window> foreground_window(
1307 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1302 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1308 wm::WindowState* background_window_state = 1303 wm::WindowState* background_window_state =
1309 wm::GetWindowState(background_window.get()); 1304 wm::GetWindowState(background_window.get());
1310 wm::WindowState* foreground_window_state = 1305 wm::WindowState* foreground_window_state =
1311 wm::GetWindowState(foreground_window.get()); 1306 wm::GetWindowState(foreground_window.get());
1312 wm::ActivateWindow(foreground_window.get()); 1307 wm::ActivateWindow(foreground_window.get());
1313 CreateMaximizeModeWindowManager(); 1308 CreateTabletModeWindowManager();
1314 1309
1315 // Fullscreen both windows. 1310 // Fullscreen both windows.
1316 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 1311 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
1317 background_window_state->OnWMEvent(&event); 1312 background_window_state->OnWMEvent(&event);
1318 foreground_window_state->OnWMEvent(&event); 1313 foreground_window_state->OnWMEvent(&event);
1319 EXPECT_TRUE(background_window_state->IsFullscreen()); 1314 EXPECT_TRUE(background_window_state->IsFullscreen());
1320 EXPECT_TRUE(foreground_window_state->IsFullscreen()); 1315 EXPECT_TRUE(foreground_window_state->IsFullscreen());
1321 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow()); 1316 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow());
1322 1317
1323 // Do an edge swipe top into screen. 1318 // Do an edge swipe top into screen.
1324 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 1319 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
1325 generator.GestureScrollSequence(gfx::Point(50, 0), gfx::Point(50, 100), 1320 generator.GestureScrollSequence(gfx::Point(50, 0), gfx::Point(50, 100),
1326 base::TimeDelta::FromMilliseconds(20), 10); 1321 base::TimeDelta::FromMilliseconds(20), 10);
1327 1322
1328 EXPECT_FALSE(foreground_window_state->IsFullscreen()); 1323 EXPECT_FALSE(foreground_window_state->IsFullscreen());
1329 EXPECT_TRUE(background_window_state->IsFullscreen()); 1324 EXPECT_TRUE(background_window_state->IsFullscreen());
1330 1325
1331 // Do a second edge swipe top into screen. 1326 // Do a second edge swipe top into screen.
1332 generator.GestureScrollSequence(gfx::Point(50, 0), gfx::Point(50, 100), 1327 generator.GestureScrollSequence(gfx::Point(50, 0), gfx::Point(50, 100),
1333 base::TimeDelta::FromMilliseconds(20), 10); 1328 base::TimeDelta::FromMilliseconds(20), 10);
1334 1329
1335 EXPECT_FALSE(foreground_window_state->IsFullscreen()); 1330 EXPECT_FALSE(foreground_window_state->IsFullscreen());
1336 EXPECT_TRUE(background_window_state->IsFullscreen()); 1331 EXPECT_TRUE(background_window_state->IsFullscreen());
1337 1332
1338 DestroyMaximizeModeWindowManager(); 1333 DestroyTabletModeWindowManager();
1339 } 1334 }
1340 1335
1341 // Test that an edge swipe from the bottom will end full screen mode. 1336 // Test that an edge swipe from the bottom will end full screen mode.
1342 TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeSwipeFromBottom) { 1337 TEST_F(TabletModeWindowManagerTest, ExitFullScreenWithEdgeSwipeFromBottom) {
1343 // TODO: investigate failure. http://crbug.com/698093. 1338 // TODO: investigate failure. http://crbug.com/698093.
1344 if (Shell::GetAshConfig() == Config::MASH) 1339 if (Shell::GetAshConfig() == Config::MASH)
1345 return; 1340 return;
1346 1341
1347 gfx::Rect rect(10, 10, 200, 50); 1342 gfx::Rect rect(10, 10, 200, 50);
1348 std::unique_ptr<aura::Window> background_window( 1343 std::unique_ptr<aura::Window> background_window(
1349 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1344 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1350 std::unique_ptr<aura::Window> foreground_window( 1345 std::unique_ptr<aura::Window> foreground_window(
1351 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1346 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1352 wm::WindowState* background_window_state = 1347 wm::WindowState* background_window_state =
1353 wm::GetWindowState(background_window.get()); 1348 wm::GetWindowState(background_window.get());
1354 wm::WindowState* foreground_window_state = 1349 wm::WindowState* foreground_window_state =
1355 wm::GetWindowState(foreground_window.get()); 1350 wm::GetWindowState(foreground_window.get());
1356 wm::ActivateWindow(foreground_window.get()); 1351 wm::ActivateWindow(foreground_window.get());
1357 CreateMaximizeModeWindowManager(); 1352 CreateTabletModeWindowManager();
1358 1353
1359 // Fullscreen both windows. 1354 // Fullscreen both windows.
1360 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 1355 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
1361 background_window_state->OnWMEvent(&event); 1356 background_window_state->OnWMEvent(&event);
1362 foreground_window_state->OnWMEvent(&event); 1357 foreground_window_state->OnWMEvent(&event);
1363 EXPECT_TRUE(background_window_state->IsFullscreen()); 1358 EXPECT_TRUE(background_window_state->IsFullscreen());
1364 EXPECT_TRUE(foreground_window_state->IsFullscreen()); 1359 EXPECT_TRUE(foreground_window_state->IsFullscreen());
1365 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow()); 1360 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow());
1366 1361
1367 // Do an edge swipe bottom into screen. 1362 // Do an edge swipe bottom into screen.
1368 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 1363 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
1369 int y = Shell::GetPrimaryRootWindow()->bounds().bottom(); 1364 int y = Shell::GetPrimaryRootWindow()->bounds().bottom();
1370 generator.GestureScrollSequence(gfx::Point(50, y), gfx::Point(50, y - 100), 1365 generator.GestureScrollSequence(gfx::Point(50, y), gfx::Point(50, y - 100),
1371 base::TimeDelta::FromMilliseconds(20), 10); 1366 base::TimeDelta::FromMilliseconds(20), 10);
1372 1367
1373 EXPECT_FALSE(foreground_window_state->IsFullscreen()); 1368 EXPECT_FALSE(foreground_window_state->IsFullscreen());
1374 EXPECT_TRUE(background_window_state->IsFullscreen()); 1369 EXPECT_TRUE(background_window_state->IsFullscreen());
1375 1370
1376 DestroyMaximizeModeWindowManager(); 1371 DestroyTabletModeWindowManager();
1377 } 1372 }
1378 1373
1379 // Test that an edge touch press at the top will end full screen mode. 1374 // Test that an edge touch press at the top will end full screen mode.
1380 TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeTouchAtTop) { 1375 TEST_F(TabletModeWindowManagerTest, ExitFullScreenWithEdgeTouchAtTop) {
1381 // TODO: investigate failure. http://crbug.com/698093. 1376 // TODO: investigate failure. http://crbug.com/698093.
1382 if (Shell::GetAshConfig() == Config::MASH) 1377 if (Shell::GetAshConfig() == Config::MASH)
1383 return; 1378 return;
1384 1379
1385 gfx::Rect rect(10, 10, 200, 50); 1380 gfx::Rect rect(10, 10, 200, 50);
1386 std::unique_ptr<aura::Window> background_window( 1381 std::unique_ptr<aura::Window> background_window(
1387 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1382 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1388 std::unique_ptr<aura::Window> foreground_window( 1383 std::unique_ptr<aura::Window> foreground_window(
1389 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1384 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1390 wm::WindowState* background_window_state = 1385 wm::WindowState* background_window_state =
1391 wm::GetWindowState(background_window.get()); 1386 wm::GetWindowState(background_window.get());
1392 wm::WindowState* foreground_window_state = 1387 wm::WindowState* foreground_window_state =
1393 wm::GetWindowState(foreground_window.get()); 1388 wm::GetWindowState(foreground_window.get());
1394 wm::ActivateWindow(foreground_window.get()); 1389 wm::ActivateWindow(foreground_window.get());
1395 CreateMaximizeModeWindowManager(); 1390 CreateTabletModeWindowManager();
1396 1391
1397 // Fullscreen both windows. 1392 // Fullscreen both windows.
1398 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 1393 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
1399 background_window_state->OnWMEvent(&event); 1394 background_window_state->OnWMEvent(&event);
1400 foreground_window_state->OnWMEvent(&event); 1395 foreground_window_state->OnWMEvent(&event);
1401 EXPECT_TRUE(background_window_state->IsFullscreen()); 1396 EXPECT_TRUE(background_window_state->IsFullscreen());
1402 EXPECT_TRUE(foreground_window_state->IsFullscreen()); 1397 EXPECT_TRUE(foreground_window_state->IsFullscreen());
1403 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow()); 1398 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow());
1404 1399
1405 // Touch tap on the top edge. 1400 // Touch tap on the top edge.
1406 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 1401 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
1407 generator.GestureTapAt(gfx::Point(100, 0)); 1402 generator.GestureTapAt(gfx::Point(100, 0));
1408 EXPECT_FALSE(foreground_window_state->IsFullscreen()); 1403 EXPECT_FALSE(foreground_window_state->IsFullscreen());
1409 EXPECT_TRUE(background_window_state->IsFullscreen()); 1404 EXPECT_TRUE(background_window_state->IsFullscreen());
1410 1405
1411 // Try the same again and see that nothing changes. 1406 // Try the same again and see that nothing changes.
1412 generator.GestureTapAt(gfx::Point(100, 0)); 1407 generator.GestureTapAt(gfx::Point(100, 0));
1413 EXPECT_FALSE(foreground_window_state->IsFullscreen()); 1408 EXPECT_FALSE(foreground_window_state->IsFullscreen());
1414 EXPECT_TRUE(background_window_state->IsFullscreen()); 1409 EXPECT_TRUE(background_window_state->IsFullscreen());
1415 1410
1416 DestroyMaximizeModeWindowManager(); 1411 DestroyTabletModeWindowManager();
1417 } 1412 }
1418 1413
1419 // Test that an edge touch press at the bottom will end full screen mode. 1414 // Test that an edge touch press at the bottom will end full screen mode.
1420 TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeTouchAtBottom) { 1415 TEST_F(TabletModeWindowManagerTest, ExitFullScreenWithEdgeTouchAtBottom) {
1421 // TODO: investigate failure. http://crbug.com/698093. 1416 // TODO: investigate failure. http://crbug.com/698093.
1422 if (Shell::GetAshConfig() == Config::MASH) 1417 if (Shell::GetAshConfig() == Config::MASH)
1423 return; 1418 return;
1424 1419
1425 gfx::Rect rect(10, 10, 200, 50); 1420 gfx::Rect rect(10, 10, 200, 50);
1426 std::unique_ptr<aura::Window> background_window( 1421 std::unique_ptr<aura::Window> background_window(
1427 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1422 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1428 std::unique_ptr<aura::Window> foreground_window( 1423 std::unique_ptr<aura::Window> foreground_window(
1429 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1424 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1430 wm::WindowState* background_window_state = 1425 wm::WindowState* background_window_state =
1431 wm::GetWindowState(background_window.get()); 1426 wm::GetWindowState(background_window.get());
1432 wm::WindowState* foreground_window_state = 1427 wm::WindowState* foreground_window_state =
1433 wm::GetWindowState(foreground_window.get()); 1428 wm::GetWindowState(foreground_window.get());
1434 wm::ActivateWindow(foreground_window.get()); 1429 wm::ActivateWindow(foreground_window.get());
1435 CreateMaximizeModeWindowManager(); 1430 CreateTabletModeWindowManager();
1436 1431
1437 // Fullscreen both windows. 1432 // Fullscreen both windows.
1438 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 1433 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
1439 background_window_state->OnWMEvent(&event); 1434 background_window_state->OnWMEvent(&event);
1440 foreground_window_state->OnWMEvent(&event); 1435 foreground_window_state->OnWMEvent(&event);
1441 EXPECT_TRUE(background_window_state->IsFullscreen()); 1436 EXPECT_TRUE(background_window_state->IsFullscreen());
1442 EXPECT_TRUE(foreground_window_state->IsFullscreen()); 1437 EXPECT_TRUE(foreground_window_state->IsFullscreen());
1443 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow()); 1438 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow());
1444 1439
1445 // Touch tap on the bottom edge. 1440 // Touch tap on the bottom edge.
1446 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 1441 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
1447 generator.GestureTapAt( 1442 generator.GestureTapAt(
1448 gfx::Point(100, Shell::GetPrimaryRootWindow()->bounds().bottom() - 1)); 1443 gfx::Point(100, Shell::GetPrimaryRootWindow()->bounds().bottom() - 1));
1449 EXPECT_FALSE(foreground_window_state->IsFullscreen()); 1444 EXPECT_FALSE(foreground_window_state->IsFullscreen());
1450 EXPECT_TRUE(background_window_state->IsFullscreen()); 1445 EXPECT_TRUE(background_window_state->IsFullscreen());
1451 1446
1452 // Try the same again and see that nothing changes. 1447 // Try the same again and see that nothing changes.
1453 generator.GestureTapAt( 1448 generator.GestureTapAt(
1454 gfx::Point(100, Shell::GetPrimaryRootWindow()->bounds().bottom() - 1)); 1449 gfx::Point(100, Shell::GetPrimaryRootWindow()->bounds().bottom() - 1));
1455 EXPECT_FALSE(foreground_window_state->IsFullscreen()); 1450 EXPECT_FALSE(foreground_window_state->IsFullscreen());
1456 EXPECT_TRUE(background_window_state->IsFullscreen()); 1451 EXPECT_TRUE(background_window_state->IsFullscreen());
1457 1452
1458 DestroyMaximizeModeWindowManager(); 1453 DestroyTabletModeWindowManager();
1459 } 1454 }
1460 1455
1461 // Test that an edge swipe from the top on an immersive mode window will not end 1456 // Test that an edge swipe from the top on an immersive mode window will not end
1462 // full screen mode. 1457 // full screen mode.
1463 TEST_F(MaximizeModeWindowManagerTest, NoExitImmersiveModeWithEdgeSwipeFromTop) { 1458 TEST_F(TabletModeWindowManagerTest, NoExitImmersiveModeWithEdgeSwipeFromTop) {
1464 std::unique_ptr<aura::Window> window(CreateWindow( 1459 std::unique_ptr<aura::Window> window(CreateWindow(
1465 aura::client::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50))); 1460 aura::client::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50)));
1466 wm::WindowState* window_state = wm::GetWindowState(window.get()); 1461 wm::WindowState* window_state = wm::GetWindowState(window.get());
1467 wm::ActivateWindow(window.get()); 1462 wm::ActivateWindow(window.get());
1468 CreateMaximizeModeWindowManager(); 1463 CreateTabletModeWindowManager();
1469 1464
1470 // Fullscreen the window. 1465 // Fullscreen the window.
1471 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 1466 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
1472 window_state->OnWMEvent(&event); 1467 window_state->OnWMEvent(&event);
1473 EXPECT_TRUE(window_state->IsFullscreen()); 1468 EXPECT_TRUE(window_state->IsFullscreen());
1474 EXPECT_FALSE(window_state->in_immersive_fullscreen()); 1469 EXPECT_FALSE(window_state->in_immersive_fullscreen());
1475 EXPECT_EQ(window.get(), wm::GetActiveWindow()); 1470 EXPECT_EQ(window.get(), wm::GetActiveWindow());
1476 1471
1477 window_state->set_in_immersive_fullscreen(true); 1472 window_state->set_in_immersive_fullscreen(true);
1478 1473
1479 // Do an edge swipe top into screen. 1474 // Do an edge swipe top into screen.
1480 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 1475 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
1481 generator.GestureScrollSequence(gfx::Point(50, 0), gfx::Point(50, 100), 1476 generator.GestureScrollSequence(gfx::Point(50, 0), gfx::Point(50, 100),
1482 base::TimeDelta::FromMilliseconds(20), 10); 1477 base::TimeDelta::FromMilliseconds(20), 10);
1483 1478
1484 // It should have not exited full screen or immersive mode. 1479 // It should have not exited full screen or immersive mode.
1485 EXPECT_TRUE(window_state->IsFullscreen()); 1480 EXPECT_TRUE(window_state->IsFullscreen());
1486 EXPECT_TRUE(window_state->in_immersive_fullscreen()); 1481 EXPECT_TRUE(window_state->in_immersive_fullscreen());
1487 1482
1488 DestroyMaximizeModeWindowManager(); 1483 DestroyTabletModeWindowManager();
1489 } 1484 }
1490 1485
1491 // Test that an edge swipe from the bottom will not end immersive mode. 1486 // Test that an edge swipe from the bottom will not end immersive mode.
1492 TEST_F(MaximizeModeWindowManagerTest, 1487 TEST_F(TabletModeWindowManagerTest,
1493 NoExitImmersiveModeWithEdgeSwipeFromBottom) { 1488 NoExitImmersiveModeWithEdgeSwipeFromBottom) {
1494 std::unique_ptr<aura::Window> window(CreateWindow( 1489 std::unique_ptr<aura::Window> window(CreateWindow(
1495 aura::client::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50))); 1490 aura::client::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50)));
1496 wm::WindowState* window_state = wm::GetWindowState(window.get()); 1491 wm::WindowState* window_state = wm::GetWindowState(window.get());
1497 wm::ActivateWindow(window.get()); 1492 wm::ActivateWindow(window.get());
1498 CreateMaximizeModeWindowManager(); 1493 CreateTabletModeWindowManager();
1499 1494
1500 // Fullscreen the window. 1495 // Fullscreen the window.
1501 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 1496 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
1502 window_state->OnWMEvent(&event); 1497 window_state->OnWMEvent(&event);
1503 EXPECT_TRUE(window_state->IsFullscreen()); 1498 EXPECT_TRUE(window_state->IsFullscreen());
1504 EXPECT_FALSE(window_state->in_immersive_fullscreen()); 1499 EXPECT_FALSE(window_state->in_immersive_fullscreen());
1505 EXPECT_EQ(window.get(), wm::GetActiveWindow()); 1500 EXPECT_EQ(window.get(), wm::GetActiveWindow());
1506 window_state->set_in_immersive_fullscreen(true); 1501 window_state->set_in_immersive_fullscreen(true);
1507 EXPECT_TRUE(window_state->in_immersive_fullscreen()); 1502 EXPECT_TRUE(window_state->in_immersive_fullscreen());
1508 1503
1509 // Do an edge swipe bottom into screen. 1504 // Do an edge swipe bottom into screen.
1510 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 1505 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
1511 int y = Shell::GetPrimaryRootWindow()->bounds().bottom(); 1506 int y = Shell::GetPrimaryRootWindow()->bounds().bottom();
1512 generator.GestureScrollSequence(gfx::Point(50, y), gfx::Point(50, y - 100), 1507 generator.GestureScrollSequence(gfx::Point(50, y), gfx::Point(50, y - 100),
1513 base::TimeDelta::FromMilliseconds(20), 10); 1508 base::TimeDelta::FromMilliseconds(20), 10);
1514 1509
1515 // The window should still be full screen and immersive. 1510 // The window should still be full screen and immersive.
1516 EXPECT_TRUE(window_state->IsFullscreen()); 1511 EXPECT_TRUE(window_state->IsFullscreen());
1517 EXPECT_TRUE(window_state->in_immersive_fullscreen()); 1512 EXPECT_TRUE(window_state->in_immersive_fullscreen());
1518 1513
1519 DestroyMaximizeModeWindowManager(); 1514 DestroyTabletModeWindowManager();
1520 } 1515 }
1521 1516
1522 // Tests that windows with the always-on-top property are not managed by 1517 // Tests that windows with the always-on-top property are not managed by
1523 // the MaximizeModeWindowManager while maximize mode is engaged (i.e., 1518 // the TabletModeWindowManager while tablet mode is engaged (i.e.,
1524 // they remain free-floating). 1519 // they remain free-floating).
1525 TEST_F(MaximizeModeWindowManagerTest, AlwaysOnTopWindows) { 1520 TEST_F(TabletModeWindowManagerTest, AlwaysOnTopWindows) {
1526 gfx::Rect rect1(10, 10, 200, 50); 1521 gfx::Rect rect1(10, 10, 200, 50);
1527 gfx::Rect rect2(20, 140, 100, 100); 1522 gfx::Rect rect2(20, 140, 100, 100);
1528 1523
1529 // Create two windows with the always-on-top property. 1524 // Create two windows with the always-on-top property.
1530 std::unique_ptr<aura::Window> w1( 1525 std::unique_ptr<aura::Window> w1(
1531 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect1)); 1526 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect1));
1532 std::unique_ptr<aura::Window> w2(CreateFixedSizeNonMaximizableWindow( 1527 std::unique_ptr<aura::Window> w2(CreateFixedSizeNonMaximizableWindow(
1533 aura::client::WINDOW_TYPE_NORMAL, rect2)); 1528 aura::client::WINDOW_TYPE_NORMAL, rect2));
1534 w1->SetProperty(aura::client::kAlwaysOnTopKey, true); 1529 w1->SetProperty(aura::client::kAlwaysOnTopKey, true);
1535 w2->SetProperty(aura::client::kAlwaysOnTopKey, true); 1530 w2->SetProperty(aura::client::kAlwaysOnTopKey, true);
1536 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); 1531 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized());
1537 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); 1532 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized());
1538 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); 1533 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
1539 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); 1534 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
1540 EXPECT_TRUE(wm::GetWindowState(w1.get())->can_be_dragged()); 1535 EXPECT_TRUE(wm::GetWindowState(w1.get())->can_be_dragged());
1541 EXPECT_TRUE(wm::GetWindowState(w2.get())->can_be_dragged()); 1536 EXPECT_TRUE(wm::GetWindowState(w2.get())->can_be_dragged());
1542 1537
1543 // Enter maximize mode. Neither window should be managed because they have 1538 // Enter tablet mode. Neither window should be managed because they have
1544 // the always-on-top property set, which means that none of their properties 1539 // the always-on-top property set, which means that none of their properties
1545 // should change. 1540 // should change.
1546 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 1541 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
1547 ASSERT_TRUE(manager); 1542 ASSERT_TRUE(manager);
1548 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 1543 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
1549 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); 1544 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized());
1550 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); 1545 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized());
1551 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); 1546 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
1552 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); 1547 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
1553 EXPECT_TRUE(wm::GetWindowState(w1.get())->can_be_dragged()); 1548 EXPECT_TRUE(wm::GetWindowState(w1.get())->can_be_dragged());
1554 EXPECT_TRUE(wm::GetWindowState(w2.get())->can_be_dragged()); 1549 EXPECT_TRUE(wm::GetWindowState(w2.get())->can_be_dragged());
1555 1550
1556 // Remove the always-on-top property from both windows while in maximize 1551 // Remove the always-on-top property from both windows while in maximize
(...skipping 17 matching lines...) Expand all
1574 w1->SetProperty(aura::client::kAlwaysOnTopKey, true); 1569 w1->SetProperty(aura::client::kAlwaysOnTopKey, true);
1575 w2->SetProperty(aura::client::kAlwaysOnTopKey, true); 1570 w2->SetProperty(aura::client::kAlwaysOnTopKey, true);
1576 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 1571 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
1577 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); 1572 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized());
1578 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); 1573 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized());
1579 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); 1574 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
1580 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); 1575 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
1581 EXPECT_TRUE(wm::GetWindowState(w1.get())->can_be_dragged()); 1576 EXPECT_TRUE(wm::GetWindowState(w1.get())->can_be_dragged());
1582 EXPECT_TRUE(wm::GetWindowState(w2.get())->can_be_dragged()); 1577 EXPECT_TRUE(wm::GetWindowState(w2.get())->can_be_dragged());
1583 1578
1584 // The always-on-top windows should not change when leaving maximize mode. 1579 // The always-on-top windows should not change when leaving tablet mode.
1585 DestroyMaximizeModeWindowManager(); 1580 DestroyTabletModeWindowManager();
1586 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); 1581 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized());
1587 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); 1582 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized());
1588 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); 1583 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
1589 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); 1584 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
1590 EXPECT_TRUE(wm::GetWindowState(w1.get())->can_be_dragged()); 1585 EXPECT_TRUE(wm::GetWindowState(w1.get())->can_be_dragged());
1591 EXPECT_TRUE(wm::GetWindowState(w2.get())->can_be_dragged()); 1586 EXPECT_TRUE(wm::GetWindowState(w2.get())->can_be_dragged());
1592 } 1587 }
1593 1588
1594 // Tests that windows that can control maximized bounds are not maximized 1589 // Tests that windows that can control maximized bounds are not maximized
1595 // and not tracked. 1590 // and not tracked.
1596 TEST_F(MaximizeModeWindowManagerTest, DontMaximizeClientManagedWindows) { 1591 TEST_F(TabletModeWindowManagerTest, DontMaximizeClientManagedWindows) {
1597 gfx::Rect rect(10, 10, 200, 50); 1592 gfx::Rect rect(10, 10, 200, 50);
1598 std::unique_ptr<aura::Window> window( 1593 std::unique_ptr<aura::Window> window(
1599 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1594 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1600 1595
1601 wm::GetWindowState(window.get())->set_allow_set_bounds_direct(true); 1596 wm::GetWindowState(window.get())->set_allow_set_bounds_direct(true);
1602 1597
1603 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 1598 TabletModeWindowManager* manager = CreateTabletModeWindowManager();
1604 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); 1599 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized());
1605 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 1600 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
1606 } 1601 }
1607 1602
1608 namespace { 1603 namespace {
1609 1604
1610 class TestObserver : public wm::WindowStateObserver { 1605 class TestObserver : public wm::WindowStateObserver {
1611 public: 1606 public:
1612 TestObserver(){}; 1607 TestObserver(){};
1613 ~TestObserver() override{}; 1608 ~TestObserver() override{};
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1646 private: 1641 private:
1647 int pre_count_ = 0; 1642 int pre_count_ = 0;
1648 int post_count_ = 0; 1643 int post_count_ = 0;
1649 wm::WindowStateType last_old_state_ = wm::WINDOW_STATE_TYPE_DEFAULT; 1644 wm::WindowStateType last_old_state_ = wm::WINDOW_STATE_TYPE_DEFAULT;
1650 1645
1651 DISALLOW_COPY_AND_ASSIGN(TestObserver); 1646 DISALLOW_COPY_AND_ASSIGN(TestObserver);
1652 }; 1647 };
1653 1648
1654 } // namespace 1649 } // namespace
1655 1650
1656 TEST_F(MaximizeModeWindowManagerTest, StateTyepChange) { 1651 TEST_F(TabletModeWindowManagerTest, StateTyepChange) {
1657 TestObserver observer; 1652 TestObserver observer;
1658 gfx::Rect rect(10, 10, 200, 50); 1653 gfx::Rect rect(10, 10, 200, 50);
1659 std::unique_ptr<aura::Window> window( 1654 std::unique_ptr<aura::Window> window(
1660 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect)); 1655 CreateWindow(aura::client::WINDOW_TYPE_NORMAL, rect));
1661 1656
1662 CreateMaximizeModeWindowManager(); 1657 CreateTabletModeWindowManager();
1663 1658
1664 wm::WindowState* window_state = wm::GetWindowState(window.get()); 1659 wm::WindowState* window_state = wm::GetWindowState(window.get());
1665 window_state->AddObserver(&observer); 1660 window_state->AddObserver(&observer);
1666 1661
1667 window->Show(); 1662 window->Show();
1668 EXPECT_TRUE(window_state->IsMaximized()); 1663 EXPECT_TRUE(window_state->IsMaximized());
1669 EXPECT_EQ(0, observer.GetPreCountAndReset()); 1664 EXPECT_EQ(0, observer.GetPreCountAndReset());
1670 EXPECT_EQ(0, observer.GetPostCountAndReset()); 1665 EXPECT_EQ(0, observer.GetPostCountAndReset());
1671 1666
1672 // Window is already in maximized mode. 1667 // Window is already in tablet mode.
1673 wm::WMEvent maximize_event(wm::WM_EVENT_MAXIMIZE); 1668 wm::WMEvent maximize_event(wm::WM_EVENT_MAXIMIZE);
1674 window_state->OnWMEvent(&maximize_event); 1669 window_state->OnWMEvent(&maximize_event);
1675 EXPECT_EQ(0, observer.GetPreCountAndReset()); 1670 EXPECT_EQ(0, observer.GetPreCountAndReset());
1676 EXPECT_EQ(0, observer.GetPostCountAndReset()); 1671 EXPECT_EQ(0, observer.GetPostCountAndReset());
1677 1672
1678 wm::WMEvent fullscreen_event(wm::WM_EVENT_FULLSCREEN); 1673 wm::WMEvent fullscreen_event(wm::WM_EVENT_FULLSCREEN);
1679 window_state->OnWMEvent(&fullscreen_event); 1674 window_state->OnWMEvent(&fullscreen_event);
1680 EXPECT_EQ(1, observer.GetPreCountAndReset()); 1675 EXPECT_EQ(1, observer.GetPreCountAndReset());
1681 EXPECT_EQ(1, observer.GetPostCountAndReset()); 1676 EXPECT_EQ(1, observer.GetPostCountAndReset());
1682 EXPECT_EQ(wm::WINDOW_STATE_TYPE_MAXIMIZED, 1677 EXPECT_EQ(wm::WINDOW_STATE_TYPE_MAXIMIZED,
(...skipping 14 matching lines...) Expand all
1697 1692
1698 wm::WMEvent restore_event(wm::WM_EVENT_NORMAL); 1693 wm::WMEvent restore_event(wm::WM_EVENT_NORMAL);
1699 window_state->OnWMEvent(&restore_event); 1694 window_state->OnWMEvent(&restore_event);
1700 EXPECT_EQ(1, observer.GetPreCountAndReset()); 1695 EXPECT_EQ(1, observer.GetPreCountAndReset());
1701 EXPECT_EQ(1, observer.GetPostCountAndReset()); 1696 EXPECT_EQ(1, observer.GetPostCountAndReset());
1702 EXPECT_EQ(wm::WINDOW_STATE_TYPE_MINIMIZED, 1697 EXPECT_EQ(wm::WINDOW_STATE_TYPE_MINIMIZED,
1703 observer.GetLastOldStateAndReset()); 1698 observer.GetLastOldStateAndReset());
1704 1699
1705 window_state->RemoveObserver(&observer); 1700 window_state->RemoveObserver(&observer);
1706 1701
1707 DestroyMaximizeModeWindowManager(); 1702 DestroyTabletModeWindowManager();
1708 } 1703 }
1709 1704
1710 } // namespace ash 1705 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698