Chromium Code Reviews| 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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 666 EXPECT_TRUE(window_state->IsMaximized()); | 668 EXPECT_TRUE(window_state->IsMaximized()); |
| 667 EXPECT_FALSE(window_state->IsMinimized()); | 669 EXPECT_FALSE(window_state->IsMinimized()); |
| 668 EXPECT_TRUE(window->IsVisible()); | 670 EXPECT_TRUE(window->IsVisible()); |
| 669 | 671 |
| 670 ash::Shell::GetInstance()->EnableMaximizeModeWindowManager(false); | 672 ash::Shell::GetInstance()->EnableMaximizeModeWindowManager(false); |
| 671 EXPECT_FALSE(window_state->IsMaximized()); | 673 EXPECT_FALSE(window_state->IsMaximized()); |
| 672 EXPECT_FALSE(window_state->IsMinimized()); | 674 EXPECT_FALSE(window_state->IsMinimized()); |
| 673 EXPECT_TRUE(window->IsVisible()); | 675 EXPECT_TRUE(window->IsVisible()); |
| 674 } | 676 } |
| 675 | 677 |
| 676 // Check that a full screen window is changing to maximized in maximize mode, | 678 // Check that a full screen window is staying full screen in maximize mode, |
| 677 // cannot go to fullscreen and goes back to fullscreen thereafter. | 679 // and that it returns to full screen thereafter (if left). |
| 678 TEST_F(MaximizeModeWindowManagerTest, FullScreenModeTests) { | 680 TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) { |
| 681 gfx::Rect rect(20, 140, 100, 100); | |
| 682 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | |
| 683 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | |
| 684 | |
| 685 ShelfLayoutManager* shelf = | |
| 686 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); | |
| 687 | |
| 688 // Allow the shelf to hide. | |
| 689 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | |
| 690 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | |
| 691 | |
| 692 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | |
| 693 window_state->OnWMEvent(&event); | |
| 694 | |
| 695 // With full screen, the shelf should get hidden. | |
| 696 EXPECT_TRUE(window_state->IsFullscreen()); | |
| 697 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | |
| 698 | |
| 699 CreateMaximizeModeWindowManager(); | |
| 700 | |
| 701 // Full screen mode should now be off and it should not come back while in | |
|
oshima
2014/04/25 18:46:55
I didn't understand this comment. Fullscreen shoul
Mr4D (OOO till 08-26)
2014/04/25 19:55:19
Right. It should stay on. Changed
| |
| 702 // maximize mode - the shelf still hidden. | |
| 703 EXPECT_TRUE(window_state->IsFullscreen()); | |
| 704 EXPECT_FALSE(window_state->IsMaximized()); | |
| 705 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | |
| 706 | |
| 707 // With leaving the fullscreen mode, the maximized mode should return and the | |
| 708 // shelf should become visible. | |
| 709 window_state->OnWMEvent(&event); | |
| 710 EXPECT_FALSE(window_state->IsFullscreen()); | |
| 711 EXPECT_TRUE(window_state->IsMaximized()); | |
| 712 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | |
| 713 | |
| 714 // Ending the maximize mode should return to full screen and the shelf should | |
| 715 // be hidden again. | |
| 716 DestroyMaximizeModeWindowManager(); | |
| 717 EXPECT_TRUE(window_state->IsFullscreen()); | |
| 718 EXPECT_FALSE(window_state->IsMaximized()); | |
| 719 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | |
| 720 } | |
| 721 | |
| 722 // Check that full screen mode can be turned on in maximized mode. | |
| 723 TEST_F(MaximizeModeWindowManagerTest, AllowFullScreenMode) { | |
| 679 gfx::Rect rect(20, 140, 100, 100); | 724 gfx::Rect rect(20, 140, 100, 100); |
| 680 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 725 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 681 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 726 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
| 682 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); | 727 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); |
|
oshima
2014/04/25 18:46:55
move this to 745, just before OnWMEvent
Mr4D (OOO till 08-26)
2014/04/25 19:55:19
Done.
| |
| 683 window_state->OnWMEvent(&event); | 728 |
| 684 EXPECT_TRUE(window_state->IsFullscreen()); | 729 ShelfLayoutManager* shelf = |
| 730 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager(); | |
| 731 | |
| 732 // Allow the shelf to hide. | |
| 733 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | |
| 734 | |
| 735 EXPECT_FALSE(window_state->IsFullscreen()); | |
| 736 EXPECT_FALSE(window_state->IsMaximized()); | |
| 737 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | |
| 685 | 738 |
| 686 CreateMaximizeModeWindowManager(); | 739 CreateMaximizeModeWindowManager(); |
| 687 | 740 |
| 688 // Fullscreen mode should now be off and it should not come back while in | 741 // Fullscreen mode should still be off and the shelf should be visible. |
| 689 // maximize mode. | |
| 690 EXPECT_FALSE(window_state->IsFullscreen()); | 742 EXPECT_FALSE(window_state->IsFullscreen()); |
| 691 EXPECT_TRUE(window_state->IsMaximized()); | 743 EXPECT_TRUE(window_state->IsMaximized()); |
| 744 EXPECT_EQ(SHELF_VISIBLE, shelf->visibility_state()); | |
| 745 | |
| 746 // After going into fullscreen mode, the shelf should be hidden. | |
| 692 window_state->OnWMEvent(&event); | 747 window_state->OnWMEvent(&event); |
| 693 EXPECT_FALSE(window_state->IsFullscreen()); | |
| 694 EXPECT_TRUE(window_state->IsMaximized()); | |
| 695 | |
| 696 DestroyMaximizeModeWindowManager(); | |
| 697 EXPECT_TRUE(window_state->IsFullscreen()); | 748 EXPECT_TRUE(window_state->IsFullscreen()); |
| 698 EXPECT_FALSE(window_state->IsMaximized()); | 749 EXPECT_FALSE(window_state->IsMaximized()); |
| 750 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); | |
| 751 | |
| 752 // With the destruction of the manager we should fall back to the old state. | |
| 753 DestroyMaximizeModeWindowManager(); | |
| 754 EXPECT_FALSE(window_state->IsFullscreen()); | |
| 755 EXPECT_FALSE(window_state->IsMaximized()); | |
| 756 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); | |
| 699 } | 757 } |
| 700 | 758 |
| 701 // Check that snapping operations get ignored. | 759 // Check that snapping operations get ignored. |
| 702 TEST_F(MaximizeModeWindowManagerTest, SnapModeTests) { | 760 TEST_F(MaximizeModeWindowManagerTest, SnapModeTests) { |
| 703 gfx::Rect rect(20, 140, 100, 100); | 761 gfx::Rect rect(20, 140, 100, 100); |
| 704 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); | 762 scoped_ptr<aura::Window> w1(CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); |
| 705 wm::WindowState* window_state = wm::GetWindowState(w1.get()); | 763 wm::WindowState* window_state = wm::GetWindowState(w1.get()); |
| 706 wm::WMEvent event_left(wm::WM_EVENT_SNAP_LEFT); | 764 wm::WMEvent event_left(wm::WM_EVENT_SNAP_LEFT); |
| 707 wm::WMEvent event_right(wm::WM_EVENT_SNAP_RIGHT); | 765 wm::WMEvent event_right(wm::WM_EVENT_SNAP_RIGHT); |
| 708 window_state->OnWMEvent(&event_left); | 766 window_state->OnWMEvent(&event_left); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 767 generator.MoveMouseBy(10, 5); | 825 generator.MoveMouseBy(10, 5); |
| 768 RunAllPendingInMessageLoop(); | 826 RunAllPendingInMessageLoop(); |
| 769 generator.ReleaseLeftButton(); | 827 generator.ReleaseLeftButton(); |
| 770 EXPECT_EQ(first_dragged_origin.x() + 10, window->bounds().x()); | 828 EXPECT_EQ(first_dragged_origin.x() + 10, window->bounds().x()); |
| 771 EXPECT_EQ(first_dragged_origin.y() + 5, window->bounds().y()); | 829 EXPECT_EQ(first_dragged_origin.y() + 5, window->bounds().y()); |
| 772 } | 830 } |
| 773 | 831 |
| 774 #endif // OS_WIN | 832 #endif // OS_WIN |
| 775 | 833 |
| 776 } // namespace ash | 834 } // namespace ash |
| OLD | NEW |