| 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/common/accelerators/accelerator_controller.h" | 5 #include "ash/common/accelerators/accelerator_controller.h" |
| 6 | 6 |
| 7 #include "ash/common/accelerators/accelerator_table.h" | 7 #include "ash/common/accelerators/accelerator_table.h" |
| 8 #include "ash/common/accessibility_delegate.h" | 8 #include "ash/common/accessibility_delegate.h" |
| 9 #include "ash/common/accessibility_types.h" | 9 #include "ash/common/accessibility_types.h" |
| 10 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 77 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
| 78 bool CanHandleAccelerators() const override; | 78 bool CanHandleAccelerators() const override; |
| 79 | 79 |
| 80 private: | 80 private: |
| 81 int accelerator_pressed_count_; | 81 int accelerator_pressed_count_; |
| 82 int accelerator_repeat_count_; | 82 int accelerator_repeat_count_; |
| 83 | 83 |
| 84 DISALLOW_COPY_AND_ASSIGN(TestTarget); | 84 DISALLOW_COPY_AND_ASSIGN(TestTarget); |
| 85 }; | 85 }; |
| 86 | 86 |
| 87 class ReleaseAccelerator : public ui::Accelerator { | 87 ui::Accelerator CreateReleaseAccelerator(ui::KeyboardCode key_code, |
| 88 public: | 88 int modifiers) { |
| 89 ReleaseAccelerator(ui::KeyboardCode keycode, int modifiers) | 89 ui::Accelerator accelerator(key_code, modifiers); |
| 90 : ui::Accelerator(keycode, modifiers) { | 90 accelerator.set_key_state(ui::Accelerator::KeyState::RELEASED); |
| 91 set_type(ui::ET_KEY_RELEASED); | 91 return accelerator; |
| 92 } | 92 } |
| 93 }; | |
| 94 | 93 |
| 95 class DummyBrightnessControlDelegate : public BrightnessControlDelegate { | 94 class DummyBrightnessControlDelegate : public BrightnessControlDelegate { |
| 96 public: | 95 public: |
| 97 DummyBrightnessControlDelegate() | 96 DummyBrightnessControlDelegate() |
| 98 : handle_brightness_down_count_(0), handle_brightness_up_count_(0) {} | 97 : handle_brightness_down_count_(0), handle_brightness_up_count_(0) {} |
| 99 ~DummyBrightnessControlDelegate() override {} | 98 ~DummyBrightnessControlDelegate() override {} |
| 100 | 99 |
| 101 void HandleBrightnessDown(const ui::Accelerator& accelerator) override { | 100 void HandleBrightnessDown(const ui::Accelerator& accelerator) override { |
| 102 ++handle_brightness_down_count_; | 101 ++handle_brightness_down_count_; |
| 103 last_accelerator_ = accelerator; | 102 last_accelerator_ = accelerator; |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 | 208 |
| 210 class AcceleratorControllerTest : public test::AshTestBase { | 209 class AcceleratorControllerTest : public test::AshTestBase { |
| 211 public: | 210 public: |
| 212 AcceleratorControllerTest() {} | 211 AcceleratorControllerTest() {} |
| 213 ~AcceleratorControllerTest() override {} | 212 ~AcceleratorControllerTest() override {} |
| 214 | 213 |
| 215 protected: | 214 protected: |
| 216 static AcceleratorController* GetController(); | 215 static AcceleratorController* GetController(); |
| 217 | 216 |
| 218 static bool ProcessInController(const ui::Accelerator& accelerator) { | 217 static bool ProcessInController(const ui::Accelerator& accelerator) { |
| 219 if (accelerator.type() == ui::ET_KEY_RELEASED) { | 218 if (accelerator.key_state() == ui::Accelerator::KeyState::RELEASED) { |
| 220 // If the |accelerator| should trigger on release, then we store the | 219 // If the |accelerator| should trigger on release, then we store the |
| 221 // pressed version of it first in history then the released one to | 220 // pressed version of it first in history then the released one to |
| 222 // simulate what happens in reality. | 221 // simulate what happens in reality. |
| 223 ui::Accelerator pressed_accelerator = accelerator; | 222 ui::Accelerator pressed_accelerator = accelerator; |
| 224 pressed_accelerator.set_type(ui::ET_KEY_PRESSED); | 223 pressed_accelerator.set_key_state(ui::Accelerator::KeyState::PRESSED); |
| 225 GetController()->accelerator_history()->StoreCurrentAccelerator( | 224 GetController()->accelerator_history()->StoreCurrentAccelerator( |
| 226 pressed_accelerator); | 225 pressed_accelerator); |
| 227 } | 226 } |
| 228 GetController()->accelerator_history()->StoreCurrentAccelerator( | 227 GetController()->accelerator_history()->StoreCurrentAccelerator( |
| 229 accelerator); | 228 accelerator); |
| 230 return GetController()->Process(accelerator); | 229 return GetController()->Process(accelerator); |
| 231 } | 230 } |
| 232 | 231 |
| 233 static const ui::Accelerator& GetPreviousAccelerator() { | 232 static const ui::Accelerator& GetPreviousAccelerator() { |
| 234 return GetController()->accelerator_history()->previous_accelerator(); | 233 return GetController()->accelerator_history()->previous_accelerator(); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 }; | 278 }; |
| 280 | 279 |
| 281 AcceleratorController* AcceleratorControllerTest::GetController() { | 280 AcceleratorController* AcceleratorControllerTest::GetController() { |
| 282 return WmShell::Get()->accelerator_controller(); | 281 return WmShell::Get()->accelerator_controller(); |
| 283 } | 282 } |
| 284 | 283 |
| 285 // Double press of exit shortcut => exiting | 284 // Double press of exit shortcut => exiting |
| 286 TEST_F(AcceleratorControllerTest, ExitWarningHandlerTestDoublePress) { | 285 TEST_F(AcceleratorControllerTest, ExitWarningHandlerTestDoublePress) { |
| 287 ui::Accelerator press(ui::VKEY_Q, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN); | 286 ui::Accelerator press(ui::VKEY_Q, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN); |
| 288 ui::Accelerator release(press); | 287 ui::Accelerator release(press); |
| 289 release.set_type(ui::ET_KEY_RELEASED); | 288 release.set_key_state(ui::Accelerator::KeyState::RELEASED); |
| 290 ExitWarningHandler* ewh = GetController()->GetExitWarningHandlerForTest(); | 289 ExitWarningHandler* ewh = GetController()->GetExitWarningHandlerForTest(); |
| 291 ASSERT_TRUE(ewh); | 290 ASSERT_TRUE(ewh); |
| 292 StubForTest(ewh); | 291 StubForTest(ewh); |
| 293 EXPECT_TRUE(is_idle(ewh)); | 292 EXPECT_TRUE(is_idle(ewh)); |
| 294 EXPECT_FALSE(is_ui_shown(ewh)); | 293 EXPECT_FALSE(is_ui_shown(ewh)); |
| 295 EXPECT_TRUE(ProcessInController(press)); | 294 EXPECT_TRUE(ProcessInController(press)); |
| 296 EXPECT_FALSE(ProcessInController(release)); | 295 EXPECT_FALSE(ProcessInController(release)); |
| 297 EXPECT_FALSE(is_idle(ewh)); | 296 EXPECT_FALSE(is_idle(ewh)); |
| 298 EXPECT_TRUE(is_ui_shown(ewh)); | 297 EXPECT_TRUE(is_ui_shown(ewh)); |
| 299 EXPECT_TRUE(ProcessInController(press)); // second press before timer. | 298 EXPECT_TRUE(ProcessInController(press)); // second press before timer. |
| 300 EXPECT_FALSE(ProcessInController(release)); | 299 EXPECT_FALSE(ProcessInController(release)); |
| 301 SimulateTimerExpired(ewh); | 300 SimulateTimerExpired(ewh); |
| 302 EXPECT_TRUE(is_exiting(ewh)); | 301 EXPECT_TRUE(is_exiting(ewh)); |
| 303 EXPECT_FALSE(is_ui_shown(ewh)); | 302 EXPECT_FALSE(is_ui_shown(ewh)); |
| 304 Reset(ewh); | 303 Reset(ewh); |
| 305 } | 304 } |
| 306 | 305 |
| 307 // Single press of exit shortcut before timer => idle | 306 // Single press of exit shortcut before timer => idle |
| 308 TEST_F(AcceleratorControllerTest, ExitWarningHandlerTestSinglePress) { | 307 TEST_F(AcceleratorControllerTest, ExitWarningHandlerTestSinglePress) { |
| 309 ui::Accelerator press(ui::VKEY_Q, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN); | 308 ui::Accelerator press(ui::VKEY_Q, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN); |
| 310 ui::Accelerator release(press); | 309 ui::Accelerator release(press); |
| 311 release.set_type(ui::ET_KEY_RELEASED); | 310 release.set_key_state(ui::Accelerator::KeyState::RELEASED); |
| 312 ExitWarningHandler* ewh = GetController()->GetExitWarningHandlerForTest(); | 311 ExitWarningHandler* ewh = GetController()->GetExitWarningHandlerForTest(); |
| 313 ASSERT_TRUE(ewh); | 312 ASSERT_TRUE(ewh); |
| 314 StubForTest(ewh); | 313 StubForTest(ewh); |
| 315 EXPECT_TRUE(is_idle(ewh)); | 314 EXPECT_TRUE(is_idle(ewh)); |
| 316 EXPECT_FALSE(is_ui_shown(ewh)); | 315 EXPECT_FALSE(is_ui_shown(ewh)); |
| 317 EXPECT_TRUE(ProcessInController(press)); | 316 EXPECT_TRUE(ProcessInController(press)); |
| 318 EXPECT_FALSE(ProcessInController(release)); | 317 EXPECT_FALSE(ProcessInController(release)); |
| 319 EXPECT_FALSE(is_idle(ewh)); | 318 EXPECT_FALSE(is_idle(ewh)); |
| 320 EXPECT_TRUE(is_ui_shown(ewh)); | 319 EXPECT_TRUE(is_ui_shown(ewh)); |
| 321 SimulateTimerExpired(ewh); | 320 SimulateTimerExpired(ewh); |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 740 | 739 |
| 741 gfx::Rect docked_bounds = window->GetBoundsInScreen(); | 740 gfx::Rect docked_bounds = window->GetBoundsInScreen(); |
| 742 GetController()->PerformActionIfEnabled(WINDOW_POSITION_CENTER); | 741 GetController()->PerformActionIfEnabled(WINDOW_POSITION_CENTER); |
| 743 // It should not get centered and should remain docked. | 742 // It should not get centered and should remain docked. |
| 744 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); | 743 EXPECT_EQ(kShellWindowId_DockedContainer, window->parent()->id()); |
| 745 EXPECT_EQ(docked_bounds.ToString(), window->GetBoundsInScreen().ToString()); | 744 EXPECT_EQ(docked_bounds.ToString(), window->GetBoundsInScreen().ToString()); |
| 746 } | 745 } |
| 747 | 746 |
| 748 TEST_F(AcceleratorControllerTest, AutoRepeat) { | 747 TEST_F(AcceleratorControllerTest, AutoRepeat) { |
| 749 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_CONTROL_DOWN); | 748 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_CONTROL_DOWN); |
| 750 accelerator_a.set_type(ui::ET_KEY_PRESSED); | |
| 751 TestTarget target_a; | 749 TestTarget target_a; |
| 752 GetController()->Register({accelerator_a}, &target_a); | 750 GetController()->Register({accelerator_a}, &target_a); |
| 753 ui::Accelerator accelerator_b(ui::VKEY_B, ui::EF_CONTROL_DOWN); | 751 ui::Accelerator accelerator_b(ui::VKEY_B, ui::EF_CONTROL_DOWN); |
| 754 accelerator_b.set_type(ui::ET_KEY_PRESSED); | |
| 755 TestTarget target_b; | 752 TestTarget target_b; |
| 756 GetController()->Register({accelerator_b}, &target_b); | 753 GetController()->Register({accelerator_b}, &target_b); |
| 757 | 754 |
| 758 ui::test::EventGenerator& generator = GetEventGenerator(); | 755 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 759 generator.PressKey(ui::VKEY_A, ui::EF_CONTROL_DOWN); | 756 generator.PressKey(ui::VKEY_A, ui::EF_CONTROL_DOWN); |
| 760 generator.ReleaseKey(ui::VKEY_A, ui::EF_CONTROL_DOWN); | 757 generator.ReleaseKey(ui::VKEY_A, ui::EF_CONTROL_DOWN); |
| 761 | 758 |
| 762 EXPECT_EQ(1, target_a.accelerator_pressed_count()); | 759 EXPECT_EQ(1, target_a.accelerator_pressed_count()); |
| 763 EXPECT_EQ(0, target_a.accelerator_repeat_count()); | 760 EXPECT_EQ(0, target_a.accelerator_repeat_count()); |
| 764 | 761 |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1025 AccessibilityDelegate* delegate = | 1022 AccessibilityDelegate* delegate = |
| 1026 Shell::GetInstance()->accessibility_delegate(); | 1023 Shell::GetInstance()->accessibility_delegate(); |
| 1027 | 1024 |
| 1028 // The press event should not toggle the AppList, the release should instead. | 1025 // The press event should not toggle the AppList, the release should instead. |
| 1029 EXPECT_FALSE( | 1026 EXPECT_FALSE( |
| 1030 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1027 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 1031 RunAllPendingInMessageLoop(); | 1028 RunAllPendingInMessageLoop(); |
| 1032 EXPECT_EQ(ui::VKEY_LWIN, GetCurrentAccelerator().key_code()); | 1029 EXPECT_EQ(ui::VKEY_LWIN, GetCurrentAccelerator().key_code()); |
| 1033 EXPECT_EQ(0u, test_app_list_presenter.toggle_count()); | 1030 EXPECT_EQ(0u, test_app_list_presenter.toggle_count()); |
| 1034 | 1031 |
| 1035 EXPECT_TRUE( | 1032 EXPECT_TRUE(ProcessInController( |
| 1036 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1033 CreateReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 1037 RunAllPendingInMessageLoop(); | 1034 RunAllPendingInMessageLoop(); |
| 1038 EXPECT_EQ(1u, test_app_list_presenter.toggle_count()); | 1035 EXPECT_EQ(1u, test_app_list_presenter.toggle_count()); |
| 1039 EXPECT_EQ(ui::VKEY_LWIN, GetPreviousAccelerator().key_code()); | 1036 EXPECT_EQ(ui::VKEY_LWIN, GetPreviousAccelerator().key_code()); |
| 1040 | 1037 |
| 1041 // When spoken feedback is on, the AppList should not toggle. | 1038 // When spoken feedback is on, the AppList should not toggle. |
| 1042 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 1039 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
| 1043 EXPECT_FALSE( | 1040 EXPECT_FALSE( |
| 1044 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1041 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 1045 EXPECT_FALSE( | 1042 EXPECT_FALSE(ProcessInController( |
| 1046 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1043 CreateReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 1047 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 1044 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
| 1048 RunAllPendingInMessageLoop(); | 1045 RunAllPendingInMessageLoop(); |
| 1049 EXPECT_EQ(1u, test_app_list_presenter.toggle_count()); | 1046 EXPECT_EQ(1u, test_app_list_presenter.toggle_count()); |
| 1050 | 1047 |
| 1051 // Turning off spoken feedback should allow the AppList to toggle again. | 1048 // Turning off spoken feedback should allow the AppList to toggle again. |
| 1052 EXPECT_FALSE( | 1049 EXPECT_FALSE( |
| 1053 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1050 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 1054 EXPECT_TRUE( | 1051 EXPECT_TRUE(ProcessInController( |
| 1055 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1052 CreateReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 1056 RunAllPendingInMessageLoop(); | 1053 RunAllPendingInMessageLoop(); |
| 1057 EXPECT_EQ(2u, test_app_list_presenter.toggle_count()); | 1054 EXPECT_EQ(2u, test_app_list_presenter.toggle_count()); |
| 1058 | 1055 |
| 1059 // The press of VKEY_BROWSER_SEARCH should toggle the AppList | 1056 // The press of VKEY_BROWSER_SEARCH should toggle the AppList |
| 1060 EXPECT_TRUE(ProcessInController( | 1057 EXPECT_TRUE(ProcessInController( |
| 1061 ui::Accelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); | 1058 ui::Accelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); |
| 1062 RunAllPendingInMessageLoop(); | 1059 RunAllPendingInMessageLoop(); |
| 1063 EXPECT_EQ(3u, test_app_list_presenter.toggle_count()); | 1060 EXPECT_EQ(3u, test_app_list_presenter.toggle_count()); |
| 1064 EXPECT_FALSE(ProcessInController( | 1061 EXPECT_FALSE(ProcessInController( |
| 1065 ReleaseAccelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); | 1062 CreateReleaseAccelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); |
| 1066 RunAllPendingInMessageLoop(); | 1063 RunAllPendingInMessageLoop(); |
| 1067 EXPECT_EQ(3u, test_app_list_presenter.toggle_count()); | 1064 EXPECT_EQ(3u, test_app_list_presenter.toggle_count()); |
| 1068 } | 1065 } |
| 1069 | 1066 |
| 1070 TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { | 1067 TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { |
| 1071 // Test IME shortcuts. | 1068 // Test IME shortcuts. |
| 1072 ui::Accelerator control_space_down(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 1069 ui::Accelerator control_space_down(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 1073 control_space_down.set_type(ui::ET_KEY_PRESSED); | |
| 1074 ui::Accelerator control_space_up(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 1070 ui::Accelerator control_space_up(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 1075 control_space_up.set_type(ui::ET_KEY_RELEASED); | 1071 control_space_up.set_key_state(ui::Accelerator::KeyState::RELEASED); |
| 1076 const ui::Accelerator convert(ui::VKEY_CONVERT, ui::EF_NONE); | 1072 const ui::Accelerator convert(ui::VKEY_CONVERT, ui::EF_NONE); |
| 1077 const ui::Accelerator non_convert(ui::VKEY_NONCONVERT, ui::EF_NONE); | 1073 const ui::Accelerator non_convert(ui::VKEY_NONCONVERT, ui::EF_NONE); |
| 1078 const ui::Accelerator wide_half_1(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE); | 1074 const ui::Accelerator wide_half_1(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE); |
| 1079 const ui::Accelerator wide_half_2(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE); | 1075 const ui::Accelerator wide_half_2(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE); |
| 1080 const ui::Accelerator hangul(ui::VKEY_HANGUL, ui::EF_NONE); | 1076 const ui::Accelerator hangul(ui::VKEY_HANGUL, ui::EF_NONE); |
| 1081 EXPECT_FALSE(ProcessInController(control_space_down)); | 1077 EXPECT_FALSE(ProcessInController(control_space_down)); |
| 1082 EXPECT_FALSE(ProcessInController(control_space_up)); | 1078 EXPECT_FALSE(ProcessInController(control_space_up)); |
| 1083 EXPECT_FALSE(ProcessInController(convert)); | 1079 EXPECT_FALSE(ProcessInController(convert)); |
| 1084 EXPECT_FALSE(ProcessInController(non_convert)); | 1080 EXPECT_FALSE(ProcessInController(non_convert)); |
| 1085 EXPECT_FALSE(ProcessInController(wide_half_1)); | 1081 EXPECT_FALSE(ProcessInController(wide_half_1)); |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1196 ASSERT_TRUE(input_method_manager); | 1192 ASSERT_TRUE(input_method_manager); |
| 1197 EXPECT_FALSE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled()); | 1193 EXPECT_FALSE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled()); |
| 1198 | 1194 |
| 1199 // 1. Press Alt, Press Search, Release Search, Release Alt. | 1195 // 1. Press Alt, Press Search, Release Search, Release Alt. |
| 1200 // Note when you press Alt then press search, the key_code at this point is | 1196 // Note when you press Alt then press search, the key_code at this point is |
| 1201 // VKEY_LWIN (for search) and Alt is the modifier. | 1197 // VKEY_LWIN (for search) and Alt is the modifier. |
| 1202 const ui::Accelerator press_alt_then_search(ui::VKEY_LWIN, ui::EF_ALT_DOWN); | 1198 const ui::Accelerator press_alt_then_search(ui::VKEY_LWIN, ui::EF_ALT_DOWN); |
| 1203 EXPECT_FALSE(ProcessInController(press_alt_then_search)); | 1199 EXPECT_FALSE(ProcessInController(press_alt_then_search)); |
| 1204 // When you release Search before Alt, the key_code is still VKEY_LWIN and | 1200 // When you release Search before Alt, the key_code is still VKEY_LWIN and |
| 1205 // Alt is still the modifier. | 1201 // Alt is still the modifier. |
| 1206 const ReleaseAccelerator release_search_before_alt(ui::VKEY_LWIN, | 1202 const ui::Accelerator release_search_before_alt( |
| 1207 ui::EF_ALT_DOWN); | 1203 CreateReleaseAccelerator(ui::VKEY_LWIN, ui::EF_ALT_DOWN)); |
| 1208 EXPECT_TRUE(ProcessInController(release_search_before_alt)); | 1204 EXPECT_TRUE(ProcessInController(release_search_before_alt)); |
| 1209 EXPECT_TRUE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled()); | 1205 EXPECT_TRUE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled()); |
| 1210 input_method_manager->GetImeKeyboard()->SetCapsLockEnabled(false); | 1206 input_method_manager->GetImeKeyboard()->SetCapsLockEnabled(false); |
| 1211 | 1207 |
| 1212 // 2. Press Search, Press Alt, Release Search, Release Alt. | 1208 // 2. Press Search, Press Alt, Release Search, Release Alt. |
| 1213 const ui::Accelerator press_search_then_alt(ui::VKEY_MENU, | 1209 const ui::Accelerator press_search_then_alt(ui::VKEY_MENU, |
| 1214 ui::EF_COMMAND_DOWN); | 1210 ui::EF_COMMAND_DOWN); |
| 1215 EXPECT_FALSE(ProcessInController(press_search_then_alt)); | 1211 EXPECT_FALSE(ProcessInController(press_search_then_alt)); |
| 1216 EXPECT_TRUE(ProcessInController(release_search_before_alt)); | 1212 EXPECT_TRUE(ProcessInController(release_search_before_alt)); |
| 1217 EXPECT_TRUE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled()); | 1213 EXPECT_TRUE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled()); |
| 1218 input_method_manager->GetImeKeyboard()->SetCapsLockEnabled(false); | 1214 input_method_manager->GetImeKeyboard()->SetCapsLockEnabled(false); |
| 1219 | 1215 |
| 1220 // 3. Press Alt, Press Search, Release Alt, Release Search. | 1216 // 3. Press Alt, Press Search, Release Alt, Release Search. |
| 1221 EXPECT_FALSE(ProcessInController(press_alt_then_search)); | 1217 EXPECT_FALSE(ProcessInController(press_alt_then_search)); |
| 1222 const ReleaseAccelerator release_alt_before_search(ui::VKEY_MENU, | 1218 const ui::Accelerator release_alt_before_search( |
| 1223 ui::EF_COMMAND_DOWN); | 1219 CreateReleaseAccelerator(ui::VKEY_MENU, ui::EF_COMMAND_DOWN)); |
| 1224 EXPECT_TRUE(ProcessInController(release_alt_before_search)); | 1220 EXPECT_TRUE(ProcessInController(release_alt_before_search)); |
| 1225 EXPECT_TRUE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled()); | 1221 EXPECT_TRUE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled()); |
| 1226 input_method_manager->GetImeKeyboard()->SetCapsLockEnabled(false); | 1222 input_method_manager->GetImeKeyboard()->SetCapsLockEnabled(false); |
| 1227 | 1223 |
| 1228 // 4. Press Search, Press Alt, Release Alt, Release Search. | 1224 // 4. Press Search, Press Alt, Release Alt, Release Search. |
| 1229 EXPECT_FALSE(ProcessInController(press_search_then_alt)); | 1225 EXPECT_FALSE(ProcessInController(press_search_then_alt)); |
| 1230 EXPECT_TRUE(ProcessInController(release_alt_before_search)); | 1226 EXPECT_TRUE(ProcessInController(release_alt_before_search)); |
| 1231 EXPECT_TRUE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled()); | 1227 EXPECT_TRUE(input_method_manager->GetImeKeyboard()->CapsLockIsEnabled()); |
| 1232 } | 1228 } |
| 1233 | 1229 |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1480 AcceleratorControllerTest::SetUp(); | 1476 AcceleratorControllerTest::SetUp(); |
| 1481 | 1477 |
| 1482 // For testing the deprecated and new IME shortcuts. | 1478 // For testing the deprecated and new IME shortcuts. |
| 1483 DummyImeControlDelegate* delegate = new DummyImeControlDelegate; | 1479 DummyImeControlDelegate* delegate = new DummyImeControlDelegate; |
| 1484 GetController()->SetImeControlDelegate( | 1480 GetController()->SetImeControlDelegate( |
| 1485 std::unique_ptr<ImeControlDelegate>(delegate)); | 1481 std::unique_ptr<ImeControlDelegate>(delegate)); |
| 1486 } | 1482 } |
| 1487 | 1483 |
| 1488 ui::Accelerator CreateAccelerator(const AcceleratorData& data) const { | 1484 ui::Accelerator CreateAccelerator(const AcceleratorData& data) const { |
| 1489 ui::Accelerator result(data.keycode, data.modifiers); | 1485 ui::Accelerator result(data.keycode, data.modifiers); |
| 1490 result.set_type(data.trigger_on_press ? ui::ET_KEY_PRESSED | 1486 result.set_key_state(data.trigger_on_press |
| 1491 : ui::ET_KEY_RELEASED); | 1487 ? ui::Accelerator::KeyState::PRESSED |
| 1488 : ui::Accelerator::KeyState::RELEASED); |
| 1492 return result; | 1489 return result; |
| 1493 } | 1490 } |
| 1494 | 1491 |
| 1495 void ResetStateIfNeeded() { | 1492 void ResetStateIfNeeded() { |
| 1496 if (WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked() || | 1493 if (WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked() || |
| 1497 WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()) { | 1494 WmShell::Get()->GetSessionStateDelegate()->IsUserSessionBlocked()) { |
| 1498 UnblockUserSession(); | 1495 UnblockUserSession(); |
| 1499 } | 1496 } |
| 1500 } | 1497 } |
| 1501 | 1498 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1568 // Expect no notifications from the new accelerators. | 1565 // Expect no notifications from the new accelerators. |
| 1569 EXPECT_TRUE(IsMessageCenterEmpty()); | 1566 EXPECT_TRUE(IsMessageCenterEmpty()); |
| 1570 | 1567 |
| 1571 // If the action is LOCK_SCREEN, we must reset the state by unlocking the | 1568 // If the action is LOCK_SCREEN, we must reset the state by unlocking the |
| 1572 // screen before we proceed testing the rest of accelerators. | 1569 // screen before we proceed testing the rest of accelerators. |
| 1573 ResetStateIfNeeded(); | 1570 ResetStateIfNeeded(); |
| 1574 } | 1571 } |
| 1575 } | 1572 } |
| 1576 | 1573 |
| 1577 } // namespace ash | 1574 } // namespace ash |
| OLD | NEW |