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

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

Issue 2113053003: Moves Shell::maximize_mode_controller() to WmShell (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: order Created 4 years, 5 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/common/wm/maximize_mode/maximize_mode_window_manager.h" 5 #include "ash/common/wm/maximize_mode/maximize_mode_window_manager.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "ash/aura/wm_window_aura.h" 9 #include "ash/aura/wm_window_aura.h"
10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 10 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 widget->Init(params); 75 widget->Init(params);
76 widget->Show(); 76 widget->Show();
77 aura::Window* window = widget->GetNativeWindow(); 77 aura::Window* window = widget->GetNativeWindow();
78 window->SetBounds(bounds); 78 window->SetBounds(bounds);
79 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 79 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
80 80
81 return window; 81 return window;
82 } 82 }
83 83
84 // Create the Maximized mode window manager. 84 // Create the Maximized mode window manager.
85 ash::MaximizeModeWindowManager* CreateMaximizeModeWindowManager() { 85 MaximizeModeWindowManager* CreateMaximizeModeWindowManager() {
86 EXPECT_FALSE(maximize_mode_window_manager()); 86 EXPECT_FALSE(maximize_mode_window_manager());
87 Shell::GetInstance() 87 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
88 ->maximize_mode_controller() 88 true);
89 ->EnableMaximizeModeWindowManager(true);
90 return maximize_mode_window_manager(); 89 return maximize_mode_window_manager();
91 } 90 }
92 91
93 // Destroy the maximized mode window manager. 92 // Destroy the maximized mode window manager.
94 void DestroyMaximizeModeWindowManager() { 93 void DestroyMaximizeModeWindowManager() {
95 Shell::GetInstance() 94 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
96 ->maximize_mode_controller() 95 false);
97 ->EnableMaximizeModeWindowManager(false);
98 EXPECT_FALSE(maximize_mode_window_manager()); 96 EXPECT_FALSE(maximize_mode_window_manager());
99 } 97 }
100 98
101 // Get the maximze window manager. 99 // Get the maximze window manager.
102 ash::MaximizeModeWindowManager* maximize_mode_window_manager() { 100 MaximizeModeWindowManager* maximize_mode_window_manager() {
103 return Shell::GetInstance() 101 return WmShell::Get()
104 ->maximize_mode_controller() 102 ->maximize_mode_controller()
105 ->maximize_mode_window_manager_.get(); 103 ->maximize_mode_window_manager_.get();
106 } 104 }
107 105
108 // Resize our desktop. 106 // Resize our desktop.
109 void ResizeDesktop(int width_delta) { 107 void ResizeDesktop(int width_delta) {
110 gfx::Size size = 108 gfx::Size size =
111 display::Screen::GetScreen() 109 display::Screen::GetScreen()
112 ->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()) 110 ->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow())
113 .size(); 111 .size();
(...skipping 28 matching lines...) Expand all
142 container->AddChild(window); 140 container->AddChild(window);
143 return window; 141 return window;
144 } 142 }
145 143
146 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManagerTest); 144 DISALLOW_COPY_AND_ASSIGN(MaximizeModeWindowManagerTest);
147 }; 145 };
148 146
149 // Test that creating the object and destroying it without any windows should 147 // Test that creating the object and destroying it without any windows should
150 // not cause any problems. 148 // not cause any problems.
151 TEST_F(MaximizeModeWindowManagerTest, SimpleStart) { 149 TEST_F(MaximizeModeWindowManagerTest, SimpleStart) {
152 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 150 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
153 ASSERT_TRUE(manager); 151 ASSERT_TRUE(manager);
154 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 152 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
155 DestroyMaximizeModeWindowManager(); 153 DestroyMaximizeModeWindowManager();
156 } 154 }
157 155
158 // Test that existing windows will handled properly when going into maximized 156 // Test that existing windows will handled properly when going into maximized
159 // mode. 157 // mode.
160 TEST_F(MaximizeModeWindowManagerTest, PreCreateWindows) { 158 TEST_F(MaximizeModeWindowManagerTest, PreCreateWindows) {
161 // Bounds for windows we know can be controlled. 159 // Bounds for windows we know can be controlled.
162 gfx::Rect rect1(10, 10, 200, 50); 160 gfx::Rect rect1(10, 10, 200, 50);
(...skipping 19 matching lines...) Expand all
182 CreateWindow(ui::wm::WINDOW_TYPE_TOOLTIP, rect)); 180 CreateWindow(ui::wm::WINDOW_TYPE_TOOLTIP, rect));
183 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); 181 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized());
184 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); 182 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized());
185 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); 183 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
186 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); 184 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
187 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); 185 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
188 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString()); 186 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString());
189 187
190 // Create the manager and make sure that all qualifying windows were detected 188 // Create the manager and make sure that all qualifying windows were detected
191 // and changed. 189 // and changed.
192 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 190 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
193 ASSERT_TRUE(manager); 191 ASSERT_TRUE(manager);
194 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 192 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
195 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized()); 193 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized());
196 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); 194 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized());
197 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); 195 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
198 EXPECT_NE(rect3.origin().ToString(), w3->bounds().origin().ToString()); 196 EXPECT_NE(rect3.origin().ToString(), w3->bounds().origin().ToString());
199 EXPECT_EQ(rect3.size().ToString(), w3->bounds().size().ToString()); 197 EXPECT_EQ(rect3.size().ToString(), w3->bounds().size().ToString());
200 198
201 // All other windows should not have been touched. 199 // All other windows should not have been touched.
202 EXPECT_FALSE(wm::GetWindowState(w4.get())->IsMaximized()); 200 EXPECT_FALSE(wm::GetWindowState(w4.get())->IsMaximized());
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); 254 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
257 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); 255 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
258 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString()); 256 EXPECT_EQ(rect3.ToString(), w3->bounds().ToString());
259 257
260 // Enable system modal dialog, and make sure both shelves are still hidden. 258 // Enable system modal dialog, and make sure both shelves are still hidden.
261 WmShell::Get()->SimulateModalWindowOpenForTesting(true); 259 WmShell::Get()->SimulateModalWindowOpenForTesting(true);
262 EXPECT_TRUE(WmShell::Get()->IsSystemModalWindowOpen()); 260 EXPECT_TRUE(WmShell::Get()->IsSystemModalWindowOpen());
263 261
264 // Create the manager and make sure that all qualifying windows were detected 262 // Create the manager and make sure that all qualifying windows were detected
265 // and changed. 263 // and changed.
266 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 264 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
267 ASSERT_TRUE(manager); 265 ASSERT_TRUE(manager);
268 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 266 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
269 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized()); 267 EXPECT_TRUE(wm::GetWindowState(w1.get())->IsMaximized());
270 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized()); 268 EXPECT_TRUE(wm::GetWindowState(w2.get())->IsMaximized());
271 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized()); 269 EXPECT_FALSE(wm::GetWindowState(w3.get())->IsMaximized());
272 EXPECT_NE(rect3.origin().ToString(), w3->bounds().origin().ToString()); 270 EXPECT_NE(rect3.origin().ToString(), w3->bounds().origin().ToString());
273 EXPECT_EQ(rect3.size().ToString(), w3->bounds().size().ToString()); 271 EXPECT_EQ(rect3.size().ToString(), w3->bounds().size().ToString());
274 272
275 // All other windows should not have been touched. 273 // All other windows should not have been touched.
276 EXPECT_FALSE(wm::GetWindowState(w4.get())->IsMaximized()); 274 EXPECT_FALSE(wm::GetWindowState(w4.get())->IsMaximized());
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString()); 318 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString());
321 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized()); 319 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized());
322 EXPECT_EQ(rect.ToString(), fixed_window->bounds().ToString()); 320 EXPECT_EQ(rect.ToString(), fixed_window->bounds().ToString());
323 321
324 gfx::Size workspace_size = 322 gfx::Size workspace_size =
325 ScreenUtil::GetMaximizedWindowBoundsInParent(unlimited_window.get()) 323 ScreenUtil::GetMaximizedWindowBoundsInParent(unlimited_window.get())
326 .size(); 324 .size();
327 325
328 // Create the manager and make sure that all qualifying windows were detected 326 // Create the manager and make sure that all qualifying windows were detected
329 // and changed. 327 // and changed.
330 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 328 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
331 ASSERT_TRUE(manager); 329 ASSERT_TRUE(manager);
332 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 330 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
333 // The unlimited window should have the size of the workspace / parent window. 331 // The unlimited window should have the size of the workspace / parent window.
334 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized()); 332 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized());
335 EXPECT_EQ("0,0", unlimited_window->bounds().origin().ToString()); 333 EXPECT_EQ("0,0", unlimited_window->bounds().origin().ToString());
336 EXPECT_EQ(workspace_size.ToString(), 334 EXPECT_EQ(workspace_size.ToString(),
337 unlimited_window->bounds().size().ToString()); 335 unlimited_window->bounds().size().ToString());
338 // The limited window should have the size of the upper possible bounds. 336 // The limited window should have the size of the upper possible bounds.
339 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized()); 337 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized());
340 EXPECT_NE(rect.origin().ToString(), 338 EXPECT_NE(rect.origin().ToString(),
(...skipping 11 matching lines...) Expand all
352 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized()); 350 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized());
353 EXPECT_EQ(rect.ToString(), unlimited_window->bounds().ToString()); 351 EXPECT_EQ(rect.ToString(), unlimited_window->bounds().ToString());
354 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized()); 352 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized());
355 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString()); 353 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString());
356 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized()); 354 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized());
357 EXPECT_EQ(rect.ToString(), fixed_window->bounds().ToString()); 355 EXPECT_EQ(rect.ToString(), fixed_window->bounds().ToString());
358 } 356 }
359 357
360 // Test that creating windows while a maximizer exists picks them properly up. 358 // Test that creating windows while a maximizer exists picks them properly up.
361 TEST_F(MaximizeModeWindowManagerTest, CreateWindows) { 359 TEST_F(MaximizeModeWindowManagerTest, CreateWindows) {
362 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 360 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
363 ASSERT_TRUE(manager); 361 ASSERT_TRUE(manager);
364 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 362 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
365 363
366 // Create the windows and see that the window manager picks them up. 364 // Create the windows and see that the window manager picks them up.
367 // Rects for windows we know can be controlled. 365 // Rects for windows we know can be controlled.
368 gfx::Rect rect1(10, 10, 200, 50); 366 gfx::Rect rect1(10, 10, 200, 50);
369 gfx::Rect rect2(10, 60, 200, 50); 367 gfx::Rect rect2(10, 60, 200, 50);
370 gfx::Rect rect3(20, 140, 100, 100); 368 gfx::Rect rect3(20, 140, 100, 100);
371 // One rect for anything else. 369 // One rect for anything else.
372 gfx::Rect rect(80, 90, 100, 110); 370 gfx::Rect rect(80, 90, 100, 110);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 EXPECT_EQ(rect.ToString(), w5->bounds().ToString()); 424 EXPECT_EQ(rect.ToString(), w5->bounds().ToString());
427 EXPECT_EQ(rect.ToString(), w6->bounds().ToString()); 425 EXPECT_EQ(rect.ToString(), w6->bounds().ToString());
428 EXPECT_EQ(rect.ToString(), w7->bounds().ToString()); 426 EXPECT_EQ(rect.ToString(), w7->bounds().ToString());
429 EXPECT_EQ(rect.ToString(), w8->bounds().ToString()); 427 EXPECT_EQ(rect.ToString(), w8->bounds().ToString());
430 } 428 }
431 429
432 // Test that a window which got created while the maximize mode window manager 430 // Test that a window which got created while the maximize mode window manager
433 // is active gets restored to a usable (non tiny) size upon switching back. 431 // is active gets restored to a usable (non tiny) size upon switching back.
434 TEST_F(MaximizeModeWindowManagerTest, 432 TEST_F(MaximizeModeWindowManagerTest,
435 CreateWindowInMaximizedModeRestoresToUsefulSize) { 433 CreateWindowInMaximizedModeRestoresToUsefulSize) {
436 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 434 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
437 ASSERT_TRUE(manager); 435 ASSERT_TRUE(manager);
438 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 436 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
439 437
440 // We pass in an empty rectangle to simulate a window creation with no 438 // We pass in an empty rectangle to simulate a window creation with no
441 // particular size. 439 // particular size.
442 gfx::Rect empty_rect(0, 0, 0, 0); 440 gfx::Rect empty_rect(0, 0, 0, 0);
443 std::unique_ptr<aura::Window> window( 441 std::unique_ptr<aura::Window> window(
444 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, empty_rect)); 442 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, empty_rect));
445 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized()); 443 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized());
446 EXPECT_NE(empty_rect.ToString(), window->bounds().ToString()); 444 EXPECT_NE(empty_rect.ToString(), window->bounds().ToString());
447 gfx::Rect maximized_size = window->bounds(); 445 gfx::Rect maximized_size = window->bounds();
448 446
449 // Destroy the maximize mode and check that the resulting size of the window 447 // Destroy the maximize mode and check that the resulting size of the window
450 // is remaining as it is (but not maximized). 448 // is remaining as it is (but not maximized).
451 DestroyMaximizeModeWindowManager(); 449 DestroyMaximizeModeWindowManager();
452 450
453 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); 451 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized());
454 EXPECT_EQ(maximized_size.ToString(), window->bounds().ToString()); 452 EXPECT_EQ(maximized_size.ToString(), window->bounds().ToString());
455 } 453 }
456 454
457 // Test that non-maximizable windows get properly handled when created in 455 // Test that non-maximizable windows get properly handled when created in
458 // maximized mode. 456 // maximized mode.
459 TEST_F(MaximizeModeWindowManagerTest, CreateNonMaximizableButResizableWindows) { 457 TEST_F(MaximizeModeWindowManagerTest, CreateNonMaximizableButResizableWindows) {
460 // Create the manager and make sure that all qualifying windows were detected 458 // Create the manager and make sure that all qualifying windows were detected
461 // and changed. 459 // and changed.
462 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 460 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
463 ASSERT_TRUE(manager); 461 ASSERT_TRUE(manager);
464 462
465 gfx::Rect rect(10, 10, 200, 50); 463 gfx::Rect rect(10, 10, 200, 50);
466 gfx::Size max_size(300, 200); 464 gfx::Size max_size(300, 200);
467 gfx::Size empty_size; 465 gfx::Size empty_size;
468 std::unique_ptr<aura::Window> unlimited_window( 466 std::unique_ptr<aura::Window> unlimited_window(
469 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, empty_size)); 467 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, empty_size));
470 std::unique_ptr<aura::Window> limited_window( 468 std::unique_ptr<aura::Window> limited_window(
471 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, max_size)); 469 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, max_size));
472 std::unique_ptr<aura::Window> fixed_window( 470 std::unique_ptr<aura::Window> fixed_window(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 506
509 // Create a string which consists of the bounds and the state for comparison. 507 // Create a string which consists of the bounds and the state for comparison.
510 std::string GetPlacementString(const gfx::Rect& bounds, 508 std::string GetPlacementString(const gfx::Rect& bounds,
511 ui::WindowShowState state) { 509 ui::WindowShowState state) {
512 return bounds.ToString() + base::StringPrintf(" %d", state); 510 return bounds.ToString() + base::StringPrintf(" %d", state);
513 } 511 }
514 512
515 // Retrieves the window's restore state override - if any - and returns it as a 513 // Retrieves the window's restore state override - if any - and returns it as a
516 // string. 514 // string.
517 std::string GetPlacementOverride(aura::Window* window) { 515 std::string GetPlacementOverride(aura::Window* window) {
518 gfx::Rect* bounds = window->GetProperty(ash::kRestoreBoundsOverrideKey); 516 gfx::Rect* bounds = window->GetProperty(kRestoreBoundsOverrideKey);
519 if (bounds) { 517 if (bounds) {
520 gfx::Rect restore_bounds = *bounds; 518 gfx::Rect restore_bounds = *bounds;
521 ui::WindowShowState restore_state = 519 ui::WindowShowState restore_state =
522 window->GetProperty(ash::kRestoreShowStateOverrideKey); 520 window->GetProperty(kRestoreShowStateOverrideKey);
523 return GetPlacementString(restore_bounds, restore_state); 521 return GetPlacementString(restore_bounds, restore_state);
524 } 522 }
525 return std::string(); 523 return std::string();
526 } 524 }
527 525
528 // Test that the restore state will be kept at its original value for 526 // Test that the restore state will be kept at its original value for
529 // session restauration purposes. 527 // session restauration purposes.
530 TEST_F(MaximizeModeWindowManagerTest, TestRestoreIntegrety) { 528 TEST_F(MaximizeModeWindowManagerTest, TestRestoreIntegrety) {
531 gfx::Rect bounds(10, 10, 200, 50); 529 gfx::Rect bounds(10, 10, 200, 50);
532 gfx::Size empty_size; 530 gfx::Size empty_size;
533 gfx::Rect empty_bounds; 531 gfx::Rect empty_bounds;
534 std::unique_ptr<aura::Window> normal_window(CreateWindowWithWidget(bounds)); 532 std::unique_ptr<aura::Window> normal_window(CreateWindowWithWidget(bounds));
535 std::unique_ptr<aura::Window> maximized_window( 533 std::unique_ptr<aura::Window> maximized_window(
536 CreateWindowWithWidget(bounds)); 534 CreateWindowWithWidget(bounds));
537 wm::GetWindowState(maximized_window.get())->Maximize(); 535 wm::GetWindowState(maximized_window.get())->Maximize();
538 536
539 EXPECT_EQ(std::string(), GetPlacementOverride(normal_window.get())); 537 EXPECT_EQ(std::string(), GetPlacementOverride(normal_window.get()));
540 EXPECT_EQ(std::string(), GetPlacementOverride(maximized_window.get())); 538 EXPECT_EQ(std::string(), GetPlacementOverride(maximized_window.get()));
541 539
542 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 540 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
543 ASSERT_TRUE(manager); 541 ASSERT_TRUE(manager);
544 542
545 // With the maximization the override states should be returned in its 543 // With the maximization the override states should be returned in its
546 // pre-maximized state. 544 // pre-maximized state.
547 EXPECT_EQ(GetPlacementString(bounds, ui::SHOW_STATE_NORMAL), 545 EXPECT_EQ(GetPlacementString(bounds, ui::SHOW_STATE_NORMAL),
548 GetPlacementOverride(normal_window.get())); 546 GetPlacementOverride(normal_window.get()));
549 EXPECT_EQ(GetPlacementString(bounds, ui::SHOW_STATE_MAXIMIZED), 547 EXPECT_EQ(GetPlacementString(bounds, ui::SHOW_STATE_MAXIMIZED),
550 GetPlacementOverride(maximized_window.get())); 548 GetPlacementOverride(maximized_window.get()));
551 549
552 // Changing a window's state now does not change the returned result. 550 // Changing a window's state now does not change the returned result.
(...skipping 10 matching lines...) Expand all
563 wm::GetWindowState(maximized_window.get())->Restore(); 561 wm::GetWindowState(maximized_window.get())->Restore();
564 gfx::Rect new_bounds(10, 10, 200, 50); 562 gfx::Rect new_bounds(10, 10, 200, 50);
565 maximized_window->SetBounds(new_bounds); 563 maximized_window->SetBounds(new_bounds);
566 564
567 EXPECT_EQ(std::string(), GetPlacementOverride(maximized_window.get())); 565 EXPECT_EQ(std::string(), GetPlacementOverride(maximized_window.get()));
568 } 566 }
569 567
570 // Test that windows which got created before the maximizer was created can be 568 // Test that windows which got created before the maximizer was created can be
571 // destroyed while the maximizer is still running. 569 // destroyed while the maximizer is still running.
572 TEST_F(MaximizeModeWindowManagerTest, PreCreateWindowsDeleteWhileActive) { 570 TEST_F(MaximizeModeWindowManagerTest, PreCreateWindowsDeleteWhileActive) {
573 ash::MaximizeModeWindowManager* manager = NULL; 571 MaximizeModeWindowManager* manager = NULL;
574 { 572 {
575 // Bounds for windows we know can be controlled. 573 // Bounds for windows we know can be controlled.
576 gfx::Rect rect1(10, 10, 200, 50); 574 gfx::Rect rect1(10, 10, 200, 50);
577 gfx::Rect rect2(10, 60, 200, 50); 575 gfx::Rect rect2(10, 60, 200, 50);
578 gfx::Rect rect3(20, 140, 100, 100); 576 gfx::Rect rect3(20, 140, 100, 100);
579 // Bounds for anything else. 577 // Bounds for anything else.
580 gfx::Rect rect(80, 90, 100, 110); 578 gfx::Rect rect(80, 90, 100, 110);
581 std::unique_ptr<aura::Window> w1( 579 std::unique_ptr<aura::Window> w1(
582 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1)); 580 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1));
583 std::unique_ptr<aura::Window> w2( 581 std::unique_ptr<aura::Window> w2(
584 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); 582 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2));
585 std::unique_ptr<aura::Window> w3( 583 std::unique_ptr<aura::Window> w3(
586 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect3)); 584 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect3));
587 585
588 // Create the manager and make sure that all qualifying windows were 586 // Create the manager and make sure that all qualifying windows were
589 // detected and changed. 587 // detected and changed.
590 manager = CreateMaximizeModeWindowManager(); 588 manager = CreateMaximizeModeWindowManager();
591 ASSERT_TRUE(manager); 589 ASSERT_TRUE(manager);
592 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 590 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
593 } 591 }
594 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 592 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
595 DestroyMaximizeModeWindowManager(); 593 DestroyMaximizeModeWindowManager();
596 } 594 }
597 595
598 // Test that windows which got created while the maximizer was running can get 596 // Test that windows which got created while the maximizer was running can get
599 // destroyed before the maximizer gets destroyed. 597 // destroyed before the maximizer gets destroyed.
600 TEST_F(MaximizeModeWindowManagerTest, CreateWindowsAndDeleteWhileActive) { 598 TEST_F(MaximizeModeWindowManagerTest, CreateWindowsAndDeleteWhileActive) {
601 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 599 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
602 ASSERT_TRUE(manager); 600 ASSERT_TRUE(manager);
603 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 601 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
604 { 602 {
605 // Bounds for windows we know can be controlled. 603 // Bounds for windows we know can be controlled.
606 gfx::Rect rect1(10, 10, 200, 50); 604 gfx::Rect rect1(10, 10, 200, 50);
607 gfx::Rect rect2(10, 60, 200, 50); 605 gfx::Rect rect2(10, 60, 200, 50);
608 gfx::Rect rect3(20, 140, 100, 100); 606 gfx::Rect rect3(20, 140, 100, 100);
609 std::unique_ptr<aura::Window> w1( 607 std::unique_ptr<aura::Window> w1(
610 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50))); 608 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50)));
611 std::unique_ptr<aura::Window> w2( 609 std::unique_ptr<aura::Window> w2(
(...skipping 12 matching lines...) Expand all
624 622
625 // Test that windows which were maximized stay maximized. 623 // Test that windows which were maximized stay maximized.
626 TEST_F(MaximizeModeWindowManagerTest, MaximizedShouldRemainMaximized) { 624 TEST_F(MaximizeModeWindowManagerTest, MaximizedShouldRemainMaximized) {
627 // Bounds for windows we know can be controlled. 625 // Bounds for windows we know can be controlled.
628 gfx::Rect rect(10, 10, 200, 50); 626 gfx::Rect rect(10, 10, 200, 50);
629 std::unique_ptr<aura::Window> window( 627 std::unique_ptr<aura::Window> window(
630 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 628 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
631 wm::GetWindowState(window.get())->Maximize(); 629 wm::GetWindowState(window.get())->Maximize();
632 630
633 // Create the manager and make sure that the window gets detected. 631 // Create the manager and make sure that the window gets detected.
634 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 632 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
635 ASSERT_TRUE(manager); 633 ASSERT_TRUE(manager);
636 EXPECT_EQ(1, manager->GetNumberOfManagedWindows()); 634 EXPECT_EQ(1, manager->GetNumberOfManagedWindows());
637 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized()); 635 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized());
638 636
639 // Destroy the manager again and check that the window will remain maximized. 637 // Destroy the manager again and check that the window will remain maximized.
640 DestroyMaximizeModeWindowManager(); 638 DestroyMaximizeModeWindowManager();
641 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized()); 639 EXPECT_TRUE(wm::GetWindowState(window.get())->IsMaximized());
642 wm::GetWindowState(window.get())->Restore(); 640 wm::GetWindowState(window.get())->Restore();
643 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); 641 EXPECT_EQ(rect.ToString(), window->bounds().ToString());
644 } 642 }
645 643
646 // Test that minimized windows do neither get maximized nor restored upon 644 // Test that minimized windows do neither get maximized nor restored upon
647 // entering maximized mode and get restored to their previous state after 645 // entering maximized mode and get restored to their previous state after
648 // leaving. 646 // leaving.
649 TEST_F(MaximizeModeWindowManagerTest, MinimizedWindowBehavior) { 647 TEST_F(MaximizeModeWindowManagerTest, MinimizedWindowBehavior) {
650 // Bounds for windows we know can be controlled. 648 // Bounds for windows we know can be controlled.
651 gfx::Rect rect(10, 10, 200, 50); 649 gfx::Rect rect(10, 10, 200, 50);
652 std::unique_ptr<aura::Window> initially_minimized_window( 650 std::unique_ptr<aura::Window> initially_minimized_window(
653 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 651 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
654 std::unique_ptr<aura::Window> initially_normal_window( 652 std::unique_ptr<aura::Window> initially_normal_window(
655 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 653 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
656 std::unique_ptr<aura::Window> initially_maximized_window( 654 std::unique_ptr<aura::Window> initially_maximized_window(
657 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 655 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
658 wm::GetWindowState(initially_minimized_window.get())->Minimize(); 656 wm::GetWindowState(initially_minimized_window.get())->Minimize();
659 wm::GetWindowState(initially_maximized_window.get())->Maximize(); 657 wm::GetWindowState(initially_maximized_window.get())->Maximize();
660 658
661 // Create the manager and make sure that the window gets detected. 659 // Create the manager and make sure that the window gets detected.
662 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 660 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
663 ASSERT_TRUE(manager); 661 ASSERT_TRUE(manager);
664 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 662 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
665 EXPECT_TRUE( 663 EXPECT_TRUE(
666 wm::GetWindowState(initially_minimized_window.get())->IsMinimized()); 664 wm::GetWindowState(initially_minimized_window.get())->IsMinimized());
667 EXPECT_TRUE(wm::GetWindowState(initially_normal_window.get())->IsMaximized()); 665 EXPECT_TRUE(wm::GetWindowState(initially_normal_window.get())->IsMaximized());
668 EXPECT_TRUE( 666 EXPECT_TRUE(
669 wm::GetWindowState(initially_maximized_window.get())->IsMaximized()); 667 wm::GetWindowState(initially_maximized_window.get())->IsMaximized());
670 // Now minimize the second window to check that upon leaving the window 668 // Now minimize the second window to check that upon leaving the window
671 // will get restored to its minimized state. 669 // will get restored to its minimized state.
672 wm::GetWindowState(initially_normal_window.get())->Minimize(); 670 wm::GetWindowState(initially_normal_window.get())->Minimize();
(...skipping 23 matching lines...) Expand all
696 std::unique_ptr<aura::Window> window1( 694 std::unique_ptr<aura::Window> window1(
697 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 695 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
698 EXPECT_EQ(rect.ToString(), window1->bounds().ToString()); 696 EXPECT_EQ(rect.ToString(), window1->bounds().ToString());
699 697
700 // This window will not move because it does fit the new bounds. 698 // This window will not move because it does fit the new bounds.
701 gfx::Rect rect2(20, 140, 100, 100); 699 gfx::Rect rect2(20, 140, 100, 100);
702 std::unique_ptr<aura::Window> window2( 700 std::unique_ptr<aura::Window> window2(
703 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); 701 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2));
704 702
705 // Turning on the manager will reposition (but not resize) the window. 703 // Turning on the manager will reposition (but not resize) the window.
706 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 704 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
707 ASSERT_TRUE(manager); 705 ASSERT_TRUE(manager);
708 EXPECT_EQ(2, manager->GetNumberOfManagedWindows()); 706 EXPECT_EQ(2, manager->GetNumberOfManagedWindows());
709 gfx::Rect moved_bounds(window1->bounds()); 707 gfx::Rect moved_bounds(window1->bounds());
710 EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString()); 708 EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString());
711 EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString()); 709 EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString());
712 710
713 // Simulating a desktop resize should move the window again. 711 // Simulating a desktop resize should move the window again.
714 UpdateDisplay("300x300"); 712 UpdateDisplay("300x300");
715 gfx::Rect new_moved_bounds(window1->bounds()); 713 gfx::Rect new_moved_bounds(window1->bounds());
716 EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString()); 714 EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString());
717 EXPECT_EQ(rect.size().ToString(), new_moved_bounds.size().ToString()); 715 EXPECT_EQ(rect.size().ToString(), new_moved_bounds.size().ToString());
718 EXPECT_NE(moved_bounds.origin().ToString(), new_moved_bounds.ToString()); 716 EXPECT_NE(moved_bounds.origin().ToString(), new_moved_bounds.ToString());
719 717
720 // Turning off the mode should not restore to the initial coordinates since 718 // Turning off the mode should not restore to the initial coordinates since
721 // the new resolution is smaller and the window was on the edge. 719 // the new resolution is smaller and the window was on the edge.
722 DestroyMaximizeModeWindowManager(); 720 DestroyMaximizeModeWindowManager();
723 EXPECT_NE(rect.ToString(), window1->bounds().ToString()); 721 EXPECT_NE(rect.ToString(), window1->bounds().ToString());
724 EXPECT_EQ(rect2.ToString(), window2->bounds().ToString()); 722 EXPECT_EQ(rect2.ToString(), window2->bounds().ToString());
725 } 723 }
726 724
727 // Check that windows return to original location if desktop size changes to 725 // Check that windows return to original location if desktop size changes to
728 // something else and back while in maximize mode. 726 // something else and back while in maximize mode.
729 TEST_F(MaximizeModeWindowManagerTest, SizeChangeReturnWindowToOriginalPos) { 727 TEST_F(MaximizeModeWindowManagerTest, SizeChangeReturnWindowToOriginalPos) {
730 gfx::Rect rect(20, 140, 100, 100); 728 gfx::Rect rect(20, 140, 100, 100);
731 std::unique_ptr<aura::Window> window( 729 std::unique_ptr<aura::Window> window(
732 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 730 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
733 731
734 // Turning on the manager will reposition (but not resize) the window. 732 // Turning on the manager will reposition (but not resize) the window.
735 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 733 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
736 ASSERT_TRUE(manager); 734 ASSERT_TRUE(manager);
737 EXPECT_EQ(1, manager->GetNumberOfManagedWindows()); 735 EXPECT_EQ(1, manager->GetNumberOfManagedWindows());
738 gfx::Rect moved_bounds(window->bounds()); 736 gfx::Rect moved_bounds(window->bounds());
739 EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString()); 737 EXPECT_NE(rect.origin().ToString(), moved_bounds.origin().ToString());
740 EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString()); 738 EXPECT_EQ(rect.size().ToString(), moved_bounds.size().ToString());
741 739
742 // Simulating a desktop resize should move the window again. 740 // Simulating a desktop resize should move the window again.
743 ResizeDesktop(-10); 741 ResizeDesktop(-10);
744 gfx::Rect new_moved_bounds(window->bounds()); 742 gfx::Rect new_moved_bounds(window->bounds());
745 EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString()); 743 EXPECT_NE(rect.origin().ToString(), new_moved_bounds.origin().ToString());
(...skipping 28 matching lines...) Expand all
774 WmShell::Get()->mru_window_tracker()->BuildMruWindowList()); 772 WmShell::Get()->mru_window_tracker()->BuildMruWindowList());
775 773
776 EXPECT_EQ(w1.get(), windows[4]); 774 EXPECT_EQ(w1.get(), windows[4]);
777 EXPECT_EQ(w2.get(), windows[3]); 775 EXPECT_EQ(w2.get(), windows[3]);
778 EXPECT_EQ(w3.get(), windows[2]); 776 EXPECT_EQ(w3.get(), windows[2]);
779 EXPECT_EQ(w4.get(), windows[1]); 777 EXPECT_EQ(w4.get(), windows[1]);
780 EXPECT_EQ(w5.get(), windows[0]); 778 EXPECT_EQ(w5.get(), windows[0]);
781 } 779 }
782 780
783 // Activating the window manager should keep the order. 781 // Activating the window manager should keep the order.
784 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 782 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
785 ASSERT_TRUE(manager); 783 ASSERT_TRUE(manager);
786 EXPECT_EQ(5, manager->GetNumberOfManagedWindows()); 784 EXPECT_EQ(5, manager->GetNumberOfManagedWindows());
787 { 785 {
788 aura::Window::Windows windows = WmWindowAura::ToAuraWindows( 786 aura::Window::Windows windows = WmWindowAura::ToAuraWindows(
789 WmShell::Get()->mru_window_tracker()->BuildMruWindowList()); 787 WmShell::Get()->mru_window_tracker()->BuildMruWindowList());
790 // We do not test maximization here again since that was done already. 788 // We do not test maximization here again since that was done already.
791 EXPECT_EQ(w1.get(), windows[4]); 789 EXPECT_EQ(w1.get(), windows[4]);
792 EXPECT_EQ(w2.get(), windows[3]); 790 EXPECT_EQ(w2.get(), windows[3]);
793 EXPECT_EQ(w3.get(), windows[2]); 791 EXPECT_EQ(w3.get(), windows[2]);
794 EXPECT_EQ(w4.get(), windows[1]); 792 EXPECT_EQ(w4.get(), windows[1]);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
826 DestroyMaximizeModeWindowManager(); 824 DestroyMaximizeModeWindowManager();
827 } 825 }
828 826
829 // Check that minimize and restore do the right thing. 827 // Check that minimize and restore do the right thing.
830 TEST_F(MaximizeModeWindowManagerTest, TestMinimize) { 828 TEST_F(MaximizeModeWindowManagerTest, TestMinimize) {
831 gfx::Rect rect(10, 10, 100, 100); 829 gfx::Rect rect(10, 10, 100, 100);
832 std::unique_ptr<aura::Window> window( 830 std::unique_ptr<aura::Window> window(
833 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 831 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
834 wm::WindowState* window_state = wm::GetWindowState(window.get()); 832 wm::WindowState* window_state = wm::GetWindowState(window.get());
835 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); 833 EXPECT_EQ(rect.ToString(), window->bounds().ToString());
836 ash::Shell::GetInstance() 834 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
837 ->maximize_mode_controller() 835 true);
838 ->EnableMaximizeModeWindowManager(true);
839 EXPECT_TRUE(window_state->IsMaximized()); 836 EXPECT_TRUE(window_state->IsMaximized());
840 EXPECT_FALSE(window_state->IsMinimized()); 837 EXPECT_FALSE(window_state->IsMinimized());
841 EXPECT_TRUE(window->IsVisible()); 838 EXPECT_TRUE(window->IsVisible());
842 839
843 window_state->Minimize(); 840 window_state->Minimize();
844 EXPECT_FALSE(window_state->IsMaximized()); 841 EXPECT_FALSE(window_state->IsMaximized());
845 EXPECT_TRUE(window_state->IsMinimized()); 842 EXPECT_TRUE(window_state->IsMinimized());
846 EXPECT_FALSE(window->IsVisible()); 843 EXPECT_FALSE(window->IsVisible());
847 844
848 window_state->Maximize(); 845 window_state->Maximize();
849 EXPECT_TRUE(window_state->IsMaximized()); 846 EXPECT_TRUE(window_state->IsMaximized());
850 EXPECT_FALSE(window_state->IsMinimized()); 847 EXPECT_FALSE(window_state->IsMinimized());
851 EXPECT_TRUE(window->IsVisible()); 848 EXPECT_TRUE(window->IsVisible());
852 849
853 ash::Shell::GetInstance() 850 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
854 ->maximize_mode_controller() 851 false);
855 ->EnableMaximizeModeWindowManager(false);
856 EXPECT_FALSE(window_state->IsMaximized()); 852 EXPECT_FALSE(window_state->IsMaximized());
857 EXPECT_FALSE(window_state->IsMinimized()); 853 EXPECT_FALSE(window_state->IsMinimized());
858 EXPECT_TRUE(window->IsVisible()); 854 EXPECT_TRUE(window->IsVisible());
859 } 855 }
860 856
861 // Check that a full screen window remains full screen upon entering maximize 857 // Check that a full screen window remains full screen upon entering maximize
862 // mode. Furthermore, checks that this window is not full screen upon exiting 858 // mode. Furthermore, checks that this window is not full screen upon exiting
863 // maximize mode if it was un-full-screened while in maximize mode. 859 // maximize mode if it was un-full-screened while in maximize mode.
864 TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) { 860 TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) {
865 gfx::Rect rect(20, 140, 100, 100); 861 gfx::Rect rect(20, 140, 100, 100);
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1230 generator.PressLeftButton(); 1226 generator.PressLeftButton();
1231 generator.MoveMouseBy(10, 5); 1227 generator.MoveMouseBy(10, 5);
1232 RunAllPendingInMessageLoop(); 1228 RunAllPendingInMessageLoop();
1233 generator.ReleaseLeftButton(); 1229 generator.ReleaseLeftButton();
1234 gfx::Point first_dragged_origin = window->bounds().origin(); 1230 gfx::Point first_dragged_origin = window->bounds().origin();
1235 EXPECT_EQ(rect.x() + 10, first_dragged_origin.x()); 1231 EXPECT_EQ(rect.x() + 10, first_dragged_origin.x());
1236 EXPECT_EQ(rect.y() + 5, first_dragged_origin.y()); 1232 EXPECT_EQ(rect.y() + 5, first_dragged_origin.y());
1237 1233
1238 // 2. Check that turning on the manager will stop allowing the window from 1234 // 2. Check that turning on the manager will stop allowing the window from
1239 // dragging. 1235 // dragging.
1240 ash::Shell::GetInstance() 1236 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
1241 ->maximize_mode_controller() 1237 true);
1242 ->EnableMaximizeModeWindowManager(true);
1243 gfx::Rect center_bounds(window->bounds()); 1238 gfx::Rect center_bounds(window->bounds());
1244 EXPECT_NE(rect.origin().ToString(), center_bounds.origin().ToString()); 1239 EXPECT_NE(rect.origin().ToString(), center_bounds.origin().ToString());
1245 generator.MoveMouseTo( 1240 generator.MoveMouseTo(
1246 gfx::Point(center_bounds.x() + 1, center_bounds.y() + 1)); 1241 gfx::Point(center_bounds.x() + 1, center_bounds.y() + 1));
1247 generator.PressLeftButton(); 1242 generator.PressLeftButton();
1248 generator.MoveMouseBy(10, 5); 1243 generator.MoveMouseBy(10, 5);
1249 RunAllPendingInMessageLoop(); 1244 RunAllPendingInMessageLoop();
1250 generator.ReleaseLeftButton(); 1245 generator.ReleaseLeftButton();
1251 EXPECT_EQ(center_bounds.x(), window->bounds().x()); 1246 EXPECT_EQ(center_bounds.x(), window->bounds().x());
1252 EXPECT_EQ(center_bounds.y(), window->bounds().y()); 1247 EXPECT_EQ(center_bounds.y(), window->bounds().y());
1253 ash::Shell::GetInstance() 1248 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
1254 ->maximize_mode_controller() 1249 false);
1255 ->EnableMaximizeModeWindowManager(false);
1256 1250
1257 // 3. Releasing the mazimize manager again will restore the window to its 1251 // 3. Releasing the mazimize manager again will restore the window to its
1258 // previous bounds and 1252 // previous bounds and
1259 generator.MoveMouseTo( 1253 generator.MoveMouseTo(
1260 gfx::Point(first_dragged_origin.x() + 1, first_dragged_origin.y() + 1)); 1254 gfx::Point(first_dragged_origin.x() + 1, first_dragged_origin.y() + 1));
1261 generator.PressLeftButton(); 1255 generator.PressLeftButton();
1262 generator.MoveMouseBy(10, 5); 1256 generator.MoveMouseBy(10, 5);
1263 RunAllPendingInMessageLoop(); 1257 RunAllPendingInMessageLoop();
1264 generator.ReleaseLeftButton(); 1258 generator.ReleaseLeftButton();
1265 EXPECT_EQ(first_dragged_origin.x() + 10, window->bounds().x()); 1259 EXPECT_EQ(first_dragged_origin.x() + 10, window->bounds().x());
1266 EXPECT_EQ(first_dragged_origin.y() + 5, window->bounds().y()); 1260 EXPECT_EQ(first_dragged_origin.y() + 5, window->bounds().y());
1267 } 1261 }
1268 1262
1269 // Test that overview is exited before entering / exiting maximize mode so that 1263 // Test that overview is exited before entering / exiting maximize mode so that
1270 // the window changes made by MaximizeModeWindowManager do not conflict with 1264 // the window changes made by MaximizeModeWindowManager do not conflict with
1271 // those made in WindowOverview. 1265 // those made in WindowOverview.
1272 TEST_F(MaximizeModeWindowManagerTest, ExitsOverview) { 1266 TEST_F(MaximizeModeWindowManagerTest, ExitsOverview) {
1273 // Bounds for windows we know can be controlled. 1267 // Bounds for windows we know can be controlled.
1274 gfx::Rect rect1(10, 10, 200, 50); 1268 gfx::Rect rect1(10, 10, 200, 50);
1275 gfx::Rect rect2(10, 60, 200, 50); 1269 gfx::Rect rect2(10, 60, 200, 50);
1276 std::unique_ptr<aura::Window> w1( 1270 std::unique_ptr<aura::Window> w1(
1277 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1)); 1271 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect1));
1278 std::unique_ptr<aura::Window> w2( 1272 std::unique_ptr<aura::Window> w2(
1279 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2)); 1273 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect2));
1280 1274
1281 WindowSelectorController* window_selector_controller = 1275 WindowSelectorController* window_selector_controller =
1282 WmShell::Get()->window_selector_controller(); 1276 WmShell::Get()->window_selector_controller();
1283 window_selector_controller->ToggleOverview(); 1277 window_selector_controller->ToggleOverview();
1284 ASSERT_TRUE(window_selector_controller->IsSelecting()); 1278 ASSERT_TRUE(window_selector_controller->IsSelecting());
1285 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 1279 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
1286 ASSERT_TRUE(manager); 1280 ASSERT_TRUE(manager);
1287 EXPECT_FALSE(window_selector_controller->IsSelecting()); 1281 EXPECT_FALSE(window_selector_controller->IsSelecting());
1288 1282
1289 window_selector_controller->ToggleOverview(); 1283 window_selector_controller->ToggleOverview();
1290 ASSERT_TRUE(window_selector_controller->IsSelecting()); 1284 ASSERT_TRUE(window_selector_controller->IsSelecting());
1291 // Destroy the manager again and check that the windows return to their 1285 // Destroy the manager again and check that the windows return to their
1292 // previous state. 1286 // previous state.
1293 DestroyMaximizeModeWindowManager(); 1287 DestroyMaximizeModeWindowManager();
1294 EXPECT_FALSE(window_selector_controller->IsSelecting()); 1288 EXPECT_FALSE(window_selector_controller->IsSelecting());
1295 } 1289 }
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); 1514 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized());
1521 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); 1515 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized());
1522 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); 1516 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
1523 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); 1517 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
1524 EXPECT_TRUE(wm::GetWindowState(w1.get())->can_be_dragged()); 1518 EXPECT_TRUE(wm::GetWindowState(w1.get())->can_be_dragged());
1525 EXPECT_TRUE(wm::GetWindowState(w2.get())->can_be_dragged()); 1519 EXPECT_TRUE(wm::GetWindowState(w2.get())->can_be_dragged());
1526 1520
1527 // Enter maximize mode. Neither window should be managed because they have 1521 // Enter maximize mode. Neither window should be managed because they have
1528 // the always-on-top property set, which means that none of their properties 1522 // the always-on-top property set, which means that none of their properties
1529 // should change. 1523 // should change.
1530 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 1524 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
1531 ASSERT_TRUE(manager); 1525 ASSERT_TRUE(manager);
1532 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 1526 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
1533 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized()); 1527 EXPECT_FALSE(wm::GetWindowState(w1.get())->IsMaximized());
1534 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized()); 1528 EXPECT_FALSE(wm::GetWindowState(w2.get())->IsMaximized());
1535 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString()); 1529 EXPECT_EQ(rect1.ToString(), w1->bounds().ToString());
1536 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString()); 1530 EXPECT_EQ(rect2.ToString(), w2->bounds().ToString());
1537 EXPECT_TRUE(wm::GetWindowState(w1.get())->can_be_dragged()); 1531 EXPECT_TRUE(wm::GetWindowState(w1.get())->can_be_dragged());
1538 EXPECT_TRUE(wm::GetWindowState(w2.get())->can_be_dragged()); 1532 EXPECT_TRUE(wm::GetWindowState(w2.get())->can_be_dragged());
1539 1533
1540 // Remove the always-on-top property from both windows while in maximize 1534 // Remove the always-on-top property from both windows while in maximize
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1579 TEST_F(MaximizeModeWindowManagerTest, DontMaximizeDockedWindows) { 1573 TEST_F(MaximizeModeWindowManagerTest, DontMaximizeDockedWindows) {
1580 gfx::Rect rect(10, 10, 200, 50); 1574 gfx::Rect rect(10, 10, 200, 50);
1581 std::unique_ptr<aura::Window> window( 1575 std::unique_ptr<aura::Window> window(
1582 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 1576 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
1583 1577
1584 wm::WMEvent dock_event(wm::WM_EVENT_DOCK); 1578 wm::WMEvent dock_event(wm::WM_EVENT_DOCK);
1585 wm::GetWindowState(window.get())->OnWMEvent(&dock_event); 1579 wm::GetWindowState(window.get())->OnWMEvent(&dock_event);
1586 EXPECT_TRUE(wm::GetWindowState(window.get())->IsDocked()); 1580 EXPECT_TRUE(wm::GetWindowState(window.get())->IsDocked());
1587 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); 1581 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized());
1588 1582
1589 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 1583 MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
1590 EXPECT_TRUE(wm::GetWindowState(window.get())->IsDocked()); 1584 EXPECT_TRUE(wm::GetWindowState(window.get())->IsDocked());
1591 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); 1585 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized());
1592 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 1586 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
1593 } 1587 }
1594 1588
1595 #endif // OS_WIN 1589 #endif // OS_WIN
1596 1590
1597 } // namespace ash 1591 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/maximize_mode/maximize_mode_controller_unittest.cc ('k') | ash/wm/overview/window_selector_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698