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 | 6 |
7 #include "ash/accelerators/accelerator_table.h" | 7 #include "ash/accelerators/accelerator_table.h" |
8 #include "ash/aura/wm_window_aura.h" | 8 #include "ash/aura/wm_window_aura.h" |
9 #include "ash/common/accessibility_delegate.h" | 9 #include "ash/common/accessibility_delegate.h" |
10 #include "ash/common/accessibility_types.h" | 10 #include "ash/common/accessibility_types.h" |
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 // NOTE: Accelerators that do not work on the lock screen need to be | 947 // NOTE: Accelerators that do not work on the lock screen need to be |
948 // tested before the sequence below is invoked because it causes a side | 948 // tested before the sequence below is invoked because it causes a side |
949 // effect of locking the screen. | 949 // effect of locking the screen. |
950 EXPECT_TRUE(ProcessInController( | 950 EXPECT_TRUE(ProcessInController( |
951 ui::Accelerator(ui::VKEY_L, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); | 951 ui::Accelerator(ui::VKEY_L, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); |
952 #endif | 952 #endif |
953 } | 953 } |
954 | 954 |
955 TEST_F(AcceleratorControllerTest, GlobalAcceleratorsToggleAppList) { | 955 TEST_F(AcceleratorControllerTest, GlobalAcceleratorsToggleAppList) { |
956 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); | 956 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); |
957 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); | 957 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); |
958 | 958 |
959 // The press event should not open the AppList, the release should instead. | 959 // The press event should not open the AppList, the release should instead. |
960 EXPECT_FALSE( | 960 EXPECT_FALSE( |
961 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 961 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
962 EXPECT_EQ(ui::VKEY_LWIN, GetCurrentAccelerator().key_code()); | 962 EXPECT_EQ(ui::VKEY_LWIN, GetCurrentAccelerator().key_code()); |
963 | 963 |
964 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); | 964 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); |
965 | 965 |
966 EXPECT_TRUE( | 966 EXPECT_TRUE( |
967 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 967 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
968 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | 968 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); |
969 | 969 |
970 EXPECT_EQ(ui::VKEY_LWIN, GetPreviousAccelerator().key_code()); | 970 EXPECT_EQ(ui::VKEY_LWIN, GetPreviousAccelerator().key_code()); |
971 | 971 |
972 // When spoken feedback is on, the AppList should not toggle. | 972 // When spoken feedback is on, the AppList should not toggle. |
973 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 973 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
974 EXPECT_FALSE( | 974 EXPECT_FALSE( |
975 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 975 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
976 EXPECT_FALSE( | 976 EXPECT_FALSE( |
977 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 977 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
978 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 978 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
979 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | 979 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); |
980 | 980 |
981 EXPECT_FALSE( | 981 EXPECT_FALSE( |
982 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 982 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
983 EXPECT_TRUE( | 983 EXPECT_TRUE( |
984 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 984 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
985 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); | 985 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); |
986 | 986 |
987 // When spoken feedback is on, the AppList should not toggle. | 987 // When spoken feedback is on, the AppList should not toggle. |
988 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 988 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
989 EXPECT_FALSE( | 989 EXPECT_FALSE( |
990 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 990 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
991 EXPECT_FALSE( | 991 EXPECT_FALSE( |
992 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 992 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
993 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 993 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
994 EXPECT_FALSE(Shell::GetInstance()->GetAppListTargetVisibility()); | 994 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); |
995 | 995 |
996 #if defined(OS_CHROMEOS) | 996 #if defined(OS_CHROMEOS) |
997 // The press of VKEY_BROWSER_SEARCH should toggle the AppList | 997 // The press of VKEY_BROWSER_SEARCH should toggle the AppList |
998 EXPECT_TRUE(ProcessInController( | 998 EXPECT_TRUE(ProcessInController( |
999 ui::Accelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); | 999 ui::Accelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); |
1000 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | 1000 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); |
1001 EXPECT_FALSE(ProcessInController( | 1001 EXPECT_FALSE(ProcessInController( |
1002 ReleaseAccelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); | 1002 ReleaseAccelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); |
1003 EXPECT_TRUE(Shell::GetInstance()->GetAppListTargetVisibility()); | 1003 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); |
1004 #endif | 1004 #endif |
1005 } | 1005 } |
1006 | 1006 |
1007 TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { | 1007 TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { |
1008 // Test IME shortcuts. | 1008 // Test IME shortcuts. |
1009 ui::Accelerator control_space_down(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 1009 ui::Accelerator control_space_down(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
1010 control_space_down.set_type(ui::ET_KEY_PRESSED); | 1010 control_space_down.set_type(ui::ET_KEY_PRESSED); |
1011 ui::Accelerator control_space_up(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 1011 ui::Accelerator control_space_up(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
1012 control_space_up.set_type(ui::ET_KEY_RELEASED); | 1012 control_space_up.set_type(ui::ET_KEY_RELEASED); |
1013 const ui::Accelerator convert(ui::VKEY_CONVERT, ui::EF_NONE); | 1013 const ui::Accelerator convert(ui::VKEY_CONVERT, ui::EF_NONE); |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1411 EXPECT_TRUE(IsMessageCenterEmpty()); | 1411 EXPECT_TRUE(IsMessageCenterEmpty()); |
1412 | 1412 |
1413 // If the action is LOCK_SCREEN, we must reset the state by unlocking the | 1413 // If the action is LOCK_SCREEN, we must reset the state by unlocking the |
1414 // screen before we proceed testing the rest of accelerators. | 1414 // screen before we proceed testing the rest of accelerators. |
1415 ResetStateIfNeeded(); | 1415 ResetStateIfNeeded(); |
1416 } | 1416 } |
1417 } | 1417 } |
1418 #endif // defined(OS_CHROMEOS) | 1418 #endif // defined(OS_CHROMEOS) |
1419 | 1419 |
1420 } // namespace ash | 1420 } // namespace ash |
OLD | NEW |