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 <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "ash/common/session/session_state_delegate.h" | 10 #include "ash/common/session/session_state_delegate.h" |
11 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" | 11 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" |
12 #include "ash/common/wm_shell.h" | 12 #include "ash/common/wm_shell.h" |
13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
14 #include "ash/test/ash_test_base.h" | 14 #include "ash/test/ash_test_base.h" |
15 #include "ash/test/test_lock_state_controller_delegate.h" | 15 #include "ash/test/test_lock_state_controller_delegate.h" |
16 #include "ash/test/test_screenshot_delegate.h" | 16 #include "ash/test/test_screenshot_delegate.h" |
17 #include "ash/test/test_session_state_animator.h" | 17 #include "ash/test/test_session_state_animator.h" |
18 #include "ash/test/test_shell_delegate.h" | 18 #include "ash/test/test_shell_delegate.h" |
19 #include "ash/wm/power_button_controller.h" | 19 #include "ash/wm/power_button_controller.h" |
20 #include "ash/wm/session_state_animator.h" | 20 #include "ash/wm/session_state_animator.h" |
21 #include "base/memory/scoped_vector.h" | 21 #include "base/memory/scoped_vector.h" |
| 22 #include "base/run_loop.h" |
| 23 #include "base/task_runner.h" |
| 24 #include "base/threading/thread_task_runner_handle.h" |
22 #include "base/time/time.h" | 25 #include "base/time/time.h" |
23 #include "chromeos/dbus/dbus_thread_manager.h" | 26 #include "chromeos/dbus/dbus_thread_manager.h" |
24 #include "chromeos/dbus/fake_session_manager_client.h" | 27 #include "chromeos/dbus/fake_session_manager_client.h" |
25 #include "ui/display/chromeos/display_configurator.h" | 28 #include "ui/display/chromeos/display_configurator.h" |
26 #include "ui/display/chromeos/test/test_display_snapshot.h" | 29 #include "ui/display/chromeos/test/test_display_snapshot.h" |
27 #include "ui/display/types/display_constants.h" | 30 #include "ui/display/types/display_constants.h" |
28 #include "ui/events/test/event_generator.h" | 31 #include "ui/events/test/event_generator.h" |
29 #include "ui/gfx/geometry/size.h" | 32 #include "ui/gfx/geometry/size.h" |
30 | 33 |
31 namespace ash { | 34 namespace ash { |
32 namespace test { | 35 namespace test { |
33 namespace { | 36 namespace { |
34 | 37 |
| 38 const int kWaitVolumeSliderHiddenInMs = 200; |
| 39 |
35 bool cursor_visible() { | 40 bool cursor_visible() { |
36 return Shell::GetInstance()->cursor_manager()->IsCursorVisible(); | 41 return Shell::GetInstance()->cursor_manager()->IsCursorVisible(); |
37 } | 42 } |
38 | 43 |
39 void CheckCalledCallback(bool* flag) { | 44 void CheckCalledCallback(bool* flag) { |
40 if (flag) | 45 if (flag) |
41 (*flag) = true; | 46 (*flag) = true; |
42 } | 47 } |
43 | 48 |
| 49 void WaitUntilVolumeSliderHidden() { |
| 50 base::RunLoop run_loop; |
| 51 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 52 FROM_HERE, run_loop.QuitClosure(), |
| 53 base::TimeDelta::FromMilliseconds(kWaitVolumeSliderHiddenInMs)); |
| 54 run_loop.Run(); |
| 55 } |
| 56 |
44 } // namespace | 57 } // namespace |
45 | 58 |
46 class LockStateControllerTest : public AshTestBase { | 59 class LockStateControllerTest : public AshTestBase { |
47 public: | 60 public: |
48 LockStateControllerTest() | 61 LockStateControllerTest() |
49 : power_button_controller_(nullptr), | 62 : power_button_controller_(nullptr), |
50 lock_state_controller_(nullptr), | 63 lock_state_controller_(nullptr), |
51 lock_state_controller_delegate_(nullptr), | 64 lock_state_controller_delegate_(nullptr), |
52 session_manager_client_(nullptr), | 65 session_manager_client_(nullptr), |
53 test_animator_(nullptr) {} | 66 test_animator_(nullptr) {} |
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1043 PressVolumeDown(); | 1056 PressVolumeDown(); |
1044 ReleaseVolumeDown(); | 1057 ReleaseVolumeDown(); |
1045 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); | 1058 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); |
1046 | 1059 |
1047 // Holding volume down and pressing power takes a screenshot. | 1060 // Holding volume down and pressing power takes a screenshot. |
1048 ASSERT_EQ(0, delegate->handle_take_screenshot_count()); | 1061 ASSERT_EQ(0, delegate->handle_take_screenshot_count()); |
1049 PressVolumeDown(); | 1062 PressVolumeDown(); |
1050 PressPowerButton(); | 1063 PressPowerButton(); |
1051 ReleasePowerButton(); | 1064 ReleasePowerButton(); |
1052 ReleaseVolumeDown(); | 1065 ReleaseVolumeDown(); |
| 1066 WaitUntilVolumeSliderHidden(); |
1053 EXPECT_EQ(1, delegate->handle_take_screenshot_count()); | 1067 EXPECT_EQ(1, delegate->handle_take_screenshot_count()); |
1054 } | 1068 } |
1055 | 1069 |
1056 // Tests that a lock action is cancellable when quick lock is turned on and | 1070 // Tests that a lock action is cancellable when quick lock is turned on and |
1057 // maximize mode is not active. | 1071 // maximize mode is not active. |
1058 TEST_F(LockStateControllerTest, QuickLockWhileNotInMaximizeMode) { | 1072 TEST_F(LockStateControllerTest, QuickLockWhileNotInMaximizeMode) { |
1059 Initialize(false, LoginStatus::USER); | 1073 Initialize(false, LoginStatus::USER); |
1060 power_button_controller_->set_enable_quick_lock_for_test(true); | 1074 power_button_controller_->set_enable_quick_lock_for_test(true); |
1061 EnableMaximizeMode(false); | 1075 EnableMaximizeMode(false); |
1062 | 1076 |
(...skipping 24 matching lines...) Expand all Loading... |
1087 ReleasePowerButton(); | 1101 ReleasePowerButton(); |
1088 | 1102 |
1089 ExpectPreLockAnimationStarted(); | 1103 ExpectPreLockAnimationStarted(); |
1090 | 1104 |
1091 test_animator_->CompleteAllAnimations(true); | 1105 test_animator_->CompleteAllAnimations(true); |
1092 EXPECT_EQ(1, session_manager_client_->request_lock_screen_call_count()); | 1106 EXPECT_EQ(1, session_manager_client_->request_lock_screen_call_count()); |
1093 } | 1107 } |
1094 | 1108 |
1095 } // namespace test | 1109 } // namespace test |
1096 } // namespace ash | 1110 } // namespace ash |
OLD | NEW |