| 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/rotation/tray_rotation_lock.h" | 5 #include "ash/system/rotation/tray_rotation_lock.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "ash/display/screen_orientation_controller_chromeos.h" | 9 #include "ash/display/screen_orientation_controller_chromeos.h" |
| 10 #include "ash/root_window_controller.h" | 10 #include "ash/root_window_controller.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 test::AshTestBase::TearDown(); | 108 test::AshTestBase::TearDown(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 // Tests that when the tray view is initially created, that it is created | 111 // Tests that when the tray view is initially created, that it is created |
| 112 // not visible. | 112 // not visible. |
| 113 TEST_F(TrayRotationLockTest, CreateTrayView) { | 113 TEST_F(TrayRotationLockTest, CreateTrayView) { |
| 114 EXPECT_FALSE(tray_view()->visible()); | 114 EXPECT_FALSE(tray_view()->visible()); |
| 115 } | 115 } |
| 116 | 116 |
| 117 // Tests that when the tray view is created, while MaximizeMode is active, that | 117 // Tests that when the tray view is created, while MaximizeMode is active, that |
| 118 // it is not visible. | 118 // it must be visible, and becomes invisible exiting MaximizeMode. |
| 119 TEST_F(TrayRotationLockTest, CreateTrayViewDuringMaximizeMode) { | 119 TEST_F(TrayRotationLockTest, CreateTrayViewDuringMaximizeMode) { |
| 120 TearDownViews(); | 120 TearDownViews(); |
| 121 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 121 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 122 true); | 122 true); |
| 123 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); | 123 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); |
| 124 EXPECT_FALSE(tray_view()->visible()); | |
| 125 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | |
| 126 false); | |
| 127 } | |
| 128 | |
| 129 // Tests that when the tray view is created, while MaximizeMode is active, and | |
| 130 // rotation is locked, that it is visible. | |
| 131 TEST_F(TrayRotationLockTest, CreateTrayViewDuringMaximizeModeAndRotationLock) { | |
| 132 TearDownViews(); | |
| 133 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | |
| 134 true); | |
| 135 Shell::Get()->screen_orientation_controller()->ToggleUserRotationLock(); | |
| 136 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); | |
| 137 EXPECT_TRUE(tray_view()->visible()); | 124 EXPECT_TRUE(tray_view()->visible()); |
| 138 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 125 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 139 false); | 126 false); |
| 140 EXPECT_FALSE(tray_view()->visible()); | 127 EXPECT_FALSE(tray_view()->visible()); |
| 141 } | 128 } |
| 142 | 129 |
| 143 // Tests that the enabling of MaximizeMode affects a previously created tray | 130 // Tests that the enabling of MaximizeMode affects a previously created tray |
| 144 // view, changing the visibility. | 131 // view, changing the visibility. |
| 145 TEST_F(TrayRotationLockTest, TrayViewVisibilityChangesDuringMaximizeMode) { | 132 TEST_F(TrayRotationLockTest, TrayViewVisibilityChangesDuringMaximizeMode) { |
| 146 ASSERT_FALSE(tray_view()->visible()); | 133 ASSERT_FALSE(tray_view()->visible()); |
| 147 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 134 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 148 true); | 135 true); |
| 149 Shell::Get()->screen_orientation_controller()->ToggleUserRotationLock(); | 136 Shell::Get()->screen_orientation_controller()->ToggleUserRotationLock(); |
| 150 EXPECT_TRUE(tray_view()->visible()); | 137 EXPECT_TRUE(tray_view()->visible()); |
| 151 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 138 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 152 false); | 139 false); |
| 153 EXPECT_FALSE(tray_view()->visible()); | 140 EXPECT_FALSE(tray_view()->visible()); |
| 154 } | 141 } |
| 155 | 142 |
| 156 // Tests that the when the tray view is created for a secondary display, that | 143 // Tests that when the tray view is created for a secondary display, that it is |
| 157 // it is not visible, and that MaximizeMode does not affect visibility. | 144 // not visible, and that MaximizeMode does not affect visibility. |
| 158 TEST_F(TrayRotationLockTest, CreateSecondaryTrayView) { | 145 TEST_F(TrayRotationLockTest, CreateSecondaryTrayView) { |
| 159 UpdateDisplay("400x400,200x200"); | 146 UpdateDisplay("400x400,200x200"); |
| 160 | 147 |
| 161 SetUpForStatusAreaWidget( | 148 SetUpForStatusAreaWidget( |
| 162 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()); | 149 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()); |
| 163 EXPECT_FALSE(tray_view()->visible()); | 150 EXPECT_FALSE(tray_view()->visible()); |
| 164 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 151 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 165 true); | 152 true); |
| 166 EXPECT_FALSE(tray_view()->visible()); | 153 EXPECT_FALSE(tray_view()->visible()); |
| 167 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 154 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 178 // Tests that when the default view is created, while MaximizeMode is active, | 165 // Tests that when the default view is created, while MaximizeMode is active, |
| 179 // that it is visible. | 166 // that it is visible. |
| 180 TEST_F(TrayRotationLockTest, CreateDefaultViewDuringMaximizeMode) { | 167 TEST_F(TrayRotationLockTest, CreateDefaultViewDuringMaximizeMode) { |
| 181 TearDownViews(); | 168 TearDownViews(); |
| 182 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 169 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 183 true); | 170 true); |
| 184 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); | 171 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); |
| 185 EXPECT_TRUE(default_view()->visible()); | 172 EXPECT_TRUE(default_view()->visible()); |
| 186 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 173 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 187 false); | 174 false); |
| 175 EXPECT_FALSE(default_view()->visible()); |
| 188 } | 176 } |
| 189 | 177 |
| 190 // Tests that the enabling of MaximizeMode affects a previously created default | 178 // Tests that the enabling of MaximizeMode affects a previously created default |
| 191 // view, changing the visibility. | 179 // view, changing the visibility. |
| 192 TEST_F(TrayRotationLockTest, DefaultViewVisibilityChangesDuringMaximizeMode) { | 180 TEST_F(TrayRotationLockTest, DefaultViewVisibilityChangesDuringMaximizeMode) { |
| 193 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 181 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 194 true); | 182 true); |
| 195 EXPECT_TRUE(default_view()->visible()); | 183 EXPECT_TRUE(default_view()->visible()); |
| 196 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 184 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 197 false); | 185 false); |
| 198 EXPECT_FALSE(default_view()->visible()); | 186 EXPECT_FALSE(default_view()->visible()); |
| 199 } | 187 } |
| 200 | 188 |
| 201 // Tests that no default view is created when the target is a secondary | 189 // Tests that no default view is created when the target is a secondary |
| 202 // display. | 190 // display. |
| 203 TEST_F(TrayRotationLockTest, CreateSecondaryDefaultView) { | 191 TEST_F(TrayRotationLockTest, CreateSecondaryDefaultView) { |
| 204 UpdateDisplay("400x400,200x200"); | 192 UpdateDisplay("400x400,200x200"); |
| 205 | 193 |
| 206 TearDownViews(); | 194 TearDownViews(); |
| 207 SetUpForStatusAreaWidget( | 195 SetUpForStatusAreaWidget( |
| 208 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()); | 196 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()); |
| 209 EXPECT_EQ(NULL, default_view()); | 197 EXPECT_EQ(NULL, default_view()); |
| 210 } | 198 } |
| 211 | 199 |
| 212 // Tests that activating the default view causes the display to have its | 200 // Tests that activating the default view causes the display to have its |
| 213 // rotation locked, and that the tray view becomes visible. | 201 // rotation locked. |
| 214 TEST_F(TrayRotationLockTest, PerformActionOnDefaultView) { | 202 TEST_F(TrayRotationLockTest, PerformActionOnDefaultView) { |
| 215 MaximizeModeController* maximize_mode_controller = | 203 MaximizeModeController* maximize_mode_controller = |
| 216 Shell::Get()->maximize_mode_controller(); | 204 Shell::Get()->maximize_mode_controller(); |
| 217 ScreenOrientationController* screen_orientation_controller = | 205 ScreenOrientationController* screen_orientation_controller = |
| 218 Shell::Get()->screen_orientation_controller(); | 206 Shell::Get()->screen_orientation_controller(); |
| 219 ASSERT_FALSE(screen_orientation_controller->rotation_locked()); | 207 ASSERT_FALSE(screen_orientation_controller->rotation_locked()); |
| 220 maximize_mode_controller->EnableMaximizeModeWindowManager(true); | 208 maximize_mode_controller->EnableMaximizeModeWindowManager(true); |
| 221 ASSERT_FALSE(tray_view()->visible()); | 209 ASSERT_TRUE(tray_view()->visible()); |
| 222 | 210 |
| 223 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), | 211 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), |
| 224 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); | 212 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); |
| 225 default_view()->OnGestureEvent(&tap); | 213 default_view()->OnGestureEvent(&tap); |
| 226 EXPECT_TRUE(screen_orientation_controller->rotation_locked()); | 214 EXPECT_TRUE(screen_orientation_controller->rotation_locked()); |
| 227 EXPECT_TRUE(tray_view()->visible()); | 215 EXPECT_TRUE(tray_view()->visible()); |
| 228 | 216 |
| 229 maximize_mode_controller->EnableMaximizeModeWindowManager(false); | 217 maximize_mode_controller->EnableMaximizeModeWindowManager(false); |
| 230 } | 218 } |
| 231 | 219 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 256 TEST_F(TrayRotationLockTest, LockUpdatedDuringDesctruction) { | 244 TEST_F(TrayRotationLockTest, LockUpdatedDuringDesctruction) { |
| 257 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 245 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 258 true); | 246 true); |
| 259 DestroyTrayView(); | 247 DestroyTrayView(); |
| 260 Shell::Get()->screen_orientation_controller()->ToggleUserRotationLock(); | 248 Shell::Get()->screen_orientation_controller()->ToggleUserRotationLock(); |
| 261 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( | 249 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 262 false); | 250 false); |
| 263 } | 251 } |
| 264 | 252 |
| 265 } // namespace ash | 253 } // namespace ash |
| OLD | NEW |