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