| 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/accelerators/accelerator_controller.h" | 5 #include "ash/accelerators/accelerator_controller.h" |
| 6 #include "ash/accelerators/accelerator_table.h" | 6 #include "ash/accelerators/accelerator_table.h" |
| 7 #include "ash/caps_lock_delegate.h" | 7 #include "ash/caps_lock_delegate.h" |
| 8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
| 9 #include "ash/ime_control_delegate.h" | 9 #include "ash/ime_control_delegate.h" |
| 10 #include "ash/screenshot_delegate.h" | 10 #include "ash/screenshot_delegate.h" |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 621 ui::Accelerator(ui::VKEY_F5, ui::EF_CONTROL_DOWN))); | 621 ui::Accelerator(ui::VKEY_F5, ui::EF_CONTROL_DOWN))); |
| 622 EXPECT_EQ(1, delegate->handle_take_screenshot_count()); | 622 EXPECT_EQ(1, delegate->handle_take_screenshot_count()); |
| 623 EXPECT_TRUE(ProcessWithContext( | 623 EXPECT_TRUE(ProcessWithContext( |
| 624 ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); | 624 ui::Accelerator(ui::VKEY_PRINT, ui::EF_NONE))); |
| 625 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); | 625 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); |
| 626 EXPECT_TRUE(ProcessWithContext( | 626 EXPECT_TRUE(ProcessWithContext( |
| 627 ui::Accelerator(ui::VKEY_F5, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); | 627 ui::Accelerator(ui::VKEY_F5, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); |
| 628 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); | 628 EXPECT_EQ(2, delegate->handle_take_screenshot_count()); |
| 629 } | 629 } |
| 630 #endif | 630 #endif |
| 631 // ToggleAppList | |
| 632 { | |
| 633 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | |
| 634 EXPECT_TRUE(ProcessWithContext( | |
| 635 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | |
| 636 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | |
| 637 EXPECT_TRUE(ProcessWithContext( | |
| 638 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | |
| 639 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | |
| 640 } | |
| 641 // ToggleAppList (with spoken feedback enabled) | |
| 642 { | |
| 643 ShellDelegate* delegate = ash::Shell::GetInstance()->delegate(); | |
| 644 delegate->ToggleSpokenFeedback(); | |
| 645 EXPECT_FALSE(ProcessWithContext( | |
| 646 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | |
| 647 delegate->ToggleSpokenFeedback(); | |
| 648 EXPECT_TRUE(ProcessWithContext( | |
| 649 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | |
| 650 } | |
| 651 // DisableCapsLock | 631 // DisableCapsLock |
| 652 { | 632 { |
| 653 CapsLockDelegate* delegate = Shell::GetInstance()->caps_lock_delegate(); | 633 CapsLockDelegate* delegate = Shell::GetInstance()->caps_lock_delegate(); |
| 654 delegate->SetCapsLockEnabled(true); | 634 delegate->SetCapsLockEnabled(true); |
| 655 EXPECT_TRUE(delegate->IsCapsLockEnabled()); | 635 EXPECT_TRUE(delegate->IsCapsLockEnabled()); |
| 656 // Handled only on key release. | 636 // Handled only on key release. |
| 657 EXPECT_FALSE(ProcessWithContext( | 637 EXPECT_FALSE(ProcessWithContext( |
| 658 ui::Accelerator(ui::VKEY_LSHIFT, ui::EF_NONE))); | 638 ui::Accelerator(ui::VKEY_LSHIFT, ui::EF_NONE))); |
| 659 EXPECT_TRUE(delegate->IsCapsLockEnabled()); | 639 EXPECT_TRUE(delegate->IsCapsLockEnabled()); |
| 660 EXPECT_TRUE(ProcessWithContext( | 640 EXPECT_TRUE(ProcessWithContext( |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 | 935 |
| 956 // Lock screen | 936 // Lock screen |
| 957 // NOTE: Accelerators that do not work on the lock screen need to be | 937 // NOTE: Accelerators that do not work on the lock screen need to be |
| 958 // tested before the sequence below is invoked because it causes a side | 938 // tested before the sequence below is invoked because it causes a side |
| 959 // effect of locking the screen. | 939 // effect of locking the screen. |
| 960 EXPECT_TRUE(ProcessWithContext( | 940 EXPECT_TRUE(ProcessWithContext( |
| 961 ui::Accelerator(ui::VKEY_L, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); | 941 ui::Accelerator(ui::VKEY_L, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); |
| 962 #endif | 942 #endif |
| 963 } | 943 } |
| 964 | 944 |
| 945 TEST_F(AcceleratorControllerTest, |
| 946 GlobalAcceleratorsToggleAppListWithoutSearchAsModifier) { |
| 947 ShellDelegate* delegate = ash::Shell::GetInstance()->delegate(); |
| 948 |
| 949 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
| 950 |
| 951 // When Search is not acting as a modifier, pressing Search should toggle |
| 952 // the AppList |
| 953 EXPECT_TRUE(ProcessWithContext( |
| 954 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 955 EXPECT_FALSE(ProcessWithContext( |
| 956 ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 957 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
| 958 |
| 959 // When spoken feedback is on, the AppList should not toggle. |
| 960 delegate->ToggleSpokenFeedback(); |
| 961 EXPECT_FALSE(ProcessWithContext( |
| 962 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 963 EXPECT_FALSE(ProcessWithContext( |
| 964 ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 965 delegate->ToggleSpokenFeedback(); |
| 966 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
| 967 |
| 968 EXPECT_TRUE(ProcessWithContext( |
| 969 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 970 EXPECT_FALSE(ProcessWithContext( |
| 971 ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 972 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
| 973 |
| 974 // When spoken feedback is on, the AppList should not toggle. |
| 975 delegate->ToggleSpokenFeedback(); |
| 976 EXPECT_FALSE(ProcessWithContext( |
| 977 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 978 EXPECT_FALSE(ProcessWithContext( |
| 979 ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 980 delegate->ToggleSpokenFeedback(); |
| 981 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
| 982 } |
| 983 |
| 984 TEST_F(AcceleratorControllerTest, |
| 985 GlobalAcceleratorsToggleAppListWithSearchAsModifier) { |
| 986 test::TestShellDelegate* delegate = |
| 987 reinterpret_cast<test::TestShellDelegate*>( |
| 988 ash::Shell::GetInstance()->delegate()); |
| 989 delegate->set_is_search_key_acting_as_function_key(true); |
| 990 |
| 991 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
| 992 |
| 993 // When Search is acting as a modifier for accessing extended keyboard |
| 994 // shortcuts, then the press event should not open the AppList, and the |
| 995 // release should instead. |
| 996 EXPECT_FALSE(ProcessWithContext( |
| 997 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 998 EXPECT_TRUE(ProcessWithContext( |
| 999 ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 1000 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
| 1001 |
| 1002 // When spoken feedback is on, the AppList should not toggle. |
| 1003 delegate->ToggleSpokenFeedback(); |
| 1004 EXPECT_FALSE(ProcessWithContext( |
| 1005 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 1006 EXPECT_FALSE(ProcessWithContext( |
| 1007 ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 1008 delegate->ToggleSpokenFeedback(); |
| 1009 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
| 1010 |
| 1011 EXPECT_FALSE(ProcessWithContext( |
| 1012 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 1013 EXPECT_TRUE(ProcessWithContext( |
| 1014 ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 1015 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
| 1016 |
| 1017 // When spoken feedback is on, the AppList should not toggle. |
| 1018 delegate->ToggleSpokenFeedback(); |
| 1019 EXPECT_FALSE(ProcessWithContext( |
| 1020 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 1021 EXPECT_FALSE(ProcessWithContext( |
| 1022 ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 1023 delegate->ToggleSpokenFeedback(); |
| 1024 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
| 1025 } |
| 1026 |
| 965 TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { | 1027 TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { |
| 966 // Test IME shortcuts. | 1028 // Test IME shortcuts. |
| 967 { | 1029 { |
| 968 const ui::Accelerator control_space(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 1030 const ui::Accelerator control_space(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 969 const ui::Accelerator convert(ui::VKEY_CONVERT, ui::EF_NONE); | 1031 const ui::Accelerator convert(ui::VKEY_CONVERT, ui::EF_NONE); |
| 970 const ui::Accelerator non_convert(ui::VKEY_NONCONVERT, ui::EF_NONE); | 1032 const ui::Accelerator non_convert(ui::VKEY_NONCONVERT, ui::EF_NONE); |
| 971 const ui::Accelerator wide_half_1(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE); | 1033 const ui::Accelerator wide_half_1(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE); |
| 972 const ui::Accelerator wide_half_2(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE); | 1034 const ui::Accelerator wide_half_2(ui::VKEY_DBE_DBCSCHAR, ui::EF_NONE); |
| 973 const ui::Accelerator hangul(ui::VKEY_HANGUL, ui::EF_NONE); | 1035 const ui::Accelerator hangul(ui::VKEY_HANGUL, ui::EF_NONE); |
| 974 EXPECT_FALSE(ProcessWithContext(control_space)); | 1036 EXPECT_FALSE(ProcessWithContext(control_space)); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 EXPECT_EQ(f9, delegate->last_accelerator()); | 1326 EXPECT_EQ(f9, delegate->last_accelerator()); |
| 1265 EXPECT_EQ(0, delegate->handle_volume_up_count()); | 1327 EXPECT_EQ(0, delegate->handle_volume_up_count()); |
| 1266 EXPECT_TRUE(ProcessWithContext(f10)); | 1328 EXPECT_TRUE(ProcessWithContext(f10)); |
| 1267 EXPECT_EQ(1, delegate->handle_volume_up_count()); | 1329 EXPECT_EQ(1, delegate->handle_volume_up_count()); |
| 1268 EXPECT_EQ(f10, delegate->last_accelerator()); | 1330 EXPECT_EQ(f10, delegate->last_accelerator()); |
| 1269 } | 1331 } |
| 1270 } | 1332 } |
| 1271 #endif | 1333 #endif |
| 1272 | 1334 |
| 1273 } // namespace ash | 1335 } // namespace ash |
| OLD | NEW |