Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(192)

Side by Side Diff: ash/wm/power_button_controller_unittest.cc

Issue 10990118: Polish lock animation - launcher should do a fade out. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/wm/power_button_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/test/ash_test_base.h" 8 #include "ash/test/ash_test_base.h"
9 #include "ash/wm/cursor_manager.h" 9 #include "ash/wm/cursor_manager.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 PowerButtonController::ANIMATION_SLOW_CLOSE)); 88 PowerButtonController::ANIMATION_SLOW_CLOSE));
89 EXPECT_TRUE(test_api_->BlackLayerIsVisible()); 89 EXPECT_TRUE(test_api_->BlackLayerIsVisible());
90 EXPECT_FALSE(test_api_->hide_black_layer_timer_is_running()); 90 EXPECT_FALSE(test_api_->hide_black_layer_timer_is_running());
91 EXPECT_FALSE(test_api_->lock_timer_is_running()); 91 EXPECT_FALSE(test_api_->lock_timer_is_running());
92 EXPECT_EQ(1, delegate_->num_lock_requests()); 92 EXPECT_EQ(1, delegate_->num_lock_requests());
93 93
94 // Notify that we locked successfully. 94 // Notify that we locked successfully.
95 controller_->OnStartingLock(); 95 controller_->OnStartingLock();
96 EXPECT_TRUE( 96 EXPECT_TRUE(
97 test_api_->ContainersAreAnimated( 97 test_api_->ContainersAreAnimated(
98 PowerButtonController::LAUNCHER,
99 PowerButtonController::ANIMATION_HIDE));
100 EXPECT_TRUE(
101 test_api_->ContainersAreAnimated(
98 PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, 102 PowerButtonController::NON_LOCK_SCREEN_CONTAINERS,
99 PowerButtonController::ANIMATION_FAST_CLOSE)); 103 PowerButtonController::ANIMATION_FAST_CLOSE));
100 EXPECT_TRUE( 104 EXPECT_TRUE(
101 test_api_->ContainersAreAnimated( 105 test_api_->ContainersAreAnimated(
102 PowerButtonController::LOCK_SCREEN_CONTAINERS, 106 PowerButtonController::LOCK_SCREEN_CONTAINERS,
103 PowerButtonController::ANIMATION_HIDE)); 107 PowerButtonController::ANIMATION_HIDE));
104 108
105 // Notify that the lock window is visible. We should make it fade in. 109 // Notify that the lock window is visible. We should make it fade in.
106 controller_->OnLockStateChanged(true); 110 controller_->OnLockStateChanged(true);
107 EXPECT_TRUE( 111 EXPECT_TRUE(
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 196
193 // Press the button again and make the shutdown timeout fire this time. 197 // Press the button again and make the shutdown timeout fire this time.
194 // Check that we start the timer for actually requesting the shutdown. 198 // Check that we start the timer for actually requesting the shutdown.
195 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); 199 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now());
196 EXPECT_TRUE(test_api_->shutdown_timer_is_running()); 200 EXPECT_TRUE(test_api_->shutdown_timer_is_running());
197 test_api_->trigger_shutdown_timeout(); 201 test_api_->trigger_shutdown_timeout();
198 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); 202 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running());
199 EXPECT_EQ(0, delegate_->num_shutdown_requests()); 203 EXPECT_EQ(0, delegate_->num_shutdown_requests());
200 EXPECT_TRUE( 204 EXPECT_TRUE(
201 test_api_->ContainersAreAnimated( 205 test_api_->ContainersAreAnimated(
202 PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, 206 PowerButtonController::LAUNCHER |
207 PowerButtonController::NON_LOCK_SCREEN_CONTAINERS,
203 PowerButtonController::ANIMATION_HIDE)); 208 PowerButtonController::ANIMATION_HIDE));
204 EXPECT_TRUE( 209 EXPECT_TRUE(
205 test_api_->ContainersAreAnimated( 210 test_api_->ContainersAreAnimated(
206 PowerButtonController::GetAllLockScreenContainersMask(), 211 PowerButtonController::GetAllLockScreenContainersMask(),
207 PowerButtonController::ANIMATION_FAST_CLOSE)); 212 PowerButtonController::ANIMATION_FAST_CLOSE));
208 213
209 // When the timout fires, we should request a shutdown. 214 // When the timout fires, we should request a shutdown.
210 test_api_->trigger_real_shutdown_timeout(); 215 test_api_->trigger_real_shutdown_timeout();
211 EXPECT_EQ(1, delegate_->num_shutdown_requests()); 216 EXPECT_EQ(1, delegate_->num_shutdown_requests());
212 } 217 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 EXPECT_TRUE( 264 EXPECT_TRUE(
260 test_api_->ContainersAreAnimated( 265 test_api_->ContainersAreAnimated(
261 PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, 266 PowerButtonController::NON_LOCK_SCREEN_CONTAINERS,
262 PowerButtonController::ANIMATION_SLOW_CLOSE)); 267 PowerButtonController::ANIMATION_SLOW_CLOSE));
263 EXPECT_TRUE(test_api_->BlackLayerIsVisible()); 268 EXPECT_TRUE(test_api_->BlackLayerIsVisible());
264 269
265 // Notify that we locked successfully. 270 // Notify that we locked successfully.
266 controller_->OnStartingLock(); 271 controller_->OnStartingLock();
267 EXPECT_TRUE( 272 EXPECT_TRUE(
268 test_api_->ContainersAreAnimated( 273 test_api_->ContainersAreAnimated(
274 PowerButtonController::LAUNCHER,
275 PowerButtonController::ANIMATION_HIDE));
276 EXPECT_TRUE(
277 test_api_->ContainersAreAnimated(
269 PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, 278 PowerButtonController::NON_LOCK_SCREEN_CONTAINERS,
270 PowerButtonController::ANIMATION_FAST_CLOSE)); 279 PowerButtonController::ANIMATION_FAST_CLOSE));
271 EXPECT_TRUE( 280 EXPECT_TRUE(
272 test_api_->ContainersAreAnimated( 281 test_api_->ContainersAreAnimated(
273 PowerButtonController::LOCK_SCREEN_CONTAINERS, 282 PowerButtonController::LOCK_SCREEN_CONTAINERS,
274 PowerButtonController::ANIMATION_HIDE)); 283 PowerButtonController::ANIMATION_HIDE));
275 284
276 // Notify that the lock window is visible. We should make it fade in. 285 // Notify that the lock window is visible. We should make it fade in.
277 controller_->OnLockStateChanged(true); 286 controller_->OnLockStateChanged(true);
278 EXPECT_TRUE( 287 EXPECT_TRUE(
279 test_api_->ContainersAreAnimated( 288 test_api_->ContainersAreAnimated(
280 PowerButtonController::GetAllLockScreenContainersMask(), 289 PowerButtonController::GetAllLockScreenContainersMask(),
281 PowerButtonController::ANIMATION_FADE_IN)); 290 PowerButtonController::ANIMATION_FADE_IN));
282 291
283 // When we release the power button, the lock-to-shutdown timer should be 292 // When we release the power button, the lock-to-shutdown timer should be
284 // stopped. 293 // stopped.
285 EXPECT_TRUE(test_api_->lock_to_shutdown_timer_is_running()); 294 EXPECT_TRUE(test_api_->lock_to_shutdown_timer_is_running());
286 controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); 295 controller_->OnPowerButtonEvent(false, base::TimeTicks::Now());
287 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); 296 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running());
288 297
289 // Notify that the screen has been unlocked. We should show the 298 // Notify that the screen has been unlocked. We should show the
290 // non-screen-locker windows and hide the black layer. 299 // non-screen-locker windows and hide the black layer.
291 controller_->OnLockStateChanged(false); 300 controller_->OnLockStateChanged(false);
292 EXPECT_TRUE( 301 EXPECT_TRUE(
293 test_api_->ContainersAreAnimated( 302 test_api_->ContainersAreAnimated(
294 PowerButtonController::DESKTOP_BACKGROUND | 303 PowerButtonController::DESKTOP_BACKGROUND |
304 PowerButtonController::LAUNCHER |
295 PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, 305 PowerButtonController::NON_LOCK_SCREEN_CONTAINERS,
296 PowerButtonController::ANIMATION_RESTORE)); 306 PowerButtonController::ANIMATION_RESTORE));
297 EXPECT_FALSE(test_api_->BlackLayerIsVisible()); 307 EXPECT_FALSE(test_api_->BlackLayerIsVisible());
298 } 308 }
299 309
300 // Hold the power button down from the unlocked state to eventual shutdown. 310 // Hold the power button down from the unlocked state to eventual shutdown.
301 TEST_F(PowerButtonControllerTest, LockToShutdown) { 311 TEST_F(PowerButtonControllerTest, LockToShutdown) {
302 controller_->set_has_legacy_power_button_for_test(false); 312 controller_->set_has_legacy_power_button_for_test(false);
303 controller_->OnLoginStateChanged(user::LOGGED_IN_USER); 313 controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
304 controller_->OnLockStateChanged(false); 314 controller_->OnLockStateChanged(false);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 347
338 controller_->set_has_legacy_power_button_for_test(false); 348 controller_->set_has_legacy_power_button_for_test(false);
339 controller_->OnLoginStateChanged(user::LOGGED_IN_USER); 349 controller_->OnLoginStateChanged(user::LOGGED_IN_USER);
340 controller_->OnLockStateChanged(false); 350 controller_->OnLockStateChanged(false);
341 351
342 // Hold the power button and lock the screen. 352 // Hold the power button and lock the screen.
343 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); 353 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now());
344 EXPECT_TRUE(test_api_->lock_timer_is_running()); 354 EXPECT_TRUE(test_api_->lock_timer_is_running());
345 EXPECT_TRUE( 355 EXPECT_TRUE(
346 test_api_->ContainersAreAnimated( 356 test_api_->ContainersAreAnimated(
357 PowerButtonController::DESKTOP_BACKGROUND |
358 PowerButtonController::LAUNCHER |
347 PowerButtonController::NON_LOCK_SCREEN_CONTAINERS, 359 PowerButtonController::NON_LOCK_SCREEN_CONTAINERS,
348 PowerButtonController::ANIMATION_RESTORE)); 360 PowerButtonController::ANIMATION_RESTORE));
349 EXPECT_TRUE(test_api_->BlackLayerIsVisible()); 361 EXPECT_TRUE(test_api_->BlackLayerIsVisible());
350 test_api_->trigger_lock_timeout(); 362 test_api_->trigger_lock_timeout();
351 EXPECT_EQ(1, delegate_->num_lock_requests()); 363 EXPECT_EQ(1, delegate_->num_lock_requests());
352 EXPECT_TRUE(test_api_->lock_fail_timer_is_running()); 364 EXPECT_TRUE(test_api_->lock_fail_timer_is_running());
353 365
354 // We shouldn't start the lock-to-shutdown timer until the screen has actually 366 // We shouldn't start the lock-to-shutdown timer until the screen has actually
355 // been locked. 367 // been locked.
356 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); 368 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running());
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 609
598 // After increasing the brightness to 10%, we should start the timer like 610 // After increasing the brightness to 10%, we should start the timer like
599 // usual. 611 // usual.
600 controller_->OnScreenBrightnessChanged(10.0); 612 controller_->OnScreenBrightnessChanged(10.0);
601 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); 613 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now());
602 EXPECT_TRUE(test_api_->lock_timer_is_running()); 614 EXPECT_TRUE(test_api_->lock_timer_is_running());
603 } 615 }
604 616
605 } // namespace test 617 } // namespace test
606 } // namespace ash 618 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/power_button_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698