| 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/session_state_delegate.h" | 8 #include "ash/session/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" |
| 11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/test/test_lock_state_controller_delegate.h" |
| 12 #include "ash/test/test_shell_delegate.h" | 13 #include "ash/test/test_shell_delegate.h" |
| 13 #include "ash/wm/power_button_controller.h" | 14 #include "ash/wm/power_button_controller.h" |
| 14 #include "ash/wm/session_state_animator.h" | 15 #include "ash/wm/session_state_animator.h" |
| 15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
| 16 #include "base/memory/scoped_ptr.h" | 17 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 18 #include "ui/aura/env.h" | 19 #include "ui/aura/env.h" |
| 19 #include "ui/aura/test/event_generator.h" | 20 #include "ui/aura/test/event_generator.h" |
| 20 #include "ui/aura/test/test_window_delegate.h" | 21 #include "ui/aura/test/test_window_delegate.h" |
| 21 #include "ui/aura/window_event_dispatcher.h" | 22 #include "ui/aura/window_event_dispatcher.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 ui::ScopedLayerAnimationSettings settings( | 62 ui::ScopedLayerAnimationSettings settings( |
| 62 GetContainer(kShellWindowId_DesktopBackgroundContainer) | 63 GetContainer(kShellWindowId_DesktopBackgroundContainer) |
| 63 ->layer() | 64 ->layer() |
| 64 ->GetAnimator()); | 65 ->GetAnimator()); |
| 65 settings.SetTransitionDuration(base::TimeDelta()); | 66 settings.SetTransitionDuration(base::TimeDelta()); |
| 66 GetContainer(kShellWindowId_DesktopBackgroundContainer)->Hide(); | 67 GetContainer(kShellWindowId_DesktopBackgroundContainer)->Hide(); |
| 67 } | 68 } |
| 68 | 69 |
| 69 } // namespace | 70 } // namespace |
| 70 | 71 |
| 71 // Fake implementation of PowerButtonControllerDelegate that just logs requests | |
| 72 // to lock the screen and shut down the device. | |
| 73 class TestLockStateControllerDelegate : public LockStateControllerDelegate { | |
| 74 public: | |
| 75 TestLockStateControllerDelegate() | |
| 76 : num_lock_requests_(0), | |
| 77 num_shutdown_requests_(0) {} | |
| 78 | |
| 79 int num_lock_requests() const { return num_lock_requests_; } | |
| 80 int num_shutdown_requests() const { return num_shutdown_requests_; } | |
| 81 | |
| 82 // LockStateControllerDelegate implementation. | |
| 83 virtual void RequestLockScreen() OVERRIDE { | |
| 84 num_lock_requests_++; | |
| 85 } | |
| 86 virtual void RequestShutdown() OVERRIDE { | |
| 87 num_shutdown_requests_++; | |
| 88 } | |
| 89 | |
| 90 private: | |
| 91 int num_lock_requests_; | |
| 92 int num_shutdown_requests_; | |
| 93 | |
| 94 DISALLOW_COPY_AND_ASSIGN(TestLockStateControllerDelegate); | |
| 95 }; | |
| 96 | |
| 97 class LockStateControllerTest : public AshTestBase { | 72 class LockStateControllerTest : public AshTestBase { |
| 98 public: | 73 public: |
| 99 LockStateControllerTest() : controller_(NULL), delegate_(NULL) {} | 74 LockStateControllerTest() : controller_(NULL), delegate_(NULL) {} |
| 100 virtual ~LockStateControllerTest() {} | 75 virtual ~LockStateControllerTest() {} |
| 101 | 76 |
| 102 virtual void SetUp() OVERRIDE { | 77 virtual void SetUp() OVERRIDE { |
| 103 AshTestBase::SetUp(); | 78 AshTestBase::SetUp(); |
| 104 | 79 |
| 105 // We would control animations in a fine way: | 80 // We would control animations in a fine way: |
| 106 animation_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( | 81 animation_duration_mode_.reset(new ui::ScopedAnimationDurationScaleMode( |
| (...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1110 | 1085 |
| 1111 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 1086 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 1112 ExpectUnlockAfterUIDestroyedAnimationFinished(); | 1087 ExpectUnlockAfterUIDestroyedAnimationFinished(); |
| 1113 EXPECT_TRUE(IsBackgroundHidden()); | 1088 EXPECT_TRUE(IsBackgroundHidden()); |
| 1114 | 1089 |
| 1115 ExpectUnlockedState(); | 1090 ExpectUnlockedState(); |
| 1116 } | 1091 } |
| 1117 | 1092 |
| 1118 } // namespace test | 1093 } // namespace test |
| 1119 } // namespace ash | 1094 } // namespace ash |
| OLD | NEW |