| 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/session_state_controller_impl2.h" | |
| 6 | |
| 7 #include "ash/ash_switches.h" | 5 #include "ash/ash_switches.h" |
| 8 #include "ash/session_state_delegate.h" | 6 #include "ash/session_state_delegate.h" |
| 9 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
| 11 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/test/test_shell_delegate.h" | 10 #include "ash/test/test_shell_delegate.h" |
| 11 #include "ash/wm/lock_state_controller.h" |
| 12 #include "ash/wm/lock_state_controller_impl2.h" |
| 13 #include "ash/wm/power_button_controller.h" | 13 #include "ash/wm/power_button_controller.h" |
| 14 #include "ash/wm/session_state_animator.h" | 14 #include "ash/wm/session_state_animator.h" |
| 15 #include "ash/wm/session_state_controller.h" | |
| 16 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 17 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 18 #include "base/time.h" | 17 #include "base/time.h" |
| 19 #include "ui/aura/env.h" | 18 #include "ui/aura/env.h" |
| 20 #include "ui/aura/root_window.h" | 19 #include "ui/aura/root_window.h" |
| 21 #include "ui/aura/test/event_generator.h" | 20 #include "ui/aura/test/event_generator.h" |
| 22 #include "ui/compositor/layer_animator.h" | 21 #include "ui/compositor/layer_animator.h" |
| 23 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 22 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 24 #include "ui/compositor/scoped_layer_animation_settings.h" | 23 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 25 #include "ui/gfx/rect.h" | 24 #include "ui/gfx/rect.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)-> | 68 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)-> |
| 70 layer()->GetAnimator()); | 69 layer()->GetAnimator()); |
| 71 settings.SetTransitionDuration(base::TimeDelta()); | 70 settings.SetTransitionDuration(base::TimeDelta()); |
| 72 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)->Hide(); | 71 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)->Hide(); |
| 73 } | 72 } |
| 74 | 73 |
| 75 } // namespace | 74 } // namespace |
| 76 | 75 |
| 77 // Fake implementation of PowerButtonControllerDelegate that just logs requests | 76 // Fake implementation of PowerButtonControllerDelegate that just logs requests |
| 78 // to lock the screen and shut down the device. | 77 // to lock the screen and shut down the device. |
| 79 class TestSessionStateControllerDelegate : | 78 class TestLockStateControllerDelegate : public LockStateControllerDelegate { |
| 80 public SessionStateControllerDelegate { | |
| 81 public: | 79 public: |
| 82 TestSessionStateControllerDelegate() | 80 TestLockStateControllerDelegate() |
| 83 : num_lock_requests_(0), | 81 : num_lock_requests_(0), |
| 84 num_shutdown_requests_(0) {} | 82 num_shutdown_requests_(0) {} |
| 85 | 83 |
| 86 int num_lock_requests() const { return num_lock_requests_; } | 84 int num_lock_requests() const { return num_lock_requests_; } |
| 87 int num_shutdown_requests() const { return num_shutdown_requests_; } | 85 int num_shutdown_requests() const { return num_shutdown_requests_; } |
| 88 | 86 |
| 89 // SessionStateControllerDelegate implementation. | 87 // LockStateControllerDelegate implementation. |
| 90 virtual void RequestLockScreen() OVERRIDE { | 88 virtual void RequestLockScreen() OVERRIDE { |
| 91 num_lock_requests_++; | 89 num_lock_requests_++; |
| 92 } | 90 } |
| 93 virtual void RequestShutdown() OVERRIDE { | 91 virtual void RequestShutdown() OVERRIDE { |
| 94 num_shutdown_requests_++; | 92 num_shutdown_requests_++; |
| 95 } | 93 } |
| 96 | 94 |
| 97 private: | 95 private: |
| 98 int num_lock_requests_; | 96 int num_lock_requests_; |
| 99 int num_shutdown_requests_; | 97 int num_shutdown_requests_; |
| 100 | 98 |
| 101 DISALLOW_COPY_AND_ASSIGN(TestSessionStateControllerDelegate); | 99 DISALLOW_COPY_AND_ASSIGN(TestLockStateControllerDelegate); |
| 102 }; | 100 }; |
| 103 | 101 |
| 104 class SessionStateControllerImpl2Test : public AshTestBase { | 102 class LockStateControllerImpl2Test : public AshTestBase { |
| 105 public: | 103 public: |
| 106 SessionStateControllerImpl2Test() : controller_(NULL), delegate_(NULL) {} | 104 LockStateControllerImpl2Test() : controller_(NULL), delegate_(NULL) {} |
| 107 virtual ~SessionStateControllerImpl2Test() {} | 105 virtual ~LockStateControllerImpl2Test() {} |
| 108 | 106 |
| 109 virtual void SetUp() OVERRIDE { | 107 virtual void SetUp() OVERRIDE { |
| 110 CHECK(!CommandLine::ForCurrentProcess()->HasSwitch( | 108 CHECK(!CommandLine::ForCurrentProcess()->HasSwitch( |
| 111 ash::switches::kAshDisableNewLockAnimations)); | 109 ash::switches::kAshDisableNewLockAnimations)); |
| 112 | 110 |
| 113 AshTestBase::SetUp(); | 111 AshTestBase::SetUp(); |
| 114 | 112 |
| 115 // We would control animations in a fine way: | 113 // We would control animations in a fine way: |
| 116 animation_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( | 114 animation_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( |
| 117 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION)); | 115 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION)); |
| 118 // TODO(antrim) : restore | 116 // TODO(antrim) : restore |
| 119 // animator_helper_ = ui::test::CreateLayerAnimatorHelperForTest(); | 117 // animator_helper_ = ui::test::CreateLayerAnimatorHelperForTest(); |
| 120 | 118 |
| 121 // Temporary disable animations so that observer is always called, and | 119 // Temporary disable animations so that observer is always called, and |
| 122 // no leaks happen during tests. | 120 // no leaks happen during tests. |
| 123 animation_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( | 121 animation_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( |
| 124 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); | 122 ui::ScopedAnimationDurationScaleMode::ZERO_DURATION)); |
| 125 // TODO(antrim): once there is a way to mock time and run animations, make | 123 // TODO(antrim): once there is a way to mock time and run animations, make |
| 126 // sure that animations are finished even in simple tests. | 124 // sure that animations are finished even in simple tests. |
| 127 | 125 |
| 128 delegate_ = new TestSessionStateControllerDelegate; | 126 delegate_ = new TestLockStateControllerDelegate; |
| 129 controller_ = Shell::GetInstance()->power_button_controller(); | 127 controller_ = Shell::GetInstance()->power_button_controller(); |
| 130 state_controller_ = static_cast<SessionStateControllerImpl2*>( | 128 lock_state_controller_ = static_cast<LockStateControllerImpl2*>( |
| 131 Shell::GetInstance()->session_state_controller()); | 129 Shell::GetInstance()->lock_state_controller()); |
| 132 state_controller_->SetDelegate(delegate_); // transfers ownership | 130 lock_state_controller_->SetDelegate(delegate_); // transfers ownership |
| 133 test_api_.reset( | 131 test_api_.reset( |
| 134 new SessionStateControllerImpl2::TestApi(state_controller_)); | 132 new LockStateControllerImpl2::TestApi(lock_state_controller_)); |
| 135 animator_api_.reset( | 133 animator_api_.reset( |
| 136 new SessionStateAnimator::TestApi(state_controller_-> | 134 new SessionStateAnimator::TestApi(lock_state_controller_-> |
| 137 animator_.get())); | 135 animator_.get())); |
| 138 shell_delegate_ = reinterpret_cast<TestShellDelegate*>( | 136 shell_delegate_ = reinterpret_cast<TestShellDelegate*>( |
| 139 ash::Shell::GetInstance()->delegate()); | 137 ash::Shell::GetInstance()->delegate()); |
| 140 state_delegate_ = Shell::GetInstance()->session_state_delegate(); | 138 session_state_delegate_ = Shell::GetInstance()->session_state_delegate(); |
| 141 } | 139 } |
| 142 | 140 |
| 143 virtual void TearDown() { | 141 virtual void TearDown() { |
| 144 // TODO(antrim) : restore | 142 // TODO(antrim) : restore |
| 145 // animator_helper_->AdvanceUntilDone(); | 143 // animator_helper_->AdvanceUntilDone(); |
| 146 AshTestBase::TearDown(); | 144 AshTestBase::TearDown(); |
| 147 } | 145 } |
| 148 | 146 |
| 149 protected: | 147 protected: |
| 150 void GenerateMouseMoveEvent() { | 148 void GenerateMouseMoveEvent() { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 void ExpectBackgroundIsHiding() { | 302 void ExpectBackgroundIsHiding() { |
| 305 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 303 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
| 306 EXPECT_TRUE( | 304 EXPECT_TRUE( |
| 307 animator_api_->ContainersAreAnimated( | 305 animator_api_->ContainersAreAnimated( |
| 308 SessionStateAnimator::DESKTOP_BACKGROUND, | 306 SessionStateAnimator::DESKTOP_BACKGROUND, |
| 309 SessionStateAnimator::ANIMATION_FADE_OUT)); | 307 SessionStateAnimator::ANIMATION_FADE_OUT)); |
| 310 } | 308 } |
| 311 | 309 |
| 312 void ExpectUnlockedState() { | 310 void ExpectUnlockedState() { |
| 313 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 311 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
| 314 EXPECT_FALSE(state_delegate_->IsScreenLocked()); | 312 EXPECT_FALSE(session_state_delegate_->IsScreenLocked()); |
| 315 | 313 |
| 316 aura::Window::Windows containers; | 314 aura::Window::Windows containers; |
| 317 | 315 |
| 318 SessionStateAnimator::GetContainers( | 316 SessionStateAnimator::GetContainers( |
| 319 SessionStateAnimator::LAUNCHER | | 317 SessionStateAnimator::LAUNCHER | |
| 320 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 318 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 321 &containers); | 319 &containers); |
| 322 for (aura::Window::Windows::const_iterator it = containers.begin(); | 320 for (aura::Window::Windows::const_iterator it = containers.begin(); |
| 323 it != containers.end(); ++it) { | 321 it != containers.end(); ++it) { |
| 324 aura::Window* window = *it; | 322 aura::Window* window = *it; |
| 325 ui::Layer* layer = window->layer(); | 323 ui::Layer* layer = window->layer(); |
| 326 EXPECT_EQ(1.0f, layer->opacity()); | 324 EXPECT_EQ(1.0f, layer->opacity()); |
| 327 EXPECT_EQ(0.0f, layer->layer_brightness()); | 325 EXPECT_EQ(0.0f, layer->layer_brightness()); |
| 328 EXPECT_EQ(0.0f, layer->layer_saturation()); | 326 EXPECT_EQ(0.0f, layer->layer_saturation()); |
| 329 EXPECT_EQ(gfx::Transform(), layer->transform()); | 327 EXPECT_EQ(gfx::Transform(), layer->transform()); |
| 330 } | 328 } |
| 331 } | 329 } |
| 332 | 330 |
| 333 void ExpectLockedState() { | 331 void ExpectLockedState() { |
| 334 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 332 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
| 335 EXPECT_TRUE(state_delegate_->IsScreenLocked()); | 333 EXPECT_TRUE(session_state_delegate_->IsScreenLocked()); |
| 336 | 334 |
| 337 aura::Window::Windows containers; | 335 aura::Window::Windows containers; |
| 338 | 336 |
| 339 SessionStateAnimator::GetContainers( | 337 SessionStateAnimator::GetContainers( |
| 340 SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS | | 338 SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS | |
| 341 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 339 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 342 &containers); | 340 &containers); |
| 343 for (aura::Window::Windows::const_iterator it = containers.begin(); | 341 for (aura::Window::Windows::const_iterator it = containers.begin(); |
| 344 it != containers.end(); ++it) { | 342 it != containers.end(); ++it) { |
| 345 aura::Window* window = *it; | 343 aura::Window* window = *it; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 363 | 361 |
| 364 void PressLockButton() { | 362 void PressLockButton() { |
| 365 controller_->OnLockButtonEvent(true, base::TimeTicks::Now()); | 363 controller_->OnLockButtonEvent(true, base::TimeTicks::Now()); |
| 366 } | 364 } |
| 367 | 365 |
| 368 void ReleaseLockButton() { | 366 void ReleaseLockButton() { |
| 369 controller_->OnLockButtonEvent(false, base::TimeTicks::Now()); | 367 controller_->OnLockButtonEvent(false, base::TimeTicks::Now()); |
| 370 } | 368 } |
| 371 | 369 |
| 372 void SystemLocks() { | 370 void SystemLocks() { |
| 373 state_controller_->OnLockStateChanged(true); | 371 lock_state_controller_->OnLockStateChanged(true); |
| 374 state_delegate_->LockScreen(); | 372 session_state_delegate_->LockScreen(); |
| 375 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); | 373 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); |
| 376 } | 374 } |
| 377 | 375 |
| 378 void SuccessfulAuthentication(bool* call_flag) { | 376 void SuccessfulAuthentication(bool* call_flag) { |
| 379 base::Closure closure = base::Bind(&CheckCalledCallback, call_flag); | 377 base::Closure closure = base::Bind(&CheckCalledCallback, call_flag); |
| 380 state_controller_->OnLockScreenHide(closure); | 378 lock_state_controller_->OnLockScreenHide(closure); |
| 381 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); | 379 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); |
| 382 } | 380 } |
| 383 | 381 |
| 384 void SystemUnlocks() { | 382 void SystemUnlocks() { |
| 385 state_controller_->OnLockStateChanged(false); | 383 lock_state_controller_->OnLockStateChanged(false); |
| 386 state_delegate_->UnlockScreen(); | 384 session_state_delegate_->UnlockScreen(); |
| 387 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); | 385 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); |
| 388 } | 386 } |
| 389 | 387 |
| 390 void Initialize(bool legacy_button, user::LoginStatus status) { | 388 void Initialize(bool legacy_button, user::LoginStatus status) { |
| 391 controller_->set_has_legacy_power_button_for_test(legacy_button); | 389 controller_->set_has_legacy_power_button_for_test(legacy_button); |
| 392 state_controller_->OnLoginStateChanged(status); | 390 lock_state_controller_->OnLoginStateChanged(status); |
| 393 SetUserLoggedIn(status != user::LOGGED_IN_NONE); | 391 SetUserLoggedIn(status != user::LOGGED_IN_NONE); |
| 394 if (status == user::LOGGED_IN_GUEST) | 392 if (status == user::LOGGED_IN_GUEST) |
| 395 SetCanLockScreen(false); | 393 SetCanLockScreen(false); |
| 396 state_controller_->OnLockStateChanged(false); | 394 lock_state_controller_->OnLockStateChanged(false); |
| 397 } | 395 } |
| 398 | 396 |
| 399 PowerButtonController* controller_; // not owned | 397 PowerButtonController* controller_; // not owned |
| 400 SessionStateControllerImpl2* state_controller_; // not owned | 398 LockStateControllerImpl2* lock_state_controller_; // not owned |
| 401 TestSessionStateControllerDelegate* delegate_; // not owned | 399 TestLockStateControllerDelegate* delegate_; // not owned |
| 402 TestShellDelegate* shell_delegate_; // not owned | 400 TestShellDelegate* shell_delegate_; // not owned |
| 403 SessionStateDelegate* state_delegate_; // not owned | 401 SessionStateDelegate* session_state_delegate_; // not owned |
| 404 | 402 |
| 405 scoped_ptr<ui::ScopedAnimationDurationScaleMode> animation_duration_mode_; | 403 scoped_ptr<ui::ScopedAnimationDurationScaleMode> animation_duration_mode_; |
| 406 scoped_ptr<SessionStateControllerImpl2::TestApi> test_api_; | 404 scoped_ptr<LockStateControllerImpl2::TestApi> test_api_; |
| 407 scoped_ptr<SessionStateAnimator::TestApi> animator_api_; | 405 scoped_ptr<SessionStateAnimator::TestApi> animator_api_; |
| 408 // TODO(antrim) : restore | 406 // TODO(antrim) : restore |
| 409 // scoped_ptr<ui::test::AnimationContainerTestHelper> animator_helper_; | 407 // scoped_ptr<ui::test::AnimationContainerTestHelper> animator_helper_; |
| 410 | 408 |
| 411 private: | 409 private: |
| 412 DISALLOW_COPY_AND_ASSIGN(SessionStateControllerImpl2Test); | 410 DISALLOW_COPY_AND_ASSIGN(LockStateControllerImpl2Test); |
| 413 }; | 411 }; |
| 414 | 412 |
| 415 // Test the lock-to-shutdown flow for non-Chrome-OS hardware that doesn't | 413 // Test the lock-to-shutdown flow for non-Chrome-OS hardware that doesn't |
| 416 // correctly report power button releases. We should lock immediately the first | 414 // correctly report power button releases. We should lock immediately the first |
| 417 // time the button is pressed and shut down when it's pressed from the locked | 415 // time the button is pressed and shut down when it's pressed from the locked |
| 418 // state. | 416 // state. |
| 419 // TODO(antrim): Reenable this: http://crbug.com/167048 | 417 // TODO(antrim): Reenable this: http://crbug.com/167048 |
| 420 TEST_F(SessionStateControllerImpl2Test, DISABLED_LegacyLockAndShutDown) { | 418 TEST_F(LockStateControllerImpl2Test, DISABLED_LegacyLockAndShutDown) { |
| 421 Initialize(true, user::LOGGED_IN_USER); | 419 Initialize(true, user::LOGGED_IN_USER); |
| 422 | 420 |
| 423 ExpectUnlockedState(); | 421 ExpectUnlockedState(); |
| 424 | 422 |
| 425 // We should request that the screen be locked immediately after seeing the | 423 // We should request that the screen be locked immediately after seeing the |
| 426 // power button get pressed. | 424 // power button get pressed. |
| 427 PressPowerButton(); | 425 PressPowerButton(); |
| 428 | 426 |
| 429 ExpectPreLockAnimationStarted(); | 427 ExpectPreLockAnimationStarted(); |
| 430 | 428 |
| 431 EXPECT_FALSE(test_api_->is_lock_cancellable()); | 429 EXPECT_FALSE(test_api_->is_lock_cancellable()); |
| 432 | 430 |
| 433 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 431 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 434 | 432 |
| 435 ExpectPreLockAnimationFinished(); | 433 ExpectPreLockAnimationFinished(); |
| 436 EXPECT_EQ(1, delegate_->num_lock_requests()); | 434 EXPECT_EQ(1, delegate_->num_lock_requests()); |
| 437 | 435 |
| 438 // Notify that we locked successfully. | 436 // Notify that we locked successfully. |
| 439 state_controller_->OnStartingLock(); | 437 lock_state_controller_->OnStartingLock(); |
| 440 // We had that animation already. | 438 // We had that animation already. |
| 441 //TODO (antrim) : restore | 439 //TODO (antrim) : restore |
| 442 // EXPECT_FALSE(animator_helper_->IsAnimating()); | 440 // EXPECT_FALSE(animator_helper_->IsAnimating()); |
| 443 | 441 |
| 444 SystemLocks(); | 442 SystemLocks(); |
| 445 | 443 |
| 446 ExpectPostLockAnimationStarted(); | 444 ExpectPostLockAnimationStarted(); |
| 447 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 445 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 448 ExpectPastLockAnimationFinished(); | 446 ExpectPastLockAnimationFinished(); |
| 449 | 447 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 463 GenerateMouseMoveEvent(); | 461 GenerateMouseMoveEvent(); |
| 464 EXPECT_FALSE(cursor_visible()); | 462 EXPECT_FALSE(cursor_visible()); |
| 465 | 463 |
| 466 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); | 464 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
| 467 test_api_->trigger_real_shutdown_timeout(); | 465 test_api_->trigger_real_shutdown_timeout(); |
| 468 EXPECT_EQ(1, NumShutdownRequests()); | 466 EXPECT_EQ(1, NumShutdownRequests()); |
| 469 } | 467 } |
| 470 | 468 |
| 471 // Test that we start shutting down immediately if the power button is pressed | 469 // Test that we start shutting down immediately if the power button is pressed |
| 472 // while we're not logged in on an unofficial system. | 470 // while we're not logged in on an unofficial system. |
| 473 TEST_F(SessionStateControllerImpl2Test, LegacyNotLoggedIn) { | 471 TEST_F(LockStateControllerImpl2Test, LegacyNotLoggedIn) { |
| 474 Initialize(true, user::LOGGED_IN_NONE); | 472 Initialize(true, user::LOGGED_IN_NONE); |
| 475 | 473 |
| 476 PressPowerButton(); | 474 PressPowerButton(); |
| 477 ExpectShutdownAnimationStarted(); | 475 ExpectShutdownAnimationStarted(); |
| 478 | 476 |
| 479 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); | 477 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
| 480 } | 478 } |
| 481 | 479 |
| 482 // Test that we start shutting down immediately if the power button is pressed | 480 // Test that we start shutting down immediately if the power button is pressed |
| 483 // while we're logged in as a guest on an unofficial system. | 481 // while we're logged in as a guest on an unofficial system. |
| 484 TEST_F(SessionStateControllerImpl2Test, LegacyGuest) { | 482 TEST_F(LockStateControllerImpl2Test, LegacyGuest) { |
| 485 Initialize(true, user::LOGGED_IN_GUEST); | 483 Initialize(true, user::LOGGED_IN_GUEST); |
| 486 | 484 |
| 487 PressPowerButton(); | 485 PressPowerButton(); |
| 488 ExpectShutdownAnimationStarted(); | 486 ExpectShutdownAnimationStarted(); |
| 489 | 487 |
| 490 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); | 488 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
| 491 } | 489 } |
| 492 | 490 |
| 493 // When we hold the power button while the user isn't logged in, we should shut | 491 // When we hold the power button while the user isn't logged in, we should shut |
| 494 // down the machine directly. | 492 // down the machine directly. |
| 495 TEST_F(SessionStateControllerImpl2Test, ShutdownWhenNotLoggedIn) { | 493 TEST_F(LockStateControllerImpl2Test, ShutdownWhenNotLoggedIn) { |
| 496 Initialize(false, user::LOGGED_IN_NONE); | 494 Initialize(false, user::LOGGED_IN_NONE); |
| 497 | 495 |
| 498 // Press the power button and check that we start the shutdown timer. | 496 // Press the power button and check that we start the shutdown timer. |
| 499 PressPowerButton(); | 497 PressPowerButton(); |
| 500 EXPECT_FALSE(test_api_->is_animating_lock()); | 498 EXPECT_FALSE(test_api_->is_animating_lock()); |
| 501 EXPECT_TRUE(test_api_->shutdown_timer_is_running()); | 499 EXPECT_TRUE(test_api_->shutdown_timer_is_running()); |
| 502 ExpectShutdownAnimationStarted(); | 500 ExpectShutdownAnimationStarted(); |
| 503 | 501 |
| 504 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN, 0.5f); | 502 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN, 0.5f); |
| 505 | 503 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 525 EXPECT_EQ(0, NumShutdownRequests()); | 523 EXPECT_EQ(0, NumShutdownRequests()); |
| 526 | 524 |
| 527 // When the timout fires, we should request a shutdown. | 525 // When the timout fires, we should request a shutdown. |
| 528 test_api_->trigger_real_shutdown_timeout(); | 526 test_api_->trigger_real_shutdown_timeout(); |
| 529 | 527 |
| 530 EXPECT_EQ(1, NumShutdownRequests()); | 528 EXPECT_EQ(1, NumShutdownRequests()); |
| 531 } | 529 } |
| 532 | 530 |
| 533 // Test that we lock the screen and deal with unlocking correctly. | 531 // Test that we lock the screen and deal with unlocking correctly. |
| 534 // TODO(antrim): Reenable this: http://crbug.com/167048 | 532 // TODO(antrim): Reenable this: http://crbug.com/167048 |
| 535 TEST_F(SessionStateControllerImpl2Test, DISABLED_LockAndUnlock) { | 533 TEST_F(LockStateControllerImpl2Test, DISABLED_LockAndUnlock) { |
| 536 Initialize(false, user::LOGGED_IN_USER); | 534 Initialize(false, user::LOGGED_IN_USER); |
| 537 | 535 |
| 538 ExpectUnlockedState(); | 536 ExpectUnlockedState(); |
| 539 | 537 |
| 540 // Press the power button and check that the lock timer is started and that we | 538 // Press the power button and check that the lock timer is started and that we |
| 541 // start lifting the non-screen-locker containers. | 539 // start lifting the non-screen-locker containers. |
| 542 PressPowerButton(); | 540 PressPowerButton(); |
| 543 | 541 |
| 544 ExpectPreLockAnimationStarted(); | 542 ExpectPreLockAnimationStarted(); |
| 545 EXPECT_TRUE(test_api_->is_lock_cancellable()); | 543 EXPECT_TRUE(test_api_->is_lock_cancellable()); |
| 546 EXPECT_EQ(0, delegate_->num_lock_requests()); | 544 EXPECT_EQ(0, delegate_->num_lock_requests()); |
| 547 | 545 |
| 548 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); | 546 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
| 549 ExpectPreLockAnimationFinished(); | 547 ExpectPreLockAnimationFinished(); |
| 550 | 548 |
| 551 EXPECT_EQ(1, delegate_->num_lock_requests()); | 549 EXPECT_EQ(1, delegate_->num_lock_requests()); |
| 552 | 550 |
| 553 // Notify that we locked successfully. | 551 // Notify that we locked successfully. |
| 554 state_controller_->OnStartingLock(); | 552 lock_state_controller_->OnStartingLock(); |
| 555 // We had that animation already. | 553 // We had that animation already. |
| 556 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 554 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
| 557 | 555 |
| 558 SystemLocks(); | 556 SystemLocks(); |
| 559 | 557 |
| 560 ExpectPostLockAnimationStarted(); | 558 ExpectPostLockAnimationStarted(); |
| 561 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 559 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 562 ExpectPastLockAnimationFinished(); | 560 ExpectPastLockAnimationFinished(); |
| 563 | 561 |
| 564 // When we release the power button, the lock-to-shutdown timer should be | 562 // When we release the power button, the lock-to-shutdown timer should be |
| (...skipping 20 matching lines...) Expand all Loading... |
| 585 | 583 |
| 586 ExpectUnlockAfterUIDestroyedAnimationStarted(); | 584 ExpectUnlockAfterUIDestroyedAnimationStarted(); |
| 587 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 585 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 588 ExpectUnlockAfterUIDestroyedAnimationFinished(); | 586 ExpectUnlockAfterUIDestroyedAnimationFinished(); |
| 589 | 587 |
| 590 ExpectUnlockedState(); | 588 ExpectUnlockedState(); |
| 591 } | 589 } |
| 592 | 590 |
| 593 // Test that we deal with cancelling lock correctly. | 591 // Test that we deal with cancelling lock correctly. |
| 594 // TODO(antrim): Reenable this: http://crbug.com/167048 | 592 // TODO(antrim): Reenable this: http://crbug.com/167048 |
| 595 TEST_F(SessionStateControllerImpl2Test, DISABLED_LockAndCancel) { | 593 TEST_F(LockStateControllerImpl2Test, DISABLED_LockAndCancel) { |
| 596 Initialize(false, user::LOGGED_IN_USER); | 594 Initialize(false, user::LOGGED_IN_USER); |
| 597 | 595 |
| 598 ExpectUnlockedState(); | 596 ExpectUnlockedState(); |
| 599 | 597 |
| 600 // Press the power button and check that the lock timer is started and that we | 598 // Press the power button and check that the lock timer is started and that we |
| 601 // start lifting the non-screen-locker containers. | 599 // start lifting the non-screen-locker containers. |
| 602 PressPowerButton(); | 600 PressPowerButton(); |
| 603 | 601 |
| 604 ExpectPreLockAnimationStarted(); | 602 ExpectPreLockAnimationStarted(); |
| 605 EXPECT_TRUE(test_api_->is_lock_cancellable()); | 603 EXPECT_TRUE(test_api_->is_lock_cancellable()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 622 // Expect no flickering, animation should proceed from mid-state. | 620 // Expect no flickering, animation should proceed from mid-state. |
| 623 EXPECT_EQ(transform_before_button_released, transform_after_button_released); | 621 EXPECT_EQ(transform_before_button_released, transform_after_button_released); |
| 624 | 622 |
| 625 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 623 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 626 ExpectUnlockedState(); | 624 ExpectUnlockedState(); |
| 627 EXPECT_EQ(0, delegate_->num_lock_requests()); | 625 EXPECT_EQ(0, delegate_->num_lock_requests()); |
| 628 } | 626 } |
| 629 | 627 |
| 630 // Test that we deal with cancelling lock correctly. | 628 // Test that we deal with cancelling lock correctly. |
| 631 // TODO(antrim): Reenable this: http://crbug.com/167048 | 629 // TODO(antrim): Reenable this: http://crbug.com/167048 |
| 632 TEST_F(SessionStateControllerImpl2Test, DISABLED_LockAndCancelAndLockAgain) { | 630 TEST_F(LockStateControllerImpl2Test, |
| 631 DISABLED_LockAndCancelAndLockAgain) { |
| 633 Initialize(false, user::LOGGED_IN_USER); | 632 Initialize(false, user::LOGGED_IN_USER); |
| 634 | 633 |
| 635 ExpectUnlockedState(); | 634 ExpectUnlockedState(); |
| 636 | 635 |
| 637 // Press the power button and check that the lock timer is started and that we | 636 // Press the power button and check that the lock timer is started and that we |
| 638 // start lifting the non-screen-locker containers. | 637 // start lifting the non-screen-locker containers. |
| 639 PressPowerButton(); | 638 PressPowerButton(); |
| 640 | 639 |
| 641 ExpectPreLockAnimationStarted(); | 640 ExpectPreLockAnimationStarted(); |
| 642 EXPECT_TRUE(test_api_->is_lock_cancellable()); | 641 EXPECT_TRUE(test_api_->is_lock_cancellable()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 659 EXPECT_EQ(0, delegate_->num_lock_requests()); | 658 EXPECT_EQ(0, delegate_->num_lock_requests()); |
| 660 ExpectPreLockAnimationStarted(); | 659 ExpectPreLockAnimationStarted(); |
| 661 | 660 |
| 662 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.6f); | 661 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.6f); |
| 663 ExpectPreLockAnimationFinished(); | 662 ExpectPreLockAnimationFinished(); |
| 664 EXPECT_EQ(1, delegate_->num_lock_requests()); | 663 EXPECT_EQ(1, delegate_->num_lock_requests()); |
| 665 } | 664 } |
| 666 | 665 |
| 667 // Hold the power button down from the unlocked state to eventual shutdown. | 666 // Hold the power button down from the unlocked state to eventual shutdown. |
| 668 // TODO(antrim): Reenable this: http://crbug.com/167048 | 667 // TODO(antrim): Reenable this: http://crbug.com/167048 |
| 669 TEST_F(SessionStateControllerImpl2Test, DISABLED_LockToShutdown) { | 668 TEST_F(LockStateControllerImpl2Test, DISABLED_LockToShutdown) { |
| 670 Initialize(false, user::LOGGED_IN_USER); | 669 Initialize(false, user::LOGGED_IN_USER); |
| 671 | 670 |
| 672 // Hold the power button and lock the screen. | 671 // Hold the power button and lock the screen. |
| 673 PressPowerButton(); | 672 PressPowerButton(); |
| 674 EXPECT_TRUE(test_api_->is_animating_lock()); | 673 EXPECT_TRUE(test_api_->is_animating_lock()); |
| 675 | 674 |
| 676 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); | 675 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
| 677 SystemLocks(); | 676 SystemLocks(); |
| 678 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 677 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 679 | 678 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 692 test_api_->trigger_shutdown_timeout(); | 691 test_api_->trigger_shutdown_timeout(); |
| 693 | 692 |
| 694 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); | 693 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
| 695 EXPECT_EQ(0, NumShutdownRequests()); | 694 EXPECT_EQ(0, NumShutdownRequests()); |
| 696 test_api_->trigger_real_shutdown_timeout(); | 695 test_api_->trigger_real_shutdown_timeout(); |
| 697 EXPECT_EQ(1, NumShutdownRequests()); | 696 EXPECT_EQ(1, NumShutdownRequests()); |
| 698 } | 697 } |
| 699 | 698 |
| 700 // Hold the power button down from the unlocked state to eventual shutdown, | 699 // Hold the power button down from the unlocked state to eventual shutdown, |
| 701 // then release the button while system does locking. | 700 // then release the button while system does locking. |
| 702 TEST_F(SessionStateControllerImpl2Test, CancelLockToShutdown) { | 701 TEST_F(LockStateControllerImpl2Test, CancelLockToShutdown) { |
| 703 Initialize(false, user::LOGGED_IN_USER); | 702 Initialize(false, user::LOGGED_IN_USER); |
| 704 | 703 |
| 705 PressPowerButton(); | 704 PressPowerButton(); |
| 706 | 705 |
| 707 // Hold the power button and lock the screen. | 706 // Hold the power button and lock the screen. |
| 708 EXPECT_TRUE(test_api_->is_animating_lock()); | 707 EXPECT_TRUE(test_api_->is_animating_lock()); |
| 709 | 708 |
| 710 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); | 709 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
| 711 SystemLocks(); | 710 SystemLocks(); |
| 712 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, 0.5f); | 711 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS, 0.5f); |
| 713 | 712 |
| 714 // Power button is released while system attempts to lock. | 713 // Power button is released while system attempts to lock. |
| 715 ReleasePowerButton(); | 714 ReleasePowerButton(); |
| 716 | 715 |
| 717 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 716 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 718 | 717 |
| 719 EXPECT_FALSE(state_controller_->ShutdownRequested()); | 718 EXPECT_FALSE(lock_state_controller_->ShutdownRequested()); |
| 720 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); | 719 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); |
| 721 EXPECT_FALSE(test_api_->shutdown_timer_is_running()); | 720 EXPECT_FALSE(test_api_->shutdown_timer_is_running()); |
| 722 } | 721 } |
| 723 | 722 |
| 724 // Test that we handle the case where lock requests are ignored. | 723 // Test that we handle the case where lock requests are ignored. |
| 725 // TODO(antrim): Reenable this: http://crbug.com/167048 | 724 // TODO(antrim): Reenable this: http://crbug.com/167048 |
| 726 TEST_F(SessionStateControllerImpl2Test, DISABLED_Lock) { | 725 TEST_F(LockStateControllerImpl2Test, DISABLED_Lock) { |
| 727 // We require animations to have a duration for this test. | 726 // We require animations to have a duration for this test. |
| 728 ui::ScopedAnimationDurationScaleMode normal_duration_mode( | 727 ui::ScopedAnimationDurationScaleMode normal_duration_mode( |
| 729 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); | 728 ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION); |
| 730 | 729 |
| 731 Initialize(false, user::LOGGED_IN_USER); | 730 Initialize(false, user::LOGGED_IN_USER); |
| 732 | 731 |
| 733 // Hold the power button and lock the screen. | 732 // Hold the power button and lock the screen. |
| 734 PressPowerButton(); | 733 PressPowerButton(); |
| 735 ExpectPreLockAnimationStarted(); | 734 ExpectPreLockAnimationStarted(); |
| 736 | 735 |
| 737 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); | 736 Advance(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE); |
| 738 | 737 |
| 739 EXPECT_EQ(1, delegate_->num_lock_requests()); | 738 EXPECT_EQ(1, delegate_->num_lock_requests()); |
| 740 EXPECT_TRUE(test_api_->lock_fail_timer_is_running()); | 739 EXPECT_TRUE(test_api_->lock_fail_timer_is_running()); |
| 741 // We shouldn't start the lock-to-shutdown timer until the screen has actually | 740 // We shouldn't start the lock-to-shutdown timer until the screen has actually |
| 742 // been locked and this was animated. | 741 // been locked and this was animated. |
| 743 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); | 742 EXPECT_FALSE(test_api_->lock_to_shutdown_timer_is_running()); |
| 744 | 743 |
| 745 // Act as if the request timed out. We should restore the windows. | 744 // Act as if the request timed out. We should restore the windows. |
| 746 test_api_->trigger_lock_fail_timeout(); | 745 test_api_->trigger_lock_fail_timeout(); |
| 747 | 746 |
| 748 ExpectUnlockAfterUIDestroyedAnimationStarted(); | 747 ExpectUnlockAfterUIDestroyedAnimationStarted(); |
| 749 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 748 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 750 ExpectUnlockAfterUIDestroyedAnimationFinished(); | 749 ExpectUnlockAfterUIDestroyedAnimationFinished(); |
| 751 ExpectUnlockedState(); | 750 ExpectUnlockedState(); |
| 752 } | 751 } |
| 753 | 752 |
| 754 // Test the basic operation of the lock button (not logged in). | 753 // Test the basic operation of the lock button (not logged in). |
| 755 TEST_F(SessionStateControllerImpl2Test, LockButtonBasicNotLoggedIn) { | 754 TEST_F(LockStateControllerImpl2Test, LockButtonBasicNotLoggedIn) { |
| 756 // The lock button shouldn't do anything if we aren't logged in. | 755 // The lock button shouldn't do anything if we aren't logged in. |
| 757 Initialize(false, user::LOGGED_IN_NONE); | 756 Initialize(false, user::LOGGED_IN_NONE); |
| 758 | 757 |
| 759 PressLockButton(); | 758 PressLockButton(); |
| 760 EXPECT_FALSE(test_api_->is_animating_lock()); | 759 EXPECT_FALSE(test_api_->is_animating_lock()); |
| 761 ReleaseLockButton(); | 760 ReleaseLockButton(); |
| 762 EXPECT_EQ(0, delegate_->num_lock_requests()); | 761 EXPECT_EQ(0, delegate_->num_lock_requests()); |
| 763 } | 762 } |
| 764 | 763 |
| 765 // Test the basic operation of the lock button (guest). | 764 // Test the basic operation of the lock button (guest). |
| 766 TEST_F(SessionStateControllerImpl2Test, LockButtonBasicGuest) { | 765 TEST_F(LockStateControllerImpl2Test, LockButtonBasicGuest) { |
| 767 // The lock button shouldn't do anything when we're logged in as a guest. | 766 // The lock button shouldn't do anything when we're logged in as a guest. |
| 768 Initialize(false, user::LOGGED_IN_GUEST); | 767 Initialize(false, user::LOGGED_IN_GUEST); |
| 769 | 768 |
| 770 PressLockButton(); | 769 PressLockButton(); |
| 771 EXPECT_FALSE(test_api_->is_animating_lock()); | 770 EXPECT_FALSE(test_api_->is_animating_lock()); |
| 772 ReleaseLockButton(); | 771 ReleaseLockButton(); |
| 773 EXPECT_EQ(0, delegate_->num_lock_requests()); | 772 EXPECT_EQ(0, delegate_->num_lock_requests()); |
| 774 } | 773 } |
| 775 | 774 |
| 776 // Test the basic operation of the lock button. | 775 // Test the basic operation of the lock button. |
| 777 // TODO(antrim): Reenable this: http://crbug.com/167048 | 776 // TODO(antrim): Reenable this: http://crbug.com/167048 |
| 778 TEST_F(SessionStateControllerImpl2Test, DISABLED_LockButtonBasic) { | 777 TEST_F(LockStateControllerImpl2Test, DISABLED_LockButtonBasic) { |
| 779 // If we're logged in as a regular user, we should start the lock timer and | 778 // If we're logged in as a regular user, we should start the lock timer and |
| 780 // the pre-lock animation. | 779 // the pre-lock animation. |
| 781 Initialize(false, user::LOGGED_IN_USER); | 780 Initialize(false, user::LOGGED_IN_USER); |
| 782 | 781 |
| 783 PressLockButton(); | 782 PressLockButton(); |
| 784 ExpectPreLockAnimationStarted(); | 783 ExpectPreLockAnimationStarted(); |
| 785 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); | 784 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); |
| 786 | 785 |
| 787 // If the button is released immediately, we shouldn't lock the screen. | 786 // If the button is released immediately, we shouldn't lock the screen. |
| 788 ReleaseLockButton(); | 787 ReleaseLockButton(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 817 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 816 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 818 ExpectPastLockAnimationFinished(); | 817 ExpectPastLockAnimationFinished(); |
| 819 | 818 |
| 820 PressLockButton(); | 819 PressLockButton(); |
| 821 ReleaseLockButton(); | 820 ReleaseLockButton(); |
| 822 ExpectPastLockAnimationFinished(); | 821 ExpectPastLockAnimationFinished(); |
| 823 } | 822 } |
| 824 | 823 |
| 825 // Test that the power button takes priority over the lock button. | 824 // Test that the power button takes priority over the lock button. |
| 826 // TODO(antrim): Reenable this: http://crbug.com/167048 | 825 // TODO(antrim): Reenable this: http://crbug.com/167048 |
| 827 TEST_F(SessionStateControllerImpl2Test, | 826 TEST_F(LockStateControllerImpl2Test, |
| 828 DISABLED_PowerButtonPreemptsLockButton) { | 827 DISABLED_PowerButtonPreemptsLockButton) { |
| 829 Initialize(false, user::LOGGED_IN_USER); | 828 Initialize(false, user::LOGGED_IN_USER); |
| 830 | 829 |
| 831 // While the lock button is down, hold the power button. | 830 // While the lock button is down, hold the power button. |
| 832 PressLockButton(); | 831 PressLockButton(); |
| 833 ExpectPreLockAnimationStarted(); | 832 ExpectPreLockAnimationStarted(); |
| 834 PressPowerButton(); | 833 PressPowerButton(); |
| 835 ExpectPreLockAnimationStarted(); | 834 ExpectPreLockAnimationStarted(); |
| 836 | 835 |
| 837 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); | 836 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 856 // Releasing the power button should stop the lock timer. | 855 // Releasing the power button should stop the lock timer. |
| 857 ReleasePowerButton(); | 856 ReleasePowerButton(); |
| 858 ExpectPreLockAnimationCancel(); | 857 ExpectPreLockAnimationCancel(); |
| 859 ReleaseLockButton(); | 858 ReleaseLockButton(); |
| 860 ExpectPreLockAnimationCancel(); | 859 ExpectPreLockAnimationCancel(); |
| 861 } | 860 } |
| 862 | 861 |
| 863 // When the screen is locked without going through the usual power-button | 862 // When the screen is locked without going through the usual power-button |
| 864 // slow-close path (e.g. via the wrench menu), test that we still show the | 863 // slow-close path (e.g. via the wrench menu), test that we still show the |
| 865 // fast-close animation. | 864 // fast-close animation. |
| 866 TEST_F(SessionStateControllerImpl2Test, LockWithoutButton) { | 865 TEST_F(LockStateControllerImpl2Test, LockWithoutButton) { |
| 867 Initialize(false, user::LOGGED_IN_USER); | 866 Initialize(false, user::LOGGED_IN_USER); |
| 868 state_controller_->OnStartingLock(); | 867 lock_state_controller_->OnStartingLock(); |
| 869 | 868 |
| 870 ExpectPreLockAnimationStarted(); | 869 ExpectPreLockAnimationStarted(); |
| 871 EXPECT_FALSE(test_api_->is_lock_cancellable()); | 870 EXPECT_FALSE(test_api_->is_lock_cancellable()); |
| 872 | 871 |
| 873 // TODO(antrim): After time-faking is fixed, let the pre-lock animation | 872 // TODO(antrim): After time-faking is fixed, let the pre-lock animation |
| 874 // complete here and check that delegate_->num_lock_requests() is 0 to | 873 // complete here and check that delegate_->num_lock_requests() is 0 to |
| 875 // prevent http://crbug.com/172487 from regressing. | 874 // prevent http://crbug.com/172487 from regressing. |
| 876 } | 875 } |
| 877 | 876 |
| 878 // When we hear that the process is exiting but we haven't had a chance to | 877 // When we hear that the process is exiting but we haven't had a chance to |
| 879 // display an animation, we should just blank the screen. | 878 // display an animation, we should just blank the screen. |
| 880 TEST_F(SessionStateControllerImpl2Test, ShutdownWithoutButton) { | 879 TEST_F(LockStateControllerImpl2Test, ShutdownWithoutButton) { |
| 881 Initialize(false, user::LOGGED_IN_USER); | 880 Initialize(false, user::LOGGED_IN_USER); |
| 882 state_controller_->OnAppTerminating(); | 881 lock_state_controller_->OnAppTerminating(); |
| 883 | 882 |
| 884 EXPECT_TRUE( | 883 EXPECT_TRUE( |
| 885 animator_api_->ContainersAreAnimated( | 884 animator_api_->ContainersAreAnimated( |
| 886 SessionStateAnimator::kAllContainersMask, | 885 SessionStateAnimator::kAllContainersMask, |
| 887 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY)); | 886 SessionStateAnimator::ANIMATION_HIDE_IMMEDIATELY)); |
| 888 GenerateMouseMoveEvent(); | 887 GenerateMouseMoveEvent(); |
| 889 EXPECT_FALSE(cursor_visible()); | 888 EXPECT_FALSE(cursor_visible()); |
| 890 } | 889 } |
| 891 | 890 |
| 892 // Test that we display the fast-close animation and shut down when we get an | 891 // Test that we display the fast-close animation and shut down when we get an |
| 893 // outside request to shut down (e.g. from the login or lock screen). | 892 // outside request to shut down (e.g. from the login or lock screen). |
| 894 TEST_F(SessionStateControllerImpl2Test, RequestShutdownFromLoginScreen) { | 893 TEST_F(LockStateControllerImpl2Test, RequestShutdownFromLoginScreen) { |
| 895 Initialize(false, user::LOGGED_IN_NONE); | 894 Initialize(false, user::LOGGED_IN_NONE); |
| 896 | 895 |
| 897 state_controller_->RequestShutdown(); | 896 lock_state_controller_->RequestShutdown(); |
| 898 | 897 |
| 899 ExpectShutdownAnimationStarted(); | 898 ExpectShutdownAnimationStarted(); |
| 900 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 899 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 901 | 900 |
| 902 GenerateMouseMoveEvent(); | 901 GenerateMouseMoveEvent(); |
| 903 EXPECT_FALSE(cursor_visible()); | 902 EXPECT_FALSE(cursor_visible()); |
| 904 | 903 |
| 905 EXPECT_EQ(0, NumShutdownRequests()); | 904 EXPECT_EQ(0, NumShutdownRequests()); |
| 906 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); | 905 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
| 907 test_api_->trigger_real_shutdown_timeout(); | 906 test_api_->trigger_real_shutdown_timeout(); |
| 908 EXPECT_EQ(1, NumShutdownRequests()); | 907 EXPECT_EQ(1, NumShutdownRequests()); |
| 909 } | 908 } |
| 910 | 909 |
| 911 TEST_F(SessionStateControllerImpl2Test, RequestShutdownFromLockScreen) { | 910 TEST_F(LockStateControllerImpl2Test, RequestShutdownFromLockScreen) { |
| 912 Initialize(false, user::LOGGED_IN_USER); | 911 Initialize(false, user::LOGGED_IN_USER); |
| 913 | 912 |
| 914 SystemLocks(); | 913 SystemLocks(); |
| 915 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 914 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 916 ExpectPastLockAnimationFinished(); | 915 ExpectPastLockAnimationFinished(); |
| 917 | 916 |
| 918 state_controller_->RequestShutdown(); | 917 lock_state_controller_->RequestShutdown(); |
| 919 | 918 |
| 920 ExpectShutdownAnimationStarted(); | 919 ExpectShutdownAnimationStarted(); |
| 921 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 920 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 922 | 921 |
| 923 GenerateMouseMoveEvent(); | 922 GenerateMouseMoveEvent(); |
| 924 EXPECT_FALSE(cursor_visible()); | 923 EXPECT_FALSE(cursor_visible()); |
| 925 | 924 |
| 926 EXPECT_EQ(0, NumShutdownRequests()); | 925 EXPECT_EQ(0, NumShutdownRequests()); |
| 927 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); | 926 EXPECT_TRUE(test_api_->real_shutdown_timer_is_running()); |
| 928 test_api_->trigger_real_shutdown_timeout(); | 927 test_api_->trigger_real_shutdown_timeout(); |
| 929 EXPECT_EQ(1, NumShutdownRequests()); | 928 EXPECT_EQ(1, NumShutdownRequests()); |
| 930 } | 929 } |
| 931 | 930 |
| 932 // TODO(antrim): Reenable this: http://crbug.com/167048 | 931 // TODO(antrim): Reenable this: http://crbug.com/167048 |
| 933 TEST_F(SessionStateControllerImpl2Test, | 932 TEST_F(LockStateControllerImpl2Test, |
| 934 DISABLED_RequestAndCancelShutdownFromLockScreen) { | 933 DISABLED_RequestAndCancelShutdownFromLockScreen) { |
| 935 Initialize(false, user::LOGGED_IN_USER); | 934 Initialize(false, user::LOGGED_IN_USER); |
| 936 | 935 |
| 937 SystemLocks(); | 936 SystemLocks(); |
| 938 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); | 937 Advance(SessionStateAnimator::ANIMATION_SPEED_SHUTDOWN); |
| 939 ExpectLockedState(); | 938 ExpectLockedState(); |
| 940 | 939 |
| 941 // Press the power button and check that we start the shutdown timer. | 940 // Press the power button and check that we start the shutdown timer. |
| 942 PressPowerButton(); | 941 PressPowerButton(); |
| 943 EXPECT_FALSE(test_api_->is_animating_lock()); | 942 EXPECT_FALSE(test_api_->is_animating_lock()); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 960 float grayscale_after_button_release = | 959 float grayscale_after_button_release = |
| 961 Shell::GetPrimaryRootWindow()->layer()->layer_grayscale(); | 960 Shell::GetPrimaryRootWindow()->layer()->layer_grayscale(); |
| 962 // Expect no flickering in undo animation. | 961 // Expect no flickering in undo animation. |
| 963 EXPECT_EQ(grayscale_before_button_release, grayscale_after_button_release); | 962 EXPECT_EQ(grayscale_before_button_release, grayscale_after_button_release); |
| 964 | 963 |
| 965 Advance(SessionStateAnimator::ANIMATION_SPEED_REVERT); | 964 Advance(SessionStateAnimator::ANIMATION_SPEED_REVERT); |
| 966 ExpectLockedState(); | 965 ExpectLockedState(); |
| 967 } | 966 } |
| 968 | 967 |
| 969 // Test that we ignore power button presses when the screen is turned off. | 968 // Test that we ignore power button presses when the screen is turned off. |
| 970 TEST_F(SessionStateControllerImpl2Test, IgnorePowerButtonIfScreenIsOff) { | 969 TEST_F(LockStateControllerImpl2Test, IgnorePowerButtonIfScreenIsOff) { |
| 971 Initialize(false, user::LOGGED_IN_USER); | 970 Initialize(false, user::LOGGED_IN_USER); |
| 972 | 971 |
| 973 // When the screen brightness is at 0%, we shouldn't do anything in response | 972 // When the screen brightness is at 0%, we shouldn't do anything in response |
| 974 // to power button presses. | 973 // to power button presses. |
| 975 controller_->OnScreenBrightnessChanged(0.0); | 974 controller_->OnScreenBrightnessChanged(0.0); |
| 976 | 975 |
| 977 PressPowerButton(); | 976 PressPowerButton(); |
| 978 EXPECT_FALSE(test_api_->is_animating_lock()); | 977 EXPECT_FALSE(test_api_->is_animating_lock()); |
| 979 ReleasePowerButton(); | 978 ReleasePowerButton(); |
| 980 | 979 |
| 981 // After increasing the brightness to 10%, we should start the timer like | 980 // After increasing the brightness to 10%, we should start the timer like |
| 982 // usual. | 981 // usual. |
| 983 controller_->OnScreenBrightnessChanged(10.0); | 982 controller_->OnScreenBrightnessChanged(10.0); |
| 984 | 983 |
| 985 PressPowerButton(); | 984 PressPowerButton(); |
| 986 EXPECT_TRUE(test_api_->is_animating_lock()); | 985 EXPECT_TRUE(test_api_->is_animating_lock()); |
| 987 } | 986 } |
| 988 | 987 |
| 989 // Test that hidden background appears and revers correctly on lock/cancel. | 988 // Test that hidden background appears and revers correctly on lock/cancel. |
| 990 // TODO(antrim): Reenable this: http://crbug.com/167048 | 989 // TODO(antrim): Reenable this: http://crbug.com/167048 |
| 991 TEST_F(SessionStateControllerImpl2Test, | 990 TEST_F(LockStateControllerImpl2Test, |
| 992 DISABLED_TestHiddenBackgroundLockCancel) { | 991 DISABLED_TestHiddenBackgroundLockCancel) { |
| 993 Initialize(false, user::LOGGED_IN_USER); | 992 Initialize(false, user::LOGGED_IN_USER); |
| 994 HideBackground(); | 993 HideBackground(); |
| 995 | 994 |
| 996 EXPECT_TRUE(IsBackgroundHidden()); | 995 EXPECT_TRUE(IsBackgroundHidden()); |
| 997 ExpectUnlockedState(); | 996 ExpectUnlockedState(); |
| 998 PressPowerButton(); | 997 PressPowerButton(); |
| 999 | 998 |
| 1000 ExpectPreLockAnimationStarted(); | 999 ExpectPreLockAnimationStarted(); |
| 1001 EXPECT_FALSE(IsBackgroundHidden()); | 1000 EXPECT_FALSE(IsBackgroundHidden()); |
| 1002 ExpectBackgroundIsShowing(); | 1001 ExpectBackgroundIsShowing(); |
| 1003 | 1002 |
| 1004 // Forward only half way through. | 1003 // Forward only half way through. |
| 1005 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); | 1004 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); |
| 1006 | 1005 |
| 1007 // Release the button before the lock timer fires. | 1006 // Release the button before the lock timer fires. |
| 1008 ReleasePowerButton(); | 1007 ReleasePowerButton(); |
| 1009 ExpectPreLockAnimationCancel(); | 1008 ExpectPreLockAnimationCancel(); |
| 1010 ExpectBackgroundIsHiding(); | 1009 ExpectBackgroundIsHiding(); |
| 1011 EXPECT_FALSE(IsBackgroundHidden()); | 1010 EXPECT_FALSE(IsBackgroundHidden()); |
| 1012 | 1011 |
| 1013 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 1012 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 1014 | 1013 |
| 1015 ExpectUnlockedState(); | 1014 ExpectUnlockedState(); |
| 1016 EXPECT_TRUE(IsBackgroundHidden()); | 1015 EXPECT_TRUE(IsBackgroundHidden()); |
| 1017 } | 1016 } |
| 1018 | 1017 |
| 1019 // Test that hidden background appears and revers correctly on lock/unlock. | 1018 // Test that hidden background appears and revers correctly on lock/unlock. |
| 1020 // TODO(antrim): Reenable this: http://crbug.com/167048 | 1019 // TODO(antrim): Reenable this: http://crbug.com/167048 |
| 1021 TEST_F(SessionStateControllerImpl2Test, | 1020 TEST_F(LockStateControllerImpl2Test, |
| 1022 DISABLED_TestHiddenBackgroundLockUnlock) { | 1021 DISABLED_TestHiddenBackgroundLockUnlock) { |
| 1023 Initialize(false, user::LOGGED_IN_USER); | 1022 Initialize(false, user::LOGGED_IN_USER); |
| 1024 HideBackground(); | 1023 HideBackground(); |
| 1025 | 1024 |
| 1026 EXPECT_TRUE(IsBackgroundHidden()); | 1025 EXPECT_TRUE(IsBackgroundHidden()); |
| 1027 ExpectUnlockedState(); | 1026 ExpectUnlockedState(); |
| 1028 | 1027 |
| 1029 // Press the power button and check that the lock timer is started and that we | 1028 // Press the power button and check that the lock timer is started and that we |
| 1030 // start lifting the non-screen-locker containers. | 1029 // start lifting the non-screen-locker containers. |
| 1031 PressPowerButton(); | 1030 PressPowerButton(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1062 | 1061 |
| 1063 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 1062 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 1064 ExpectUnlockAfterUIDestroyedAnimationFinished(); | 1063 ExpectUnlockAfterUIDestroyedAnimationFinished(); |
| 1065 EXPECT_TRUE(IsBackgroundHidden()); | 1064 EXPECT_TRUE(IsBackgroundHidden()); |
| 1066 | 1065 |
| 1067 ExpectUnlockedState(); | 1066 ExpectUnlockedState(); |
| 1068 } | 1067 } |
| 1069 | 1068 |
| 1070 } // namespace test | 1069 } // namespace test |
| 1071 } // namespace ash | 1070 } // namespace ash |
| OLD | NEW |