OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/power_button_controller.h" | 5 #include "ash/wm/power_button_controller.h" |
6 #include "ash/wm/session_state_animator.h" | 6 #include "ash/wm/session_state_animator.h" |
7 #include "ash/wm/session_state_controller.h" | 7 #include "ash/wm/session_state_controller.h" |
| 8 #include "ash/wm/session_state_controller_impl.h" |
8 | 9 |
| 10 #include "ash/ash_switches.h" |
9 #include "ash/shell.h" | 11 #include "ash/shell.h" |
10 #include "ash/test/ash_test_base.h" | 12 #include "ash/test/ash_test_base.h" |
11 #include "ash/test/test_shell_delegate.h" | 13 #include "ash/test/test_shell_delegate.h" |
12 #include "ash/wm/cursor_manager.h" | 14 #include "ash/wm/cursor_manager.h" |
| 15 #include "base/command_line.h" |
13 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
14 #include "base/time.h" | 17 #include "base/time.h" |
15 #include "ui/aura/env.h" | 18 #include "ui/aura/env.h" |
16 #include "ui/aura/root_window.h" | 19 #include "ui/aura/root_window.h" |
17 #include "ui/aura/test/event_generator.h" | 20 #include "ui/aura/test/event_generator.h" |
18 #include "ui/gfx/rect.h" | 21 #include "ui/gfx/rect.h" |
19 #include "ui/gfx/size.h" | 22 #include "ui/gfx/size.h" |
20 | 23 |
21 namespace ash { | 24 namespace ash { |
22 namespace test { | 25 namespace test { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 58 |
56 class PowerButtonControllerTest : public AshTestBase { | 59 class PowerButtonControllerTest : public AshTestBase { |
57 public: | 60 public: |
58 PowerButtonControllerTest() : controller_(NULL), delegate_(NULL) {} | 61 PowerButtonControllerTest() : controller_(NULL), delegate_(NULL) {} |
59 virtual ~PowerButtonControllerTest() {} | 62 virtual ~PowerButtonControllerTest() {} |
60 | 63 |
61 void SetUp() OVERRIDE { | 64 void SetUp() OVERRIDE { |
62 AshTestBase::SetUp(); | 65 AshTestBase::SetUp(); |
63 delegate_ = new TestPowerButtonControllerDelegate; | 66 delegate_ = new TestPowerButtonControllerDelegate; |
64 controller_ = Shell::GetInstance()->power_button_controller(); | 67 controller_ = Shell::GetInstance()->power_button_controller(); |
65 state_controller_ = Shell::GetInstance()->session_state_controller(); | 68 CHECK(!CommandLine::ForCurrentProcess()->HasSwitch( |
| 69 ash::switches::kAshNewLockAnimationsEnabled)); |
| 70 state_controller_ = static_cast<SessionStateControllerImpl*>( |
| 71 Shell::GetInstance()->session_state_controller()); |
66 state_controller_->SetDelegate(delegate_); // transfers ownership | 72 state_controller_->SetDelegate(delegate_); // transfers ownership |
67 test_api_.reset(new SessionStateController::TestApi(state_controller_)); | 73 test_api_.reset(new SessionStateControllerImpl::TestApi(state_controller_)); |
68 animator_api_.reset( | 74 animator_api_.reset( |
69 new internal::SessionStateAnimator::TestApi(state_controller_-> | 75 new internal::SessionStateAnimator::TestApi(state_controller_-> |
70 animator_.get())); | 76 animator_.get())); |
71 } | 77 } |
72 | 78 |
73 protected: | 79 protected: |
74 void GenerateMouseMoveEvent() { | 80 void GenerateMouseMoveEvent() { |
75 aura::test::EventGenerator generator( | 81 aura::test::EventGenerator generator( |
76 Shell::GetPrimaryRootWindow()); | 82 Shell::GetPrimaryRootWindow()); |
77 generator.MoveMouseTo(10, 10); | 83 generator.MoveMouseTo(10, 10); |
78 } | 84 } |
79 | 85 |
80 int NumShutdownRequests() { | 86 int NumShutdownRequests() { |
81 return delegate_->num_shutdown_requests() + | 87 return delegate_->num_shutdown_requests() + |
82 reinterpret_cast<TestShellDelegate*>( | 88 reinterpret_cast<TestShellDelegate*>( |
83 ash::Shell::GetInstance()->delegate())->num_exit_requests(); | 89 ash::Shell::GetInstance()->delegate())->num_exit_requests(); |
84 } | 90 } |
85 | 91 |
86 PowerButtonController* controller_; // not owned | 92 PowerButtonController* controller_; // not owned |
87 SessionStateController* state_controller_; // not owned | 93 SessionStateControllerImpl* state_controller_; // not owned |
88 TestPowerButtonControllerDelegate* delegate_; // not owned | 94 TestPowerButtonControllerDelegate* delegate_; // not owned |
89 | 95 |
90 scoped_ptr<SessionStateController::TestApi> test_api_; | 96 scoped_ptr<SessionStateControllerImpl::TestApi> test_api_; |
91 scoped_ptr<internal::SessionStateAnimator::TestApi> animator_api_; | 97 scoped_ptr<internal::SessionStateAnimator::TestApi> animator_api_; |
92 | 98 |
93 private: | 99 private: |
94 DISALLOW_COPY_AND_ASSIGN(PowerButtonControllerTest); | 100 DISALLOW_COPY_AND_ASSIGN(PowerButtonControllerTest); |
95 }; | 101 }; |
96 | 102 |
97 // Test the lock-to-shutdown flow for non-Chrome-OS hardware that doesn't | 103 // Test the lock-to-shutdown flow for non-Chrome-OS hardware that doesn't |
98 // correctly report power button releases. We should lock immediately the first | 104 // correctly report power button releases. We should lock immediately the first |
99 // time the button is pressed and shut down when it's pressed from the locked | 105 // time the button is pressed and shut down when it's pressed from the locked |
100 // state. | 106 // state. |
101 TEST_F(PowerButtonControllerTest, LegacyLockAndShutDown) { | 107 TEST_F(PowerButtonControllerTest, LegacyLockAndShutDown) { |
102 controller_->set_has_legacy_power_button_for_test(true); | 108 controller_->set_has_legacy_power_button_for_test(true); |
103 state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER); | 109 state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER); |
104 state_controller_->OnLockStateChanged(false); | 110 state_controller_->OnLockStateChanged(false); |
105 | 111 |
106 // We should request that the screen be locked immediately after seeing the | 112 // We should request that the screen be locked immediately after seeing the |
107 // power button get pressed. | 113 // power button get pressed. |
108 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); | 114 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
109 EXPECT_TRUE( | 115 EXPECT_TRUE( |
110 animator_api_->ContainersAreAnimated( | 116 animator_api_->ContainersAreAnimated( |
111 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 117 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
112 internal::SessionStateAnimator::ANIMATION_SLOW_CLOSE)); | 118 internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE)); |
113 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); | 119 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); |
114 EXPECT_FALSE(animator_api_->hide_black_layer_timer_is_running()); | 120 EXPECT_FALSE(animator_api_->hide_black_layer_timer_is_running()); |
115 EXPECT_FALSE(test_api_->lock_timer_is_running()); | 121 EXPECT_FALSE(test_api_->lock_timer_is_running()); |
116 EXPECT_EQ(1, delegate_->num_lock_requests()); | 122 EXPECT_EQ(1, delegate_->num_lock_requests()); |
117 | 123 |
118 // Notify that we locked successfully. | 124 // Notify that we locked successfully. |
119 state_controller_->OnStartingLock(); | 125 state_controller_->OnStartingLock(); |
120 EXPECT_TRUE( | 126 EXPECT_TRUE( |
121 animator_api_->ContainersAreAnimated( | 127 animator_api_->ContainersAreAnimated( |
122 internal::SessionStateAnimator::LAUNCHER, | 128 internal::SessionStateAnimator::LAUNCHER, |
123 internal::SessionStateAnimator::ANIMATION_HIDE)); | 129 internal::SessionStateAnimator::ANIMATION_HIDE)); |
124 EXPECT_TRUE( | 130 EXPECT_TRUE( |
125 animator_api_->ContainersAreAnimated( | 131 animator_api_->ContainersAreAnimated( |
126 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 132 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
127 internal::SessionStateAnimator::ANIMATION_FAST_CLOSE)); | 133 internal::SessionStateAnimator::ANIMATION_FULL_CLOSE)); |
128 EXPECT_TRUE( | 134 EXPECT_TRUE( |
129 animator_api_->ContainersAreAnimated( | 135 animator_api_->ContainersAreAnimated( |
130 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 136 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
131 internal::SessionStateAnimator::ANIMATION_HIDE)); | 137 internal::SessionStateAnimator::ANIMATION_HIDE)); |
132 | 138 |
133 // Notify that the lock window is visible. We should make it fade in. | 139 // Notify that the lock window is visible. We should make it fade in. |
134 state_controller_->OnLockStateChanged(true); | 140 state_controller_->OnLockStateChanged(true); |
135 EXPECT_TRUE( | 141 EXPECT_TRUE( |
136 animator_api_->ContainersAreAnimated( | 142 animator_api_->ContainersAreAnimated( |
137 internal::SessionStateAnimator::kAllLockScreenContainersMask, | 143 internal::SessionStateAnimator::kAllLockScreenContainersMask, |
(...skipping 13 matching lines...) Expand all Loading... |
151 // 1. All user session containers have transform (including wallpaper). | 157 // 1. All user session containers have transform (including wallpaper). |
152 // They're in this state after lock. | 158 // They're in this state after lock. |
153 // 2. Screen locker and related containers are in fact animating | 159 // 2. Screen locker and related containers are in fact animating |
154 // (as shutdown is in progress). | 160 // (as shutdown is in progress). |
155 // With http://crbug.com/144737 we no longer animate user session wallpaper | 161 // With http://crbug.com/144737 we no longer animate user session wallpaper |
156 // during lock so it makes sense only to check that screen lock and related | 162 // during lock so it makes sense only to check that screen lock and related |
157 // containers are animated during shutdown. | 163 // containers are animated during shutdown. |
158 EXPECT_TRUE( | 164 EXPECT_TRUE( |
159 animator_api_->ContainersAreAnimated( | 165 animator_api_->ContainersAreAnimated( |
160 internal::SessionStateAnimator::kAllLockScreenContainersMask, | 166 internal::SessionStateAnimator::kAllLockScreenContainersMask, |
161 internal::SessionStateAnimator::ANIMATION_FAST_CLOSE)); | 167 internal::SessionStateAnimator::ANIMATION_FULL_CLOSE)); |
162 // Make sure a mouse move event won't show the cursor. | 168 // Make sure a mouse move event won't show the cursor. |
163 GenerateMouseMoveEvent(); | 169 GenerateMouseMoveEvent(); |
164 EXPECT_FALSE(cursor_visible()); | 170 EXPECT_FALSE(cursor_visible()); |
165 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); | 171 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
166 test_api_->trigger_real_shutdown_timeout(); | 172 test_api_->trigger_real_shutdown_timeout(); |
167 EXPECT_EQ(1, NumShutdownRequests()); | 173 EXPECT_EQ(1, NumShutdownRequests()); |
168 } | 174 } |
169 | 175 |
170 // Test that we start shutting down immediately if the power button is pressed | 176 // Test that we start shutting down immediately if the power button is pressed |
171 // while we're not logged in on an unofficial system. | 177 // while we're not logged in on an unofficial system. |
(...skipping 23 matching lines...) Expand all Loading... |
195 state_controller_->OnLockStateChanged(false); | 201 state_controller_->OnLockStateChanged(false); |
196 EXPECT_FALSE(animator_api_->BlackLayerIsVisible()); | 202 EXPECT_FALSE(animator_api_->BlackLayerIsVisible()); |
197 | 203 |
198 // Press the power button and check that we start the shutdown timer. | 204 // Press the power button and check that we start the shutdown timer. |
199 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); | 205 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
200 EXPECT_FALSE(test_api_->lock_timer_is_running()); | 206 EXPECT_FALSE(test_api_->lock_timer_is_running()); |
201 EXPECT_TRUE(test_api_->shutdown_timer_is_running()); | 207 EXPECT_TRUE(test_api_->shutdown_timer_is_running()); |
202 EXPECT_TRUE( | 208 EXPECT_TRUE( |
203 animator_api_->ContainersAreAnimated( | 209 animator_api_->ContainersAreAnimated( |
204 internal::SessionStateAnimator::kAllContainersMask, | 210 internal::SessionStateAnimator::kAllContainersMask, |
205 internal::SessionStateAnimator::ANIMATION_SLOW_CLOSE)); | 211 internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE)); |
206 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); | 212 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); |
207 | 213 |
208 // Release the power button before the shutdown timer fires. | 214 // Release the power button before the shutdown timer fires. |
209 controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); | 215 controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); |
210 EXPECT_FALSE(test_api_->shutdown_timer_is_running()); | 216 EXPECT_FALSE(test_api_->shutdown_timer_is_running()); |
211 EXPECT_TRUE( | 217 EXPECT_TRUE( |
212 animator_api_->ContainersAreAnimated( | 218 animator_api_->ContainersAreAnimated( |
213 internal::SessionStateAnimator::kAllContainersMask, | 219 internal::SessionStateAnimator::kAllContainersMask, |
214 internal::SessionStateAnimator::ANIMATION_UNDO_SLOW_CLOSE)); | 220 internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE)); |
215 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); | 221 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); |
216 | 222 |
217 // We should re-hide the black layer after waiting long enough for | 223 // We should re-hide the black layer after waiting long enough for |
218 // the animation to finish. | 224 // the animation to finish. |
219 EXPECT_TRUE(animator_api_->hide_black_layer_timer_is_running()); | 225 EXPECT_TRUE(animator_api_->hide_black_layer_timer_is_running()); |
220 animator_api_->TriggerHideBlackLayerTimeout(); | 226 animator_api_->TriggerHideBlackLayerTimeout(); |
221 EXPECT_FALSE(animator_api_->BlackLayerIsVisible()); | 227 EXPECT_FALSE(animator_api_->BlackLayerIsVisible()); |
222 | 228 |
223 // Press the button again and make the shutdown timeout fire this time. | 229 // Press the button again and make the shutdown timeout fire this time. |
224 // Check that we start the timer for actually requesting the shutdown. | 230 // Check that we start the timer for actually requesting the shutdown. |
225 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); | 231 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
226 EXPECT_TRUE(test_api_->shutdown_timer_is_running()); | 232 EXPECT_TRUE(test_api_->shutdown_timer_is_running()); |
227 test_api_->trigger_shutdown_timeout(); | 233 test_api_->trigger_shutdown_timeout(); |
228 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); | 234 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
229 EXPECT_EQ(0, NumShutdownRequests()); | 235 EXPECT_EQ(0, NumShutdownRequests()); |
230 EXPECT_TRUE( | 236 EXPECT_TRUE( |
231 animator_api_->ContainersAreAnimated( | 237 animator_api_->ContainersAreAnimated( |
232 internal::SessionStateAnimator::LAUNCHER | | 238 internal::SessionStateAnimator::LAUNCHER | |
233 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 239 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
234 internal::SessionStateAnimator::ANIMATION_HIDE)); | 240 internal::SessionStateAnimator::ANIMATION_HIDE)); |
235 EXPECT_TRUE( | 241 EXPECT_TRUE( |
236 animator_api_->ContainersAreAnimated( | 242 animator_api_->ContainersAreAnimated( |
237 internal::SessionStateAnimator::kAllLockScreenContainersMask, | 243 internal::SessionStateAnimator::kAllLockScreenContainersMask, |
238 internal::SessionStateAnimator::ANIMATION_FAST_CLOSE)); | 244 internal::SessionStateAnimator::ANIMATION_FULL_CLOSE)); |
239 | 245 |
240 // When the timout fires, we should request a shutdown. | 246 // When the timout fires, we should request a shutdown. |
241 test_api_->trigger_real_shutdown_timeout(); | 247 test_api_->trigger_real_shutdown_timeout(); |
242 EXPECT_EQ(1, NumShutdownRequests()); | 248 EXPECT_EQ(1, NumShutdownRequests()); |
243 } | 249 } |
244 | 250 |
245 // Test that we lock the screen and deal with unlocking correctly. | 251 // Test that we lock the screen and deal with unlocking correctly. |
246 TEST_F(PowerButtonControllerTest, LockAndUnlock) { | 252 TEST_F(PowerButtonControllerTest, LockAndUnlock) { |
247 controller_->set_has_legacy_power_button_for_test(false); | 253 controller_->set_has_legacy_power_button_for_test(false); |
248 state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER); | 254 state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER); |
249 state_controller_->OnLockStateChanged(false); | 255 state_controller_->OnLockStateChanged(false); |
250 EXPECT_FALSE(animator_api_->BlackLayerIsVisible()); | 256 EXPECT_FALSE(animator_api_->BlackLayerIsVisible()); |
251 | 257 |
252 // We should initially be showing the screen locker containers, since they | 258 // We should initially be showing the screen locker containers, since they |
253 // also contain login-related windows that we want to show during the | 259 // also contain login-related windows that we want to show during the |
254 // logging-in animation. | 260 // logging-in animation. |
255 EXPECT_TRUE( | 261 EXPECT_TRUE( |
256 animator_api_->ContainersAreAnimated( | 262 animator_api_->ContainersAreAnimated( |
257 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 263 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
258 internal::SessionStateAnimator::ANIMATION_RESTORE)); | 264 internal::SessionStateAnimator::ANIMATION_RESTORE)); |
259 | 265 |
260 // Press the power button and check that the lock timer is started and that we | 266 // Press the power button and check that the lock timer is started and that we |
261 // start scaling the non-screen-locker containers. | 267 // start scaling the non-screen-locker containers. |
262 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); | 268 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
263 EXPECT_TRUE(test_api_->lock_timer_is_running()); | 269 EXPECT_TRUE(test_api_->lock_timer_is_running()); |
264 EXPECT_FALSE(test_api_->shutdown_timer_is_running()); | 270 EXPECT_FALSE(test_api_->shutdown_timer_is_running()); |
265 EXPECT_TRUE( | 271 EXPECT_TRUE( |
266 animator_api_->ContainersAreAnimated( | 272 animator_api_->ContainersAreAnimated( |
267 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 273 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
268 internal::SessionStateAnimator::ANIMATION_SLOW_CLOSE)); | 274 internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE)); |
269 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); | 275 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); |
270 | 276 |
271 // Release the button before the lock timer fires. | 277 // Release the button before the lock timer fires. |
272 controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); | 278 controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); |
273 EXPECT_FALSE(test_api_->lock_timer_is_running()); | 279 EXPECT_FALSE(test_api_->lock_timer_is_running()); |
274 EXPECT_TRUE( | 280 EXPECT_TRUE( |
275 animator_api_->ContainersAreAnimated( | 281 animator_api_->ContainersAreAnimated( |
276 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 282 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
277 internal::SessionStateAnimator::ANIMATION_UNDO_SLOW_CLOSE)); | 283 internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE)); |
278 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); | 284 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); |
279 EXPECT_TRUE(animator_api_->hide_black_layer_timer_is_running()); | 285 EXPECT_TRUE(animator_api_->hide_black_layer_timer_is_running()); |
280 animator_api_->TriggerHideBlackLayerTimeout(); | 286 animator_api_->TriggerHideBlackLayerTimeout(); |
281 EXPECT_FALSE(animator_api_->BlackLayerIsVisible()); | 287 EXPECT_FALSE(animator_api_->BlackLayerIsVisible()); |
282 | 288 |
283 // Press the button and fire the lock timer. We should request that the | 289 // Press the button and fire the lock timer. We should request that the |
284 // screen be locked, but we should still be in the slow-close animation. | 290 // screen be locked, but we should still be in the slow-close animation. |
285 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); | 291 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
286 EXPECT_TRUE(test_api_->lock_timer_is_running()); | 292 EXPECT_TRUE(test_api_->lock_timer_is_running()); |
287 EXPECT_EQ(0, delegate_->num_lock_requests()); | 293 EXPECT_EQ(0, delegate_->num_lock_requests()); |
288 test_api_->trigger_lock_timeout(); | 294 test_api_->trigger_lock_timeout(); |
289 EXPECT_EQ(1, delegate_->num_lock_requests()); | 295 EXPECT_EQ(1, delegate_->num_lock_requests()); |
290 EXPECT_TRUE( | 296 EXPECT_TRUE( |
291 animator_api_->ContainersAreAnimated( | 297 animator_api_->ContainersAreAnimated( |
292 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 298 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
293 internal::SessionStateAnimator::ANIMATION_SLOW_CLOSE)); | 299 internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE)); |
294 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); | 300 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); |
295 | 301 |
296 // Notify that we locked successfully. | 302 // Notify that we locked successfully. |
297 state_controller_->OnStartingLock(); | 303 state_controller_->OnStartingLock(); |
298 EXPECT_TRUE( | 304 EXPECT_TRUE( |
299 animator_api_->ContainersAreAnimated( | 305 animator_api_->ContainersAreAnimated( |
300 internal::SessionStateAnimator::LAUNCHER, | 306 internal::SessionStateAnimator::LAUNCHER, |
301 internal::SessionStateAnimator::ANIMATION_HIDE)); | 307 internal::SessionStateAnimator::ANIMATION_HIDE)); |
302 EXPECT_TRUE( | 308 EXPECT_TRUE( |
303 animator_api_->ContainersAreAnimated( | 309 animator_api_->ContainersAreAnimated( |
304 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 310 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
305 internal::SessionStateAnimator::ANIMATION_FAST_CLOSE)); | 311 internal::SessionStateAnimator::ANIMATION_FULL_CLOSE)); |
306 EXPECT_TRUE( | 312 EXPECT_TRUE( |
307 animator_api_->ContainersAreAnimated( | 313 animator_api_->ContainersAreAnimated( |
308 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 314 internal::SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
309 internal::SessionStateAnimator::ANIMATION_HIDE)); | 315 internal::SessionStateAnimator::ANIMATION_HIDE)); |
310 | 316 |
311 // Notify that the lock window is visible. We should make it fade in. | 317 // Notify that the lock window is visible. We should make it fade in. |
312 state_controller_->OnLockStateChanged(true); | 318 state_controller_->OnLockStateChanged(true); |
313 EXPECT_TRUE( | 319 EXPECT_TRUE( |
314 animator_api_->ContainersAreAnimated( | 320 animator_api_->ContainersAreAnimated( |
315 internal::SessionStateAnimator::kAllLockScreenContainersMask, | 321 internal::SessionStateAnimator::kAllLockScreenContainersMask, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); | 354 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); |
349 | 355 |
350 // When the lock-to-shutdown timeout fires, we should start the shutdown | 356 // When the lock-to-shutdown timeout fires, we should start the shutdown |
351 // timer. | 357 // timer. |
352 EXPECT_TRUE(test_api_->lock_to_shutdown_timer_is_running()); | 358 EXPECT_TRUE(test_api_->lock_to_shutdown_timer_is_running()); |
353 test_api_->trigger_lock_to_shutdown_timeout(); | 359 test_api_->trigger_lock_to_shutdown_timeout(); |
354 EXPECT_TRUE(test_api_->shutdown_timer_is_running()); | 360 EXPECT_TRUE(test_api_->shutdown_timer_is_running()); |
355 EXPECT_TRUE( | 361 EXPECT_TRUE( |
356 animator_api_->ContainersAreAnimated( | 362 animator_api_->ContainersAreAnimated( |
357 internal::SessionStateAnimator::kAllContainersMask, | 363 internal::SessionStateAnimator::kAllContainersMask, |
358 internal::SessionStateAnimator::ANIMATION_SLOW_CLOSE)); | 364 internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE)); |
359 | 365 |
360 // Fire the shutdown timeout and check that we request shutdown. | 366 // Fire the shutdown timeout and check that we request shutdown. |
361 test_api_->trigger_shutdown_timeout(); | 367 test_api_->trigger_shutdown_timeout(); |
362 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); | 368 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
363 EXPECT_EQ(0, NumShutdownRequests()); | 369 EXPECT_EQ(0, NumShutdownRequests()); |
364 test_api_->trigger_real_shutdown_timeout(); | 370 test_api_->trigger_real_shutdown_timeout(); |
365 EXPECT_EQ(1, NumShutdownRequests()); | 371 EXPECT_EQ(1, NumShutdownRequests()); |
366 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); | 372 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); |
367 } | 373 } |
368 | 374 |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 EXPECT_EQ(0, delegate_->num_lock_requests()); | 468 EXPECT_EQ(0, delegate_->num_lock_requests()); |
463 | 469 |
464 // If we're logged in as a regular user, we should start the lock timer and | 470 // If we're logged in as a regular user, we should start the lock timer and |
465 // the pre-lock animation. | 471 // the pre-lock animation. |
466 state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER); | 472 state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER); |
467 controller_->OnLockButtonEvent(true, base::TimeTicks::Now()); | 473 controller_->OnLockButtonEvent(true, base::TimeTicks::Now()); |
468 EXPECT_TRUE(test_api_->lock_timer_is_running()); | 474 EXPECT_TRUE(test_api_->lock_timer_is_running()); |
469 EXPECT_TRUE( | 475 EXPECT_TRUE( |
470 animator_api_->ContainersAreAnimated( | 476 animator_api_->ContainersAreAnimated( |
471 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 477 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
472 internal::SessionStateAnimator::ANIMATION_SLOW_CLOSE)); | 478 internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE)); |
473 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); | 479 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); |
474 | 480 |
475 // If the button is released immediately, we shouldn't lock the screen. | 481 // If the button is released immediately, we shouldn't lock the screen. |
476 controller_->OnLockButtonEvent(false, base::TimeTicks::Now()); | 482 controller_->OnLockButtonEvent(false, base::TimeTicks::Now()); |
477 EXPECT_FALSE(test_api_->lock_timer_is_running()); | 483 EXPECT_FALSE(test_api_->lock_timer_is_running()); |
478 EXPECT_TRUE( | 484 EXPECT_TRUE( |
479 animator_api_->ContainersAreAnimated( | 485 animator_api_->ContainersAreAnimated( |
480 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 486 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
481 internal::SessionStateAnimator::ANIMATION_UNDO_SLOW_CLOSE)); | 487 internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE)); |
482 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); | 488 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); |
483 EXPECT_TRUE(animator_api_->hide_black_layer_timer_is_running()); | 489 EXPECT_TRUE(animator_api_->hide_black_layer_timer_is_running()); |
484 animator_api_->TriggerHideBlackLayerTimeout(); | 490 animator_api_->TriggerHideBlackLayerTimeout(); |
485 EXPECT_FALSE(animator_api_->BlackLayerIsVisible()); | 491 EXPECT_FALSE(animator_api_->BlackLayerIsVisible()); |
486 EXPECT_EQ(0, delegate_->num_lock_requests()); | 492 EXPECT_EQ(0, delegate_->num_lock_requests()); |
487 | 493 |
488 // Press the button again and let the lock timeout fire. We should request | 494 // Press the button again and let the lock timeout fire. We should request |
489 // that the screen be locked. | 495 // that the screen be locked. |
490 controller_->OnLockButtonEvent(true, base::TimeTicks::Now()); | 496 controller_->OnLockButtonEvent(true, base::TimeTicks::Now()); |
491 EXPECT_TRUE(test_api_->lock_timer_is_running()); | 497 EXPECT_TRUE(test_api_->lock_timer_is_running()); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 | 546 |
541 // When the screen is locked without going through the usual power-button | 547 // When the screen is locked without going through the usual power-button |
542 // slow-close path (e.g. via the wrench menu), test that we still show the | 548 // slow-close path (e.g. via the wrench menu), test that we still show the |
543 // fast-close animation and display the black layer. | 549 // fast-close animation and display the black layer. |
544 TEST_F(PowerButtonControllerTest, LockWithoutButton) { | 550 TEST_F(PowerButtonControllerTest, LockWithoutButton) { |
545 state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER); | 551 state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER); |
546 state_controller_->OnStartingLock(); | 552 state_controller_->OnStartingLock(); |
547 EXPECT_TRUE( | 553 EXPECT_TRUE( |
548 animator_api_->ContainersAreAnimated( | 554 animator_api_->ContainersAreAnimated( |
549 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 555 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
550 internal::SessionStateAnimator::ANIMATION_FAST_CLOSE)); | 556 internal::SessionStateAnimator::ANIMATION_FULL_CLOSE)); |
551 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); | 557 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); |
552 } | 558 } |
553 | 559 |
554 // When we hear that the process is exiting but we haven't had a chance to | 560 // When we hear that the process is exiting but we haven't had a chance to |
555 // display an animation, we should just blank the screen. | 561 // display an animation, we should just blank the screen. |
556 TEST_F(PowerButtonControllerTest, ShutdownWithoutButton) { | 562 TEST_F(PowerButtonControllerTest, ShutdownWithoutButton) { |
557 state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER); | 563 state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER); |
558 state_controller_->OnAppTerminating(); | 564 state_controller_->OnAppTerminating(); |
559 EXPECT_TRUE( | 565 EXPECT_TRUE( |
560 animator_api_->ContainersAreAnimated( | 566 animator_api_->ContainersAreAnimated( |
561 internal::SessionStateAnimator::kAllContainersMask, | 567 internal::SessionStateAnimator::kAllContainersMask, |
562 internal::SessionStateAnimator::ANIMATION_HIDE)); | 568 internal::SessionStateAnimator::ANIMATION_HIDE)); |
563 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); | 569 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); |
564 GenerateMouseMoveEvent(); | 570 GenerateMouseMoveEvent(); |
565 EXPECT_FALSE(cursor_visible()); | 571 EXPECT_FALSE(cursor_visible()); |
566 } | 572 } |
567 | 573 |
568 // Test that we display the fast-close animation and shut down when we get an | 574 // Test that we display the fast-close animation and shut down when we get an |
569 // outside request to shut down (e.g. from the login or lock screen). | 575 // outside request to shut down (e.g. from the login or lock screen). |
570 TEST_F(PowerButtonControllerTest, RequestShutdownFromLoginScreen) { | 576 TEST_F(PowerButtonControllerTest, RequestShutdownFromLoginScreen) { |
571 state_controller_->OnLoginStateChanged(user::LOGGED_IN_NONE); | 577 state_controller_->OnLoginStateChanged(user::LOGGED_IN_NONE); |
572 state_controller_->RequestShutdown(); | 578 state_controller_->RequestShutdown(); |
573 EXPECT_TRUE( | 579 EXPECT_TRUE( |
574 animator_api_->ContainersAreAnimated( | 580 animator_api_->ContainersAreAnimated( |
575 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 581 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
576 internal::SessionStateAnimator::ANIMATION_HIDE)); | 582 internal::SessionStateAnimator::ANIMATION_HIDE)); |
577 EXPECT_TRUE( | 583 EXPECT_TRUE( |
578 animator_api_->ContainersAreAnimated( | 584 animator_api_->ContainersAreAnimated( |
579 internal::SessionStateAnimator::kAllLockScreenContainersMask, | 585 internal::SessionStateAnimator::kAllLockScreenContainersMask, |
580 internal::SessionStateAnimator::ANIMATION_FAST_CLOSE)); | 586 internal::SessionStateAnimator::ANIMATION_FULL_CLOSE)); |
581 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); | 587 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); |
582 GenerateMouseMoveEvent(); | 588 GenerateMouseMoveEvent(); |
583 EXPECT_FALSE(cursor_visible()); | 589 EXPECT_FALSE(cursor_visible()); |
584 | 590 |
585 EXPECT_EQ(0, NumShutdownRequests()); | 591 EXPECT_EQ(0, NumShutdownRequests()); |
586 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); | 592 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
587 test_api_->trigger_real_shutdown_timeout(); | 593 test_api_->trigger_real_shutdown_timeout(); |
588 EXPECT_EQ(1, NumShutdownRequests()); | 594 EXPECT_EQ(1, NumShutdownRequests()); |
589 } | 595 } |
590 | 596 |
591 TEST_F(PowerButtonControllerTest, RequestShutdownFromLockScreen) { | 597 TEST_F(PowerButtonControllerTest, RequestShutdownFromLockScreen) { |
592 state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER); | 598 state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER); |
593 state_controller_->OnLockStateChanged(true); | 599 state_controller_->OnLockStateChanged(true); |
594 state_controller_->RequestShutdown(); | 600 state_controller_->RequestShutdown(); |
595 EXPECT_TRUE( | 601 EXPECT_TRUE( |
596 animator_api_->ContainersAreAnimated( | 602 animator_api_->ContainersAreAnimated( |
597 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 603 internal::SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
598 internal::SessionStateAnimator::ANIMATION_HIDE)); | 604 internal::SessionStateAnimator::ANIMATION_HIDE)); |
599 EXPECT_TRUE( | 605 EXPECT_TRUE( |
600 animator_api_->ContainersAreAnimated( | 606 animator_api_->ContainersAreAnimated( |
601 internal::SessionStateAnimator::kAllLockScreenContainersMask, | 607 internal::SessionStateAnimator::kAllLockScreenContainersMask, |
602 internal::SessionStateAnimator::ANIMATION_FAST_CLOSE)); | 608 internal::SessionStateAnimator::ANIMATION_FULL_CLOSE)); |
603 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); | 609 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); |
604 GenerateMouseMoveEvent(); | 610 GenerateMouseMoveEvent(); |
605 EXPECT_FALSE(cursor_visible()); | 611 EXPECT_FALSE(cursor_visible()); |
606 | 612 |
607 EXPECT_EQ(0, NumShutdownRequests()); | 613 EXPECT_EQ(0, NumShutdownRequests()); |
608 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); | 614 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
609 test_api_->trigger_real_shutdown_timeout(); | 615 test_api_->trigger_real_shutdown_timeout(); |
610 EXPECT_EQ(1, NumShutdownRequests()); | 616 EXPECT_EQ(1, NumShutdownRequests()); |
611 } | 617 } |
612 | 618 |
613 TEST_F(PowerButtonControllerTest, RequestAndCancelShutdownFromLockScreen) { | 619 TEST_F(PowerButtonControllerTest, RequestAndCancelShutdownFromLockScreen) { |
614 state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER); | 620 state_controller_->OnLoginStateChanged(user::LOGGED_IN_USER); |
615 state_controller_->OnLockStateChanged(true); | 621 state_controller_->OnLockStateChanged(true); |
616 | 622 |
617 // Press the power button and check that we start the shutdown timer. | 623 // Press the power button and check that we start the shutdown timer. |
618 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); | 624 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
619 EXPECT_FALSE(test_api_->lock_timer_is_running()); | 625 EXPECT_FALSE(test_api_->lock_timer_is_running()); |
620 EXPECT_TRUE(test_api_->shutdown_timer_is_running()); | 626 EXPECT_TRUE(test_api_->shutdown_timer_is_running()); |
621 EXPECT_TRUE( | 627 EXPECT_TRUE( |
622 animator_api_->ContainersAreAnimated( | 628 animator_api_->ContainersAreAnimated( |
623 internal::SessionStateAnimator::kAllContainersMask, | 629 internal::SessionStateAnimator::kAllContainersMask, |
624 internal::SessionStateAnimator::ANIMATION_SLOW_CLOSE)); | 630 internal::SessionStateAnimator::ANIMATION_PARTIAL_CLOSE)); |
625 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); | 631 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); |
626 | 632 |
627 // Release the power button before the shutdown timer fires. | 633 // Release the power button before the shutdown timer fires. |
628 controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); | 634 controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); |
629 EXPECT_FALSE(test_api_->shutdown_timer_is_running()); | 635 EXPECT_FALSE(test_api_->shutdown_timer_is_running()); |
630 EXPECT_TRUE( | 636 EXPECT_TRUE( |
631 animator_api_->ContainersAreAnimated( | 637 animator_api_->ContainersAreAnimated( |
632 internal::SessionStateAnimator::kAllLockScreenContainersMask, | 638 internal::SessionStateAnimator::kAllLockScreenContainersMask, |
633 internal::SessionStateAnimator::ANIMATION_UNDO_SLOW_CLOSE)); | 639 internal::SessionStateAnimator::ANIMATION_UNDO_PARTIAL_CLOSE)); |
634 EXPECT_TRUE( | 640 EXPECT_TRUE( |
635 animator_api_->ContainersAreAnimated( | 641 animator_api_->ContainersAreAnimated( |
636 internal::SessionStateAnimator::DESKTOP_BACKGROUND, | 642 internal::SessionStateAnimator::DESKTOP_BACKGROUND, |
637 internal::SessionStateAnimator::ANIMATION_RESTORE)); | 643 internal::SessionStateAnimator::ANIMATION_RESTORE)); |
638 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); | 644 EXPECT_TRUE(animator_api_->BlackLayerIsVisible()); |
639 } | 645 } |
640 | 646 |
641 // Test that the black layer is resized in response to root window resizes. | 647 // Test that the black layer is resized in response to root window resizes. |
642 TEST_F(PowerButtonControllerTest, ResizeBlackLayer) { | 648 TEST_F(PowerButtonControllerTest, ResizeBlackLayer) { |
643 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); | 649 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
(...skipping 18 matching lines...) Expand all Loading... |
662 | 668 |
663 // After increasing the brightness to 10%, we should start the timer like | 669 // After increasing the brightness to 10%, we should start the timer like |
664 // usual. | 670 // usual. |
665 controller_->OnScreenBrightnessChanged(10.0); | 671 controller_->OnScreenBrightnessChanged(10.0); |
666 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); | 672 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
667 EXPECT_TRUE(test_api_->lock_timer_is_running()); | 673 EXPECT_TRUE(test_api_->lock_timer_is_running()); |
668 } | 674 } |
669 | 675 |
670 } // namespace test | 676 } // namespace test |
671 } // namespace ash | 677 } // namespace ash |
OLD | NEW |