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

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

Issue 2017413002: ash: Fix variable names and setters in ShelfLayoutManager and tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@shellshelf
Patch Set: rebase 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/root_window_controller.h" 9 #include "ash/root_window_controller.h"
10 #include "ash/screen_util.h" 10 #include "ash/screen_util.h"
11 #include "ash/shelf/shelf_layout_manager.h" 11 #include "ash/shelf/shelf_layout_manager.h"
msw 2016/06/01 17:30:08 nit: include shelf.h instead
James Cook 2016/06/01 17:56:04 Done.
12 #include "ash/shell.h" 12 #include "ash/shell.h"
13 #include "ash/test/ash_test_base.h" 13 #include "ash/test/ash_test_base.h"
14 #include "ash/test/shell_test_api.h" 14 #include "ash/test/shell_test_api.h"
15 #include "ash/wm/common/switchable_windows.h" 15 #include "ash/wm/common/switchable_windows.h"
16 #include "ash/wm/common/window_state.h" 16 #include "ash/wm/common/window_state.h"
17 #include "ash/wm/common/wm_event.h" 17 #include "ash/wm/common/wm_event.h"
18 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 18 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
19 #include "ash/wm/mru_window_tracker.h" 19 #include "ash/wm/mru_window_tracker.h"
20 #include "ash/wm/overview/window_selector_controller.h" 20 #include "ash/wm/overview/window_selector_controller.h"
21 #include "ash/wm/window_properties.h" 21 #include "ash/wm/window_properties.h"
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 857
858 // Check that a full screen window remains full screen upon entering maximize 858 // Check that a full screen window remains full screen upon entering maximize
859 // mode. Furthermore, checks that this window is not full screen upon exiting 859 // mode. Furthermore, checks that this window is not full screen upon exiting
860 // maximize mode if it was un-full-screened while in maximize mode. 860 // maximize mode if it was un-full-screened while in maximize mode.
861 TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) { 861 TEST_F(MaximizeModeWindowManagerTest, KeepFullScreenModeOn) {
862 gfx::Rect rect(20, 140, 100, 100); 862 gfx::Rect rect(20, 140, 100, 100);
863 std::unique_ptr<aura::Window> w1( 863 std::unique_ptr<aura::Window> w1(
864 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 864 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
865 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 865 wm::WindowState* window_state = wm::GetWindowState(w1.get());
866 866
867 ShelfLayoutManager* shelf = 867 Shelf* shelf = Shelf::ForPrimaryDisplay();
868 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
869 868
870 // Allow the shelf to hide. 869 // Allow the shelf to hide.
871 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 870 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
872 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 871 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
873 872
874 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 873 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
875 window_state->OnWMEvent(&event); 874 window_state->OnWMEvent(&event);
876 875
877 // With full screen, the shelf should get hidden. 876 // With full screen, the shelf should get hidden.
878 EXPECT_TRUE(window_state->IsFullscreen()); 877 EXPECT_TRUE(window_state->IsFullscreen());
879 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); 878 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
880 879
881 CreateMaximizeModeWindowManager(); 880 CreateMaximizeModeWindowManager();
882 881
883 // The Full screen mode should continue to be on. 882 // The Full screen mode should continue to be on.
884 EXPECT_TRUE(window_state->IsFullscreen()); 883 EXPECT_TRUE(window_state->IsFullscreen());
885 EXPECT_FALSE(window_state->IsMaximized()); 884 EXPECT_FALSE(window_state->IsMaximized());
886 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); 885 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
887 886
888 // With leaving the fullscreen mode, the maximized mode should return and the 887 // With leaving the fullscreen mode, the maximized mode should return and the
889 // shelf should maintain its state from before maximize mode. 888 // shelf should maintain its state from before maximize mode.
890 window_state->OnWMEvent(&event); 889 window_state->OnWMEvent(&event);
891 EXPECT_FALSE(window_state->IsFullscreen()); 890 EXPECT_FALSE(window_state->IsFullscreen());
892 EXPECT_TRUE(window_state->IsMaximized()); 891 EXPECT_TRUE(window_state->IsMaximized());
893 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 892 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
894 893
895 // We left fullscreen mode while in maximize mode, so the window should 894 // We left fullscreen mode while in maximize mode, so the window should
896 // remain maximized and the shelf should not change state upon exiting 895 // remain maximized and the shelf should not change state upon exiting
897 // maximize mode. 896 // maximize mode.
898 DestroyMaximizeModeWindowManager(); 897 DestroyMaximizeModeWindowManager();
899 EXPECT_FALSE(window_state->IsFullscreen()); 898 EXPECT_FALSE(window_state->IsFullscreen());
900 EXPECT_TRUE(window_state->IsMaximized()); 899 EXPECT_TRUE(window_state->IsMaximized());
901 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 900 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
902 } 901 }
903 902
904 // Verifies that if a window is un-full-screened while in maximize mode, 903 // Verifies that if a window is un-full-screened while in maximize mode,
905 // other changes to that window's state (such as minimizing it) are 904 // other changes to that window's state (such as minimizing it) are
906 // preserved upon exiting maximize mode. 905 // preserved upon exiting maximize mode.
907 TEST_F(MaximizeModeWindowManagerTest, MinimizePreservedAfterLeavingFullscreen) { 906 TEST_F(MaximizeModeWindowManagerTest, MinimizePreservedAfterLeavingFullscreen) {
908 gfx::Rect rect(20, 140, 100, 100); 907 gfx::Rect rect(20, 140, 100, 100);
909 std::unique_ptr<aura::Window> w1( 908 std::unique_ptr<aura::Window> w1(
910 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 909 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
911 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 910 wm::WindowState* window_state = wm::GetWindowState(w1.get());
912 911
913 ShelfLayoutManager* shelf = 912 Shelf* shelf = Shelf::ForPrimaryDisplay();
914 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
915 913
916 // Allow the shelf to hide and enter full screen. 914 // Allow the shelf to hide and enter full screen.
917 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 915 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
918 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 916 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
919 window_state->OnWMEvent(&event); 917 window_state->OnWMEvent(&event);
920 ASSERT_FALSE(window_state->IsMinimized()); 918 ASSERT_FALSE(window_state->IsMinimized());
921 919
922 // Enter maximize mode, exit full screen, and then minimize the window. 920 // Enter maximize mode, exit full screen, and then minimize the window.
923 CreateMaximizeModeWindowManager(); 921 CreateMaximizeModeWindowManager();
924 window_state->OnWMEvent(&event); 922 window_state->OnWMEvent(&event);
925 window_state->Minimize(); 923 window_state->Minimize();
926 ASSERT_TRUE(window_state->IsMinimized()); 924 ASSERT_TRUE(window_state->IsMinimized());
927 925
928 // The window should remain minimized when exiting maximize mode. 926 // The window should remain minimized when exiting maximize mode.
929 DestroyMaximizeModeWindowManager(); 927 DestroyMaximizeModeWindowManager();
930 EXPECT_TRUE(window_state->IsMinimized()); 928 EXPECT_TRUE(window_state->IsMinimized());
931 } 929 }
932 930
933 // Check that full screen mode can be turned on in maximized mode and remains 931 // Check that full screen mode can be turned on in maximized mode and remains
934 // upon coming back. 932 // upon coming back.
935 TEST_F(MaximizeModeWindowManagerTest, AllowFullScreenMode) { 933 TEST_F(MaximizeModeWindowManagerTest, AllowFullScreenMode) {
936 gfx::Rect rect(20, 140, 100, 100); 934 gfx::Rect rect(20, 140, 100, 100);
937 std::unique_ptr<aura::Window> w1( 935 std::unique_ptr<aura::Window> w1(
938 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect)); 936 CreateWindow(ui::wm::WINDOW_TYPE_NORMAL, rect));
939 wm::WindowState* window_state = wm::GetWindowState(w1.get()); 937 wm::WindowState* window_state = wm::GetWindowState(w1.get());
940 938
941 ShelfLayoutManager* shelf = 939 Shelf* shelf = Shelf::ForPrimaryDisplay();
942 Shell::GetPrimaryRootWindowController()->GetShelfLayoutManager();
943 940
944 // Allow the shelf to hide. 941 // Allow the shelf to hide.
945 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); 942 shelf->SetAutoHideBehavior(SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
946 943
947 EXPECT_FALSE(window_state->IsFullscreen()); 944 EXPECT_FALSE(window_state->IsFullscreen());
948 EXPECT_FALSE(window_state->IsMaximized()); 945 EXPECT_FALSE(window_state->IsMaximized());
949 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 946 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
950 947
951 CreateMaximizeModeWindowManager(); 948 CreateMaximizeModeWindowManager();
952 949
953 // Fullscreen mode should still be off and the shelf should maintain its 950 // Fullscreen mode should still be off and the shelf should maintain its
954 // state. 951 // state.
955 EXPECT_FALSE(window_state->IsFullscreen()); 952 EXPECT_FALSE(window_state->IsFullscreen());
956 EXPECT_TRUE(window_state->IsMaximized()); 953 EXPECT_TRUE(window_state->IsMaximized());
957 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->visibility_state()); 954 EXPECT_EQ(SHELF_AUTO_HIDE, shelf->GetVisibilityState());
958 955
959 // After going into fullscreen mode, the shelf should be hidden. 956 // After going into fullscreen mode, the shelf should be hidden.
960 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN); 957 wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
961 window_state->OnWMEvent(&event); 958 window_state->OnWMEvent(&event);
962 EXPECT_TRUE(window_state->IsFullscreen()); 959 EXPECT_TRUE(window_state->IsFullscreen());
963 EXPECT_FALSE(window_state->IsMaximized()); 960 EXPECT_FALSE(window_state->IsMaximized());
964 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); 961 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
965 962
966 // With the destruction of the manager we should remain in full screen. 963 // With the destruction of the manager we should remain in full screen.
967 DestroyMaximizeModeWindowManager(); 964 DestroyMaximizeModeWindowManager();
968 EXPECT_TRUE(window_state->IsFullscreen()); 965 EXPECT_TRUE(window_state->IsFullscreen());
969 EXPECT_FALSE(window_state->IsMaximized()); 966 EXPECT_FALSE(window_state->IsMaximized());
970 EXPECT_EQ(SHELF_HIDDEN, shelf->visibility_state()); 967 EXPECT_EQ(SHELF_HIDDEN, shelf->GetVisibilityState());
971 } 968 }
972 969
973 // Check that the full screen mode will stay active when the maximize mode is 970 // Check that the full screen mode will stay active when the maximize mode is
974 // ended. 971 // ended.
975 TEST_F(MaximizeModeWindowManagerTest, 972 TEST_F(MaximizeModeWindowManagerTest,
976 FullScreenModeRemainsWhenCreatedInMaximizedMode) { 973 FullScreenModeRemainsWhenCreatedInMaximizedMode) {
977 CreateMaximizeModeWindowManager(); 974 CreateMaximizeModeWindowManager();
978 975
979 gfx::Rect rect(20, 140, 100, 100); 976 gfx::Rect rect(20, 140, 100, 100);
980 std::unique_ptr<aura::Window> w1( 977 std::unique_ptr<aura::Window> w1(
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
1446 1443
1447 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager(); 1444 ash::MaximizeModeWindowManager* manager = CreateMaximizeModeWindowManager();
1448 EXPECT_TRUE(wm::GetWindowState(window.get())->IsDocked()); 1445 EXPECT_TRUE(wm::GetWindowState(window.get())->IsDocked());
1449 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized()); 1446 EXPECT_FALSE(wm::GetWindowState(window.get())->IsMaximized());
1450 EXPECT_EQ(0, manager->GetNumberOfManagedWindows()); 1447 EXPECT_EQ(0, manager->GetNumberOfManagedWindows());
1451 } 1448 }
1452 1449
1453 #endif // OS_WIN 1450 #endif // OS_WIN
1454 1451
1455 } // namespace ash 1452 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698