[email protected] | ab4f8c9 | 2013-05-30 19:07:47 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | cafaeca | 2013-10-01 21:08:32 | [diff] [blame] | 5 | #include "ash/wm/lock_state_controller.h" |
| 6 | |
dcheng | a9454747 | 2016-04-08 08:41:11 | [diff] [blame] | 7 | #include <memory> |
dcheng | cbf0d9d | 2015-12-27 22:49:23 | [diff] [blame] | 8 | #include <utility> |
| 9 | |
jamescook | 2b624c5a | 2016-06-08 01:34:02 | [diff] [blame] | 10 | #include "ash/common/session/session_state_delegate.h" |
sky | 1593c7bf | 2016-10-07 21:07:53 | [diff] [blame] | 11 | #include "ash/common/test/test_session_state_delegate.h" |
sky | e2bde217 | 2016-07-01 18:27:02 | [diff] [blame] | 12 | #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
msw | bc0a8b48 | 2016-06-30 02:21:14 | [diff] [blame] | 13 | #include "ash/common/wm_shell.h" |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 14 | #include "ash/shell.h" |
| 15 | #include "ash/test/ash_test_base.h" |
[email protected] | 587926a | 2014-05-11 01:41:36 | [diff] [blame] | 16 | #include "ash/test/test_lock_state_controller_delegate.h" |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 17 | #include "ash/test/test_screenshot_delegate.h" |
| 18 | #include "ash/test/test_session_state_animator.h" |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 19 | #include "ash/test/test_shell_delegate.h" |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 20 | #include "ash/wm/power_button_controller.h" |
| 21 | #include "ash/wm/session_state_animator.h" |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 22 | #include "base/memory/scoped_vector.h" |
[email protected] | 1e84c63 | 2013-06-27 23:12:21 | [diff] [blame] | 23 | #include "base/time/time.h" |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 24 | #include "chromeos/dbus/dbus_thread_manager.h" |
| 25 | #include "chromeos/dbus/fake_session_manager_client.h" |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 26 | #include "ui/display/chromeos/display_configurator.h" |
kylechar | c354dd2 | 2016-10-24 21:03:56 | [diff] [blame^] | 27 | #include "ui/display/fake_display_snapshot.h" |
[email protected] | 44ab9f5 | 2014-04-15 16:26:53 | [diff] [blame] | 28 | #include "ui/display/types/display_constants.h" |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 29 | #include "ui/events/test/event_generator.h" |
| 30 | #include "ui/gfx/geometry/size.h" |
[email protected] | 685442f3 | 2014-02-28 10:40:06 | [diff] [blame] | 31 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 32 | namespace ash { |
| 33 | namespace test { |
| 34 | namespace { |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 35 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 36 | bool cursor_visible() { |
msw | bc0a8b48 | 2016-06-30 02:21:14 | [diff] [blame] | 37 | return Shell::GetInstance()->cursor_manager()->IsCursorVisible(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 38 | } |
| 39 | |
| 40 | void CheckCalledCallback(bool* flag) { |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 41 | if (flag) |
| 42 | (*flag) = true; |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 43 | } |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 44 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 45 | } // namespace |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 46 | |
[email protected] | cafaeca | 2013-10-01 21:08:32 | [diff] [blame] | 47 | class LockStateControllerTest : public AshTestBase { |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 48 | public: |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 49 | LockStateControllerTest() |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 50 | : power_button_controller_(nullptr), |
| 51 | lock_state_controller_(nullptr), |
| 52 | lock_state_controller_delegate_(nullptr), |
| 53 | session_manager_client_(nullptr), |
| 54 | test_animator_(nullptr) {} |
dcheng | 28401c2 | 2014-10-28 01:26:19 | [diff] [blame] | 55 | ~LockStateControllerTest() override {} |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 56 | |
dcheng | 28401c2 | 2014-10-28 01:26:19 | [diff] [blame] | 57 | void SetUp() override { |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 58 | session_manager_client_ = new chromeos::FakeSessionManagerClient; |
| 59 | chromeos::DBusThreadManager::GetSetterForTesting()->SetSessionManagerClient( |
| 60 | base::WrapUnique(session_manager_client_)); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 61 | AshTestBase::SetUp(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 62 | |
dcheng | a9454747 | 2016-04-08 08:41:11 | [diff] [blame] | 63 | std::unique_ptr<LockStateControllerDelegate> lock_state_controller_delegate( |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 64 | lock_state_controller_delegate_ = new TestLockStateControllerDelegate); |
| 65 | test_animator_ = new TestSessionStateAnimator; |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 66 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 67 | lock_state_controller_ = Shell::GetInstance()->lock_state_controller(); |
dcheng | cbf0d9d | 2015-12-27 22:49:23 | [diff] [blame] | 68 | lock_state_controller_->SetDelegate( |
| 69 | std::move(lock_state_controller_delegate)); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 70 | lock_state_controller_->set_animator_for_test(test_animator_); |
[email protected] | 76e52aad | 2012-12-20 18:34:13 | [diff] [blame] | 71 | |
[email protected] | cafaeca | 2013-10-01 21:08:32 | [diff] [blame] | 72 | test_api_.reset(new LockStateController::TestApi(lock_state_controller_)); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 73 | |
| 74 | power_button_controller_ = Shell::GetInstance()->power_button_controller(); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 75 | |
msw | bc0a8b48 | 2016-06-30 02:21:14 | [diff] [blame] | 76 | shell_delegate_ = |
msw | 0414d412 | 2016-07-06 22:58:48 | [diff] [blame] | 77 | static_cast<TestShellDelegate*>(WmShell::Get()->delegate()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 78 | } |
| 79 | |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 80 | void TearDown() override { |
| 81 | AshTestBase::TearDown(); |
| 82 | chromeos::DBusThreadManager::Shutdown(); |
| 83 | } |
| 84 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 85 | protected: |
| 86 | void GenerateMouseMoveEvent() { |
[email protected] | 73c9fd0 | 2014-07-28 01:48:52 | [diff] [blame] | 87 | ui::test::EventGenerator generator(Shell::GetPrimaryRootWindow()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 88 | generator.MoveMouseTo(10, 10); |
| 89 | } |
| 90 | |
| 91 | int NumShutdownRequests() { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 92 | return lock_state_controller_delegate_->num_shutdown_requests() + |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 93 | shell_delegate_->num_exit_requests(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 94 | } |
| 95 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 96 | void Advance(SessionStateAnimator::AnimationSpeed speed) { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 97 | test_animator_->Advance(test_animator_->GetDuration(speed)); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 98 | } |
| 99 | |
| 100 | void AdvancePartially(SessionStateAnimator::AnimationSpeed speed, |
| 101 | float factor) { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 102 | base::TimeDelta duration = test_animator_->GetDuration(speed); |
| 103 | base::TimeDelta partial_duration = |
| 104 | base::TimeDelta::FromInternalValue(duration.ToInternalValue() * factor); |
| 105 | test_animator_->Advance(partial_duration); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | void ExpectPreLockAnimationStarted() { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 109 | SCOPED_TRACE("Failure in ExpectPreLockAnimationStarted"); |
| 110 | EXPECT_LT(0u, test_animator_->GetAnimationCount()); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 111 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
| 112 | SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 113 | SessionStateAnimator::ANIMATION_LIFT)); |
| 114 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
| 115 | SessionStateAnimator::LAUNCHER, |
| 116 | SessionStateAnimator::ANIMATION_FADE_OUT)); |
| 117 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
| 118 | SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 119 | SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY)); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 120 | EXPECT_TRUE(test_api_->is_animating_lock()); |
| 121 | } |
| 122 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 123 | void ExpectPreLockAnimationRunning() { |
| 124 | SCOPED_TRACE("Failure in ExpectPreLockAnimationRunning"); |
| 125 | EXPECT_LT(0u, test_animator_->GetAnimationCount()); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 126 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
| 127 | SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 128 | SessionStateAnimator::ANIMATION_LIFT)); |
| 129 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
| 130 | SessionStateAnimator::LAUNCHER, |
| 131 | SessionStateAnimator::ANIMATION_FADE_OUT)); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 132 | EXPECT_TRUE(test_api_->is_animating_lock()); |
| 133 | } |
| 134 | |
| 135 | void ExpectPreLockAnimationCancel() { |
| 136 | SCOPED_TRACE("Failure in ExpectPreLockAnimationCancel"); |
| 137 | EXPECT_LT(0u, test_animator_->GetAnimationCount()); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 138 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
| 139 | SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 140 | SessionStateAnimator::ANIMATION_UNDO_LIFT)); |
| 141 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
| 142 | SessionStateAnimator::LAUNCHER, |
| 143 | SessionStateAnimator::ANIMATION_FADE_IN)); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 144 | } |
| 145 | |
| 146 | void ExpectPreLockAnimationFinished() { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 147 | SCOPED_TRACE("Failure in ExpectPreLockAnimationFinished"); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 148 | EXPECT_FALSE(test_animator_->AreContainersAnimated( |
| 149 | SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 150 | SessionStateAnimator::ANIMATION_LIFT)); |
| 151 | EXPECT_FALSE(test_animator_->AreContainersAnimated( |
| 152 | SessionStateAnimator::LAUNCHER, |
| 153 | SessionStateAnimator::ANIMATION_FADE_OUT)); |
| 154 | EXPECT_FALSE(test_animator_->AreContainersAnimated( |
| 155 | SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 156 | SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY)); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 157 | } |
| 158 | |
| 159 | void ExpectPostLockAnimationStarted() { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 160 | SCOPED_TRACE("Failure in ExpectPostLockAnimationStarted"); |
| 161 | EXPECT_LT(0u, test_animator_->GetAnimationCount()); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 162 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
| 163 | SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 164 | SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN)); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 165 | } |
| 166 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 167 | void ExpectPostLockAnimationFinished() { |
| 168 | SCOPED_TRACE("Failure in ExpectPostLockAnimationFinished"); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 169 | EXPECT_FALSE(test_animator_->AreContainersAnimated( |
| 170 | SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 171 | SessionStateAnimator::ANIMATION_RAISE_TO_SCREEN)); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 172 | } |
| 173 | |
| 174 | void ExpectUnlockBeforeUIDestroyedAnimationStarted() { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 175 | SCOPED_TRACE("Failure in ExpectUnlockBeforeUIDestroyedAnimationStarted"); |
| 176 | EXPECT_LT(0u, test_animator_->GetAnimationCount()); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 177 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
| 178 | SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 179 | SessionStateAnimator::ANIMATION_LIFT)); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | void ExpectUnlockBeforeUIDestroyedAnimationFinished() { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 183 | SCOPED_TRACE("Failure in ExpectUnlockBeforeUIDestroyedAnimationFinished"); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 184 | EXPECT_FALSE(test_animator_->AreContainersAnimated( |
| 185 | SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 186 | SessionStateAnimator::ANIMATION_LIFT)); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | void ExpectUnlockAfterUIDestroyedAnimationStarted() { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 190 | SCOPED_TRACE("Failure in ExpectUnlockAfterUIDestroyedAnimationStarted"); |
| 191 | EXPECT_LT(0u, test_animator_->GetAnimationCount()); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 192 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
| 193 | SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 194 | SessionStateAnimator::ANIMATION_DROP)); |
| 195 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
| 196 | SessionStateAnimator::LAUNCHER, |
| 197 | SessionStateAnimator::ANIMATION_FADE_IN)); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 198 | } |
| 199 | |
| 200 | void ExpectUnlockAfterUIDestroyedAnimationFinished() { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 201 | SCOPED_TRACE("Failure in ExpectUnlockAfterUIDestroyedAnimationFinished"); |
| 202 | EXPECT_EQ(0u, test_animator_->GetAnimationCount()); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 203 | EXPECT_FALSE(test_animator_->AreContainersAnimated( |
| 204 | SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 205 | SessionStateAnimator::ANIMATION_DROP)); |
| 206 | EXPECT_FALSE(test_animator_->AreContainersAnimated( |
| 207 | SessionStateAnimator::LAUNCHER, |
| 208 | SessionStateAnimator::ANIMATION_FADE_IN)); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | void ExpectShutdownAnimationStarted() { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 212 | SCOPED_TRACE("Failure in ExpectShutdownAnimationStarted"); |
| 213 | EXPECT_LT(0u, test_animator_->GetAnimationCount()); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 214 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
| 215 | SessionStateAnimator::ROOT_CONTAINER, |
| 216 | SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS)); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 217 | } |
| 218 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 219 | void ExpectShutdownAnimationFinished() { |
| 220 | SCOPED_TRACE("Failure in ExpectShutdownAnimationFinished"); |
| 221 | EXPECT_EQ(0u, test_animator_->GetAnimationCount()); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 222 | EXPECT_FALSE(test_animator_->AreContainersAnimated( |
| 223 | SessionStateAnimator::ROOT_CONTAINER, |
| 224 | SessionStateAnimator::ANIMATION_GRAYSCALE_BRIGHTNESS)); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 225 | } |
| 226 | |
| 227 | void ExpectShutdownAnimationCancel() { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 228 | SCOPED_TRACE("Failure in ExpectShutdownAnimationCancel"); |
| 229 | EXPECT_LT(0u, test_animator_->GetAnimationCount()); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 230 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
| 231 | SessionStateAnimator::ROOT_CONTAINER, |
| 232 | SessionStateAnimator::ANIMATION_UNDO_GRAYSCALE_BRIGHTNESS)); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 233 | } |
| 234 | |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 235 | void ExpectWallpaperIsShowing() { |
| 236 | SCOPED_TRACE("Failure in ExpectWallpaperIsShowing"); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 237 | EXPECT_LT(0u, test_animator_->GetAnimationCount()); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 238 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 239 | SessionStateAnimator::WALLPAPER, |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 240 | SessionStateAnimator::ANIMATION_FADE_IN)); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 241 | } |
| 242 | |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 243 | void ExpectWallpaperIsHiding() { |
| 244 | SCOPED_TRACE("Failure in ExpectWallpaperIsHiding"); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 245 | EXPECT_LT(0u, test_animator_->GetAnimationCount()); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 246 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 247 | SessionStateAnimator::WALLPAPER, |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 248 | SessionStateAnimator::ANIMATION_FADE_OUT)); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 249 | } |
| 250 | |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 251 | void ExpectRestoringWallpaperVisibility() { |
| 252 | SCOPED_TRACE("Failure in ExpectRestoringWallpaperVisibility"); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 253 | EXPECT_LT(0u, test_animator_->GetAnimationCount()); |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 254 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 255 | SessionStateAnimator::WALLPAPER, |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 256 | SessionStateAnimator::ANIMATION_FADE_IN)); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 257 | } |
| 258 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 259 | void ExpectUnlockedState() { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 260 | SCOPED_TRACE("Failure in ExpectUnlockedState"); |
| 261 | EXPECT_EQ(0u, test_animator_->GetAnimationCount()); |
msw | bc0a8b48 | 2016-06-30 02:21:14 | [diff] [blame] | 262 | EXPECT_FALSE(WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | void ExpectLockedState() { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 266 | SCOPED_TRACE("Failure in ExpectLockedState"); |
| 267 | EXPECT_EQ(0u, test_animator_->GetAnimationCount()); |
msw | bc0a8b48 | 2016-06-30 02:21:14 | [diff] [blame] | 268 | EXPECT_TRUE(WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked()); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 269 | } |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 270 | |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 271 | void HideWallpaper() { test_animator_->HideWallpaper(); } |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 272 | |
| 273 | void PressPowerButton() { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 274 | power_button_controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 275 | } |
| 276 | |
| 277 | void ReleasePowerButton() { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 278 | power_button_controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | void PressLockButton() { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 282 | power_button_controller_->OnLockButtonEvent(true, base::TimeTicks::Now()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | void ReleaseLockButton() { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 286 | power_button_controller_->OnLockButtonEvent(false, base::TimeTicks::Now()); |
| 287 | } |
| 288 | |
| 289 | void PressVolumeDown() { |
| 290 | GetEventGenerator().PressKey(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); |
| 291 | } |
| 292 | |
| 293 | void ReleaseVolumeDown() { |
| 294 | GetEventGenerator().ReleaseKey(ui::VKEY_VOLUME_DOWN, ui::EF_NONE); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 295 | } |
| 296 | |
| 297 | void SystemLocks() { |
[email protected] | ab4f8c9 | 2013-05-30 19:07:47 | [diff] [blame] | 298 | lock_state_controller_->OnLockStateChanged(true); |
msw | bc0a8b48 | 2016-06-30 02:21:14 | [diff] [blame] | 299 | WmShell::Get()->GetSessionStateDelegate()->LockScreen(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 300 | } |
| 301 | |
| 302 | void SuccessfulAuthentication(bool* call_flag) { |
| 303 | base::Closure closure = base::Bind(&CheckCalledCallback, call_flag); |
[email protected] | ab4f8c9 | 2013-05-30 19:07:47 | [diff] [blame] | 304 | lock_state_controller_->OnLockScreenHide(closure); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | void SystemUnlocks() { |
[email protected] | ab4f8c9 | 2013-05-30 19:07:47 | [diff] [blame] | 308 | lock_state_controller_->OnLockStateChanged(false); |
msw | bc0a8b48 | 2016-06-30 02:21:14 | [diff] [blame] | 309 | WmShell::Get()->GetSessionStateDelegate()->UnlockScreen(); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 310 | } |
| 311 | |
| 312 | void EnableMaximizeMode(bool enable) { |
sky | c68696c | 2016-07-01 21:06:02 | [diff] [blame] | 313 | WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 314 | enable); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 315 | } |
| 316 | |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 317 | void Initialize(bool legacy_button, LoginStatus status) { |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 318 | power_button_controller_->set_has_legacy_power_button_for_test( |
| 319 | legacy_button); |
[email protected] | ab4f8c9 | 2013-05-30 19:07:47 | [diff] [blame] | 320 | lock_state_controller_->OnLoginStateChanged(status); |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 321 | SetUserLoggedIn(status != LoginStatus::NOT_LOGGED_IN); |
| 322 | if (status == LoginStatus::GUEST) |
sky | 8335eed | 2016-10-06 23:25:09 | [diff] [blame] | 323 | TestSessionStateDelegate::SetCanLockScreen(false); |
[email protected] | ab4f8c9 | 2013-05-30 19:07:47 | [diff] [blame] | 324 | lock_state_controller_->OnLockStateChanged(false); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 325 | } |
| 326 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 327 | PowerButtonController* power_button_controller_; // not owned |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 328 | LockStateController* lock_state_controller_; // not owned |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 329 | TestLockStateControllerDelegate* |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 330 | lock_state_controller_delegate_; // not owned |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 331 | // Ownership is passed on to chromeos::DBusThreadManager. |
| 332 | chromeos::FakeSessionManagerClient* session_manager_client_; |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 333 | TestSessionStateAnimator* test_animator_; // not owned |
dcheng | a9454747 | 2016-04-08 08:41:11 | [diff] [blame] | 334 | std::unique_ptr<LockStateController::TestApi> test_api_; |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 335 | TestShellDelegate* shell_delegate_; // not owned |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 336 | |
| 337 | private: |
[email protected] | cafaeca | 2013-10-01 21:08:32 | [diff] [blame] | 338 | DISALLOW_COPY_AND_ASSIGN(LockStateControllerTest); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 339 | }; |
| 340 | |
| 341 | // Test the lock-to-shutdown flow for non-Chrome-OS hardware that doesn't |
| 342 | // correctly report power button releases. We should lock immediately the first |
| 343 | // time the button is pressed and shut down when it's pressed from the locked |
| 344 | // state. |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 345 | TEST_F(LockStateControllerTest, LegacyLockAndShutDown) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 346 | Initialize(true, LoginStatus::USER); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 347 | |
| 348 | ExpectUnlockedState(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 349 | |
| 350 | // We should request that the screen be locked immediately after seeing the |
| 351 | // power button get pressed. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 352 | PressPowerButton(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 353 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 354 | EXPECT_FALSE(test_api_->is_lock_cancellable()); |
| 355 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 356 | ExpectPreLockAnimationStarted(); |
| 357 | test_animator_->CompleteAllAnimations(true); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 358 | ExpectPreLockAnimationFinished(); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 359 | |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 360 | EXPECT_EQ(1, session_manager_client_->request_lock_screen_call_count()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 361 | |
| 362 | // Notify that we locked successfully. |
[email protected] | ab4f8c9 | 2013-05-30 19:07:47 | [diff] [blame] | 363 | lock_state_controller_->OnStartingLock(); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 364 | EXPECT_EQ(0u, test_animator_->GetAnimationCount()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 365 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 366 | SystemLocks(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 367 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 368 | ExpectPostLockAnimationStarted(); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 369 | test_animator_->CompleteAllAnimations(true); |
| 370 | ExpectPostLockAnimationFinished(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 371 | |
| 372 | // We shouldn't progress towards the shutdown state, however. |
| 373 | EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); |
| 374 | EXPECT_FALSE(test_api_->shutdown_timer_is_running()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 375 | |
| 376 | ReleasePowerButton(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 377 | |
| 378 | // Hold the button again and check that we start shutting down. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 379 | PressPowerButton(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 380 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 381 | ExpectShutdownAnimationStarted(); |
| 382 | |
| 383 | EXPECT_EQ(0, NumShutdownRequests()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 384 | // Make sure a mouse move event won't show the cursor. |
| 385 | GenerateMouseMoveEvent(); |
| 386 | EXPECT_FALSE(cursor_visible()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 387 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 388 | EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
| 389 | test_api_->trigger_real_shutdown_timeout(); |
| 390 | EXPECT_EQ(1, NumShutdownRequests()); |
| 391 | } |
| 392 | |
| 393 | // Test that we start shutting down immediately if the power button is pressed |
| 394 | // while we're not logged in on an unofficial system. |
[email protected] | cafaeca | 2013-10-01 21:08:32 | [diff] [blame] | 395 | TEST_F(LockStateControllerTest, LegacyNotLoggedIn) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 396 | Initialize(true, LoginStatus::NOT_LOGGED_IN); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 397 | |
| 398 | PressPowerButton(); |
| 399 | ExpectShutdownAnimationStarted(); |
| 400 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 401 | EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
| 402 | } |
| 403 | |
| 404 | // Test that we start shutting down immediately if the power button is pressed |
| 405 | // while we're logged in as a guest on an unofficial system. |
[email protected] | cafaeca | 2013-10-01 21:08:32 | [diff] [blame] | 406 | TEST_F(LockStateControllerTest, LegacyGuest) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 407 | Initialize(true, LoginStatus::GUEST); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 408 | |
| 409 | PressPowerButton(); |
| 410 | ExpectShutdownAnimationStarted(); |
| 411 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 412 | EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
| 413 | } |
| 414 | |
| 415 | // When we hold the power button while the user isn't logged in, we should shut |
| 416 | // down the machine directly. |
[email protected] | cafaeca | 2013-10-01 21:08:32 | [diff] [blame] | 417 | TEST_F(LockStateControllerTest, ShutdownWhenNotLoggedIn) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 418 | Initialize(false, LoginStatus::NOT_LOGGED_IN); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 419 | |
| 420 | // Press the power button and check that we start the shutdown timer. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 421 | PressPowerButton(); |
| 422 | EXPECT_FALSE(test_api_->is_animating_lock()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 423 | EXPECT_TRUE(test_api_->shutdown_timer_is_running()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 424 | ExpectShutdownAnimationStarted(); |
| 425 | |
| 426 | AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN, 0.5f); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 427 | |
| 428 | // Release the power button before the shutdown timer fires. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 429 | ReleasePowerButton(); |
| 430 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 431 | EXPECT_FALSE(test_api_->shutdown_timer_is_running()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 432 | ExpectShutdownAnimationCancel(); |
| 433 | |
| 434 | AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_REVERT, 0.5f); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 435 | |
| 436 | // Press the button again and make the shutdown timeout fire this time. |
| 437 | // Check that we start the timer for actually requesting the shutdown. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 438 | PressPowerButton(); |
| 439 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 440 | EXPECT_TRUE(test_api_->shutdown_timer_is_running()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 441 | |
| 442 | Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 443 | ExpectShutdownAnimationFinished(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 444 | test_api_->trigger_shutdown_timeout(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 445 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 446 | EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
| 447 | EXPECT_EQ(0, NumShutdownRequests()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 448 | |
| 449 | // When the timout fires, we should request a shutdown. |
| 450 | test_api_->trigger_real_shutdown_timeout(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 451 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 452 | EXPECT_EQ(1, NumShutdownRequests()); |
| 453 | } |
| 454 | |
| 455 | // Test that we lock the screen and deal with unlocking correctly. |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 456 | TEST_F(LockStateControllerTest, LockAndUnlock) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 457 | Initialize(false, LoginStatus::USER); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 458 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 459 | ExpectUnlockedState(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 460 | |
| 461 | // Press the power button and check that the lock timer is started and that we |
| 462 | // start lifting the non-screen-locker containers. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 463 | PressPowerButton(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 464 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 465 | ExpectPreLockAnimationStarted(); |
| 466 | EXPECT_TRUE(test_api_->is_lock_cancellable()); |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 467 | EXPECT_EQ(0, session_manager_client_->request_lock_screen_call_count()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 468 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 469 | test_animator_->CompleteAllAnimations(true); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 470 | ExpectPreLockAnimationFinished(); |
| 471 | |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 472 | EXPECT_EQ(1, session_manager_client_->request_lock_screen_call_count()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 473 | |
| 474 | // Notify that we locked successfully. |
[email protected] | ab4f8c9 | 2013-05-30 19:07:47 | [diff] [blame] | 475 | lock_state_controller_->OnStartingLock(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 476 | // We had that animation already. |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 477 | EXPECT_EQ(0u, test_animator_->GetAnimationCount()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 478 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 479 | SystemLocks(); |
| 480 | |
| 481 | ExpectPostLockAnimationStarted(); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 482 | test_animator_->CompleteAllAnimations(true); |
| 483 | ExpectPostLockAnimationFinished(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 484 | |
| 485 | // When we release the power button, the lock-to-shutdown timer should be |
| 486 | // stopped. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 487 | ExpectLockedState(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 488 | EXPECT_TRUE(test_api_->lock_to_shutdown_timer_is_running()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 489 | ReleasePowerButton(); |
| 490 | ExpectLockedState(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 491 | EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); |
| 492 | |
| 493 | // Notify that the screen has been unlocked. We should show the |
| 494 | // non-screen-locker windows. |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 495 | bool called = false; |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 496 | SuccessfulAuthentication(&called); |
| 497 | |
| 498 | ExpectUnlockBeforeUIDestroyedAnimationStarted(); |
| 499 | EXPECT_FALSE(called); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 500 | test_animator_->CompleteAllAnimations(true); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 501 | ExpectUnlockBeforeUIDestroyedAnimationFinished(); |
| 502 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 503 | EXPECT_TRUE(called); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 504 | |
| 505 | SystemUnlocks(); |
| 506 | |
| 507 | ExpectUnlockAfterUIDestroyedAnimationStarted(); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 508 | test_animator_->CompleteAllAnimations(true); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 509 | ExpectUnlockAfterUIDestroyedAnimationFinished(); |
| 510 | |
| 511 | ExpectUnlockedState(); |
| 512 | } |
| 513 | |
| 514 | // Test that we deal with cancelling lock correctly. |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 515 | TEST_F(LockStateControllerTest, LockAndCancel) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 516 | Initialize(false, LoginStatus::USER); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 517 | |
| 518 | ExpectUnlockedState(); |
| 519 | |
| 520 | // Press the power button and check that the lock timer is started and that we |
| 521 | // start lifting the non-screen-locker containers. |
| 522 | PressPowerButton(); |
| 523 | |
| 524 | ExpectPreLockAnimationStarted(); |
| 525 | EXPECT_TRUE(test_api_->is_lock_cancellable()); |
| 526 | |
| 527 | // forward only half way through |
| 528 | AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); |
| 529 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 530 | // Release the button before the lock timer fires. |
| 531 | ReleasePowerButton(); |
| 532 | |
| 533 | ExpectPreLockAnimationCancel(); |
| 534 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 535 | Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 536 | ExpectUnlockedState(); |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 537 | EXPECT_EQ(0, session_manager_client_->request_lock_screen_call_count()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 538 | } |
| 539 | |
| 540 | // Test that we deal with cancelling lock correctly. |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 541 | TEST_F(LockStateControllerTest, LockAndCancelAndLockAgain) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 542 | Initialize(false, LoginStatus::USER); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 543 | |
| 544 | ExpectUnlockedState(); |
| 545 | |
| 546 | // Press the power button and check that the lock timer is started and that we |
| 547 | // start lifting the non-screen-locker containers. |
| 548 | PressPowerButton(); |
| 549 | |
| 550 | ExpectPreLockAnimationStarted(); |
| 551 | EXPECT_TRUE(test_api_->is_lock_cancellable()); |
| 552 | |
| 553 | // forward only half way through |
| 554 | AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); |
| 555 | |
| 556 | // Release the button before the lock timer fires. |
| 557 | ReleasePowerButton(); |
| 558 | ExpectPreLockAnimationCancel(); |
| 559 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 560 | AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS, |
| 561 | 0.5f); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 562 | |
| 563 | PressPowerButton(); |
| 564 | ExpectPreLockAnimationStarted(); |
| 565 | EXPECT_TRUE(test_api_->is_lock_cancellable()); |
| 566 | |
| 567 | AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.6f); |
| 568 | |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 569 | EXPECT_EQ(0, session_manager_client_->request_lock_screen_call_count()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 570 | |
| 571 | AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.6f); |
| 572 | ExpectPreLockAnimationFinished(); |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 573 | EXPECT_EQ(1, session_manager_client_->request_lock_screen_call_count()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 574 | } |
| 575 | |
| 576 | // Hold the power button down from the unlocked state to eventual shutdown. |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 577 | TEST_F(LockStateControllerTest, LockToShutdown) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 578 | Initialize(false, LoginStatus::USER); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 579 | |
| 580 | // Hold the power button and lock the screen. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 581 | PressPowerButton(); |
| 582 | EXPECT_TRUE(test_api_->is_animating_lock()); |
| 583 | |
| 584 | Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
| 585 | SystemLocks(); |
| 586 | Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 587 | |
| 588 | // When the lock-to-shutdown timeout fires, we should start the shutdown |
| 589 | // timer. |
| 590 | EXPECT_TRUE(test_api_->lock_to_shutdown_timer_is_running()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 591 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 592 | test_api_->trigger_lock_to_shutdown_timeout(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 593 | |
| 594 | ExpectShutdownAnimationStarted(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 595 | EXPECT_TRUE(test_api_->shutdown_timer_is_running()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 596 | |
| 597 | // Fire the shutdown timeout and check that we request shutdown. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 598 | Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 599 | ExpectShutdownAnimationFinished(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 600 | test_api_->trigger_shutdown_timeout(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 601 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 602 | EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
| 603 | EXPECT_EQ(0, NumShutdownRequests()); |
| 604 | test_api_->trigger_real_shutdown_timeout(); |
| 605 | EXPECT_EQ(1, NumShutdownRequests()); |
| 606 | } |
| 607 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 608 | // Hold the power button down from the unlocked state to eventual shutdown, |
| 609 | // then release the button while system does locking. |
[email protected] | cafaeca | 2013-10-01 21:08:32 | [diff] [blame] | 610 | TEST_F(LockStateControllerTest, CancelLockToShutdown) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 611 | Initialize(false, LoginStatus::USER); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 612 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 613 | PressPowerButton(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 614 | |
| 615 | // Hold the power button and lock the screen. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 616 | EXPECT_TRUE(test_api_->is_animating_lock()); |
| 617 | |
| 618 | Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
| 619 | SystemLocks(); |
| 620 | AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, 0.5f); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 621 | |
| 622 | // Power button is released while system attempts to lock. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 623 | ReleasePowerButton(); |
| 624 | |
| 625 | Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 626 | |
[email protected] | ab4f8c9 | 2013-05-30 19:07:47 | [diff] [blame] | 627 | EXPECT_FALSE(lock_state_controller_->ShutdownRequested()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 628 | EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); |
| 629 | EXPECT_FALSE(test_api_->shutdown_timer_is_running()); |
| 630 | } |
| 631 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 632 | // TODO(bruthig): Investigate why this hangs on Windows 8 and whether it can be |
| 633 | // safely enabled on OS_WIN. |
| 634 | #ifndef OS_WIN |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 635 | // Test that we handle the case where lock requests are ignored. |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 636 | TEST_F(LockStateControllerTest, Lock) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 637 | Initialize(false, LoginStatus::USER); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 638 | |
| 639 | // Hold the power button and lock the screen. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 640 | PressPowerButton(); |
| 641 | ExpectPreLockAnimationStarted(); |
| 642 | |
| 643 | Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
| 644 | |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 645 | EXPECT_EQ(1, session_manager_client_->request_lock_screen_call_count()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 646 | EXPECT_TRUE(test_api_->lock_fail_timer_is_running()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 647 | // We shouldn't start the lock-to-shutdown timer until the screen has actually |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 648 | // been locked and this was animated. |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 649 | EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); |
| 650 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 651 | // Act as if the request timed out. |
| 652 | EXPECT_DEATH(test_api_->trigger_lock_fail_timeout(), ""); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 653 | } |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 654 | #endif |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 655 | |
| 656 | // Test the basic operation of the lock button (not logged in). |
[email protected] | cafaeca | 2013-10-01 21:08:32 | [diff] [blame] | 657 | TEST_F(LockStateControllerTest, LockButtonBasicNotLoggedIn) { |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 658 | // The lock button shouldn't do anything if we aren't logged in. |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 659 | Initialize(false, LoginStatus::NOT_LOGGED_IN); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 660 | |
| 661 | PressLockButton(); |
| 662 | EXPECT_FALSE(test_api_->is_animating_lock()); |
| 663 | ReleaseLockButton(); |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 664 | EXPECT_EQ(0, session_manager_client_->request_lock_screen_call_count()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | // Test the basic operation of the lock button (guest). |
[email protected] | cafaeca | 2013-10-01 21:08:32 | [diff] [blame] | 668 | TEST_F(LockStateControllerTest, LockButtonBasicGuest) { |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 669 | // The lock button shouldn't do anything when we're logged in as a guest. |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 670 | Initialize(false, LoginStatus::GUEST); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 671 | |
| 672 | PressLockButton(); |
| 673 | EXPECT_FALSE(test_api_->is_animating_lock()); |
| 674 | ReleaseLockButton(); |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 675 | EXPECT_EQ(0, session_manager_client_->request_lock_screen_call_count()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 676 | } |
| 677 | |
| 678 | // Test the basic operation of the lock button. |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 679 | TEST_F(LockStateControllerTest, LockButtonBasic) { |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 680 | // If we're logged in as a regular user, we should start the lock timer and |
| 681 | // the pre-lock animation. |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 682 | Initialize(false, LoginStatus::USER); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 683 | |
| 684 | PressLockButton(); |
| 685 | ExpectPreLockAnimationStarted(); |
| 686 | AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 687 | |
| 688 | // If the button is released immediately, we shouldn't lock the screen. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 689 | ReleaseLockButton(); |
| 690 | ExpectPreLockAnimationCancel(); |
| 691 | Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 692 | |
| 693 | ExpectUnlockedState(); |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 694 | EXPECT_EQ(0, session_manager_client_->request_lock_screen_call_count()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 695 | |
| 696 | // Press the button again and let the lock timeout fire. We should request |
| 697 | // that the screen be locked. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 698 | PressLockButton(); |
| 699 | ExpectPreLockAnimationStarted(); |
| 700 | Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 701 | EXPECT_EQ(1, session_manager_client_->request_lock_screen_call_count()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 702 | |
| 703 | // Pressing the lock button while we have a pending lock request shouldn't do |
| 704 | // anything. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 705 | ReleaseLockButton(); |
| 706 | PressLockButton(); |
| 707 | ExpectPreLockAnimationFinished(); |
| 708 | ReleaseLockButton(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 709 | |
| 710 | // Pressing the button also shouldn't do anything after the screen is locked. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 711 | SystemLocks(); |
| 712 | ExpectPostLockAnimationStarted(); |
| 713 | |
| 714 | PressLockButton(); |
| 715 | ReleaseLockButton(); |
| 716 | ExpectPostLockAnimationStarted(); |
| 717 | |
| 718 | Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 719 | ExpectPostLockAnimationFinished(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 720 | |
| 721 | PressLockButton(); |
| 722 | ReleaseLockButton(); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 723 | ExpectPostLockAnimationFinished(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 724 | } |
| 725 | |
| 726 | // Test that the power button takes priority over the lock button. |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 727 | TEST_F(LockStateControllerTest, PowerButtonPreemptsLockButton) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 728 | Initialize(false, LoginStatus::USER); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 729 | |
| 730 | // While the lock button is down, hold the power button. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 731 | PressLockButton(); |
| 732 | ExpectPreLockAnimationStarted(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 733 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 734 | AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.1f); |
| 735 | ExpectPreLockAnimationRunning(); |
| 736 | |
| 737 | PressPowerButton(); |
| 738 | ExpectPreLockAnimationRunning(); |
| 739 | |
| 740 | AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.1f); |
| 741 | ExpectPreLockAnimationRunning(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 742 | |
| 743 | // The lock timer shouldn't be stopped when the lock button is released. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 744 | ReleaseLockButton(); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 745 | ExpectPreLockAnimationRunning(); |
| 746 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 747 | ReleasePowerButton(); |
| 748 | ExpectPreLockAnimationCancel(); |
| 749 | |
| 750 | Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 751 | ExpectUnlockedState(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 752 | |
| 753 | // Now press the power button first and then the lock button. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 754 | PressPowerButton(); |
| 755 | ExpectPreLockAnimationStarted(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 756 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 757 | AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.1f); |
| 758 | |
| 759 | PressLockButton(); |
| 760 | ExpectPreLockAnimationRunning(); |
| 761 | |
| 762 | AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.1f); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 763 | |
| 764 | // Releasing the power button should stop the lock timer. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 765 | ReleasePowerButton(); |
| 766 | ExpectPreLockAnimationCancel(); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 767 | |
| 768 | AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.1f); |
| 769 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 770 | ReleaseLockButton(); |
| 771 | ExpectPreLockAnimationCancel(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 772 | } |
| 773 | |
| 774 | // When the screen is locked without going through the usual power-button |
| 775 | // slow-close path (e.g. via the wrench menu), test that we still show the |
| 776 | // fast-close animation. |
[email protected] | cafaeca | 2013-10-01 21:08:32 | [diff] [blame] | 777 | TEST_F(LockStateControllerTest, LockWithoutButton) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 778 | Initialize(false, LoginStatus::USER); |
[email protected] | ab4f8c9 | 2013-05-30 19:07:47 | [diff] [blame] | 779 | lock_state_controller_->OnStartingLock(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 780 | |
| 781 | ExpectPreLockAnimationStarted(); |
| 782 | EXPECT_FALSE(test_api_->is_lock_cancellable()); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 783 | EXPECT_LT(0u, test_animator_->GetAnimationCount()); |
[email protected] | 19c6c4e | 2013-01-28 16:25:48 | [diff] [blame] | 784 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 785 | test_animator_->CompleteAllAnimations(true); |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 786 | EXPECT_EQ(0, session_manager_client_->request_lock_screen_call_count()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 787 | } |
| 788 | |
| 789 | // When we hear that the process is exiting but we haven't had a chance to |
| 790 | // display an animation, we should just blank the screen. |
[email protected] | cafaeca | 2013-10-01 21:08:32 | [diff] [blame] | 791 | TEST_F(LockStateControllerTest, ShutdownWithoutButton) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 792 | Initialize(false, LoginStatus::USER); |
[email protected] | ab4f8c9 | 2013-05-30 19:07:47 | [diff] [blame] | 793 | lock_state_controller_->OnAppTerminating(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 794 | |
jamescook | b8dcef52 | 2016-06-25 14:42:55 | [diff] [blame] | 795 | EXPECT_TRUE(test_animator_->AreContainersAnimated( |
| 796 | SessionStateAnimator::kAllNonRootContainersMask, |
| 797 | SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY)); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 798 | GenerateMouseMoveEvent(); |
| 799 | EXPECT_FALSE(cursor_visible()); |
| 800 | } |
| 801 | |
| 802 | // Test that we display the fast-close animation and shut down when we get an |
| 803 | // outside request to shut down (e.g. from the login or lock screen). |
[email protected] | cafaeca | 2013-10-01 21:08:32 | [diff] [blame] | 804 | TEST_F(LockStateControllerTest, RequestShutdownFromLoginScreen) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 805 | Initialize(false, LoginStatus::NOT_LOGGED_IN); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 806 | |
cschuet | 7f630ba | 2015-01-22 13:17:05 | [diff] [blame] | 807 | lock_state_controller_->RequestShutdown(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 808 | |
| 809 | ExpectShutdownAnimationStarted(); |
| 810 | Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 811 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 812 | GenerateMouseMoveEvent(); |
| 813 | EXPECT_FALSE(cursor_visible()); |
| 814 | |
| 815 | EXPECT_EQ(0, NumShutdownRequests()); |
| 816 | EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
| 817 | test_api_->trigger_real_shutdown_timeout(); |
| 818 | EXPECT_EQ(1, NumShutdownRequests()); |
| 819 | } |
| 820 | |
[email protected] | cafaeca | 2013-10-01 21:08:32 | [diff] [blame] | 821 | TEST_F(LockStateControllerTest, RequestShutdownFromLockScreen) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 822 | Initialize(false, LoginStatus::USER); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 823 | |
| 824 | SystemLocks(); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 825 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 826 | Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 827 | ExpectPostLockAnimationFinished(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 828 | |
cschuet | 7f630ba | 2015-01-22 13:17:05 | [diff] [blame] | 829 | lock_state_controller_->RequestShutdown(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 830 | |
| 831 | ExpectShutdownAnimationStarted(); |
| 832 | Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 833 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 834 | GenerateMouseMoveEvent(); |
| 835 | EXPECT_FALSE(cursor_visible()); |
| 836 | |
| 837 | EXPECT_EQ(0, NumShutdownRequests()); |
| 838 | EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
| 839 | test_api_->trigger_real_shutdown_timeout(); |
| 840 | EXPECT_EQ(1, NumShutdownRequests()); |
| 841 | } |
| 842 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 843 | TEST_F(LockStateControllerTest, RequestAndCancelShutdownFromLockScreen) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 844 | Initialize(false, LoginStatus::USER); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 845 | |
| 846 | SystemLocks(); |
| 847 | Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 848 | ExpectLockedState(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 849 | |
| 850 | // Press the power button and check that we start the shutdown timer. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 851 | PressPowerButton(); |
| 852 | EXPECT_FALSE(test_api_->is_animating_lock()); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 853 | EXPECT_TRUE(test_api_->shutdown_timer_is_running()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 854 | |
| 855 | ExpectShutdownAnimationStarted(); |
| 856 | |
| 857 | AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN, 0.5f); |
| 858 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 859 | // Release the power button before the shutdown timer fires. |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 860 | ReleasePowerButton(); |
| 861 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 862 | EXPECT_FALSE(test_api_->shutdown_timer_is_running()); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 863 | |
| 864 | ExpectShutdownAnimationCancel(); |
| 865 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 866 | Advance(SessionStateAnimator::ANIMATION_SPEED_REVERT_SHUTDOWN); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 867 | ExpectLockedState(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 868 | } |
| 869 | |
| 870 | // Test that we ignore power button presses when the screen is turned off. |
[email protected] | cafaeca | 2013-10-01 21:08:32 | [diff] [blame] | 871 | TEST_F(LockStateControllerTest, IgnorePowerButtonIfScreenIsOff) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 872 | Initialize(false, LoginStatus::USER); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 873 | |
| 874 | // When the screen brightness is at 0%, we shouldn't do anything in response |
| 875 | // to power button presses. |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 876 | power_button_controller_->OnScreenBrightnessChanged(0.0); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 877 | PressPowerButton(); |
| 878 | EXPECT_FALSE(test_api_->is_animating_lock()); |
| 879 | ReleasePowerButton(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 880 | |
| 881 | // After increasing the brightness to 10%, we should start the timer like |
| 882 | // usual. |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 883 | power_button_controller_->OnScreenBrightnessChanged(10.0); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 884 | PressPowerButton(); |
| 885 | EXPECT_TRUE(test_api_->is_animating_lock()); |
[email protected] | 685442f3 | 2014-02-28 10:40:06 | [diff] [blame] | 886 | ReleasePowerButton(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 887 | } |
| 888 | |
[email protected] | 685442f3 | 2014-02-28 10:40:06 | [diff] [blame] | 889 | TEST_F(LockStateControllerTest, HonorPowerButtonInDockedMode) { |
| 890 | // Create two outputs, the first internal and the second external. |
[email protected] | 1e31cbd | 2014-04-07 20:06:11 | [diff] [blame] | 891 | ui::DisplayConfigurator::DisplayStateList outputs; |
[email protected] | 71da07e | 2014-03-18 21:16:04 | [diff] [blame] | 892 | |
kylechar | c354dd2 | 2016-10-24 21:03:56 | [diff] [blame^] | 893 | std::unique_ptr<ui::DisplaySnapshot> internal_display = |
| 894 | display::FakeDisplaySnapshot::Builder() |
| 895 | .SetId(123) |
| 896 | .SetNativeMode(gfx::Size(1, 1)) |
| 897 | .SetType(ui::DISPLAY_CONNECTION_TYPE_INTERNAL) |
| 898 | .Build(); |
| 899 | outputs.push_back(internal_display.get()); |
| 900 | |
| 901 | std::unique_ptr<ui::DisplaySnapshot> external_display = |
| 902 | display::FakeDisplaySnapshot::Builder() |
| 903 | .SetId(456) |
| 904 | .SetNativeMode(gfx::Size(1, 1)) |
| 905 | .SetType(ui::DISPLAY_CONNECTION_TYPE_HDMI) |
| 906 | .Build(); |
| 907 | outputs.push_back(external_display.get()); |
[email protected] | 685442f3 | 2014-02-28 10:40:06 | [diff] [blame] | 908 | |
| 909 | // When all of the displays are turned off (e.g. due to user inactivity), the |
| 910 | // power button should be ignored. |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 911 | power_button_controller_->OnScreenBrightnessChanged(0.0); |
kylechar | c354dd2 | 2016-10-24 21:03:56 | [diff] [blame^] | 912 | internal_display->set_current_mode(nullptr); |
| 913 | external_display->set_current_mode(nullptr); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 914 | power_button_controller_->OnDisplayModeChanged(outputs); |
[email protected] | 685442f3 | 2014-02-28 10:40:06 | [diff] [blame] | 915 | PressPowerButton(); |
| 916 | EXPECT_FALSE(test_api_->is_animating_lock()); |
| 917 | ReleasePowerButton(); |
| 918 | |
| 919 | // When the screen brightness is 0% but the external display is still turned |
| 920 | // on (indicating either docked mode or the user having manually decreased the |
| 921 | // brightness to 0%), the power button should still be handled. |
kylechar | c354dd2 | 2016-10-24 21:03:56 | [diff] [blame^] | 922 | external_display->set_current_mode(external_display->modes().back().get()); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 923 | power_button_controller_->OnDisplayModeChanged(outputs); |
[email protected] | 685442f3 | 2014-02-28 10:40:06 | [diff] [blame] | 924 | PressPowerButton(); |
| 925 | EXPECT_TRUE(test_api_->is_animating_lock()); |
| 926 | ReleasePowerButton(); |
| 927 | } |
[email protected] | 685442f3 | 2014-02-28 10:40:06 | [diff] [blame] | 928 | |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 929 | // Test that hidden wallpaper appears and revers correctly on lock/cancel. |
| 930 | TEST_F(LockStateControllerTest, TestHiddenWallpaperLockCancel) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 931 | Initialize(false, LoginStatus::USER); |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 932 | HideWallpaper(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 933 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 934 | ExpectUnlockedState(); |
| 935 | PressPowerButton(); |
| 936 | |
| 937 | ExpectPreLockAnimationStarted(); |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 938 | ExpectWallpaperIsShowing(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 939 | |
| 940 | // Forward only half way through. |
| 941 | AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); |
| 942 | |
| 943 | // Release the button before the lock timer fires. |
| 944 | ReleasePowerButton(); |
| 945 | ExpectPreLockAnimationCancel(); |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 946 | ExpectWallpaperIsHiding(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 947 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 948 | Advance(SessionStateAnimator::ANIMATION_SPEED_UNDO_MOVE_WINDOWS); |
| 949 | |
| 950 | // When the CancelPrelockAnimation sequence finishes it queues up a |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 951 | // restore wallpaper visibility sequence when the wallpaper is hidden. |
| 952 | ExpectRestoringWallpaperVisibility(); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 953 | |
| 954 | Advance(SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 955 | |
| 956 | ExpectUnlockedState(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 957 | } |
| 958 | |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 959 | // Test that hidden wallpaper appears and revers correctly on lock/unlock. |
| 960 | TEST_F(LockStateControllerTest, TestHiddenWallpaperLockUnlock) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 961 | Initialize(false, LoginStatus::USER); |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 962 | HideWallpaper(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 963 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 964 | ExpectUnlockedState(); |
| 965 | |
| 966 | // Press the power button and check that the lock timer is started and that we |
| 967 | // start lifting the non-screen-locker containers. |
| 968 | PressPowerButton(); |
| 969 | |
| 970 | ExpectPreLockAnimationStarted(); |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 971 | ExpectWallpaperIsShowing(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 972 | |
| 973 | Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
| 974 | |
| 975 | ExpectPreLockAnimationFinished(); |
| 976 | |
| 977 | SystemLocks(); |
| 978 | |
| 979 | ReleasePowerButton(); |
| 980 | |
| 981 | ExpectPostLockAnimationStarted(); |
| 982 | Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 983 | ExpectPostLockAnimationFinished(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 984 | |
| 985 | ExpectLockedState(); |
| 986 | |
| 987 | SuccessfulAuthentication(NULL); |
| 988 | |
| 989 | ExpectUnlockBeforeUIDestroyedAnimationStarted(); |
| 990 | Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 991 | ExpectUnlockBeforeUIDestroyedAnimationFinished(); |
| 992 | |
| 993 | SystemUnlocks(); |
| 994 | |
| 995 | ExpectUnlockAfterUIDestroyedAnimationStarted(); |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 996 | ExpectWallpaperIsHiding(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 997 | |
| 998 | Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 999 | |
| 1000 | // When the StartUnlockAnimationAfterUIDestroyed sequence finishes it queues |
msw | 607227f8 | 2016-08-30 17:22:39 | [diff] [blame] | 1001 | // up a restore wallpaper visibility sequence when the wallpaper is hidden. |
| 1002 | ExpectRestoringWallpaperVisibility(); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 1003 | |
| 1004 | Advance(SessionStateAnimator::ANIMATION_SPEED_IMMEDIATE); |
| 1005 | |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 1006 | ExpectUnlockAfterUIDestroyedAnimationFinished(); |
[email protected] | 72e8d4e | 2012-12-17 15:02:33 | [diff] [blame] | 1007 | |
| 1008 | ExpectUnlockedState(); |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 1009 | } |
| 1010 | |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 1011 | TEST_F(LockStateControllerTest, Screenshot) { |
| 1012 | test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); |
| 1013 | delegate->set_can_take_screenshot(true); |
| 1014 | |
| 1015 | EnableMaximizeMode(false); |
| 1016 | |
| 1017 | // Screenshot handling should not be active when not in maximize mode. |
| 1018 | ASSERT_EQ(0, delegate->handle_take_screenshot_count()); |
| 1019 | PressVolumeDown(); |
| 1020 | PressPowerButton(); |
| 1021 | ReleasePowerButton(); |
| 1022 | ReleaseVolumeDown(); |
| 1023 | EXPECT_EQ(0, delegate->handle_take_screenshot_count()); |
| 1024 | |
| 1025 | EnableMaximizeMode(true); |
| 1026 | |
| 1027 | // Pressing power alone does not take a screenshot. |
| 1028 | PressPowerButton(); |
| 1029 | ReleasePowerButton(); |
| 1030 | EXPECT_EQ(0, delegate->handle_take_screenshot_count()); |
| 1031 | |
| 1032 | // Press & release volume then pressing power does not take a screenshot. |
| 1033 | ASSERT_EQ(0, delegate->handle_take_screenshot_count()); |
| 1034 | PressVolumeDown(); |
| 1035 | ReleaseVolumeDown(); |
| 1036 | PressPowerButton(); |
| 1037 | ReleasePowerButton(); |
| 1038 | EXPECT_EQ(0, delegate->handle_take_screenshot_count()); |
| 1039 | |
| 1040 | // Pressing power and then volume does not take a screenshot. |
| 1041 | ASSERT_EQ(0, delegate->handle_take_screenshot_count()); |
| 1042 | PressPowerButton(); |
| 1043 | ReleasePowerButton(); |
| 1044 | PressVolumeDown(); |
| 1045 | ReleaseVolumeDown(); |
| 1046 | EXPECT_EQ(0, delegate->handle_take_screenshot_count()); |
| 1047 | |
| 1048 | // Holding volume down and pressing power takes a screenshot. |
| 1049 | ASSERT_EQ(0, delegate->handle_take_screenshot_count()); |
| 1050 | PressVolumeDown(); |
| 1051 | PressPowerButton(); |
| 1052 | ReleasePowerButton(); |
| 1053 | ReleaseVolumeDown(); |
| 1054 | EXPECT_EQ(1, delegate->handle_take_screenshot_count()); |
| 1055 | } |
| 1056 | |
| 1057 | // Tests that a lock action is cancellable when quick lock is turned on and |
| 1058 | // maximize mode is not active. |
| 1059 | TEST_F(LockStateControllerTest, QuickLockWhileNotInMaximizeMode) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 1060 | Initialize(false, LoginStatus::USER); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 1061 | power_button_controller_->set_enable_quick_lock_for_test(true); |
| 1062 | EnableMaximizeMode(false); |
| 1063 | |
| 1064 | PressPowerButton(); |
| 1065 | |
| 1066 | ExpectPreLockAnimationStarted(); |
| 1067 | EXPECT_TRUE(test_api_->is_animating_lock()); |
| 1068 | EXPECT_TRUE(lock_state_controller_->CanCancelLockAnimation()); |
| 1069 | |
| 1070 | ReleasePowerButton(); |
| 1071 | |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 1072 | EXPECT_EQ(0, session_manager_client_->request_lock_screen_call_count()); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 1073 | } |
| 1074 | |
| 1075 | // Tests that a lock action is not cancellable when quick lock is turned on and |
| 1076 | // maximize mode is active. |
| 1077 | TEST_F(LockStateControllerTest, QuickLockWhileInMaximizeMode) { |
sky | e79274a | 2016-06-08 05:39:02 | [diff] [blame] | 1078 | Initialize(false, LoginStatus::USER); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 1079 | power_button_controller_->set_enable_quick_lock_for_test(true); |
| 1080 | EnableMaximizeMode(true); |
| 1081 | |
| 1082 | PressPowerButton(); |
| 1083 | |
| 1084 | ExpectPreLockAnimationStarted(); |
| 1085 | EXPECT_TRUE(test_api_->is_animating_lock()); |
| 1086 | EXPECT_FALSE(lock_state_controller_->CanCancelLockAnimation()); |
| 1087 | |
| 1088 | ReleasePowerButton(); |
| 1089 | |
| 1090 | ExpectPreLockAnimationStarted(); |
| 1091 | |
| 1092 | test_animator_->CompleteAllAnimations(true); |
sadrul | 522f2ec8 | 2016-07-19 22:38:44 | [diff] [blame] | 1093 | EXPECT_EQ(1, session_manager_client_->request_lock_screen_call_count()); |
bruthig | ca2e149 | 2014-09-12 23:48:06 | [diff] [blame] | 1094 | } |
| 1095 | |
[email protected] | 88223751 | 2012-11-26 22:29:07 | [diff] [blame] | 1096 | } // namespace test |
| 1097 | } // namespace ash |