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

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

Issue 2095193002: clang-format all of //ash (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" 5 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h"
6 6
7 #include <string> 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/mru_window_tracker.h" 10 #include "ash/common/wm/mru_window_tracker.h"
(...skipping 29 matching lines...) Expand all
40 #if !defined(OS_WIN) 40 #if !defined(OS_WIN)
41 41
42 class MaximizeModeWindowManagerTest : public test::AshTestBase { 42 class MaximizeModeWindowManagerTest : public test::AshTestBase {
43 public: 43 public:
44 MaximizeModeWindowManagerTest() {} 44 MaximizeModeWindowManagerTest() {}
45 ~MaximizeModeWindowManagerTest() override {} 45 ~MaximizeModeWindowManagerTest() override {}
46 46
47 // Creates a window which has a fixed size. 47 // Creates a window which has a fixed size.
48 aura::Window* CreateFixedSizeNonMaximizableWindow(ui::wm::WindowType type, 48 aura::Window* CreateFixedSizeNonMaximizableWindow(ui::wm::WindowType type,
49 const gfx::Rect& bounds) { 49 const gfx::Rect& bounds) {
50 return CreateWindowInWatchedContainer( 50 return CreateWindowInWatchedContainer(type, bounds, gfx::Size(), false,
51 type, bounds, gfx::Size(), false, false); 51 false);
52 } 52 }
53 53
54 // Creates a window which can not be maximized, but resized. |max_size| 54 // Creates a window which can not be maximized, but resized. |max_size|
55 // denotes the maximal possible size, if the size is empty, the window has no 55 // denotes the maximal possible size, if the size is empty, the window has no
56 // upper limit. Note: This function will only work with a single root window. 56 // upper limit. Note: This function will only work with a single root window.
57 aura::Window* CreateNonMaximizableWindow(ui::wm::WindowType type, 57 aura::Window* CreateNonMaximizableWindow(ui::wm::WindowType type,
58 const gfx::Rect& bounds, 58 const gfx::Rect& bounds,
59 const gfx::Size& max_size) { 59 const gfx::Size& max_size) {
60 return CreateWindowInWatchedContainer(type, bounds, max_size, false, true); 60 return CreateWindowInWatchedContainer(type, bounds, max_size, false, true);
61 } 61 }
62 62
63 // Creates a maximizable and resizable window. 63 // Creates a maximizable and resizable window.
64 aura::Window* CreateWindow(ui::wm::WindowType type, 64 aura::Window* CreateWindow(ui::wm::WindowType type, const gfx::Rect bounds) {
65 const gfx::Rect bounds) { 65 return CreateWindowInWatchedContainer(type, bounds, gfx::Size(), true,
66 return CreateWindowInWatchedContainer( 66 true);
67 type, bounds, gfx::Size(), true, true);
68 } 67 }
69 68
70 // Creates a window which also has a widget. 69 // Creates a window which also has a widget.
71 aura::Window* CreateWindowWithWidget(const gfx::Rect& bounds) { 70 aura::Window* CreateWindowWithWidget(const gfx::Rect& bounds) {
72 views::Widget* widget = new views::Widget(); 71 views::Widget* widget = new views::Widget();
73 views::Widget::InitParams params; 72 views::Widget::InitParams params;
74 params.context = CurrentContext(); 73 params.context = CurrentContext();
75 // Note: The widget will get deleted with the window. 74 // Note: The widget will get deleted with the window.
76 widget->Init(params); 75 widget->Init(params);
77 widget->Show(); 76 widget->Show();
78 aura::Window* window = widget->GetNativeWindow(); 77 aura::Window* window = widget->GetNativeWindow();
79 window->SetBounds(bounds); 78 window->SetBounds(bounds);
80 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL); 79 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
81 80
82 return window; 81 return window;
83 } 82 }
84 83
85 // Create the Maximized mode window manager. 84 // Create the Maximized mode window manager.
86 ash::MaximizeModeWindowManager* CreateMaximizeModeWindowManager() { 85 ash::MaximizeModeWindowManager* CreateMaximizeModeWindowManager() {
87 EXPECT_FALSE(maximize_mode_window_manager()); 86 EXPECT_FALSE(maximize_mode_window_manager());
88 Shell::GetInstance()->maximize_mode_controller()-> 87 Shell::GetInstance()
89 EnableMaximizeModeWindowManager(true); 88 ->maximize_mode_controller()
89 ->EnableMaximizeModeWindowManager(true);
90 return maximize_mode_window_manager(); 90 return maximize_mode_window_manager();
91 } 91 }
92 92
93 // Destroy the maximized mode window manager. 93 // Destroy the maximized mode window manager.
94 void DestroyMaximizeModeWindowManager() { 94 void DestroyMaximizeModeWindowManager() {
95 Shell::GetInstance()->maximize_mode_controller()-> 95 Shell::GetInstance()
96 EnableMaximizeModeWindowManager(false); 96 ->maximize_mode_controller()
97 ->EnableMaximizeModeWindowManager(false);
97 EXPECT_FALSE(maximize_mode_window_manager()); 98 EXPECT_FALSE(maximize_mode_window_manager());
98 } 99 }
99 100
100 // Get the maximze window manager. 101 // Get the maximze window manager.
101 ash::MaximizeModeWindowManager* maximize_mode_window_manager() { 102 ash::MaximizeModeWindowManager* maximize_mode_window_manager() {
102 return Shell::GetInstance()->maximize_mode_controller()-> 103 return Shell::GetInstance()
103 maximize_mode_window_manager_.get(); 104 ->maximize_mode_controller()
105 ->maximize_mode_window_manager_.get();
104 } 106 }
105 107
106 // Resize our desktop. 108 // Resize our desktop.
107 void ResizeDesktop(int width_delta) { 109 void ResizeDesktop(int width_delta) {
108 gfx::Size size = 110 gfx::Size size =
109 display::Screen::GetScreen() 111 display::Screen::GetScreen()
110 ->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow()) 112 ->GetDisplayNearestWindow(Shell::GetPrimaryRootWindow())
111 .size(); 113 .size();
112 size.Enlarge(0, width_delta); 114 size.Enlarge(0, width_delta);
113 UpdateDisplay(size.ToString()); 115 UpdateDisplay(size.ToString());
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, max_size)); 314 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, max_size));
313 std::unique_ptr<aura::Window> fixed_window( 315 std::unique_ptr<aura::Window> fixed_window(
314 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 316 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
315 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized()); 317 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized());
316 EXPECT_EQ(rect.ToString(), unlimited_window->bounds().ToString()); 318 EXPECT_EQ(rect.ToString(), unlimited_window->bounds().ToString());
317 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized()); 319 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized());
318 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString()); 320 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString());
319 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized()); 321 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized());
320 EXPECT_EQ(rect.ToString(), fixed_window->bounds().ToString()); 322 EXPECT_EQ(rect.ToString(), fixed_window->bounds().ToString());
321 323
322 gfx::Size workspace_size = ScreenUtil::GetMaximizedWindowBoundsInParent( 324 gfx::Size workspace_size =
323 unlimited_window.get()).size(); 325 ScreenUtil::GetMaximizedWindowBoundsInParent(unlimited_window.get())
326 .size();
324 327
325 // Create the manager and make sure that all qualifying windows were detected 328 // Create the manager and make sure that all qualifying windows were detected
326 // and changed. 329 // and changed.
327 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 330 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
328 ASSERT_TRUE(manager); 331 ASSERT_TRUE(manager);
329 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 332 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
330 // The unlimited window should have the size of the workspace / parent window. 333 // The unlimited window should have the size of the workspace / parent window.
331 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized()); 334 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized());
332 EXPECT_EQ("0,0", unlimited_window->bounds().origin().ToString()); 335 EXPECT_EQ("0,0", unlimited_window->bounds().origin().ToString());
333 EXPECT_EQ(workspace_size.ToString(), 336 EXPECT_EQ(workspace_size.ToString(),
334 unlimited_window->bounds().size().ToString()); 337 unlimited_window->bounds().size().ToString());
335 // The limited window should have the size of the upper possible bounds. 338 // The limited window should have the size of the upper possible bounds.
336 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized()); 339 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized());
337 EXPECT_NE(rect.origin().ToString(), 340 EXPECT_NE(rect.origin().ToString(),
338 limited_window->bounds().origin().ToString()); 341 limited_window->bounds().origin().ToString());
339 EXPECT_EQ(max_size.ToString(), 342 EXPECT_EQ(max_size.ToString(), limited_window->bounds().size().ToString());
340 limited_window->bounds().size().ToString());
341 // The fixed size window should have the size of the original window. 343 // The fixed size window should have the size of the original window.
342 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized()); 344 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized());
343 EXPECT_NE(rect.origin().ToString(), 345 EXPECT_NE(rect.origin().ToString(),
344 fixed_window->bounds().origin().ToString()); 346 fixed_window->bounds().origin().ToString());
345 EXPECT_EQ(rect.size().ToString(), 347 EXPECT_EQ(rect.size().ToString(), fixed_window->bounds().size().ToString());
346 fixed_window->bounds().size().ToString());
347 348
348 // Destroy the manager again and check that the windows return to their 349 // Destroy the manager again and check that the windows return to their
349 // previous state. 350 // previous state.
350 DestroyMaximizeModeWindowManager(); 351 DestroyMaximizeModeWindowManager();
351 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized()); 352 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized());
352 EXPECT_EQ(rect.ToString(), unlimited_window->bounds().ToString()); 353 EXPECT_EQ(rect.ToString(), unlimited_window->bounds().ToString());
353 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized()); 354 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized());
354 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString()); 355 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString());
355 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized()); 356 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized());
356 EXPECT_EQ(rect.ToString(), fixed_window->bounds().ToString()); 357 EXPECT_EQ(rect.ToString(), fixed_window->bounds().ToString());
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 // Destroy the maximize mode and check that the resulting size of the window 449 // Destroy the maximize mode and check that the resulting size of the window
449 // is remaining as it is (but not maximized). 450 // is remaining as it is (but not maximized).
450 DestroyMaximizeModeWindowManager(); 451 DestroyMaximizeModeWindowManager();
451 452
452 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); 453 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized());
453 EXPECT_EQ(maximized_size.ToString(), window->bounds().ToString()); 454 EXPECT_EQ(maximized_size.ToString(), window->bounds().ToString());
454 } 455 }
455 456
456 // Test that non-maximizable windows get properly handled when created in 457 // Test that non-maximizable windows get properly handled when created in
457 // maximized mode. 458 // maximized mode.
458 TEST_F(MaximizeModeWindowManagerTest, 459 TEST_F(MaximizeModeWindowManagerTest, CreateNonMaximizableButResizableWindows) {
459 CreateNonMaximizableButResizableWindows) {
460 // Create the manager and make sure that all qualifying windows were detected 460 // Create the manager and make sure that all qualifying windows were detected
461 // and changed. 461 // and changed.
462 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 462 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
463 ASSERT_TRUE(manager); 463 ASSERT_TRUE(manager);
464 464
465 gfx::Rect rect(10, 10, 200, 50); 465 gfx::Rect rect(10, 10, 200, 50);
466 gfx::Size max_size(300, 200); 466 gfx::Size max_size(300, 200);
467 gfx::Size empty_size; 467 gfx::Size empty_size;
468 std::unique_ptr<aura::Window> unlimited_window( 468 std::unique_ptr<aura::Window> unlimited_window(
469 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, empty_size)); 469 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, empty_size));
470 std::unique_ptr<aura::Window> limited_window( 470 std::unique_ptr<aura::Window> limited_window(
471 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, max_size)); 471 CreateNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect, max_size));
472 std::unique_ptr<aura::Window> fixed_window( 472 std::unique_ptr<aura::Window> fixed_window(
473 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 473 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
474 474
475 gfx::Size workspace_size = ScreenUtil::GetMaximizedWindowBoundsInParent( 475 gfx::Size workspace_size =
476 unlimited_window.get()).size(); 476 ScreenUtil::GetMaximizedWindowBoundsInParent(unlimited_window.get())
477 .size();
477 478
478 // All windows should be sized now as big as possible and be centered. 479 // All windows should be sized now as big as possible and be centered.
479 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 480 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
480 // The unlimited window should have the size of the workspace / parent window. 481 // The unlimited window should have the size of the workspace / parent window.
481 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized()); 482 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized());
482 EXPECT_EQ("0,0", unlimited_window->bounds().origin().ToString()); 483 EXPECT_EQ("0,0", unlimited_window->bounds().origin().ToString());
483 EXPECT_EQ(workspace_size.ToString(), 484 EXPECT_EQ(workspace_size.ToString(),
484 unlimited_window->bounds().size().ToString()); 485 unlimited_window->bounds().size().ToString());
485 // The limited window should have the size of the upper possible bounds. 486 // The limited window should have the size of the upper possible bounds.
486 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized()); 487 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized());
487 EXPECT_NE(rect.origin().ToString(), 488 EXPECT_NE(rect.origin().ToString(),
488 limited_window->bounds().origin().ToString()); 489 limited_window->bounds().origin().ToString());
489 EXPECT_EQ(max_size.ToString(), 490 EXPECT_EQ(max_size.ToString(), limited_window->bounds().size().ToString());
490 limited_window->bounds().size().ToString());
491 // The fixed size window should have the size of the original window. 491 // The fixed size window should have the size of the original window.
492 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized()); 492 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized());
493 EXPECT_NE(rect.origin().ToString(), 493 EXPECT_NE(rect.origin().ToString(),
494 fixed_window->bounds().origin().ToString()); 494 fixed_window->bounds().origin().ToString());
495 EXPECT_EQ(rect.size().ToString(), 495 EXPECT_EQ(rect.size().ToString(), fixed_window->bounds().size().ToString());
496 fixed_window->bounds().size().ToString());
497 496
498 // Destroy the manager again and check that the windows return to their 497 // Destroy the manager again and check that the windows return to their
499 // creation state. 498 // creation state.
500 DestroyMaximizeModeWindowManager(); 499 DestroyMaximizeModeWindowManager();
501 500
502 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized()); 501 EXPECT_FALSE(wm::GetWindowState(unlimited_window.get())->IsMaximized());
503 EXPECT_EQ(rect.ToString(), unlimited_window->bounds().ToString()); 502 EXPECT_EQ(rect.ToString(), unlimited_window->bounds().ToString());
504 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized()); 503 EXPECT_FALSE(wm::GetWindowState(limited_window.get())->IsMaximized());
505 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString()); 504 EXPECT_EQ(rect.ToString(), limited_window->bounds().ToString());
506 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized()); 505 EXPECT_FALSE(wm::GetWindowState(fixed_window.get())->IsMaximized());
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 655 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
657 std::unique_ptr<aura::Window> initially_maximized_window( 656 std::unique_ptr<aura::Window> initially_maximized_window(
658 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 657 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
659 wm::GetWindowState(initially_minimized_window.get())->Minimize(); 658 wm::GetWindowState(initially_minimized_window.get())->Minimize();
660 wm::GetWindowState(initially_maximized_window.get())->Maximize(); 659 wm::GetWindowState(initially_maximized_window.get())->Maximize();
661 660
662 // Create the manager and make sure that the window gets detected. 661 // Create the manager and make sure that the window gets detected.
663 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 662 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
664 ASSERT_TRUE(manager); 663 ASSERT_TRUE(manager);
665 EXPECT_EQ(3, manager->GetNumberOfManagedWindows()); 664 EXPECT_EQ(3, manager->GetNumberOfManagedWindows());
666 EXPECT_TRUE(wm::GetWindowState( 665 EXPECT_TRUE(
667 initially_minimized_window.get())->IsMinimized()); 666 wm::GetWindowState(initially_minimized_window.get())->IsMinimized());
668 EXPECT_TRUE(wm::GetWindowState(initially_normal_window.get())->IsMaximized()); 667 EXPECT_TRUE(wm::GetWindowState(initially_normal_window.get())->IsMaximized());
669 EXPECT_TRUE(wm::GetWindowState( 668 EXPECT_TRUE(
670 initially_maximized_window.get())->IsMaximized()); 669 wm::GetWindowState(initially_maximized_window.get())->IsMaximized());
671 // Now minimize the second window to check that upon leaving the window 670 // Now minimize the second window to check that upon leaving the window
672 // will get restored to its minimized state. 671 // will get restored to its minimized state.
673 wm::GetWindowState(initially_normal_window.get())->Minimize(); 672 wm::GetWindowState(initially_normal_window.get())->Minimize();
674 wm::GetWindowState(initially_maximized_window.get())->Minimize(); 673 wm::GetWindowState(initially_maximized_window.get())->Minimize();
675 EXPECT_TRUE(wm::GetWindowState( 674 EXPECT_TRUE(
676 initially_minimized_window.get())->IsMinimized()); 675 wm::GetWindowState(initially_minimized_window.get())->IsMinimized());
677 EXPECT_TRUE(wm::GetWindowState( 676 EXPECT_TRUE(wm::GetWindowState(initially_normal_window.get())->IsMinimized());
678 initially_normal_window.get())->IsMinimized()); 677 EXPECT_TRUE(
679 EXPECT_TRUE(wm::GetWindowState( 678 wm::GetWindowState(initially_maximized_window.get())->IsMinimized());
680 initially_maximized_window.get())->IsMinimized());
681 679
682 // Destroy the manager again and check that the window will get minimized. 680 // Destroy the manager again and check that the window will get minimized.
683 DestroyMaximizeModeWindowManager(); 681 DestroyMaximizeModeWindowManager();
684 EXPECT_TRUE(wm::GetWindowState( 682 EXPECT_TRUE(
685 initially_minimized_window.get())->IsMinimized()); 683 wm::GetWindowState(initially_minimized_window.get())->IsMinimized());
686 EXPECT_FALSE(wm::GetWindowState( 684 EXPECT_FALSE(
687 initially_normal_window.get())->IsMinimized()); 685 wm::GetWindowState(initially_normal_window.get())->IsMinimized());
688 EXPECT_TRUE(wm::GetWindowState( 686 EXPECT_TRUE(
689 initially_maximized_window.get())->IsMaximized()); 687 wm::GetWindowState(initially_maximized_window.get())->IsMaximized());
690 } 688 }
691 689
692 // Check that resizing the desktop does reposition unmaximizable, unresizable & 690 // Check that resizing the desktop does reposition unmaximizable, unresizable &
693 // managed windows. 691 // managed windows.
694 TEST_F(MaximizeModeWindowManagerTest, DesktopSizeChangeMovesUnmaximizable) { 692 TEST_F(MaximizeModeWindowManagerTest, DesktopSizeChangeMovesUnmaximizable) {
695 UpdateDisplay("400x400"); 693 UpdateDisplay("400x400");
696 // This window will move because it does not fit the new bounds. 694 // This window will move because it does not fit the new bounds.
697 gfx::Rect rect(20, 300, 100, 100); 695 gfx::Rect rect(20, 300, 100, 100);
698 std::unique_ptr<aura::Window> window1( 696 std::unique_ptr<aura::Window> window1(
699 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 697 CreateFixedSizeNonMaximizableWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 DestroyMaximizeModeWindowManager(); 826 DestroyMaximizeModeWindowManager();
829 } 827 }
830 828
831 // Check that minimize and restore do the right thing. 829 // Check that minimize and restore do the right thing.
832 TEST_F(MaximizeModeWindowManagerTest, TestMinimize) { 830 TEST_F(MaximizeModeWindowManagerTest, TestMinimize) {
833 gfx::Rect rect(10, 10, 100, 100); 831 gfx::Rect rect(10, 10, 100, 100);
834 std::unique_ptr<aura::Window> window( 832 std::unique_ptr<aura::Window> window(
835 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 833 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
836 wm::WindowState* window_state = wm::GetWindowState(window.get()); 834 wm::WindowState* window_state = wm::GetWindowState(window.get());
837 EXPECT_EQ(rect.ToString(), window->bounds().ToString()); 835 EXPECT_EQ(rect.ToString(), window->bounds().ToString());
838 ash::Shell::GetInstance()->maximize_mode_controller()-> 836 ash::Shell::GetInstance()
839 EnableMaximizeModeWindowManager(true); 837 ->maximize_mode_controller()
838 ->EnableMaximizeModeWindowManager(true);
840 EXPECT_TRUE(window_state->IsMaximized()); 839 EXPECT_TRUE(window_state->IsMaximized());
841 EXPECT_FALSE(window_state->IsMinimized()); 840 EXPECT_FALSE(window_state->IsMinimized());
842 EXPECT_TRUE(window->IsVisible()); 841 EXPECT_TRUE(window->IsVisible());
843 842
844 window_state->Minimize(); 843 window_state->Minimize();
845 EXPECT_FALSE(window_state->IsMaximized()); 844 EXPECT_FALSE(window_state->IsMaximized());
846 EXPECT_TRUE(window_state->IsMinimized()); 845 EXPECT_TRUE(window_state->IsMinimized());
847 EXPECT_FALSE(window->IsVisible()); 846 EXPECT_FALSE(window->IsVisible());
848 847
849 window_state->Maximize(); 848 window_state->Maximize();
850 EXPECT_TRUE(window_state->IsMaximized()); 849 EXPECT_TRUE(window_state->IsMaximized());
851 EXPECT_FALSE(window_state->IsMinimized()); 850 EXPECT_FALSE(window_state->IsMinimized());
852 EXPECT_TRUE(window->IsVisible()); 851 EXPECT_TRUE(window->IsVisible());
853 852
854 ash::Shell::GetInstance()->maximize_mode_controller()-> 853 ash::Shell::GetInstance()
855 EnableMaximizeModeWindowManager(false); 854 ->maximize_mode_controller()
855 ->EnableMaximizeModeWindowManager(false);
856 EXPECT_FALSE(window_state->IsMaximized()); 856 EXPECT_FALSE(window_state->IsMaximized());
857 EXPECT_FALSE(window_state->IsMinimized()); 857 EXPECT_FALSE(window_state->IsMinimized());
858 EXPECT_TRUE(window->IsVisible()); 858 EXPECT_TRUE(window->IsVisible());
859 } 859 }
860 860
861 // Check that a full screen window remains full screen upon entering maximize 861 // 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 862 // 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. 863 // maximize mode if it was un-full-screened while in maximize mode.
864 TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) { 864 TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) {
865 gfx::Rect rect(20, 140, 100, 100); 865 gfx::Rect rect(20, 140, 100, 100);
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 generator.PressLeftButton(); 1080 generator.PressLeftButton();
1081 generator.MoveMouseBy(10, 5); 1081 generator.MoveMouseBy(10, 5);
1082 RunAllPendingInMessageLoop(); 1082 RunAllPendingInMessageLoop();
1083 generator.ReleaseLeftButton(); 1083 generator.ReleaseLeftButton();
1084 gfx::Point first_dragged_origin = window->bounds().origin(); 1084 gfx::Point first_dragged_origin = window->bounds().origin();
1085 EXPECT_EQ(rect.x() + 10, first_dragged_origin.x()); 1085 EXPECT_EQ(rect.x() + 10, first_dragged_origin.x());
1086 EXPECT_EQ(rect.y() + 5, first_dragged_origin.y()); 1086 EXPECT_EQ(rect.y() + 5, first_dragged_origin.y());
1087 1087
1088 // 2. Check that turning on the manager will stop allowing the window from 1088 // 2. Check that turning on the manager will stop allowing the window from
1089 // dragging. 1089 // dragging.
1090 ash::Shell::GetInstance()->maximize_mode_controller()-> 1090 ash::Shell::GetInstance()
1091 EnableMaximizeModeWindowManager(true); 1091 ->maximize_mode_controller()
1092 ->EnableMaximizeModeWindowManager(true);
1092 gfx::Rect center_bounds(window->bounds()); 1093 gfx::Rect center_bounds(window->bounds());
1093 EXPECT_NE(rect.origin().ToString(), center_bounds.origin().ToString()); 1094 EXPECT_NE(rect.origin().ToString(), center_bounds.origin().ToString());
1094 generator.MoveMouseTo(gfx::Point(center_bounds.x() + 1, 1095 generator.MoveMouseTo(
1095 center_bounds.y() + 1)); 1096 gfx::Point(center_bounds.x() + 1, center_bounds.y() + 1));
1096 generator.PressLeftButton(); 1097 generator.PressLeftButton();
1097 generator.MoveMouseBy(10, 5); 1098 generator.MoveMouseBy(10, 5);
1098 RunAllPendingInMessageLoop(); 1099 RunAllPendingInMessageLoop();
1099 generator.ReleaseLeftButton(); 1100 generator.ReleaseLeftButton();
1100 EXPECT_EQ(center_bounds.x(), window->bounds().x()); 1101 EXPECT_EQ(center_bounds.x(), window->bounds().x());
1101 EXPECT_EQ(center_bounds.y(), window->bounds().y()); 1102 EXPECT_EQ(center_bounds.y(), window->bounds().y());
1102 ash::Shell::GetInstance()->maximize_mode_controller()-> 1103 ash::Shell::GetInstance()
1103 EnableMaximizeModeWindowManager(false); 1104 ->maximize_mode_controller()
1105 ->EnableMaximizeModeWindowManager(false);
1104 1106
1105 // 3. Releasing the mazimize manager again will restore the window to its 1107 // 3. Releasing the mazimize manager again will restore the window to its
1106 // previous bounds and 1108 // previous bounds and
1107 generator.MoveMouseTo(gfx::Point(first_dragged_origin.x() + 1, 1109 generator.MoveMouseTo(
1108 first_dragged_origin.y() + 1)); 1110 gfx::Point(first_dragged_origin.x() + 1, first_dragged_origin.y() + 1));
1109 generator.PressLeftButton(); 1111 generator.PressLeftButton();
1110 generator.MoveMouseBy(10, 5); 1112 generator.MoveMouseBy(10, 5);
1111 RunAllPendingInMessageLoop(); 1113 RunAllPendingInMessageLoop();
1112 generator.ReleaseLeftButton(); 1114 generator.ReleaseLeftButton();
1113 EXPECT_EQ(first_dragged_origin.x() + 10, window->bounds().x()); 1115 EXPECT_EQ(first_dragged_origin.x() + 10, window->bounds().x());
1114 EXPECT_EQ(first_dragged_origin.y() + 5, window->bounds().y()); 1116 EXPECT_EQ(first_dragged_origin.y() + 5, window->bounds().y());
1115 } 1117 }
1116 1118
1117 // Test that overview is exited before entering / exiting maximize mode so that 1119 // Test that overview is exited before entering / exiting maximize mode so that
1118 // the window changes made by MaximizeModeWindowManager do not conflict with 1120 // the window changes made by MaximizeModeWindowManager do not conflict with
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 // Fullscreen both windows. 1161 // Fullscreen both windows.
1160 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 1162 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
1161 background_window_state->OnWMEvent(&event); 1163 background_window_state->OnWMEvent(&event);
1162 foreground_window_state->OnWMEvent(&event); 1164 foreground_window_state->OnWMEvent(&event);
1163 EXPECT_TRUE(background_window_state->IsFullscreen()); 1165 EXPECT_TRUE(background_window_state->IsFullscreen());
1164 EXPECT_TRUE(foreground_window_state->IsFullscreen()); 1166 EXPECT_TRUE(foreground_window_state->IsFullscreen());
1165 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow()); 1167 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow());
1166 1168
1167 // Do an edge swipe top into screen. 1169 // Do an edge swipe top into screen.
1168 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 1170 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
1169 generator.GestureScrollSequence(gfx::Point(50, 0), 1171 generator.GestureScrollSequence(gfx::Point(50, 0), gfx::Point(50, 100),
1170 gfx::Point(50, 100), 1172 base::TimeDelta::FromMilliseconds(20), 10);
1171 base::TimeDelta::FromMilliseconds(20),
1172 10);
1173 1173
1174 EXPECT_FALSE(foreground_window_state->IsFullscreen()); 1174 EXPECT_FALSE(foreground_window_state->IsFullscreen());
1175 EXPECT_TRUE(background_window_state->IsFullscreen()); 1175 EXPECT_TRUE(background_window_state->IsFullscreen());
1176 1176
1177 // Do a second edge swipe top into screen. 1177 // Do a second edge swipe top into screen.
1178 generator.GestureScrollSequence(gfx::Point(50, 0), 1178 generator.GestureScrollSequence(gfx::Point(50, 0), gfx::Point(50, 100),
1179 gfx::Point(50, 100), 1179 base::TimeDelta::FromMilliseconds(20), 10);
1180 base::TimeDelta::FromMilliseconds(20),
1181 10);
1182 1180
1183 EXPECT_FALSE(foreground_window_state->IsFullscreen()); 1181 EXPECT_FALSE(foreground_window_state->IsFullscreen());
1184 EXPECT_TRUE(background_window_state->IsFullscreen()); 1182 EXPECT_TRUE(background_window_state->IsFullscreen());
1185 1183
1186 DestroyMaximizeModeWindowManager(); 1184 DestroyMaximizeModeWindowManager();
1187 } 1185 }
1188 1186
1189 // Test that an edge swipe from the bottom will end full screen mode. 1187 // Test that an edge swipe from the bottom will end full screen mode.
1190 TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeSwipeFromBottom) { 1188 TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeSwipeFromBottom) {
1191 gfx::Rect rect(10, 10, 200, 50); 1189 gfx::Rect rect(10, 10, 200, 50);
(...skipping 12 matching lines...) Expand all
1204 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 1202 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
1205 background_window_state->OnWMEvent(&event); 1203 background_window_state->OnWMEvent(&event);
1206 foreground_window_state->OnWMEvent(&event); 1204 foreground_window_state->OnWMEvent(&event);
1207 EXPECT_TRUE(background_window_state->IsFullscreen()); 1205 EXPECT_TRUE(background_window_state->IsFullscreen());
1208 EXPECT_TRUE(foreground_window_state->IsFullscreen()); 1206 EXPECT_TRUE(foreground_window_state->IsFullscreen());
1209 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow()); 1207 EXPECT_EQ(foreground_window.get(), wm::GetActiveWindow());
1210 1208
1211 // Do an edge swipe bottom into screen. 1209 // Do an edge swipe bottom into screen.
1212 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 1210 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
1213 int y = Shell::GetPrimaryRootWindow()->bounds().bottom(); 1211 int y = Shell::GetPrimaryRootWindow()->bounds().bottom();
1214 generator.GestureScrollSequence(gfx::Point(50, y), 1212 generator.GestureScrollSequence(gfx::Point(50, y), gfx::Point(50, y - 100),
1215 gfx::Point(50, y - 100), 1213 base::TimeDelta::FromMilliseconds(20), 10);
1216 base::TimeDelta::FromMilliseconds(20),
1217 10);
1218 1214
1219 EXPECT_FALSE(foreground_window_state->IsFullscreen()); 1215 EXPECT_FALSE(foreground_window_state->IsFullscreen());
1220 EXPECT_TRUE(background_window_state->IsFullscreen()); 1216 EXPECT_TRUE(background_window_state->IsFullscreen());
1221 1217
1222 DestroyMaximizeModeWindowManager(); 1218 DestroyMaximizeModeWindowManager();
1223 } 1219 }
1224 1220
1225 // Test that an edge touch press at the top will end full screen mode. 1221 // Test that an edge touch press at the top will end full screen mode.
1226 TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeTouchAtTop) { 1222 TEST_F(MaximizeModeWindowManagerTest, ExitFullScreenWithEdgeTouchAtTop) {
1227 gfx::Rect rect(10, 10, 200, 50); 1223 gfx::Rect rect(10, 10, 200, 50);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 1305 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
1310 window_state->OnWMEvent(&event); 1306 window_state->OnWMEvent(&event);
1311 EXPECT_TRUE(window_state->IsFullscreen()); 1307 EXPECT_TRUE(window_state->IsFullscreen());
1312 EXPECT_FALSE(window_state->in_immersive_fullscreen()); 1308 EXPECT_FALSE(window_state->in_immersive_fullscreen());
1313 EXPECT_EQ(window.get(), wm::GetActiveWindow()); 1309 EXPECT_EQ(window.get(), wm::GetActiveWindow());
1314 1310
1315 window_state->set_in_immersive_fullscreen(true); 1311 window_state->set_in_immersive_fullscreen(true);
1316 1312
1317 // Do an edge swipe top into screen. 1313 // Do an edge swipe top into screen.
1318 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 1314 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
1319 generator.GestureScrollSequence(gfx::Point(50, 0), 1315 generator.GestureScrollSequence(gfx::Point(50, 0), gfx::Point(50, 100),
1320 gfx::Point(50, 100), 1316 base::TimeDelta::FromMilliseconds(20), 10);
1321 base::TimeDelta::FromMilliseconds(20),
1322 10);
1323 1317
1324 // It should have not exited full screen or immersive mode. 1318 // It should have not exited full screen or immersive mode.
1325 EXPECT_TRUE(window_state->IsFullscreen()); 1319 EXPECT_TRUE(window_state->IsFullscreen());
1326 EXPECT_TRUE(window_state->in_immersive_fullscreen()); 1320 EXPECT_TRUE(window_state->in_immersive_fullscreen());
1327 1321
1328 DestroyMaximizeModeWindowManager(); 1322 DestroyMaximizeModeWindowManager();
1329 } 1323 }
1330 1324
1331 // Test that an edge swipe from the bottom will not end immersive mode. 1325 // Test that an edge swipe from the bottom will not end immersive mode.
1332 TEST_F(MaximizeModeWindowManagerTest, 1326 TEST_F(MaximizeModeWindowManagerTest,
1333 NoExitImmersiveModeWithEdgeSwipeFromBottom) { 1327 NoExitImmersiveModeWithEdgeSwipeFromBottom) {
1334 std::unique_ptr<aura::Window> window( 1328 std::unique_ptr<aura::Window> window(
1335 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50))); 1329 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, gfx::Rect(10, 10, 200, 50)));
1336 wm::WindowState* window_state = wm::GetWindowState(window.get()); 1330 wm::WindowState* window_state = wm::GetWindowState(window.get());
1337 wm::ActivateWindow(window.get()); 1331 wm::ActivateWindow(window.get());
1338 CreateMaximizeModeWindowManager(); 1332 CreateMaximizeModeWindowManager();
1339 1333
1340 // Fullscreen the window. 1334 // Fullscreen the window.
1341 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 1335 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
1342 window_state->OnWMEvent(&event); 1336 window_state->OnWMEvent(&event);
1343 EXPECT_TRUE(window_state->IsFullscreen()); 1337 EXPECT_TRUE(window_state->IsFullscreen());
1344 EXPECT_FALSE(window_state->in_immersive_fullscreen()); 1338 EXPECT_FALSE(window_state->in_immersive_fullscreen());
1345 EXPECT_EQ(window.get(), wm::GetActiveWindow()); 1339 EXPECT_EQ(window.get(), wm::GetActiveWindow());
1346 window_state->set_in_immersive_fullscreen(true); 1340 window_state->set_in_immersive_fullscreen(true);
1347 EXPECT_TRUE(window_state->in_immersive_fullscreen()); 1341 EXPECT_TRUE(window_state->in_immersive_fullscreen());
1348 1342
1349 // Do an edge swipe bottom into screen. 1343 // Do an edge swipe bottom into screen.
1350 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); 1344 ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow());
1351 int y = Shell::GetPrimaryRootWindow()->bounds().bottom(); 1345 int y = Shell::GetPrimaryRootWindow()->bounds().bottom();
1352 generator.GestureScrollSequence(gfx::Point(50, y), 1346 generator.GestureScrollSequence(gfx::Point(50, y), gfx::Point(50, y - 100),
1353 gfx::Point(50, y - 100), 1347 base::TimeDelta::FromMilliseconds(20), 10);
1354 base::TimeDelta::FromMilliseconds(20),
1355 10);
1356 1348
1357 // The window should still be full screen and immersive. 1349 // The window should still be full screen and immersive.
1358 EXPECT_TRUE(window_state->IsFullscreen()); 1350 EXPECT_TRUE(window_state->IsFullscreen());
1359 EXPECT_TRUE(window_state->in_immersive_fullscreen()); 1351 EXPECT_TRUE(window_state->in_immersive_fullscreen());
1360 1352
1361 DestroyMaximizeModeWindowManager(); 1353 DestroyMaximizeModeWindowManager();
1362 } 1354 }
1363 1355
1364 // Tests that windows with the always-on-top property are not managed by 1356 // Tests that windows with the always-on-top property are not managed by
1365 // the MaximizeModeWindowManager while maximize mode is engaged (i.e., 1357 // the MaximizeModeWindowManager while maximize mode is engaged (i.e.,
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 1438
1447 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 1439 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
1448 EXPECT_TRUE(wm::GetWindowState(window.get())->IsDocked()); 1440 EXPECT_TRUE(wm::GetWindowState(window.get())->IsDocked());
1449 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); 1441 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized());
1450 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 1442 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
1451 } 1443 }
1452 1444
1453 #endif // OS_WIN 1445 #endif // OS_WIN
1454 1446
1455 } // namespace ash 1447 } // 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.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698