| 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 | 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_->ContainerGroupIsAnimated( | 97 test_api_->ContainerGroupIsAnimated( |
| 98 PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, | 98 PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, |
| 99 PowerButtonController::ANIMATION_FAST_CLOSE)); | 99 PowerButtonController::ANIMATION_FAST_CLOSE)); |
| 100 EXPECT_TRUE( | 100 EXPECT_TRUE( |
| 101 test_api_->ContainerGroupIsAnimated( | 101 test_api_->ContainerGroupIsAnimated( |
| 102 PowerButtonController::SCREEN_LOCKER_CONTAINERS, | 102 PowerButtonController::SCREEN_LOCKER_CONTAINERS_EXCEPT_WALLPAPER, |
| 103 PowerButtonController::ANIMATION_HIDE)); | 103 PowerButtonController::ANIMATION_HIDE)); |
| 104 | 104 |
| 105 // Notify that the lock window is visible. We should make it fade in. | 105 // Notify that the lock window is visible. We should make it fade in. |
| 106 controller_->OnLockStateChanged(true); | 106 controller_->OnLockStateChanged(true); |
| 107 EXPECT_TRUE( | 107 EXPECT_TRUE( |
| 108 test_api_->ContainerGroupIsAnimated( | 108 test_api_->ContainerGroupIsAnimated( |
| 109 PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS, | 109 PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS, |
| 110 PowerButtonController::ANIMATION_FADE_IN)); | 110 PowerButtonController::ANIMATION_FADE_IN)); |
| 111 | 111 |
| 112 // We shouldn't progress towards the shutdown state, however. | 112 // We shouldn't progress towards the shutdown state, however. |
| 113 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); | 113 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); |
| 114 EXPECT_FALSE(test_api_->shutdown_timer_is_running()); | 114 EXPECT_FALSE(test_api_->shutdown_timer_is_running()); |
| 115 controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); | 115 controller_->OnPowerButtonEvent(false, base::TimeTicks::Now()); |
| 116 | 116 |
| 117 // Hold the button again and check that we start shutting down. | 117 // Hold the button again and check that we start shutting down. |
| 118 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); | 118 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
| 119 EXPECT_EQ(0, delegate_->num_shutdown_requests()); | 119 EXPECT_EQ(0, delegate_->num_shutdown_requests()); |
| 120 // Previously we're checking that ALL_CONTAINERS are animated which was in |
| 121 // fact checking that |
| 122 // 1. ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS have transform |
| 123 // (including wallpaper). They're in this state after lock. |
| 124 // 2. SCREEN_LOCKER_AND_RELATED_CONTAINERS are in fact animating |
| 125 // (shutdown is in progress). |
| 126 // With http://crbug.com/144737 we no longer animate wallpaper during lock |
| 127 // so it makes sense only to check that SCREEN_LOCKER_AND_RELATED_CONTAINERS |
| 128 // are animated during shutdown. |
| 120 EXPECT_TRUE( | 129 EXPECT_TRUE( |
| 121 test_api_->ContainerGroupIsAnimated( | 130 test_api_->ContainerGroupIsAnimated( |
| 122 PowerButtonController::ALL_CONTAINERS, | 131 PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS, |
| 123 PowerButtonController::ANIMATION_FAST_CLOSE)); | 132 PowerButtonController::ANIMATION_FAST_CLOSE)); |
| 124 EXPECT_FALSE(cursor_visible()); | 133 EXPECT_FALSE(cursor_visible()); |
| 125 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); | 134 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
| 126 test_api_->trigger_real_shutdown_timeout(); | 135 test_api_->trigger_real_shutdown_timeout(); |
| 127 EXPECT_EQ(1, delegate_->num_shutdown_requests()); | 136 EXPECT_EQ(1, delegate_->num_shutdown_requests()); |
| 128 } | 137 } |
| 129 | 138 |
| 130 // Test that we start shutting down immediately if the power button is pressed | 139 // Test that we start shutting down immediately if the power button is pressed |
| 131 // while we're not logged in on an unofficial system. | 140 // while we're not logged in on an unofficial system. |
| 132 TEST_F(PowerButtonControllerTest, LegacyNotLoggedIn) { | 141 TEST_F(PowerButtonControllerTest, LegacyNotLoggedIn) { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 206 controller_->set_has_legacy_power_button_for_test(false); | 215 controller_->set_has_legacy_power_button_for_test(false); |
| 207 controller_->OnLoginStateChanged(user::LOGGED_IN_USER); | 216 controller_->OnLoginStateChanged(user::LOGGED_IN_USER); |
| 208 controller_->OnLockStateChanged(false); | 217 controller_->OnLockStateChanged(false); |
| 209 EXPECT_FALSE(test_api_->BackgroundLayerIsVisible()); | 218 EXPECT_FALSE(test_api_->BackgroundLayerIsVisible()); |
| 210 | 219 |
| 211 // We should initially be showing the screen locker containers, since they | 220 // We should initially be showing the screen locker containers, since they |
| 212 // also contain login-related windows that we want to show during the | 221 // also contain login-related windows that we want to show during the |
| 213 // logging-in animation. | 222 // logging-in animation. |
| 214 EXPECT_TRUE( | 223 EXPECT_TRUE( |
| 215 test_api_->ContainerGroupIsAnimated( | 224 test_api_->ContainerGroupIsAnimated( |
| 216 PowerButtonController::SCREEN_LOCKER_CONTAINERS, | 225 PowerButtonController::SCREEN_LOCKER_CONTAINERS_EXCEPT_WALLPAPER, |
| 217 PowerButtonController::ANIMATION_RESTORE)); | 226 PowerButtonController::ANIMATION_RESTORE)); |
| 218 | 227 |
| 219 // Press the power button and check that the lock timer is started and that we | 228 // Press the power button and check that the lock timer is started and that we |
| 220 // start scaling the non-screen-locker containers. | 229 // start scaling the non-screen-locker containers. |
| 221 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); | 230 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
| 222 EXPECT_TRUE(test_api_->lock_timer_is_running()); | 231 EXPECT_TRUE(test_api_->lock_timer_is_running()); |
| 223 EXPECT_FALSE(test_api_->shutdown_timer_is_running()); | 232 EXPECT_FALSE(test_api_->shutdown_timer_is_running()); |
| 224 EXPECT_TRUE( | 233 EXPECT_TRUE( |
| 225 test_api_->ContainerGroupIsAnimated( | 234 test_api_->ContainerGroupIsAnimated( |
| 226 PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, | 235 PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 253 EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); | 262 EXPECT_TRUE(test_api_->BackgroundLayerIsVisible()); |
| 254 | 263 |
| 255 // Notify that we locked successfully. | 264 // Notify that we locked successfully. |
| 256 controller_->OnStartingLock(); | 265 controller_->OnStartingLock(); |
| 257 EXPECT_TRUE( | 266 EXPECT_TRUE( |
| 258 test_api_->ContainerGroupIsAnimated( | 267 test_api_->ContainerGroupIsAnimated( |
| 259 PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, | 268 PowerButtonController::ALL_BUT_SCREEN_LOCKER_AND_RELATED_CONTAINERS, |
| 260 PowerButtonController::ANIMATION_FAST_CLOSE)); | 269 PowerButtonController::ANIMATION_FAST_CLOSE)); |
| 261 EXPECT_TRUE( | 270 EXPECT_TRUE( |
| 262 test_api_->ContainerGroupIsAnimated( | 271 test_api_->ContainerGroupIsAnimated( |
| 263 PowerButtonController::SCREEN_LOCKER_CONTAINERS, | 272 PowerButtonController::SCREEN_LOCKER_CONTAINERS_EXCEPT_WALLPAPER, |
| 264 PowerButtonController::ANIMATION_HIDE)); | 273 PowerButtonController::ANIMATION_HIDE)); |
| 265 | 274 |
| 266 // Notify that the lock window is visible. We should make it fade in. | 275 // Notify that the lock window is visible. We should make it fade in. |
| 267 controller_->OnLockStateChanged(true); | 276 controller_->OnLockStateChanged(true); |
| 268 EXPECT_TRUE( | 277 EXPECT_TRUE( |
| 269 test_api_->ContainerGroupIsAnimated( | 278 test_api_->ContainerGroupIsAnimated( |
| 270 PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS, | 279 PowerButtonController::SCREEN_LOCKER_AND_RELATED_CONTAINERS, |
| 271 PowerButtonController::ANIMATION_FADE_IN)); | 280 PowerButtonController::ANIMATION_FADE_IN)); |
| 272 | 281 |
| 273 // When we release the power button, the lock-to-shutdown timer should be | 282 // When we release the power button, the lock-to-shutdown timer should be |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 | 567 |
| 559 // After increasing the brightness to 10%, we should start the timer like | 568 // After increasing the brightness to 10%, we should start the timer like |
| 560 // usual. | 569 // usual. |
| 561 controller_->OnScreenBrightnessChanged(10.0); | 570 controller_->OnScreenBrightnessChanged(10.0); |
| 562 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); | 571 controller_->OnPowerButtonEvent(true, base::TimeTicks::Now()); |
| 563 EXPECT_TRUE(test_api_->lock_timer_is_running()); | 572 EXPECT_TRUE(test_api_->lock_timer_is_running()); |
| 564 } | 573 } |
| 565 | 574 |
| 566 } // namespace test | 575 } // namespace test |
| 567 } // namespace ash | 576 } // namespace ash |
| OLD | NEW |