OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/lock_state_controller.h" | 5 #include "ash/wm/lock_state_controller.h" |
6 | 6 |
7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
8 #include "ash/session_state_delegate.h" | 8 #include "ash/session_state_delegate.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 #include "ui/display/chromeos/output_configurator.h" | 29 #include "ui/display/chromeos/output_configurator.h" |
30 #include "ui/display/chromeos/test/test_display_snapshot.h" | 30 #include "ui/display/chromeos/test/test_display_snapshot.h" |
31 #include "ui/display/display_constants.h" | 31 #include "ui/display/display_constants.h" |
32 #endif | 32 #endif |
33 | 33 |
34 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
35 #include "base/win/windows_version.h" | 35 #include "base/win/windows_version.h" |
36 #endif | 36 #endif |
37 | 37 |
38 namespace ash { | 38 namespace ash { |
39 | |
40 using internal::SessionStateAnimator; | |
41 | |
42 namespace test { | 39 namespace test { |
43 | |
44 namespace { | 40 namespace { |
45 | 41 |
46 bool cursor_visible() { | 42 bool cursor_visible() { |
47 return ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible(); | 43 return ash::Shell::GetInstance()->cursor_manager()->IsCursorVisible(); |
48 } | 44 } |
49 | 45 |
50 void CheckCalledCallback(bool* flag) { | 46 void CheckCalledCallback(bool* flag) { |
51 if (flag) | 47 if (flag) |
52 (*flag) = true; | 48 (*flag) = true; |
53 } | 49 } |
54 | 50 |
55 aura::Window* GetContainer(int container ) { | 51 aura::Window* GetContainer(int container ) { |
56 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 52 aura::Window* root_window = Shell::GetPrimaryRootWindow(); |
57 return Shell::GetContainer(root_window, container); | 53 return Shell::GetContainer(root_window, container); |
58 } | 54 } |
59 | 55 |
60 bool IsBackgroundHidden() { | 56 bool IsBackgroundHidden() { |
61 return !GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)-> | 57 return !GetContainer(kShellWindowId_DesktopBackgroundContainer)->IsVisible(); |
62 IsVisible(); | |
63 } | 58 } |
64 | 59 |
65 void HideBackground() { | 60 void HideBackground() { |
66 ui::ScopedLayerAnimationSettings settings( | 61 ui::ScopedLayerAnimationSettings settings( |
67 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)-> | 62 GetContainer(kShellWindowId_DesktopBackgroundContainer) |
68 layer()->GetAnimator()); | 63 ->layer() |
| 64 ->GetAnimator()); |
69 settings.SetTransitionDuration(base::TimeDelta()); | 65 settings.SetTransitionDuration(base::TimeDelta()); |
70 GetContainer(internal::kShellWindowId_DesktopBackgroundContainer)->Hide(); | 66 GetContainer(kShellWindowId_DesktopBackgroundContainer)->Hide(); |
71 } | 67 } |
72 | 68 |
73 } // namespace | 69 } // namespace |
74 | 70 |
75 // Fake implementation of PowerButtonControllerDelegate that just logs requests | 71 // Fake implementation of PowerButtonControllerDelegate that just logs requests |
76 // to lock the screen and shut down the device. | 72 // to lock the screen and shut down the device. |
77 class TestLockStateControllerDelegate : public LockStateControllerDelegate { | 73 class TestLockStateControllerDelegate : public LockStateControllerDelegate { |
78 public: | 74 public: |
79 TestLockStateControllerDelegate() | 75 TestLockStateControllerDelegate() |
80 : num_lock_requests_(0), | 76 : num_lock_requests_(0), |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 SetCanLockScreen(false); | 385 SetCanLockScreen(false); |
390 lock_state_controller_->OnLockStateChanged(false); | 386 lock_state_controller_->OnLockStateChanged(false); |
391 } | 387 } |
392 | 388 |
393 void CreateWindowForLockscreen() { | 389 void CreateWindowForLockscreen() { |
394 window_.reset(new aura::Window(&window_delegate_)); | 390 window_.reset(new aura::Window(&window_delegate_)); |
395 window_->SetBounds(gfx::Rect(0, 0, 100, 100)); | 391 window_->SetBounds(gfx::Rect(0, 0, 100, 100)); |
396 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); | 392 window_->SetType(ui::wm::WINDOW_TYPE_NORMAL); |
397 window_->Init(aura::WINDOW_LAYER_TEXTURED); | 393 window_->Init(aura::WINDOW_LAYER_TEXTURED); |
398 window_->SetName("WINDOW"); | 394 window_->SetName("WINDOW"); |
399 aura::Window* container = Shell::GetContainer(Shell::GetPrimaryRootWindow(), | 395 aura::Window* container = Shell::GetContainer( |
400 internal::kShellWindowId_LockScreenContainer); | 396 Shell::GetPrimaryRootWindow(), kShellWindowId_LockScreenContainer); |
401 ASSERT_TRUE(container); | 397 ASSERT_TRUE(container); |
402 container->AddChild(window_.get()); | 398 container->AddChild(window_.get()); |
403 window_->Show(); | 399 window_->Show(); |
404 } | 400 } |
405 | 401 |
406 PowerButtonController* controller_; // not owned | 402 PowerButtonController* controller_; // not owned |
407 LockStateController* lock_state_controller_; // not owned | 403 LockStateController* lock_state_controller_; // not owned |
408 TestLockStateControllerDelegate* delegate_; // not owned | 404 TestLockStateControllerDelegate* delegate_; // not owned |
409 TestShellDelegate* shell_delegate_; // not owned | 405 TestShellDelegate* shell_delegate_; // not owned |
410 SessionStateDelegate* session_state_delegate_; // not owned | 406 SessionStateDelegate* session_state_delegate_; // not owned |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 // start lifting the non-screen-locker containers. | 606 // start lifting the non-screen-locker containers. |
611 PressPowerButton(); | 607 PressPowerButton(); |
612 | 608 |
613 ExpectPreLockAnimationStarted(); | 609 ExpectPreLockAnimationStarted(); |
614 EXPECT_TRUE(test_api_->is_lock_cancellable()); | 610 EXPECT_TRUE(test_api_->is_lock_cancellable()); |
615 | 611 |
616 // forward only half way through | 612 // forward only half way through |
617 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); | 613 AdvancePartially(SessionStateAnimator::ANIMATION_SPEED_UNDOABLE, 0.5f); |
618 | 614 |
619 gfx::Transform transform_before_button_released = | 615 gfx::Transform transform_before_button_released = |
620 GetContainer(internal::kShellWindowId_DefaultContainer)-> | 616 GetContainer(kShellWindowId_DefaultContainer)->layer()->transform(); |
621 layer()->transform(); | |
622 | 617 |
623 // Release the button before the lock timer fires. | 618 // Release the button before the lock timer fires. |
624 ReleasePowerButton(); | 619 ReleasePowerButton(); |
625 | 620 |
626 ExpectPreLockAnimationCancel(); | 621 ExpectPreLockAnimationCancel(); |
627 | 622 |
628 gfx::Transform transform_after_button_released = | 623 gfx::Transform transform_after_button_released = |
629 GetContainer(internal::kShellWindowId_DefaultContainer)-> | 624 GetContainer(kShellWindowId_DefaultContainer)->layer()->transform(); |
630 layer()->transform(); | |
631 // Expect no flickering, animation should proceed from mid-state. | 625 // Expect no flickering, animation should proceed from mid-state. |
632 EXPECT_EQ(transform_before_button_released, transform_after_button_released); | 626 EXPECT_EQ(transform_before_button_released, transform_after_button_released); |
633 | 627 |
634 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 628 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
635 ExpectUnlockedState(); | 629 ExpectUnlockedState(); |
636 EXPECT_EQ(0, delegate_->num_lock_requests()); | 630 EXPECT_EQ(0, delegate_->num_lock_requests()); |
637 } | 631 } |
638 | 632 |
639 // Test that we deal with cancelling lock correctly. | 633 // Test that we deal with cancelling lock correctly. |
640 // TODO(antrim): Reenable this: http://crbug.com/167048 | 634 // TODO(antrim): Reenable this: http://crbug.com/167048 |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1116 | 1110 |
1117 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 1111 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
1118 ExpectUnlockAfterUIDestroyedAnimationFinished(); | 1112 ExpectUnlockAfterUIDestroyedAnimationFinished(); |
1119 EXPECT_TRUE(IsBackgroundHidden()); | 1113 EXPECT_TRUE(IsBackgroundHidden()); |
1120 | 1114 |
1121 ExpectUnlockedState(); | 1115 ExpectUnlockedState(); |
1122 } | 1116 } |
1123 | 1117 |
1124 } // namespace test | 1118 } // namespace test |
1125 } // namespace ash | 1119 } // namespace ash |
OLD | NEW |