| 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 872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 883 | 883 |
| 884 // Lock screen | 884 // Lock screen |
| 885 // NOTE: Accelerators that do not work on the lock screen need to be | 885 // NOTE: Accelerators that do not work on the lock screen need to be |
| 886 // tested before the sequence below is invoked because it causes a side | 886 // tested before the sequence below is invoked because it causes a side |
| 887 // effect of locking the screen. | 887 // effect of locking the screen. |
| 888 EXPECT_TRUE(ProcessWithContext( | 888 EXPECT_TRUE(ProcessWithContext( |
| 889 ui::Accelerator(ui::VKEY_L, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); | 889 ui::Accelerator(ui::VKEY_L, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); |
| 890 #endif | 890 #endif |
| 891 } | 891 } |
| 892 | 892 |
| 893 TEST_F(AcceleratorControllerTest, | 893 TEST_F(AcceleratorControllerTest, GlobalAcceleratorsToggleAppList) { |
| 894 GlobalAcceleratorsToggleAppListWithoutSearchAsModifier) { | |
| 895 ShellDelegate* delegate = ash::Shell::GetInstance()->delegate(); | |
| 896 | |
| 897 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | |
| 898 | |
| 899 // When Search is not acting as a modifier, pressing Search should toggle | |
| 900 // the AppList | |
| 901 EXPECT_TRUE(ProcessWithContext( | |
| 902 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | |
| 903 EXPECT_FALSE(ProcessWithContext( | |
| 904 ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | |
| 905 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | |
| 906 | |
| 907 // When spoken feedback is on, the AppList should not toggle. | |
| 908 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | |
| 909 EXPECT_FALSE(ProcessWithContext( | |
| 910 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | |
| 911 EXPECT_FALSE(ProcessWithContext( | |
| 912 ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | |
| 913 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | |
| 914 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | |
| 915 | |
| 916 EXPECT_TRUE(ProcessWithContext( | |
| 917 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | |
| 918 EXPECT_FALSE(ProcessWithContext( | |
| 919 ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | |
| 920 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | |
| 921 | |
| 922 // When spoken feedback is on, the AppList should not toggle. | |
| 923 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | |
| 924 EXPECT_FALSE(ProcessWithContext( | |
| 925 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | |
| 926 EXPECT_FALSE(ProcessWithContext( | |
| 927 ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | |
| 928 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | |
| 929 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | |
| 930 } | |
| 931 | |
| 932 TEST_F(AcceleratorControllerTest, | |
| 933 GlobalAcceleratorsToggleAppListWithSearchAsModifier) { | |
| 934 test::TestShellDelegate* delegate = | 894 test::TestShellDelegate* delegate = |
| 935 reinterpret_cast<test::TestShellDelegate*>( | 895 reinterpret_cast<test::TestShellDelegate*>( |
| 936 ash::Shell::GetInstance()->delegate()); | 896 ash::Shell::GetInstance()->delegate()); |
| 937 delegate->set_is_search_key_acting_as_function_key(true); | |
| 938 | |
| 939 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | 897 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
| 940 | 898 |
| 941 // When Search is acting as a modifier for accessing extended keyboard | 899 // The press event should not open the AppList, the release should instead. |
| 942 // shortcuts, then the press event should not open the AppList, and the | |
| 943 // release should instead. | |
| 944 EXPECT_FALSE(ProcessWithContext( | 900 EXPECT_FALSE(ProcessWithContext( |
| 945 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 901 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 946 EXPECT_TRUE(ProcessWithContext( | 902 EXPECT_TRUE(ProcessWithContext( |
| 947 ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 903 ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 948 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | 904 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
| 949 | 905 |
| 950 // When spoken feedback is on, the AppList should not toggle. | 906 // When spoken feedback is on, the AppList should not toggle. |
| 951 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 907 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
| 952 EXPECT_FALSE(ProcessWithContext( | 908 EXPECT_FALSE(ProcessWithContext( |
| 953 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 909 ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1276 EXPECT_EQ(volume_down, delegate->last_accelerator()); | 1232 EXPECT_EQ(volume_down, delegate->last_accelerator()); |
| 1277 EXPECT_EQ(0, delegate->handle_volume_up_count()); | 1233 EXPECT_EQ(0, delegate->handle_volume_up_count()); |
| 1278 EXPECT_TRUE(ProcessWithContext(volume_up)); | 1234 EXPECT_TRUE(ProcessWithContext(volume_up)); |
| 1279 EXPECT_EQ(1, delegate->handle_volume_up_count()); | 1235 EXPECT_EQ(1, delegate->handle_volume_up_count()); |
| 1280 EXPECT_EQ(volume_up, delegate->last_accelerator()); | 1236 EXPECT_EQ(volume_up, delegate->last_accelerator()); |
| 1281 } | 1237 } |
| 1282 } | 1238 } |
| 1283 #endif | 1239 #endif |
| 1284 | 1240 |
| 1285 } // namespace ash | 1241 } // namespace ash |
| OLD | NEW |