| 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/system/chromeos/rotation/tray_rotation_lock.h" | 5 #include "ash/system/chromeos/rotation/tray_rotation_lock.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/content/display/screen_orientation_delegate_chromeos.h" |
| 8 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
| 9 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| 10 #include "ash/shelf/shelf_widget.h" | 11 #include "ash/shelf/shelf_widget.h" |
| 11 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 12 #include "ash/system/status_area_widget.h" | 13 #include "ash/system/status_area_widget.h" |
| 13 #include "ash/system/tray/system_tray.h" | 14 #include "ash/system/tray/system_tray.h" |
| 14 #include "ash/system/tray/system_tray_delegate.h" | 15 #include "ash/system/tray/system_tray_delegate.h" |
| 15 #include "ash/test/ash_test_base.h" | 16 #include "ash/test/ash_test_base.h" |
| 16 #include "ash/test/status_area_widget_test_helper.h" | 17 #include "ash/test/status_area_widget_test_helper.h" |
| 17 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 18 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 Shell::GetInstance()->maximize_mode_controller()-> | 112 Shell::GetInstance()->maximize_mode_controller()-> |
| 112 EnableMaximizeModeWindowManager(false); | 113 EnableMaximizeModeWindowManager(false); |
| 113 } | 114 } |
| 114 | 115 |
| 115 // Tests that when the tray view is created, while MaximizeMode is active, and | 116 // Tests that when the tray view is created, while MaximizeMode is active, and |
| 116 // rotation is locked, that it is visible. | 117 // rotation is locked, that it is visible. |
| 117 TEST_F(TrayRotationLockTest, CreateTrayViewDuringMaximizeModeAndRotationLock) { | 118 TEST_F(TrayRotationLockTest, CreateTrayViewDuringMaximizeModeAndRotationLock) { |
| 118 TearDownViews(); | 119 TearDownViews(); |
| 119 Shell::GetInstance()->maximize_mode_controller()-> | 120 Shell::GetInstance()->maximize_mode_controller()-> |
| 120 EnableMaximizeModeWindowManager(true); | 121 EnableMaximizeModeWindowManager(true); |
| 121 Shell::GetInstance()-> maximize_mode_controller()->SetRotationLocked(true); | 122 Shell::GetInstance()->screen_orientation_delegate()->SetRotationLocked(true); |
| 122 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); | 123 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); |
| 123 EXPECT_TRUE(tray_view()->visible()); | 124 EXPECT_TRUE(tray_view()->visible()); |
| 124 Shell::GetInstance()->maximize_mode_controller()-> | 125 Shell::GetInstance()->maximize_mode_controller()-> |
| 125 EnableMaximizeModeWindowManager(false); | 126 EnableMaximizeModeWindowManager(false); |
| 126 EXPECT_FALSE(tray_view()->visible()); | 127 EXPECT_FALSE(tray_view()->visible()); |
| 127 } | 128 } |
| 128 | 129 |
| 129 // Tests that the enabling of MaximizeMode affects a previously created tray | 130 // Tests that the enabling of MaximizeMode affects a previously created tray |
| 130 // view, changing the visibility. | 131 // view, changing the visibility. |
| 131 TEST_F(TrayRotationLockTest, TrayViewVisibilityChangesDuringMaximizeMode) { | 132 TEST_F(TrayRotationLockTest, TrayViewVisibilityChangesDuringMaximizeMode) { |
| 132 ASSERT_FALSE(tray_view()->visible()); | 133 ASSERT_FALSE(tray_view()->visible()); |
| 133 Shell::GetInstance()->maximize_mode_controller()-> | 134 Shell::GetInstance()->maximize_mode_controller()-> |
| 134 EnableMaximizeModeWindowManager(true); | 135 EnableMaximizeModeWindowManager(true); |
| 135 Shell::GetInstance()->maximize_mode_controller()->SetRotationLocked(true); | 136 Shell::GetInstance()->screen_orientation_delegate()->SetRotationLocked(true); |
| 136 EXPECT_TRUE(tray_view()->visible()); | 137 EXPECT_TRUE(tray_view()->visible()); |
| 137 Shell::GetInstance()->maximize_mode_controller()-> | 138 Shell::GetInstance()->maximize_mode_controller()-> |
| 138 EnableMaximizeModeWindowManager(false); | 139 EnableMaximizeModeWindowManager(false); |
| 139 EXPECT_FALSE(tray_view()->visible()); | 140 EXPECT_FALSE(tray_view()->visible()); |
| 140 } | 141 } |
| 141 | 142 |
| 142 // Tests that the when the tray view is created for a secondary display, that | 143 // Tests that the when the tray view is created for a secondary display, that |
| 143 // it is not visible, and that MaximizeMode does not affect visibility. | 144 // it is not visible, and that MaximizeMode does not affect visibility. |
| 144 TEST_F(TrayRotationLockTest, CreateSecondaryTrayView) { | 145 TEST_F(TrayRotationLockTest, CreateSecondaryTrayView) { |
| 145 if (!SupportsMultipleDisplays()) | 146 if (!SupportsMultipleDisplays()) |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 SetUpForStatusAreaWidget( | 198 SetUpForStatusAreaWidget( |
| 198 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()); | 199 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()); |
| 199 EXPECT_EQ(NULL, default_view()); | 200 EXPECT_EQ(NULL, default_view()); |
| 200 } | 201 } |
| 201 | 202 |
| 202 // Tests that activating the default view causes the display to have its | 203 // Tests that activating the default view causes the display to have its |
| 203 // rotation locked, and that the tray view becomes visible. | 204 // rotation locked, and that the tray view becomes visible. |
| 204 TEST_F(TrayRotationLockTest, PerformActionOnDefaultView) { | 205 TEST_F(TrayRotationLockTest, PerformActionOnDefaultView) { |
| 205 MaximizeModeController* maximize_mode_controller = Shell::GetInstance()-> | 206 MaximizeModeController* maximize_mode_controller = Shell::GetInstance()-> |
| 206 maximize_mode_controller(); | 207 maximize_mode_controller(); |
| 207 ASSERT_FALSE(maximize_mode_controller->rotation_locked()); | 208 ScreenOrientationDelegate* screen_orientation_delegate = |
| 208 Shell::GetInstance()->maximize_mode_controller()-> | 209 Shell::GetInstance()->screen_orientation_delegate(); |
| 209 EnableMaximizeModeWindowManager(true); | 210 ASSERT_FALSE(screen_orientation_delegate->rotation_locked()); |
| 211 maximize_mode_controller->EnableMaximizeModeWindowManager(true); |
| 210 ASSERT_FALSE(tray_view()->visible()); | 212 ASSERT_FALSE(tray_view()->visible()); |
| 211 | 213 |
| 212 ui::GestureEvent tap( | 214 ui::GestureEvent tap( |
| 213 0, 0, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | 215 0, 0, 0, base::TimeDelta(), ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
| 214 default_view()->OnGestureEvent(&tap); | 216 default_view()->OnGestureEvent(&tap); |
| 215 EXPECT_TRUE(maximize_mode_controller->rotation_locked()); | 217 EXPECT_TRUE(screen_orientation_delegate->rotation_locked()); |
| 216 EXPECT_TRUE(tray_view()->visible()); | 218 EXPECT_TRUE(tray_view()->visible()); |
| 217 | 219 |
| 218 Shell::GetInstance()->maximize_mode_controller()-> | 220 maximize_mode_controller->EnableMaximizeModeWindowManager(false); |
| 219 EnableMaximizeModeWindowManager(false); | |
| 220 } | 221 } |
| 221 | 222 |
| 222 } // namespace ash | 223 } // namespace ash |
| OLD | NEW |