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

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

Issue 224113005: Eliminate ash::internal namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" 5 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/switchable_windows.h" 8 #include "ash/switchable_windows.h"
9 #include "ash/test/ash_test_base.h" 9 #include "ash/test/ash_test_base.h"
10 #include "ash/test/shell_test_api.h" 10 #include "ash/test/shell_test_api.h"
(...skipping 27 matching lines...) Expand all
38 return CreateWindowInWatchedContainer(type, bounds, false); 38 return CreateWindowInWatchedContainer(type, bounds, false);
39 } 39 }
40 40
41 // Creates a window. 41 // Creates a window.
42 aura::Window* CreateWindow(ui::wm::WindowType type, 42 aura::Window* CreateWindow(ui::wm::WindowType type,
43 const gfx::Rect bounds) { 43 const gfx::Rect bounds) {
44 return CreateWindowInWatchedContainer(type, bounds, true); 44 return CreateWindowInWatchedContainer(type, bounds, true);
45 } 45 }
46 46
47 // Create the Maximized mode window manager. 47 // Create the Maximized mode window manager.
48 ash::internal::MaximizeModeWindowManager* CreateMaximizeModeWindowManager() { 48 ash::MaximizeModeWindowManager* CreateMaximizeModeWindowManager() {
49 EXPECT_FALSE(maximize_mode_window_manager()); 49 EXPECT_FALSE(maximize_mode_window_manager());
50 Shell::GetInstance()->EnableMaximizeModeWindowManager(true); 50 Shell::GetInstance()->EnableMaximizeModeWindowManager(true);
51 return maximize_mode_window_manager(); 51 return maximize_mode_window_manager();
52 } 52 }
53 53
54 // Destroy the maximized mode window manager. 54 // Destroy the maximized mode window manager.
55 void DestroyMaximizeModeWindowManager() { 55 void DestroyMaximizeModeWindowManager() {
56 Shell::GetInstance()->EnableMaximizeModeWindowManager(false); 56 Shell::GetInstance()->EnableMaximizeModeWindowManager(false);
57 EXPECT_FALSE(maximize_mode_window_manager()); 57 EXPECT_FALSE(maximize_mode_window_manager());
58 } 58 }
59 59
60 // Get the maximze window manager. 60 // Get the maximze window manager.
61 ash::internal::MaximizeModeWindowManager* maximize_mode_window_manager() { 61 ash::MaximizeModeWindowManager* maximize_mode_window_manager() {
62 test::ShellTestApi test_api(Shell::GetInstance()); 62 test::ShellTestApi test_api(Shell::GetInstance());
63 return test_api.maximize_mode_window_manager(); 63 return test_api.maximize_mode_window_manager();
64 } 64 }
65 65
66 // Resize our desktop. 66 // Resize our desktop.
67 void ResizeDesktop(int width_delta) { 67 void ResizeDesktop(int width_delta) {
68 gfx::Size size = Shell::GetScreen()->GetDisplayNearestWindow( 68 gfx::Size size = Shell::GetScreen()->GetDisplayNearestWindow(
69 Shell::GetPrimaryRootWindow()).size(); 69 Shell::GetPrimaryRootWindow()).size();
70 size.Enlarge(0, width_delta); 70 size.Enlarge(0, width_delta);
71 UpdateDisplay(size.ToString()); 71 UpdateDisplay(size.ToString());
(...skipping 19 matching lines...) Expand all
91 container->AddChild(window); 91 container->AddChild(window);
92 return window; 92 return window;
93 } 93 }
94 94
95 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManagerTest); 95 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManagerTest);
96 }; 96 };
97 97
98 // Test that creating the object and destroying it without any windows should 98 // Test that creating the object and destroying it without any windows should
99 // not cause any problems. 99 // not cause any problems.
100 TEST_F(MaximizeModeWindowManagerTest, SimpleStart) { 100 TEST_F(MaximizeModeWindowManagerTest, SimpleStart) {
101 ash::internal::MaximizeModeWindowManager* manager = 101 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
102 CreateMaximizeModeWindowManager();
103 ASSERT_TRUE(manager); 102 ASSERT_TRUE(manager);
104 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 103 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
105 DestroyMaximizeModeWindowManager(); 104 DestroyMaximizeModeWindowManager();
106 } 105 }
107 106
108 // Test that existing windows will handled properly when going into maximized 107 // Test that existing windows will handled properly when going into maximized
109 // mode. 108 // mode.
110 TEST_F(MaximizeModeWindowManagerTest, PreCreateWindows) { 109 TEST_F(MaximizeModeWindowManagerTest, PreCreateWindows) {
111 // Bounds for windows we know can be controlled. 110 // Bounds for windows we know can be controlled.
112 gfx::Rect rect1(10, 10, 200, 50); 111 gfx::Rect rect1(10, 10, 200, 50);
(...skipping 12 matching lines...) Expand all
125 scoped_ptr<aura::Window> w8(CreateWindow(ui::wm::WINDOW_TYPE_TOOLTIP, rect)); 124 scoped_ptr<aura::Window> w8(CreateWindow(ui::wm::WINDOW_TYPE_TOOLTIP, rect));
126 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); 125 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized());
127 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); 126 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized());
128 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); 127 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
129 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); 128 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
130 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); 129 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
131 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString()); 130 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString());
132 131
133 // Create the manager and make sure that all qualifying windows were detected 132 // Create the manager and make sure that all qualifying windows were detected
134 // and changed. 133 // and changed.
135 ash::internal::MaximizeModeWindowManager* manager = 134 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
136 CreateMaximizeModeWindowManager();
137 ASSERT_TRUE(manager); 135 ASSERT_TRUE(manager);
138 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 136 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
139 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized()); 137 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized());
140 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); 138 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized());
141 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); 139 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
142 EXPECT_NE(rect3.origin().ToString(), w3->bounds().origin().ToString()); 140 EXPECT_NE(rect3.origin().ToString(), w3->bounds().origin().ToString());
143 EXPECT_EQ(rect3.size().ToString(), w3->bounds().size().ToString()); 141 EXPECT_EQ(rect3.size().ToString(), w3->bounds().size().ToString());
144 142
145 // All other windows should not have been touched. 143 // All other windows should not have been touched.
146 EXPECT_FALSE(wm::GetWindowState(w4.get())->IsMaximized()); 144 EXPECT_FALSE(wm::GetWindowState(w4.get())->IsMaximized());
(...skipping 18 matching lines...) Expand all
165 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString()); 163 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString());
166 EXPECT_EQ(rect.ToString(), w4->bounds().ToString()); 164 EXPECT_EQ(rect.ToString(), w4->bounds().ToString());
167 EXPECT_EQ(rect.ToString(), w5->bounds().ToString()); 165 EXPECT_EQ(rect.ToString(), w5->bounds().ToString());
168 EXPECT_EQ(rect.ToString(), w6->bounds().ToString()); 166 EXPECT_EQ(rect.ToString(), w6->bounds().ToString());
169 EXPECT_EQ(rect.ToString(), w7->bounds().ToString()); 167 EXPECT_EQ(rect.ToString(), w7->bounds().ToString());
170 EXPECT_EQ(rect.ToString(), w8->bounds().ToString()); 168 EXPECT_EQ(rect.ToString(), w8->bounds().ToString());
171 } 169 }
172 170
173 // Test that creating windows while a maximizer exists picks them properly up. 171 // Test that creating windows while a maximizer exists picks them properly up.
174 TEST_F(MaximizeModeWindowManagerTest, CreateWindows) { 172 TEST_F(MaximizeModeWindowManagerTest, CreateWindows) {
175 ash::internal::MaximizeModeWindowManager* manager = 173 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
176 CreateMaximizeModeWindowManager();
177 ASSERT_TRUE(manager); 174 ASSERT_TRUE(manager);
178 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 175 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
179 176
180 // Create the windows and see that the window manager picks them up. 177 // Create the windows and see that the window manager picks them up.
181 // Rects for windows we know can be controlled. 178 // Rects for windows we know can be controlled.
182 gfx::Rect rect1(10, 10, 200, 50); 179 gfx::Rect rect1(10, 10, 200, 50);
183 gfx::Rect rect2(10, 60, 200, 50); 180 gfx::Rect rect2(10, 60, 200, 50);
184 gfx::Rect rect3(20, 140, 100, 100); 181 gfx::Rect rect3(20, 140, 100, 100);
185 // One rect for anything else. 182 // One rect for anything else.
186 gfx::Rect rect(80, 90, 100, 110); 183 gfx::Rect rect(80, 90, 100, 110);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 EXPECT_EQ(rect.ToString(), w4->bounds().ToString()); 220 EXPECT_EQ(rect.ToString(), w4->bounds().ToString());
224 EXPECT_EQ(rect.ToString(), w5->bounds().ToString()); 221 EXPECT_EQ(rect.ToString(), w5->bounds().ToString());
225 EXPECT_EQ(rect.ToString(), w6->bounds().ToString()); 222 EXPECT_EQ(rect.ToString(), w6->bounds().ToString());
226 EXPECT_EQ(rect.ToString(), w7->bounds().ToString()); 223 EXPECT_EQ(rect.ToString(), w7->bounds().ToString());
227 EXPECT_EQ(rect.ToString(), w8->bounds().ToString()); 224 EXPECT_EQ(rect.ToString(), w8->bounds().ToString());
228 } 225 }
229 226
230 // Test that windows which got created before the maximizer was created can be 227 // Test that windows which got created before the maximizer was created can be
231 // destroyed while the maximizer is still running. 228 // destroyed while the maximizer is still running.
232 TEST_F(MaximizeModeWindowManagerTest, PreCreateWindowsDeleteWhileActive) { 229 TEST_F(MaximizeModeWindowManagerTest, PreCreateWindowsDeleteWhileActive) {
233 ash::internal::MaximizeModeWindowManager* manager = NULL; 230 ash::MaximizeModeWindowManager* manager = NULL;
234 { 231 {
235 // Bounds for windows we know can be controlled. 232 // Bounds for windows we know can be controlled.
236 gfx::Rect rect1(10, 10, 200, 50); 233 gfx::Rect rect1(10, 10, 200, 50);
237 gfx::Rect rect2(10, 60, 200, 50); 234 gfx::Rect rect2(10, 60, 200, 50);
238 gfx::Rect rect3(20, 140, 100, 100); 235 gfx::Rect rect3(20, 140, 100, 100);
239 // Bounds for anything else. 236 // Bounds for anything else.
240 gfx::Rect rect(80, 90, 100, 110); 237 gfx::Rect rect(80, 90, 100, 110);
241 scoped_ptr<aura::Window> w1( 238 scoped_ptr<aura::Window> w1(
242 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1)); 239 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1));
243 scoped_ptr<aura::Window> w2( 240 scoped_ptr<aura::Window> w2(
244 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); 241 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2));
245 scoped_ptr<aura::Window> w3( 242 scoped_ptr<aura::Window> w3(
246 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect3)); 243 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect3));
247 244
248 // Create the manager and make sure that all qualifying windows were 245 // Create the manager and make sure that all qualifying windows were
249 // detected and changed. 246 // detected and changed.
250 manager = CreateMaximizeModeWindowManager(); 247 manager = CreateMaximizeModeWindowManager();
251 ASSERT_TRUE(manager); 248 ASSERT_TRUE(manager);
252 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 249 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
253 } 250 }
254 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 251 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
255 DestroyMaximizeModeWindowManager(); 252 DestroyMaximizeModeWindowManager();
256 } 253 }
257 254
258 // Test that windows which got created while the maximizer was running can get 255 // Test that windows which got created while the maximizer was running can get
259 // destroyed before the maximizer gets destroyed. 256 // destroyed before the maximizer gets destroyed.
260 TEST_F(MaximizeModeWindowManagerTest, CreateWindowsAndDeleteWhileActive) { 257 TEST_F(MaximizeModeWindowManagerTest, CreateWindowsAndDeleteWhileActive) {
261 ash::internal::MaximizeModeWindowManager* manager = 258 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
262 CreateMaximizeModeWindowManager();
263 ASSERT_TRUE(manager); 259 ASSERT_TRUE(manager);
264 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 260 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
265 { 261 {
266 // Bounds for windows we know can be controlled. 262 // Bounds for windows we know can be controlled.
267 gfx::Rect rect1(10, 10, 200, 50); 263 gfx::Rect rect1(10, 10, 200, 50);
268 gfx::Rect rect2(10, 60, 200, 50); 264 gfx::Rect rect2(10, 60, 200, 50);
269 gfx::Rect rect3(20, 140, 100, 100); 265 gfx::Rect rect3(20, 140, 100, 100);
270 scoped_ptr<aura::Window> w1( 266 scoped_ptr<aura::Window> w1(
271 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50))); 267 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50)));
272 scoped_ptr<aura::Window> w2( 268 scoped_ptr<aura::Window> w2(
(...skipping 13 matching lines...) Expand all
286 282
287 // Test that windows which were maximized stay maximized. 283 // Test that windows which were maximized stay maximized.
288 TEST_F(MaximizeModeWindowManagerTest, MaximizedShouldRemainMaximized) { 284 TEST_F(MaximizeModeWindowManagerTest, MaximizedShouldRemainMaximized) {
289 // Bounds for windows we know can be controlled. 285 // Bounds for windows we know can be controlled.
290 gfx::Rect rect(10, 10, 200, 50); 286 gfx::Rect rect(10, 10, 200, 50);
291 scoped_ptr<aura::Window> window( 287 scoped_ptr<aura::Window> window(
292 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 288 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
293 wm::GetWindowState(window.get())->Maximize(); 289 wm::GetWindowState(window.get())->Maximize();
294 290
295 // Create the manager and make sure that the window gets detected. 291 // Create the manager and make sure that the window gets detected.
296 ash::internal::MaximizeModeWindowManager* manager = 292 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
297 CreateMaximizeModeWindowManager();
298 ASSERT_TRUE(manager); 293 ASSERT_TRUE(manager);
299 EXPECT_EQ(1, manager->GetNumberOfManagedWindows()); 294 EXPECT_EQ(1, manager->GetNumberOfManagedWindows());
300 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized()); 295 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized());
301 296
302 // Destroy the manager again and check that the window will remain maximized. 297 // Destroy the manager again and check that the window will remain maximized.
303 DestroyMaximizeModeWindowManager(); 298 DestroyMaximizeModeWindowManager();
304 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized()); 299 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized());
305 wm::GetWindowState(window.get())->Restore(); 300 wm::GetWindowState(window.get())->Restore();
306 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); 301 EXPECT_EQ(rect.ToString(), window->bounds().ToString());
307 } 302 }
308 303
309 // Test that minimized windows do neither get maximized nor restored upon 304 // Test that minimized windows do neither get maximized nor restored upon
310 // entering maximized mode and get restored to their previous state after 305 // entering maximized mode and get restored to their previous state after
311 // leaving. 306 // leaving.
312 TEST_F(MaximizeModeWindowManagerTest, MinimizedWindowBehavior) { 307 TEST_F(MaximizeModeWindowManagerTest, MinimizedWindowBehavior) {
313 // Bounds for windows we know can be controlled. 308 // Bounds for windows we know can be controlled.
314 gfx::Rect rect(10, 10, 200, 50); 309 gfx::Rect rect(10, 10, 200, 50);
315 scoped_ptr<aura::Window> initially_minimized_window( 310 scoped_ptr<aura::Window> initially_minimized_window(
316 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 311 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
317 scoped_ptr<aura::Window> initially_normal_window( 312 scoped_ptr<aura::Window> initially_normal_window(
318 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 313 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
319 scoped_ptr<aura::Window> initially_maximized_window( 314 scoped_ptr<aura::Window> initially_maximized_window(
320 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 315 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
321 wm::GetWindowState(initially_minimized_window.get())->Minimize(); 316 wm::GetWindowState(initially_minimized_window.get())->Minimize();
322 wm::GetWindowState(initially_maximized_window.get())->Maximize(); 317 wm::GetWindowState(initially_maximized_window.get())->Maximize();
323 318
324 // Create the manager and make sure that the window gets detected. 319 // Create the manager and make sure that the window gets detected.
325 ash::internal::MaximizeModeWindowManager* manager = 320 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
326 CreateMaximizeModeWindowManager();
327 ASSERT_TRUE(manager); 321 ASSERT_TRUE(manager);
328 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 322 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
329 EXPECT_TRUE(wm::GetWindowState( 323 EXPECT_TRUE(wm::GetWindowState(
330 initially_minimized_window.get())->IsMinimized()); 324 initially_minimized_window.get())->IsMinimized());
331 EXPECT_TRUE(wm::GetWindowState(initially_normal_window.get())->IsMaximized()); 325 EXPECT_TRUE(wm::GetWindowState(initially_normal_window.get())->IsMaximized());
332 EXPECT_TRUE(wm::GetWindowState( 326 EXPECT_TRUE(wm::GetWindowState(
333 initially_maximized_window.get())->IsMaximized()); 327 initially_maximized_window.get())->IsMaximized());
334 // Now minimize the second window to check that upon leaving the window 328 // Now minimize the second window to check that upon leaving the window
335 // will get restored to its minimized state. 329 // will get restored to its minimized state.
336 wm::GetWindowState(initially_normal_window.get())->Minimize(); 330 wm::GetWindowState(initially_normal_window.get())->Minimize();
(...skipping 24 matching lines...) Expand all
361 scoped_ptr<aura::Window> window1( 355 scoped_ptr<aura::Window> window1(
362 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 356 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
363 EXPECT_EQ(rect.ToString(), window1->bounds().ToString()); 357 EXPECT_EQ(rect.ToString(), window1->bounds().ToString());
364 358
365 // This window will not move because it does fit the new bounds. 359 // This window will not move because it does fit the new bounds.
366 gfx::Rect rect2(20, 140, 100, 100); 360 gfx::Rect rect2(20, 140, 100, 100);
367 scoped_ptr<aura::Window> window2( 361 scoped_ptr<aura::Window> window2(
368 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); 362 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2));
369 363
370 // Turning on the manager will reposition (but not resize) the window. 364 // Turning on the manager will reposition (but not resize) the window.
371 ash::internal::MaximizeModeWindowManager* manager = 365 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
372 CreateMaximizeModeWindowManager();
373 ASSERT_TRUE(manager); 366 ASSERT_TRUE(manager);
374 EXPECT_EQ(2, manager->GetNumberOfManagedWindows()); 367 EXPECT_EQ(2, manager->GetNumberOfManagedWindows());
375 gfx::Rect moved_bounds(window1->bounds()); 368 gfx::Rect moved_bounds(window1->bounds());
376 EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString()); 369 EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString());
377 EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString()); 370 EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString());
378 371
379 // Simulating a desktop resize should move the window again. 372 // Simulating a desktop resize should move the window again.
380 UpdateDisplay("300x300"); 373 UpdateDisplay("300x300");
381 gfx::Rect new_moved_bounds(window1->bounds()); 374 gfx::Rect new_moved_bounds(window1->bounds());
382 EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString()); 375 EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString());
383 EXPECT_EQ(rect.size().ToString(), new_moved_bounds.size().ToString()); 376 EXPECT_EQ(rect.size().ToString(), new_moved_bounds.size().ToString());
384 EXPECT_NE(moved_bounds.origin().ToString(), new_moved_bounds.ToString()); 377 EXPECT_NE(moved_bounds.origin().ToString(), new_moved_bounds.ToString());
385 378
386 // Turning off the mode should not restore to the initial coordinates since 379 // Turning off the mode should not restore to the initial coordinates since
387 // the new resolution is smaller and the window was on the edge. 380 // the new resolution is smaller and the window was on the edge.
388 DestroyMaximizeModeWindowManager(); 381 DestroyMaximizeModeWindowManager();
389 EXPECT_NE(rect.ToString(), window1->bounds().ToString()); 382 EXPECT_NE(rect.ToString(), window1->bounds().ToString());
390 EXPECT_EQ(rect2.ToString(), window2->bounds().ToString()); 383 EXPECT_EQ(rect2.ToString(), window2->bounds().ToString());
391 } 384 }
392 385
393 // Check that windows return to original location if desktop size changes to 386 // Check that windows return to original location if desktop size changes to
394 // something else and back while in maximize mode. 387 // something else and back while in maximize mode.
395 TEST_F(MaximizeModeWindowManagerTest, SizeChangeReturnWindowToOriginalPos) { 388 TEST_F(MaximizeModeWindowManagerTest, SizeChangeReturnWindowToOriginalPos) {
396 gfx::Rect rect(20, 140, 100, 100); 389 gfx::Rect rect(20, 140, 100, 100);
397 scoped_ptr<aura::Window> window( 390 scoped_ptr<aura::Window> window(
398 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 391 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
399 392
400 // Turning on the manager will reposition (but not resize) the window. 393 // Turning on the manager will reposition (but not resize) the window.
401 ash::internal::MaximizeModeWindowManager* manager = 394 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
402 CreateMaximizeModeWindowManager();
403 ASSERT_TRUE(manager); 395 ASSERT_TRUE(manager);
404 EXPECT_EQ(1, manager->GetNumberOfManagedWindows()); 396 EXPECT_EQ(1, manager->GetNumberOfManagedWindows());
405 gfx::Rect moved_bounds(window->bounds()); 397 gfx::Rect moved_bounds(window->bounds());
406 EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString()); 398 EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString());
407 EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString()); 399 EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString());
408 400
409 // Simulating a desktop resize should move the window again. 401 // Simulating a desktop resize should move the window again.
410 ResizeDesktop(-10); 402 ResizeDesktop(-10);
411 gfx::Rect new_moved_bounds(window->bounds()); 403 gfx::Rect new_moved_bounds(window->bounds());
412 EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString()); 404 EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString());
(...skipping 24 matching lines...) Expand all
437 MruWindowTracker::WindowList windows = 429 MruWindowTracker::WindowList windows =
438 MruWindowTracker::BuildWindowList(false); 430 MruWindowTracker::BuildWindowList(false);
439 EXPECT_EQ(w1.get(), windows[4]); 431 EXPECT_EQ(w1.get(), windows[4]);
440 EXPECT_EQ(w2.get(), windows[3]); 432 EXPECT_EQ(w2.get(), windows[3]);
441 EXPECT_EQ(w3.get(), windows[2]); 433 EXPECT_EQ(w3.get(), windows[2]);
442 EXPECT_EQ(w4.get(), windows[1]); 434 EXPECT_EQ(w4.get(), windows[1]);
443 EXPECT_EQ(w5.get(), windows[0]); 435 EXPECT_EQ(w5.get(), windows[0]);
444 } 436 }
445 437
446 // Activating the window manager should keep the order. 438 // Activating the window manager should keep the order.
447 ash::internal::MaximizeModeWindowManager* manager = 439 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
448 CreateMaximizeModeWindowManager();
449 ASSERT_TRUE(manager); 440 ASSERT_TRUE(manager);
450 EXPECT_EQ(5, manager->GetNumberOfManagedWindows()); 441 EXPECT_EQ(5, manager->GetNumberOfManagedWindows());
451 { 442 {
452 MruWindowTracker::WindowList windows = 443 MruWindowTracker::WindowList windows =
453 MruWindowTracker::BuildWindowList(false); 444 MruWindowTracker::BuildWindowList(false);
454 // We do not test maximization here again since that was done already. 445 // We do not test maximization here again since that was done already.
455 EXPECT_EQ(w1.get(), windows[4]); 446 EXPECT_EQ(w1.get(), windows[4]);
456 EXPECT_EQ(w2.get(), windows[3]); 447 EXPECT_EQ(w2.get(), windows[3]);
457 EXPECT_EQ(w3.get(), windows[2]); 448 EXPECT_EQ(w3.get(), windows[2]);
458 EXPECT_EQ(w4.get(), windows[1]); 449 EXPECT_EQ(w4.get(), windows[1]);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 generator.MoveMouseBy(10, 5); 574 generator.MoveMouseBy(10, 5);
584 RunAllPendingInMessageLoop(); 575 RunAllPendingInMessageLoop();
585 generator.ReleaseLeftButton(); 576 generator.ReleaseLeftButton();
586 EXPECT_EQ(first_dragged_origin.x() + 10, window->bounds().x()); 577 EXPECT_EQ(first_dragged_origin.x() + 10, window->bounds().x());
587 EXPECT_EQ(first_dragged_origin.y() + 5, window->bounds().y()); 578 EXPECT_EQ(first_dragged_origin.y() + 5, window->bounds().y());
588 } 579 }
589 580
590 #endif // OS_WIN 581 #endif // OS_WIN
591 582
592 } // namespace ash 583 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/maximize_mode/maximize_mode_window_manager.cc ('k') | ash/wm/maximize_mode/maximize_mode_window_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698