OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/lock_state_controller.h" | 5 #include "ash/wm/lock_state_controller.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 } | 224 } |
225 | 225 |
226 void ExpectShutdownAnimationCancel() { | 226 void ExpectShutdownAnimationCancel() { |
227 SCOPED_TRACE("Failure in ExpectShutdownAnimationCancel"); | 227 SCOPED_TRACE("Failure in ExpectShutdownAnimationCancel"); |
228 EXPECT_LT(0u, test_animator_->GetAnimationCount()); | 228 EXPECT_LT(0u, test_animator_->GetAnimationCount()); |
229 EXPECT_TRUE(test_animator_->AreContainersAnimated( | 229 EXPECT_TRUE(test_animator_->AreContainersAnimated( |
230 SessionStateAnimator::ROOT_CONTAINER, | 230 SessionStateAnimator::ROOT_CONTAINER, |
231 SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS)); | 231 SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS)); |
232 } | 232 } |
233 | 233 |
234 void ExpectBackgroundIsShowing() { | 234 void ExpectWallpaperIsShowing() { |
235 SCOPED_TRACE("Failure in ExpectBackgroundIsShowing"); | 235 SCOPED_TRACE("Failure in ExpectWallpaperIsShowing"); |
236 EXPECT_LT(0u, test_animator_->GetAnimationCount()); | 236 EXPECT_LT(0u, test_animator_->GetAnimationCount()); |
237 EXPECT_TRUE(test_animator_->AreContainersAnimated( | 237 EXPECT_TRUE(test_animator_->AreContainersAnimated( |
238 SessionStateAnimator::DESKTOP_BACKGROUND, | 238 SessionStateAnimator::WALLPAPER, |
239 SessionStateAnimator::ANIMATION_FADE_IN)); | 239 SessionStateAnimator::ANIMATION_FADE_IN)); |
240 } | 240 } |
241 | 241 |
242 void ExpectBackgroundIsHiding() { | 242 void ExpectWallpaperIsHiding() { |
243 SCOPED_TRACE("Failure in ExpectBackgroundIsHiding"); | 243 SCOPED_TRACE("Failure in ExpectWallpaperIsHiding"); |
244 EXPECT_LT(0u, test_animator_->GetAnimationCount()); | 244 EXPECT_LT(0u, test_animator_->GetAnimationCount()); |
245 EXPECT_TRUE(test_animator_->AreContainersAnimated( | 245 EXPECT_TRUE(test_animator_->AreContainersAnimated( |
246 SessionStateAnimator::DESKTOP_BACKGROUND, | 246 SessionStateAnimator::WALLPAPER, |
247 SessionStateAnimator::ANIMATION_FADE_OUT)); | 247 SessionStateAnimator::ANIMATION_FADE_OUT)); |
248 } | 248 } |
249 | 249 |
250 void ExpectRestoringBackgroundVisibility() { | 250 void ExpectRestoringWallpaperVisibility() { |
251 SCOPED_TRACE("Failure in ExpectRestoringBackgroundVisibility"); | 251 SCOPED_TRACE("Failure in ExpectRestoringWallpaperVisibility"); |
252 EXPECT_LT(0u, test_animator_->GetAnimationCount()); | 252 EXPECT_LT(0u, test_animator_->GetAnimationCount()); |
253 EXPECT_TRUE(test_animator_->AreContainersAnimated( | 253 EXPECT_TRUE(test_animator_->AreContainersAnimated( |
254 SessionStateAnimator::DESKTOP_BACKGROUND, | 254 SessionStateAnimator::WALLPAPER, |
255 SessionStateAnimator::ANIMATION_FADE_IN)); | 255 SessionStateAnimator::ANIMATION_FADE_IN)); |
256 } | 256 } |
257 | 257 |
258 void ExpectUnlockedState() { | 258 void ExpectUnlockedState() { |
259 SCOPED_TRACE("Failure in ExpectUnlockedState"); | 259 SCOPED_TRACE("Failure in ExpectUnlockedState"); |
260 EXPECT_EQ(0u, test_animator_->GetAnimationCount()); | 260 EXPECT_EQ(0u, test_animator_->GetAnimationCount()); |
261 EXPECT_FALSE(WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked()); | 261 EXPECT_FALSE(WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked()); |
262 } | 262 } |
263 | 263 |
264 void ExpectLockedState() { | 264 void ExpectLockedState() { |
265 SCOPED_TRACE("Failure in ExpectLockedState"); | 265 SCOPED_TRACE("Failure in ExpectLockedState"); |
266 EXPECT_EQ(0u, test_animator_->GetAnimationCount()); | 266 EXPECT_EQ(0u, test_animator_->GetAnimationCount()); |
267 EXPECT_TRUE(WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked()); | 267 EXPECT_TRUE(WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked()); |
268 } | 268 } |
269 | 269 |
270 void HideBackground() { test_animator_->HideBackground(); } | 270 void HideWallpaper() { test_animator_->HideWallpaper(); } |
271 | 271 |
272 void PressPowerButton() { | 272 void PressPowerButton() { |
273 power_button_controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); | 273 power_button_controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
274 } | 274 } |
275 | 275 |
276 void ReleasePowerButton() { | 276 void ReleasePowerButton() { |
277 power_button_controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); | 277 power_button_controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); |
278 } | 278 } |
279 | 279 |
280 void PressLockButton() { | 280 void PressLockButton() { |
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 // When the screen brightness is 0% but the external display is still turned | 918 // When the screen brightness is 0% but the external display is still turned |
919 // on (indicating either docked mode or the user having manually decreased the | 919 // on (indicating either docked mode or the user having manually decreased the |
920 // brightness to 0%), the power button should still be handled. | 920 // brightness to 0%), the power button should still be handled. |
921 external_display.set_current_mode(external_display.modes().back().get()); | 921 external_display.set_current_mode(external_display.modes().back().get()); |
922 power_button_controller_->OnDisplayModeChanged(outputs); | 922 power_button_controller_->OnDisplayModeChanged(outputs); |
923 PressPowerButton(); | 923 PressPowerButton(); |
924 EXPECT_TRUE(test_api_->is_animating_lock()); | 924 EXPECT_TRUE(test_api_->is_animating_lock()); |
925 ReleasePowerButton(); | 925 ReleasePowerButton(); |
926 } | 926 } |
927 | 927 |
928 // Test that hidden background appears and revers correctly on lock/cancel. | 928 // Test that hidden wallpaper appears and revers correctly on lock/cancel. |
929 TEST_F(LockStateControllerTest, TestHiddenBackgroundLockCancel) { | 929 TEST_F(LockStateControllerTest, TestHiddenWallpaperLockCancel) { |
930 Initialize(false, LoginStatus::USER); | 930 Initialize(false, LoginStatus::USER); |
931 HideBackground(); | 931 HideWallpaper(); |
932 | 932 |
933 ExpectUnlockedState(); | 933 ExpectUnlockedState(); |
934 PressPowerButton(); | 934 PressPowerButton(); |
935 | 935 |
936 ExpectPreLockAnimationStarted(); | 936 ExpectPreLockAnimationStarted(); |
937 ExpectBackgroundIsShowing(); | 937 ExpectWallpaperIsShowing(); |
938 | 938 |
939 // Forward only half way through. | 939 // Forward only half way through. |
940 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); | 940 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); |
941 | 941 |
942 // Release the button before the lock timer fires. | 942 // Release the button before the lock timer fires. |
943 ReleasePowerButton(); | 943 ReleasePowerButton(); |
944 ExpectPreLockAnimationCancel(); | 944 ExpectPreLockAnimationCancel(); |
945 ExpectBackgroundIsHiding(); | 945 ExpectWallpaperIsHiding(); |
946 | 946 |
947 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS); | 947 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS); |
948 | 948 |
949 // When the CancelPrelockAnimation sequence finishes it queues up a | 949 // When the CancelPrelockAnimation sequence finishes it queues up a |
950 // restore background visibility sequence when the background is hidden. | 950 // restore wallpaper visibility sequence when the wallpaper is hidden. |
951 ExpectRestoringBackgroundVisibility(); | 951 ExpectRestoringWallpaperVisibility(); |
952 | 952 |
953 Advance(SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 953 Advance(SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
954 | 954 |
955 ExpectUnlockedState(); | 955 ExpectUnlockedState(); |
956 } | 956 } |
957 | 957 |
958 // Test that hidden background appears and revers correctly on lock/unlock. | 958 // Test that hidden wallpaper appears and revers correctly on lock/unlock. |
959 TEST_F(LockStateControllerTest, TestHiddenBackgroundLockUnlock) { | 959 TEST_F(LockStateControllerTest, TestHiddenWallpaperLockUnlock) { |
960 Initialize(false, LoginStatus::USER); | 960 Initialize(false, LoginStatus::USER); |
961 HideBackground(); | 961 HideWallpaper(); |
962 | 962 |
963 ExpectUnlockedState(); | 963 ExpectUnlockedState(); |
964 | 964 |
965 // Press the power button and check that the lock timer is started and that we | 965 // Press the power button and check that the lock timer is started and that we |
966 // start lifting the non-screen-locker containers. | 966 // start lifting the non-screen-locker containers. |
967 PressPowerButton(); | 967 PressPowerButton(); |
968 | 968 |
969 ExpectPreLockAnimationStarted(); | 969 ExpectPreLockAnimationStarted(); |
970 ExpectBackgroundIsShowing(); | 970 ExpectWallpaperIsShowing(); |
971 | 971 |
972 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); | 972 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
973 | 973 |
974 ExpectPreLockAnimationFinished(); | 974 ExpectPreLockAnimationFinished(); |
975 | 975 |
976 SystemLocks(); | 976 SystemLocks(); |
977 | 977 |
978 ReleasePowerButton(); | 978 ReleasePowerButton(); |
979 | 979 |
980 ExpectPostLockAnimationStarted(); | 980 ExpectPostLockAnimationStarted(); |
981 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 981 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
982 ExpectPostLockAnimationFinished(); | 982 ExpectPostLockAnimationFinished(); |
983 | 983 |
984 ExpectLockedState(); | 984 ExpectLockedState(); |
985 | 985 |
986 SuccessfulAuthentication(NULL); | 986 SuccessfulAuthentication(NULL); |
987 | 987 |
988 ExpectUnlockBeforeUIDestroyedAnimationStarted(); | 988 ExpectUnlockBeforeUIDestroyedAnimationStarted(); |
989 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 989 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
990 ExpectUnlockBeforeUIDestroyedAnimationFinished(); | 990 ExpectUnlockBeforeUIDestroyedAnimationFinished(); |
991 | 991 |
992 SystemUnlocks(); | 992 SystemUnlocks(); |
993 | 993 |
994 ExpectUnlockAfterUIDestroyedAnimationStarted(); | 994 ExpectUnlockAfterUIDestroyedAnimationStarted(); |
995 ExpectBackgroundIsHiding(); | 995 ExpectWallpaperIsHiding(); |
996 | 996 |
997 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 997 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
998 | 998 |
999 // When the StartUnlockAnimationAfterUIDestroyed sequence finishes it queues | 999 // When the StartUnlockAnimationAfterUIDestroyed sequence finishes it queues |
1000 // up a restore background visibility sequence when the background is hidden. | 1000 // up a restore wallpaper visibility sequence when the wallpaper is hidden. |
1001 ExpectRestoringBackgroundVisibility(); | 1001 ExpectRestoringWallpaperVisibility(); |
1002 | 1002 |
1003 Advance(SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); | 1003 Advance(SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
1004 | 1004 |
1005 ExpectUnlockAfterUIDestroyedAnimationFinished(); | 1005 ExpectUnlockAfterUIDestroyedAnimationFinished(); |
1006 | 1006 |
1007 ExpectUnlockedState(); | 1007 ExpectUnlockedState(); |
1008 } | 1008 } |
1009 | 1009 |
1010 TEST_F(LockStateControllerTest, Screenshot) { | 1010 TEST_F(LockStateControllerTest, Screenshot) { |
1011 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); | 1011 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1087 ReleasePowerButton(); | 1087 ReleasePowerButton(); |
1088 | 1088 |
1089 ExpectPreLockAnimationStarted(); | 1089 ExpectPreLockAnimationStarted(); |
1090 | 1090 |
1091 test_animator_->CompleteAllAnimations(true); | 1091 test_animator_->CompleteAllAnimations(true); |
1092 EXPECT_EQ(1, session_manager_client_->request_lock_screen_call_count()); | 1092 EXPECT_EQ(1, session_manager_client_->request_lock_screen_call_count()); |
1093 } | 1093 } |
1094 | 1094 |
1095 } // namespace test | 1095 } // namespace test |
1096 } // namespace ash | 1096 } // namespace ash |
OLD | NEW |