OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" | 5 #include "ash/wm/maximize_mode/maximize_mode_window_manager.h" |
6 | 6 |
| 7 #include "ash/root_window_controller.h" |
7 #include "ash/screen_util.h" | 8 #include "ash/screen_util.h" |
| 9 #include "ash/shelf/shelf_layout_manager.h" |
8 #include "ash/shell.h" | 10 #include "ash/shell.h" |
9 #include "ash/switchable_windows.h" | 11 #include "ash/switchable_windows.h" |
10 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
11 #include "ash/test/shell_test_api.h" | 13 #include "ash/test/shell_test_api.h" |
12 #include "ash/wm/mru_window_tracker.h" | 14 #include "ash/wm/mru_window_tracker.h" |
13 #include "ash/wm/window_state.h" | 15 #include "ash/wm/window_state.h" |
14 #include "ash/wm/wm_event.h" | 16 #include "ash/wm/wm_event.h" |
15 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
16 #include "base/values.h" | 18 #include "base/values.h" |
17 #include "ui/aura/client/aura_constants.h" | 19 #include "ui/aura/client/aura_constants.h" |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 EXPECT_TRUE(window_state->IsMaximized()); | 634 EXPECT_TRUE(window_state->IsMaximized()); |
633 EXPECT_FALSE(window_state->IsMinimized()); | 635 EXPECT_FALSE(window_state->IsMinimized()); |
634 EXPECT_TRUE(window->IsVisible()); | 636 EXPECT_TRUE(window->IsVisible()); |
635 | 637 |
636 ash::Shell::GetInstance()->EnableMaximizeModeWindowManager(false); | 638 ash::Shell::GetInstance()->EnableMaximizeModeWindowManager(false); |
637 EXPECT_FALSE(window_state->IsMaximized()); | 639 EXPECT_FALSE(window_state->IsMaximized()); |
638 EXPECT_FALSE(window_state->IsMinimized()); | 640 EXPECT_FALSE(window_state->IsMinimized()); |
639 EXPECT_TRUE(window->IsVisible()); | 641 EXPECT_TRUE(window->IsVisible()); |
640 } | 642 } |
641 | 643 |
642 // Check that a full screen window is changing to maximized in maximize mode, | 644 // Check that a full screen window is staying full screen in maximize mode, |
643 // cannot go to fullscreen and goes back to fullscreen thereafter. | 645 // and that it returns to full screen thereafter (if left). |
644 TEST_F(MaximizeModeWindowManagerTest, FullScreenModeTests) { | 646 TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) { |
| 647 gfx::Rect rect(20, 140, 100, 100); |
| 648 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 649 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
| 650 |
| 651 ShelfLayoutManager* shelf = |
| 652 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); |
| 653 |
| 654 // Allow the shelf to hide. |
| 655 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 656 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
| 657 |
| 658 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
| 659 window_state->OnWMEvent(&event); |
| 660 |
| 661 // With full screen, the shelf should get hidden. |
| 662 EXPECT_TRUE(window_state->IsFullscreen()); |
| 663 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 664 |
| 665 CreateMaximizeModeWindowManager(); |
| 666 |
| 667 // Full screen mode should now be off and it should not come back while in |
| 668 // maximize mode - the shelf still hidden. |
| 669 EXPECT_TRUE(window_state->IsFullscreen()); |
| 670 EXPECT_FALSE(window_state->IsMaximized()); |
| 671 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 672 |
| 673 // With leaving the fullscreen mode, the maximized mode should return and the |
| 674 // shelf should become visible. |
| 675 window_state->OnWMEvent(&event); |
| 676 EXPECT_FALSE(window_state->IsFullscreen()); |
| 677 EXPECT_TRUE(window_state->IsMaximized()); |
| 678 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 679 |
| 680 // Ending the maximize mode should return to full screen and the shelf should |
| 681 // be hidden again. |
| 682 DestroyMaximizeModeWindowManager(); |
| 683 EXPECT_TRUE(window_state->IsFullscreen()); |
| 684 EXPECT_FALSE(window_state->IsMaximized()); |
| 685 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 686 } |
| 687 |
| 688 // Check that full screen mode can be turned on in maximized mode. |
| 689 TEST_F(MaximizeModeWindowManagerTest, AllowFullScreenMode) { |
645 gfx::Rect rect(20, 140, 100, 100); | 690 gfx::Rect rect(20, 140, 100, 100); |
646 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 691 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
647 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 692 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
648 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 693 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
649 window_state->OnWMEvent(&event); | 694 |
650 EXPECT_TRUE(window_state->IsFullscreen()); | 695 ShelfLayoutManager* shelf = |
| 696 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); |
| 697 |
| 698 // Allow the shelf to hide. |
| 699 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 700 |
| 701 EXPECT_FALSE(window_state->IsFullscreen()); |
| 702 EXPECT_FALSE(window_state->IsMaximized()); |
| 703 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
651 | 704 |
652 CreateMaximizeModeWindowManager(); | 705 CreateMaximizeModeWindowManager(); |
653 | 706 |
654 // Fullscreen mode should now be off and it should not come back while in | 707 // Fullscreen mode should still be off and the shelf should be visible. |
655 // maximize mode. | |
656 EXPECT_FALSE(window_state->IsFullscreen()); | 708 EXPECT_FALSE(window_state->IsFullscreen()); |
657 EXPECT_TRUE(window_state->IsMaximized()); | 709 EXPECT_TRUE(window_state->IsMaximized()); |
| 710 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); |
| 711 |
| 712 // After going into fullscreen mode, the shelf should be hidden. |
658 window_state->OnWMEvent(&event); | 713 window_state->OnWMEvent(&event); |
659 EXPECT_FALSE(window_state->IsFullscreen()); | |
660 EXPECT_TRUE(window_state->IsMaximized()); | |
661 | |
662 DestroyMaximizeModeWindowManager(); | |
663 EXPECT_TRUE(window_state->IsFullscreen()); | 714 EXPECT_TRUE(window_state->IsFullscreen()); |
664 EXPECT_FALSE(window_state->IsMaximized()); | 715 EXPECT_FALSE(window_state->IsMaximized()); |
| 716 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); |
| 717 |
| 718 // With the destruction of the manager we should fall back to the old state. |
| 719 DestroyMaximizeModeWindowManager(); |
| 720 EXPECT_FALSE(window_state->IsFullscreen()); |
| 721 EXPECT_FALSE(window_state->IsMaximized()); |
| 722 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); |
665 } | 723 } |
666 | 724 |
667 // Check that snapping operations get ignored. | 725 // Check that snapping operations get ignored. |
668 TEST_F(MaximizeModeWindowManagerTest, SnapModeTests) { | 726 TEST_F(MaximizeModeWindowManagerTest, SnapModeTests) { |
669 gfx::Rect rect(20, 140, 100, 100); | 727 gfx::Rect rect(20, 140, 100, 100); |
670 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 728 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
671 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 729 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
672 wm::WMEvent event_left(wm::WM_EVENT_SNAP_LEFT); | 730 wm::WMEvent event_left(wm::WM_EVENT_SNAP_LEFT); |
673 wm::WMEvent event_right(wm::WM_EVENT_SNAP_RIGHT); | 731 wm::WMEvent event_right(wm::WM_EVENT_SNAP_RIGHT); |
674 window_state->OnWMEvent(&event_left); | 732 window_state->OnWMEvent(&event_left); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 generator.MoveMouseBy(10, 5); | 791 generator.MoveMouseBy(10, 5); |
734 RunAllPendingInMessageLoop(); | 792 RunAllPendingInMessageLoop(); |
735 generator.ReleaseLeftButton(); | 793 generator.ReleaseLeftButton(); |
736 EXPECT_EQ(first_dragged_origin.x() + 10, window->bounds().x()); | 794 EXPECT_EQ(first_dragged_origin.x() + 10, window->bounds().x()); |
737 EXPECT_EQ(first_dragged_origin.y() + 5, window->bounds().y()); | 795 EXPECT_EQ(first_dragged_origin.y() + 5, window->bounds().y()); |
738 } | 796 } |
739 | 797 |
740 #endif // OS_WIN | 798 #endif // OS_WIN |
741 | 799 |
742 } // namespace ash | 800 } // namespace ash |
OLD | NEW |