| 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" | 5 #include "ash/wm/session_state_controller_impl2.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/session_state_delegate.h" | |
| 9 #include "ash/shell.h" | 8 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 9 #include "ash/shell_window_ids.h" |
| 11 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/test/test_shell_delegate.h" | 11 #include "ash/test/test_shell_delegate.h" |
| 13 #include "ash/wm/power_button_controller.h" | 12 #include "ash/wm/power_button_controller.h" |
| 14 #include "ash/wm/session_state_animator.h" | 13 #include "ash/wm/session_state_animator.h" |
| 15 #include "ash/wm/session_state_controller.h" | 14 #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" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 state_controller_ = static_cast<SessionStateControllerImpl2*>( | 130 state_controller_ = static_cast<SessionStateControllerImpl2*>( |
| 132 Shell::GetInstance()->session_state_controller()); | 131 Shell::GetInstance()->session_state_controller()); |
| 133 state_controller_->SetDelegate(delegate_); // transfers ownership | 132 state_controller_->SetDelegate(delegate_); // transfers ownership |
| 134 test_api_.reset( | 133 test_api_.reset( |
| 135 new SessionStateControllerImpl2::TestApi(state_controller_)); | 134 new SessionStateControllerImpl2::TestApi(state_controller_)); |
| 136 animator_api_.reset( | 135 animator_api_.reset( |
| 137 new SessionStateAnimator::TestApi(state_controller_-> | 136 new SessionStateAnimator::TestApi(state_controller_-> |
| 138 animator_.get())); | 137 animator_.get())); |
| 139 shell_delegate_ = reinterpret_cast<TestShellDelegate*>( | 138 shell_delegate_ = reinterpret_cast<TestShellDelegate*>( |
| 140 ash::Shell::GetInstance()->delegate()); | 139 ash::Shell::GetInstance()->delegate()); |
| 141 state_delegate_ = Shell::GetInstance()->session_state_delegate(); | |
| 142 } | 140 } |
| 143 | 141 |
| 144 virtual void TearDown() { | 142 virtual void TearDown() { |
| 145 // TODO(antrim) : restore | 143 // TODO(antrim) : restore |
| 146 // animator_helper_->AdvanceUntilDone(); | 144 // animator_helper_->AdvanceUntilDone(); |
| 147 AshTestBase::TearDown(); | 145 AshTestBase::TearDown(); |
| 148 } | 146 } |
| 149 | 147 |
| 150 protected: | 148 protected: |
| 151 void GenerateMouseMoveEvent() { | 149 void GenerateMouseMoveEvent() { |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 void ExpectBackgroundIsHiding() { | 303 void ExpectBackgroundIsHiding() { |
| 306 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); | 304 //TODO (antrim) : restore EXPECT_TRUE(animator_helper_->IsAnimating()); |
| 307 EXPECT_TRUE( | 305 EXPECT_TRUE( |
| 308 animator_api_->ContainersAreAnimated( | 306 animator_api_->ContainersAreAnimated( |
| 309 SessionStateAnimator::DESKTOP_BACKGROUND, | 307 SessionStateAnimator::DESKTOP_BACKGROUND, |
| 310 SessionStateAnimator::ANIMATION_FADE_OUT)); | 308 SessionStateAnimator::ANIMATION_FADE_OUT)); |
| 311 } | 309 } |
| 312 | 310 |
| 313 void ExpectUnlockedState() { | 311 void ExpectUnlockedState() { |
| 314 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 312 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
| 315 EXPECT_FALSE(state_delegate_->IsScreenLocked()); | 313 EXPECT_FALSE(shell_delegate_->IsScreenLocked()); |
| 316 | 314 |
| 317 aura::Window::Windows containers; | 315 aura::Window::Windows containers; |
| 318 | 316 |
| 319 SessionStateAnimator::GetContainers( | 317 SessionStateAnimator::GetContainers( |
| 320 SessionStateAnimator::LAUNCHER | | 318 SessionStateAnimator::LAUNCHER | |
| 321 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, | 319 SessionStateAnimator::NON_LOCK_SCREEN_CONTAINERS, |
| 322 &containers); | 320 &containers); |
| 323 for (aura::Window::Windows::const_iterator it = containers.begin(); | 321 for (aura::Window::Windows::const_iterator it = containers.begin(); |
| 324 it != containers.end(); ++it) { | 322 it != containers.end(); ++it) { |
| 325 aura::Window* window = *it; | 323 aura::Window* window = *it; |
| 326 ui::Layer* layer = window->layer(); | 324 ui::Layer* layer = window->layer(); |
| 327 EXPECT_EQ(1.0f, layer->opacity()); | 325 EXPECT_EQ(1.0f, layer->opacity()); |
| 328 EXPECT_EQ(0.0f, layer->layer_brightness()); | 326 EXPECT_EQ(0.0f, layer->layer_brightness()); |
| 329 EXPECT_EQ(0.0f, layer->layer_saturation()); | 327 EXPECT_EQ(0.0f, layer->layer_saturation()); |
| 330 EXPECT_EQ(gfx::Transform(), layer->transform()); | 328 EXPECT_EQ(gfx::Transform(), layer->transform()); |
| 331 } | 329 } |
| 332 } | 330 } |
| 333 | 331 |
| 334 void ExpectLockedState() { | 332 void ExpectLockedState() { |
| 335 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); | 333 //TODO (antrim) : restore EXPECT_FALSE(animator_helper_->IsAnimating()); |
| 336 EXPECT_TRUE(state_delegate_->IsScreenLocked()); | 334 EXPECT_TRUE(shell_delegate_->IsScreenLocked()); |
| 337 | 335 |
| 338 aura::Window::Windows containers; | 336 aura::Window::Windows containers; |
| 339 | 337 |
| 340 SessionStateAnimator::GetContainers( | 338 SessionStateAnimator::GetContainers( |
| 341 SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS | | 339 SessionStateAnimator::LOCK_SCREEN_RELATED_CONTAINERS | |
| 342 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, | 340 SessionStateAnimator::LOCK_SCREEN_CONTAINERS, |
| 343 &containers); | 341 &containers); |
| 344 for (aura::Window::Windows::const_iterator it = containers.begin(); | 342 for (aura::Window::Windows::const_iterator it = containers.begin(); |
| 345 it != containers.end(); ++it) { | 343 it != containers.end(); ++it) { |
| 346 aura::Window* window = *it; | 344 aura::Window* window = *it; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 365 void PressLockButton() { | 363 void PressLockButton() { |
| 366 controller_->OnLockButtonEvent(true, base::TimeTicks::Now()); | 364 controller_->OnLockButtonEvent(true, base::TimeTicks::Now()); |
| 367 } | 365 } |
| 368 | 366 |
| 369 void ReleaseLockButton() { | 367 void ReleaseLockButton() { |
| 370 controller_->OnLockButtonEvent(false, base::TimeTicks::Now()); | 368 controller_->OnLockButtonEvent(false, base::TimeTicks::Now()); |
| 371 } | 369 } |
| 372 | 370 |
| 373 void SystemLocks() { | 371 void SystemLocks() { |
| 374 state_controller_->OnLockStateChanged(true); | 372 state_controller_->OnLockStateChanged(true); |
| 375 state_delegate_->LockScreen(); | 373 shell_delegate_->LockScreen(); |
| 376 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); | 374 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); |
| 377 } | 375 } |
| 378 | 376 |
| 379 void SuccessfulAuthentication(bool* call_flag) { | 377 void SuccessfulAuthentication(bool* call_flag) { |
| 380 base::Closure closure = base::Bind(&CheckCalledCallback, call_flag); | 378 base::Closure closure = base::Bind(&CheckCalledCallback, call_flag); |
| 381 state_controller_->OnLockScreenHide(closure); | 379 state_controller_->OnLockScreenHide(closure); |
| 382 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); | 380 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); |
| 383 } | 381 } |
| 384 | 382 |
| 385 void SystemUnlocks() { | 383 void SystemUnlocks() { |
| 386 state_controller_->OnLockStateChanged(false); | 384 state_controller_->OnLockStateChanged(false); |
| 387 state_delegate_->UnlockScreen(); | 385 shell_delegate_->UnlockScreen(); |
| 388 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); | 386 //TODO (antrim) : restore animator_helper_->Advance(base::TimeDelta()); |
| 389 } | 387 } |
| 390 | 388 |
| 391 void Initialize(bool legacy_button, user::LoginStatus status) { | 389 void Initialize(bool legacy_button, user::LoginStatus status) { |
| 392 controller_->set_has_legacy_power_button_for_test(legacy_button); | 390 controller_->set_has_legacy_power_button_for_test(legacy_button); |
| 393 state_controller_->OnLoginStateChanged(status); | 391 state_controller_->OnLoginStateChanged(status); |
| 394 SetUserLoggedIn(status != user::LOGGED_IN_NONE); | 392 SetUserLoggedIn(status != user::LOGGED_IN_NONE); |
| 395 if (status == user::LOGGED_IN_GUEST) | 393 if (status == user::LOGGED_IN_GUEST) |
| 396 SetCanLockScreen(false); | 394 SetCanLockScreen(false); |
| 397 state_controller_->OnLockStateChanged(false); | 395 state_controller_->OnLockStateChanged(false); |
| 398 } | 396 } |
| 399 | 397 |
| 400 PowerButtonController* controller_; // not owned | 398 PowerButtonController* controller_; // not owned |
| 401 SessionStateControllerImpl2* state_controller_; // not owned | 399 SessionStateControllerImpl2* state_controller_; // not owned |
| 402 TestSessionStateControllerDelegate* delegate_; // not owned | 400 TestSessionStateControllerDelegate* delegate_; // not owned |
| 403 TestShellDelegate* shell_delegate_; // not owned | 401 TestShellDelegate* shell_delegate_; // not owned |
| 404 SessionStateDelegate* state_delegate_; // not owned | |
| 405 | 402 |
| 406 scoped_ptr<ui::ScopedAnimationDurationScaleMode> animation_duration_mode_; | 403 scoped_ptr<ui::ScopedAnimationDurationScaleMode> animation_duration_mode_; |
| 407 scoped_ptr<SessionStateControllerImpl2::TestApi> test_api_; | 404 scoped_ptr<SessionStateControllerImpl2::TestApi> test_api_; |
| 408 scoped_ptr<SessionStateAnimator::TestApi> animator_api_; | 405 scoped_ptr<SessionStateAnimator::TestApi> animator_api_; |
| 409 // TODO(antrim) : restore | 406 // TODO(antrim) : restore |
| 410 // scoped_ptr<ui::test::AnimationContainerTestHelper> animator_helper_; | 407 // scoped_ptr<ui::test::AnimationContainerTestHelper> animator_helper_; |
| 411 | 408 |
| 412 private: | 409 private: |
| 413 DISALLOW_COPY_AND_ASSIGN(SessionStateControllerImpl2Test); | 410 DISALLOW_COPY_AND_ASSIGN(SessionStateControllerImpl2Test); |
| 414 }; | 411 }; |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1063 | 1060 |
| 1064 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 1061 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 1065 ExpectUnlockAfterUIDestroyedAnimationFinished(); | 1062 ExpectUnlockAfterUIDestroyedAnimationFinished(); |
| 1066 EXPECT_TRUE(IsBackgroundHidden()); | 1063 EXPECT_TRUE(IsBackgroundHidden()); |
| 1067 | 1064 |
| 1068 ExpectUnlockedState(); | 1065 ExpectUnlockedState(); |
| 1069 } | 1066 } |
| 1070 | 1067 |
| 1071 } // namespace test | 1068 } // namespace test |
| 1072 } // namespace ash | 1069 } // namespace ash |
| OLD | NEW |