| 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 824 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 835 // CycleBackward | 835 // CycleBackward |
| 836 EXPECT_TRUE(ProcessInController( | 836 EXPECT_TRUE(ProcessInController( |
| 837 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); | 837 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); |
| 838 // CycleForward | 838 // CycleForward |
| 839 EXPECT_TRUE( | 839 EXPECT_TRUE( |
| 840 ProcessInController(ui::Accelerator(ui::VKEY_TAB, ui::EF_ALT_DOWN))); | 840 ProcessInController(ui::Accelerator(ui::VKEY_TAB, ui::EF_ALT_DOWN))); |
| 841 // CycleLinear | 841 // CycleLinear |
| 842 EXPECT_TRUE(ProcessInController( | 842 EXPECT_TRUE(ProcessInController( |
| 843 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_NONE))); | 843 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_NONE))); |
| 844 | 844 |
| 845 #if defined(OS_CHROMEOS) | |
| 846 // The "Take Screenshot", "Take Partial Screenshot", volume, brightness, and | 845 // The "Take Screenshot", "Take Partial Screenshot", volume, brightness, and |
| 847 // keyboard brightness accelerators are only defined on ChromeOS. | 846 // keyboard brightness accelerators are only defined on ChromeOS. |
| 848 // TODO: needs ScreenShotDelegate converted: http://crbug.com/612331. | 847 // TODO: needs ScreenShotDelegate converted: http://crbug.com/612331. |
| 849 /* | 848 /* |
| 850 { | 849 { |
| 851 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); | 850 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); |
| 852 delegate->set_can_take_screenshot(false); | 851 delegate->set_can_take_screenshot(false); |
| 853 EXPECT_TRUE(ProcessInController( | 852 EXPECT_TRUE(ProcessInController( |
| 854 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_CONTROL_DOWN))); | 853 ui::Accelerator(ui::VKEY_MEDIA_LAUNCH_APP1, ui::EF_CONTROL_DOWN))); |
| 855 EXPECT_TRUE( | 854 EXPECT_TRUE( |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 925 std::unique_ptr<KeyboardBrightnessControlDelegate>(delegate)); | 924 std::unique_ptr<KeyboardBrightnessControlDelegate>(delegate)); |
| 926 EXPECT_EQ(0, delegate->handle_keyboard_brightness_down_count()); | 925 EXPECT_EQ(0, delegate->handle_keyboard_brightness_down_count()); |
| 927 EXPECT_TRUE(ProcessInController(alt_brightness_down)); | 926 EXPECT_TRUE(ProcessInController(alt_brightness_down)); |
| 928 EXPECT_EQ(1, delegate->handle_keyboard_brightness_down_count()); | 927 EXPECT_EQ(1, delegate->handle_keyboard_brightness_down_count()); |
| 929 EXPECT_EQ(alt_brightness_down, delegate->last_accelerator()); | 928 EXPECT_EQ(alt_brightness_down, delegate->last_accelerator()); |
| 930 EXPECT_EQ(0, delegate->handle_keyboard_brightness_up_count()); | 929 EXPECT_EQ(0, delegate->handle_keyboard_brightness_up_count()); |
| 931 EXPECT_TRUE(ProcessInController(alt_brightness_up)); | 930 EXPECT_TRUE(ProcessInController(alt_brightness_up)); |
| 932 EXPECT_EQ(1, delegate->handle_keyboard_brightness_up_count()); | 931 EXPECT_EQ(1, delegate->handle_keyboard_brightness_up_count()); |
| 933 EXPECT_EQ(alt_brightness_up, delegate->last_accelerator()); | 932 EXPECT_EQ(alt_brightness_up, delegate->last_accelerator()); |
| 934 } | 933 } |
| 935 #endif | |
| 936 | 934 |
| 937 #if !defined(OS_WIN) | |
| 938 // Exit | 935 // Exit |
| 939 ExitWarningHandler* ewh = GetController()->GetExitWarningHandlerForTest(); | 936 ExitWarningHandler* ewh = GetController()->GetExitWarningHandlerForTest(); |
| 940 ASSERT_TRUE(ewh); | 937 ASSERT_TRUE(ewh); |
| 941 StubForTest(ewh); | 938 StubForTest(ewh); |
| 942 EXPECT_TRUE(is_idle(ewh)); | 939 EXPECT_TRUE(is_idle(ewh)); |
| 943 EXPECT_FALSE(is_ui_shown(ewh)); | 940 EXPECT_FALSE(is_ui_shown(ewh)); |
| 944 EXPECT_TRUE(ProcessInController( | 941 EXPECT_TRUE(ProcessInController( |
| 945 ui::Accelerator(ui::VKEY_Q, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); | 942 ui::Accelerator(ui::VKEY_Q, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); |
| 946 EXPECT_FALSE(is_idle(ewh)); | 943 EXPECT_FALSE(is_idle(ewh)); |
| 947 EXPECT_TRUE(is_ui_shown(ewh)); | 944 EXPECT_TRUE(is_ui_shown(ewh)); |
| 948 SimulateTimerExpired(ewh); | 945 SimulateTimerExpired(ewh); |
| 949 EXPECT_TRUE(is_idle(ewh)); | 946 EXPECT_TRUE(is_idle(ewh)); |
| 950 EXPECT_FALSE(is_ui_shown(ewh)); | 947 EXPECT_FALSE(is_ui_shown(ewh)); |
| 951 Reset(ewh); | 948 Reset(ewh); |
| 952 #endif | |
| 953 | 949 |
| 954 // New tab | 950 // New tab |
| 955 EXPECT_TRUE( | 951 EXPECT_TRUE( |
| 956 ProcessInController(ui::Accelerator(ui::VKEY_T, ui::EF_CONTROL_DOWN))); | 952 ProcessInController(ui::Accelerator(ui::VKEY_T, ui::EF_CONTROL_DOWN))); |
| 957 | 953 |
| 958 // New incognito window | 954 // New incognito window |
| 959 // TODO(sky): this should be true but fails because WmTestBase is not using | 955 // TODO(sky): this should be true but fails because WmTestBase is not using |
| 960 // TestShellDelegate: http://crbug.com/632211. | 956 // TestShellDelegate: http://crbug.com/632211. |
| 961 EXPECT_FALSE(ProcessInController( | 957 EXPECT_FALSE(ProcessInController( |
| 962 ui::Accelerator(ui::VKEY_N, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); | 958 ui::Accelerator(ui::VKEY_N, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); |
| 963 | 959 |
| 964 // New window | 960 // New window |
| 965 EXPECT_TRUE( | 961 EXPECT_TRUE( |
| 966 ProcessInController(ui::Accelerator(ui::VKEY_N, ui::EF_CONTROL_DOWN))); | 962 ProcessInController(ui::Accelerator(ui::VKEY_N, ui::EF_CONTROL_DOWN))); |
| 967 | 963 |
| 968 // Restore tab | 964 // Restore tab |
| 969 EXPECT_TRUE(ProcessInController( | 965 EXPECT_TRUE(ProcessInController( |
| 970 ui::Accelerator(ui::VKEY_T, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); | 966 ui::Accelerator(ui::VKEY_T, ui::EF_SHIFT_DOWN | ui::EF_CONTROL_DOWN))); |
| 971 | 967 |
| 972 // Show task manager | 968 // Show task manager |
| 973 EXPECT_TRUE( | 969 EXPECT_TRUE( |
| 974 ProcessInController(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_SHIFT_DOWN))); | 970 ProcessInController(ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_SHIFT_DOWN))); |
| 975 | 971 |
| 976 #if defined(OS_CHROMEOS) | |
| 977 // Open file manager | 972 // Open file manager |
| 978 EXPECT_TRUE(ProcessInController( | 973 EXPECT_TRUE(ProcessInController( |
| 979 ui::Accelerator(ui::VKEY_M, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); | 974 ui::Accelerator(ui::VKEY_M, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); |
| 980 | 975 |
| 981 // Lock screen | 976 // Lock screen |
| 982 // TODO(derat): Reenable this once user sessions work in mash. | 977 // TODO(derat): Reenable this once user sessions work in mash. |
| 983 EXPECT_FALSE( | 978 EXPECT_FALSE( |
| 984 ProcessInController(ui::Accelerator(ui::VKEY_L, ui::EF_COMMAND_DOWN))); | 979 ProcessInController(ui::Accelerator(ui::VKEY_L, ui::EF_COMMAND_DOWN))); |
| 985 #endif | |
| 986 } | 980 } |
| 987 | 981 |
| 988 // TODO: fails in mash, http://crbug.com/632180. | 982 // TODO: fails in mash, http://crbug.com/632180. |
| 989 TEST_F(AcceleratorControllerTest, DISABLED_GlobalAcceleratorsToggleAppList) { | 983 TEST_F(AcceleratorControllerTest, DISABLED_GlobalAcceleratorsToggleAppList) { |
| 990 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); | 984 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); |
| 991 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); | 985 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); |
| 992 | 986 |
| 993 // The press event should not open the AppList, the release should instead. | 987 // The press event should not open the AppList, the release should instead. |
| 994 EXPECT_FALSE( | 988 EXPECT_FALSE( |
| 995 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 989 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1020 | 1014 |
| 1021 // When spoken feedback is on, the AppList should not toggle. | 1015 // When spoken feedback is on, the AppList should not toggle. |
| 1022 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 1016 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
| 1023 EXPECT_FALSE( | 1017 EXPECT_FALSE( |
| 1024 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1018 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 1025 EXPECT_FALSE( | 1019 EXPECT_FALSE( |
| 1026 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1020 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 1027 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 1021 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
| 1028 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); | 1022 EXPECT_FALSE(WmShell::Get()->GetAppListTargetVisibility()); |
| 1029 | 1023 |
| 1030 #if defined(OS_CHROMEOS) | |
| 1031 // The press of VKEY_BROWSER_SEARCH should toggle the AppList | 1024 // The press of VKEY_BROWSER_SEARCH should toggle the AppList |
| 1032 EXPECT_TRUE(ProcessInController( | 1025 EXPECT_TRUE(ProcessInController( |
| 1033 ui::Accelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); | 1026 ui::Accelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); |
| 1034 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); | 1027 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); |
| 1035 EXPECT_FALSE(ProcessInController( | 1028 EXPECT_FALSE(ProcessInController( |
| 1036 ReleaseAccelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); | 1029 ReleaseAccelerator(ui::VKEY_BROWSER_SEARCH, ui::EF_NONE))); |
| 1037 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); | 1030 EXPECT_TRUE(WmShell::Get()->GetAppListTargetVisibility()); |
| 1038 #endif | |
| 1039 } | 1031 } |
| 1040 | 1032 |
| 1041 TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { | 1033 TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { |
| 1042 // Test IME shortcuts. | 1034 // Test IME shortcuts. |
| 1043 ui::Accelerator control_space_down(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 1035 ui::Accelerator control_space_down(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 1044 control_space_down.set_type(ui::ET_KEY_PRESSED); | 1036 control_space_down.set_type(ui::ET_KEY_PRESSED); |
| 1045 ui::Accelerator control_space_up(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 1037 ui::Accelerator control_space_up(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
| 1046 control_space_up.set_type(ui::ET_KEY_RELEASED); | 1038 control_space_up.set_type(ui::ET_KEY_RELEASED); |
| 1047 const ui::Accelerator convert(ui::VKEY_CONVERT, ui::EF_NONE); | 1039 const ui::Accelerator convert(ui::VKEY_CONVERT, ui::EF_NONE); |
| 1048 const ui::Accelerator non_convert(ui::VKEY_NONCONVERT, ui::EF_NONE); | 1040 const ui::Accelerator non_convert(ui::VKEY_NONCONVERT, ui::EF_NONE); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 // use Shift+Alt+Enter/Space with ET_KEY_PRESSED as an accelerator. Test it. | 1075 // use Shift+Alt+Enter/Space with ET_KEY_PRESSED as an accelerator. Test it. |
| 1084 const ui::Accelerator shift_alt_return_press( | 1076 const ui::Accelerator shift_alt_return_press( |
| 1085 ui::VKEY_RETURN, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); | 1077 ui::VKEY_RETURN, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); |
| 1086 EXPECT_FALSE(ProcessInController(shift_alt_return_press)); | 1078 EXPECT_FALSE(ProcessInController(shift_alt_return_press)); |
| 1087 const ui::Accelerator shift_alt_space_press( | 1079 const ui::Accelerator shift_alt_space_press( |
| 1088 ui::VKEY_SPACE, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); | 1080 ui::VKEY_SPACE, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN); |
| 1089 EXPECT_FALSE(ProcessInController(shift_alt_space_press)); | 1081 EXPECT_FALSE(ProcessInController(shift_alt_space_press)); |
| 1090 } | 1082 } |
| 1091 | 1083 |
| 1092 TEST_F(AcceleratorControllerTest, PreferredReservedAccelerators) { | 1084 TEST_F(AcceleratorControllerTest, PreferredReservedAccelerators) { |
| 1093 #if defined(OS_CHROMEOS) | |
| 1094 // Power key is reserved on chromeos. | 1085 // Power key is reserved on chromeos. |
| 1095 EXPECT_TRUE(GetController()->IsReserved( | 1086 EXPECT_TRUE(GetController()->IsReserved( |
| 1096 ui::Accelerator(ui::VKEY_POWER, ui::EF_NONE))); | 1087 ui::Accelerator(ui::VKEY_POWER, ui::EF_NONE))); |
| 1097 EXPECT_FALSE(GetController()->IsPreferred( | 1088 EXPECT_FALSE(GetController()->IsPreferred( |
| 1098 ui::Accelerator(ui::VKEY_POWER, ui::EF_NONE))); | 1089 ui::Accelerator(ui::VKEY_POWER, ui::EF_NONE))); |
| 1099 #endif | |
| 1100 // ALT+Tab are not reserved but preferred. | 1090 // ALT+Tab are not reserved but preferred. |
| 1101 EXPECT_FALSE(GetController()->IsReserved( | 1091 EXPECT_FALSE(GetController()->IsReserved( |
| 1102 ui::Accelerator(ui::VKEY_TAB, ui::EF_ALT_DOWN))); | 1092 ui::Accelerator(ui::VKEY_TAB, ui::EF_ALT_DOWN))); |
| 1103 EXPECT_FALSE(GetController()->IsReserved( | 1093 EXPECT_FALSE(GetController()->IsReserved( |
| 1104 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); | 1094 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); |
| 1105 EXPECT_TRUE(GetController()->IsPreferred( | 1095 EXPECT_TRUE(GetController()->IsPreferred( |
| 1106 ui::Accelerator(ui::VKEY_TAB, ui::EF_ALT_DOWN))); | 1096 ui::Accelerator(ui::VKEY_TAB, ui::EF_ALT_DOWN))); |
| 1107 EXPECT_TRUE(GetController()->IsPreferred( | 1097 EXPECT_TRUE(GetController()->IsPreferred( |
| 1108 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); | 1098 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); |
| 1109 | 1099 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1148 WmWindow* w1 = WmWindow::Get(CreateTestWindow(gfx::Rect())); | 1138 WmWindow* w1 = WmWindow::Get(CreateTestWindow(gfx::Rect())); |
| 1149 WmWindow* w2 = WmWindow::Get(CreateTestWindow(gfx::Rect())); | 1139 WmWindow* w2 = WmWindow::Get(CreateTestWindow(gfx::Rect())); |
| 1150 wm::ActivateWindow(w1); | 1140 wm::ActivateWindow(w1); |
| 1151 | 1141 |
| 1152 wm::WMEvent fullscreen(wm::WM_EVENT_FULLSCREEN); | 1142 wm::WMEvent fullscreen(wm::WM_EVENT_FULLSCREEN); |
| 1153 wm::WindowState* w1_state = w1->GetWindowState(); | 1143 wm::WindowState* w1_state = w1->GetWindowState(); |
| 1154 w1_state->OnWMEvent(&fullscreen); | 1144 w1_state->OnWMEvent(&fullscreen); |
| 1155 ASSERT_TRUE(w1_state->IsFullscreen()); | 1145 ASSERT_TRUE(w1_state->IsFullscreen()); |
| 1156 | 1146 |
| 1157 ui::test::EventGenerator& generator = GetEventGenerator(); | 1147 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 1158 #if defined(OS_CHROMEOS) | |
| 1159 // Power key (reserved) should always be handled. | 1148 // Power key (reserved) should always be handled. |
| 1160 LockStateController::TestApi test_api( | 1149 LockStateController::TestApi test_api( |
| 1161 Shell::GetInstance()->lock_state_controller()); | 1150 Shell::GetInstance()->lock_state_controller()); |
| 1162 EXPECT_FALSE(test_api.is_animating_lock()); | 1151 EXPECT_FALSE(test_api.is_animating_lock()); |
| 1163 generator.PressKey(ui::VKEY_POWER, ui::EF_NONE); | 1152 generator.PressKey(ui::VKEY_POWER, ui::EF_NONE); |
| 1164 EXPECT_TRUE(test_api.is_animating_lock()); | 1153 EXPECT_TRUE(test_api.is_animating_lock()); |
| 1165 #endif | |
| 1166 | 1154 |
| 1167 // A fullscreen window can consume ALT-TAB (preferred). | 1155 // A fullscreen window can consume ALT-TAB (preferred). |
| 1168 ASSERT_EQ(w1, wm::GetActiveWindow()); | 1156 ASSERT_EQ(w1, wm::GetActiveWindow()); |
| 1169 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); | 1157 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| 1170 ASSERT_EQ(w1, wm::GetActiveWindow()); | 1158 ASSERT_EQ(w1, wm::GetActiveWindow()); |
| 1171 ASSERT_NE(w2, wm::GetActiveWindow()); | 1159 ASSERT_NE(w2, wm::GetActiveWindow()); |
| 1172 | 1160 |
| 1173 // ALT-TAB is non repeatable. Press A to cancel the | 1161 // ALT-TAB is non repeatable. Press A to cancel the |
| 1174 // repeat record. | 1162 // repeat record. |
| 1175 generator.PressKey(ui::VKEY_A, ui::EF_NONE); | 1163 generator.PressKey(ui::VKEY_A, ui::EF_NONE); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1193 wm::ActivateWindow(w1); | 1181 wm::ActivateWindow(w1); |
| 1194 | 1182 |
| 1195 { | 1183 { |
| 1196 wm::WMEvent pin_event(wm::WM_EVENT_PIN); | 1184 wm::WMEvent pin_event(wm::WM_EVENT_PIN); |
| 1197 wm::WindowState* w1_state = wm::GetWindowState(w1); | 1185 wm::WindowState* w1_state = wm::GetWindowState(w1); |
| 1198 w1_state->OnWMEvent(&pin_event); | 1186 w1_state->OnWMEvent(&pin_event); |
| 1199 ASSERT_TRUE(w1_state->IsPinned()); | 1187 ASSERT_TRUE(w1_state->IsPinned()); |
| 1200 } | 1188 } |
| 1201 | 1189 |
| 1202 ui::test::EventGenerator& generator = GetEventGenerator(); | 1190 ui::test::EventGenerator& generator = GetEventGenerator(); |
| 1203 #if defined(OS_CHROMEOS) | |
| 1204 // Power key (reserved) should always be handled. | 1191 // Power key (reserved) should always be handled. |
| 1205 LockStateController::TestApi test_api( | 1192 LockStateController::TestApi test_api( |
| 1206 Shell::GetInstance()->lock_state_controller()); | 1193 Shell::GetInstance()->lock_state_controller()); |
| 1207 EXPECT_FALSE(test_api.is_animating_lock()); | 1194 EXPECT_FALSE(test_api.is_animating_lock()); |
| 1208 generator.PressKey(ui::VKEY_POWER, ui::EF_NONE); | 1195 generator.PressKey(ui::VKEY_POWER, ui::EF_NONE); |
| 1209 EXPECT_TRUE(test_api.is_animating_lock()); | 1196 EXPECT_TRUE(test_api.is_animating_lock()); |
| 1210 #endif | |
| 1211 | 1197 |
| 1212 // A pinned window can consume ALT-TAB (preferred), but no side effect. | 1198 // A pinned window can consume ALT-TAB (preferred), but no side effect. |
| 1213 ASSERT_EQ(w1, wm::GetActiveWindow()); | 1199 ASSERT_EQ(w1, wm::GetActiveWindow()); |
| 1214 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); | 1200 generator.PressKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| 1215 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); | 1201 generator.ReleaseKey(ui::VKEY_TAB, ui::EF_ALT_DOWN); |
| 1216 ASSERT_EQ(w1, wm::GetActiveWindow()); | 1202 ASSERT_EQ(w1, wm::GetActiveWindow()); |
| 1217 ASSERT_NE(w2, wm::GetActiveWindow()); | 1203 ASSERT_NE(w2, wm::GetActiveWindow()); |
| 1218 } | 1204 } |
| 1219 */ | 1205 */ |
| 1220 | 1206 |
| 1221 #if defined(OS_CHROMEOS) | |
| 1222 TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { | 1207 TEST_F(AcceleratorControllerTest, DisallowedAtModalWindow) { |
| 1223 std::set<AcceleratorAction> all_actions; | 1208 std::set<AcceleratorAction> all_actions; |
| 1224 for (size_t i = 0; i < kAcceleratorDataLength; ++i) | 1209 for (size_t i = 0; i < kAcceleratorDataLength; ++i) |
| 1225 all_actions.insert(kAcceleratorData[i].action); | 1210 all_actions.insert(kAcceleratorData[i].action); |
| 1226 std::set<AcceleratorAction> all_debug_actions; | 1211 std::set<AcceleratorAction> all_debug_actions; |
| 1227 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) | 1212 for (size_t i = 0; i < kDebugAcceleratorDataLength; ++i) |
| 1228 all_debug_actions.insert(kDebugAcceleratorData[i].action); | 1213 all_debug_actions.insert(kDebugAcceleratorData[i].action); |
| 1229 std::set<AcceleratorAction> all_dev_actions; | 1214 std::set<AcceleratorAction> all_dev_actions; |
| 1230 for (size_t i = 0; i < kDeveloperAcceleratorDataLength; ++i) | 1215 for (size_t i = 0; i < kDeveloperAcceleratorDataLength; ++i) |
| 1231 all_dev_actions.insert(kDeveloperAcceleratorData[i].action); | 1216 all_dev_actions.insert(kDeveloperAcceleratorData[i].action); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 EXPECT_TRUE(ProcessInController(volume_down)); | 1300 EXPECT_TRUE(ProcessInController(volume_down)); |
| 1316 EXPECT_EQ(1, user_action_tester.GetActionCount("Accel_VolumeDown_F9")); | 1301 EXPECT_EQ(1, user_action_tester.GetActionCount("Accel_VolumeDown_F9")); |
| 1317 EXPECT_EQ(volume_down, history->current_accelerator()); | 1302 EXPECT_EQ(volume_down, history->current_accelerator()); |
| 1318 | 1303 |
| 1319 EXPECT_EQ(0, user_action_tester.GetActionCount("Accel_VolumeUp_F10")); | 1304 EXPECT_EQ(0, user_action_tester.GetActionCount("Accel_VolumeUp_F10")); |
| 1320 EXPECT_TRUE(ProcessInController(volume_up)); | 1305 EXPECT_TRUE(ProcessInController(volume_up)); |
| 1321 EXPECT_EQ(volume_up, history->current_accelerator()); | 1306 EXPECT_EQ(volume_up, history->current_accelerator()); |
| 1322 EXPECT_EQ(1, user_action_tester.GetActionCount("Accel_VolumeUp_F10")); | 1307 EXPECT_EQ(1, user_action_tester.GetActionCount("Accel_VolumeUp_F10")); |
| 1323 } | 1308 } |
| 1324 } | 1309 } |
| 1325 #endif | |
| 1326 | 1310 |
| 1327 // TODO: reenable. Disabled because shelf asynchronously created: | 1311 // TODO: reenable. Disabled because shelf asynchronously created: |
| 1328 // http://crbug.com/632192. | 1312 // http://crbug.com/632192. |
| 1329 TEST_F(AcceleratorControllerTest, DISABLED_DisallowedWithNoWindow) { | 1313 TEST_F(AcceleratorControllerTest, DISABLED_DisallowedWithNoWindow) { |
| 1330 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); | 1314 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); |
| 1331 | 1315 |
| 1332 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { | 1316 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
| 1333 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); | 1317 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
| 1334 EXPECT_TRUE( | 1318 EXPECT_TRUE( |
| 1335 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i])); | 1319 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i])); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1351 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); | 1335 aura::Window* aura_window = CreateTestWindow(gfx::Rect(5, 5, 20, 20)); |
| 1352 WmWindow::Get(aura_window)->Activate(); | 1336 WmWindow::Get(aura_window)->Activate(); |
| 1353 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); | 1337 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); |
| 1354 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); | 1338 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
| 1355 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); | 1339 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); |
| 1356 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); | 1340 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); |
| 1357 delete aura_window; | 1341 delete aura_window; |
| 1358 } | 1342 } |
| 1359 } | 1343 } |
| 1360 | 1344 |
| 1361 #if defined(OS_CHROMEOS) | |
| 1362 namespace { | 1345 namespace { |
| 1363 | 1346 |
| 1364 // defines a class to test the behavior of deprecated accelerators. | 1347 // defines a class to test the behavior of deprecated accelerators. |
| 1365 class DeprecatedAcceleratorTester : public AcceleratorControllerTest { | 1348 class DeprecatedAcceleratorTester : public AcceleratorControllerTest { |
| 1366 public: | 1349 public: |
| 1367 DeprecatedAcceleratorTester() {} | 1350 DeprecatedAcceleratorTester() {} |
| 1368 ~DeprecatedAcceleratorTester() override {} | 1351 ~DeprecatedAcceleratorTester() override {} |
| 1369 | 1352 |
| 1370 // TODO: this override should be removed and put in WmTestBase. | 1353 // TODO: this override should be removed and put in WmTestBase. |
| 1371 // http://crbug.com/632200. | 1354 // http://crbug.com/632200. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1462 EXPECT_TRUE(ProcessInController(CreateAccelerator(data))); | 1445 EXPECT_TRUE(ProcessInController(CreateAccelerator(data))); |
| 1463 | 1446 |
| 1464 // Expect no notifications from the new accelerators. | 1447 // Expect no notifications from the new accelerators. |
| 1465 EXPECT_TRUE(IsMessageCenterEmpty()); | 1448 EXPECT_TRUE(IsMessageCenterEmpty()); |
| 1466 | 1449 |
| 1467 // If the action is LOCK_SCREEN, we must reset the state by unlocking the | 1450 // If the action is LOCK_SCREEN, we must reset the state by unlocking the |
| 1468 // screen before we proceed testing the rest of accelerators. | 1451 // screen before we proceed testing the rest of accelerators. |
| 1469 ResetStateIfNeeded(); | 1452 ResetStateIfNeeded(); |
| 1470 } | 1453 } |
| 1471 } | 1454 } |
| 1472 #endif // defined(OS_CHROMEOS) | |
| 1473 | 1455 |
| 1474 } // namespace ash | 1456 } // namespace ash |
| OLD | NEW |