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/ash_switches.h" | 11 #include "ash/common/ash_switches.h" |
11 #include "ash/common/shell_window_ids.h" | 12 #include "ash/common/shell_window_ids.h" |
12 #include "ash/common/system/tray/system_tray_delegate.h" | 13 #include "ash/common/system/tray/system_tray_delegate.h" |
13 #include "ash/common/system/volume_control_delegate.h" | 14 #include "ash/common/system/volume_control_delegate.h" |
14 #include "ash/common/wm/panels/panel_layout_manager.h" | 15 #include "ash/common/wm/panels/panel_layout_manager.h" |
15 #include "ash/common/wm/window_positioning_utils.h" | 16 #include "ash/common/wm/window_positioning_utils.h" |
16 #include "ash/common/wm/window_state.h" | 17 #include "ash/common/wm/window_state.h" |
17 #include "ash/common/wm/wm_event.h" | 18 #include "ash/common/wm/wm_event.h" |
18 #include "ash/common/wm_shell.h" | 19 #include "ash/common/wm_shell.h" |
19 #include "ash/display/display_manager.h" | 20 #include "ash/display/display_manager.h" |
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
989 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | 990 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
990 | 991 |
991 EXPECT_TRUE( | 992 EXPECT_TRUE( |
992 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 993 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
993 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | 994 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
994 | 995 |
995 EXPECT_EQ(ui::VKEY_LWIN, | 996 EXPECT_EQ(ui::VKEY_LWIN, |
996 GetPreviousAccelerator().key_code()); | 997 GetPreviousAccelerator().key_code()); |
997 | 998 |
998 // When spoken feedback is on, the AppList should not toggle. | 999 // When spoken feedback is on, the AppList should not toggle. |
999 delegate->ToggleSpokenFeedback(ui::A11Y_NOTIFICATION_NONE); | 1000 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
1000 EXPECT_FALSE( | 1001 EXPECT_FALSE( |
1001 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1002 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
1002 EXPECT_FALSE( | 1003 EXPECT_FALSE( |
1003 ProcessInController(ReleaseAccelerator( | 1004 ProcessInController(ReleaseAccelerator( |
1004 ui::VKEY_LWIN, ui::EF_NONE))); | 1005 ui::VKEY_LWIN, ui::EF_NONE))); |
1005 delegate->ToggleSpokenFeedback(ui::A11Y_NOTIFICATION_NONE); | 1006 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
1006 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | 1007 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
1007 | 1008 |
1008 EXPECT_FALSE( | 1009 EXPECT_FALSE( |
1009 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1010 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
1010 EXPECT_TRUE( | 1011 EXPECT_TRUE( |
1011 ProcessInController(ReleaseAccelerator( | 1012 ProcessInController(ReleaseAccelerator( |
1012 ui::VKEY_LWIN, ui::EF_NONE))); | 1013 ui::VKEY_LWIN, ui::EF_NONE))); |
1013 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | 1014 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
1014 | 1015 |
1015 // When spoken feedback is on, the AppList should not toggle. | 1016 // When spoken feedback is on, the AppList should not toggle. |
1016 delegate->ToggleSpokenFeedback(ui::A11Y_NOTIFICATION_NONE); | 1017 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
1017 EXPECT_FALSE( | 1018 EXPECT_FALSE( |
1018 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1019 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
1019 EXPECT_FALSE( | 1020 EXPECT_FALSE( |
1020 ProcessInController(ReleaseAccelerator( | 1021 ProcessInController(ReleaseAccelerator( |
1021 ui::VKEY_LWIN, ui::EF_NONE))); | 1022 ui::VKEY_LWIN, ui::EF_NONE))); |
1022 delegate->ToggleSpokenFeedback(ui::A11Y_NOTIFICATION_NONE); | 1023 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); |
1023 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | 1024 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
1024 | 1025 |
1025 #if defined(OS_CHROMEOS) | 1026 #if defined(OS_CHROMEOS) |
1026 // The press of VKEY_BROWSER_SEARCH should toggle the AppList | 1027 // The press of VKEY_BROWSER_SEARCH should toggle the AppList |
1027 EXPECT_TRUE(ProcessInController(ui::Accelerator(ui::VKEY_BROWSER_SEARCH, | 1028 EXPECT_TRUE(ProcessInController(ui::Accelerator(ui::VKEY_BROWSER_SEARCH, |
1028 ui::EF_NONE))); | 1029 ui::EF_NONE))); |
1029 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | 1030 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
1030 EXPECT_FALSE(ProcessInController(ReleaseAccelerator(ui::VKEY_BROWSER_SEARCH, | 1031 EXPECT_FALSE(ProcessInController(ReleaseAccelerator(ui::VKEY_BROWSER_SEARCH, |
1031 ui::EF_NONE))); | 1032 ui::EF_NONE))); |
1032 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | 1033 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1313 EXPECT_EQ(volume_up, delegate->last_accelerator()); | 1314 EXPECT_EQ(volume_up, delegate->last_accelerator()); |
1314 } | 1315 } |
1315 } | 1316 } |
1316 #endif | 1317 #endif |
1317 | 1318 |
1318 TEST_F(AcceleratorControllerTest, DisallowedWithNoWindow) { | 1319 TEST_F(AcceleratorControllerTest, DisallowedWithNoWindow) { |
1319 AccessibilityDelegate* delegate = | 1320 AccessibilityDelegate* delegate = |
1320 ash::Shell::GetInstance()->accessibility_delegate(); | 1321 ash::Shell::GetInstance()->accessibility_delegate(); |
1321 | 1322 |
1322 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { | 1323 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
1323 delegate->TriggerAccessibilityAlert(ui::A11Y_ALERT_NONE); | 1324 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
1324 EXPECT_TRUE( | 1325 EXPECT_TRUE( |
1325 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i])); | 1326 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i])); |
1326 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), | 1327 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); |
1327 ui::A11Y_ALERT_WINDOW_NEEDED); | |
1328 } | 1328 } |
1329 | 1329 |
1330 // Make sure we don't alert if we do have a window. | 1330 // Make sure we don't alert if we do have a window. |
1331 std::unique_ptr<aura::Window> window; | 1331 std::unique_ptr<aura::Window> window; |
1332 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { | 1332 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
1333 window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 1333 window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
1334 wm::ActivateWindow(window.get()); | 1334 wm::ActivateWindow(window.get()); |
1335 delegate->TriggerAccessibilityAlert(ui::A11Y_ALERT_NONE); | 1335 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
1336 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); | 1336 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); |
1337 EXPECT_NE(delegate->GetLastAccessibilityAlert(), | 1337 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); |
1338 ui::A11Y_ALERT_WINDOW_NEEDED); | |
1339 } | 1338 } |
1340 | 1339 |
1341 // Don't alert if we have a minimized window either. | 1340 // Don't alert if we have a minimized window either. |
1342 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { | 1341 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
1343 window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 1342 window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
1344 wm::ActivateWindow(window.get()); | 1343 wm::ActivateWindow(window.get()); |
1345 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); | 1344 GetController()->PerformActionIfEnabled(WINDOW_MINIMIZE); |
1346 delegate->TriggerAccessibilityAlert(ui::A11Y_ALERT_NONE); | 1345 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
1347 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); | 1346 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i]); |
1348 EXPECT_NE(delegate->GetLastAccessibilityAlert(), | 1347 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); |
1349 ui::A11Y_ALERT_WINDOW_NEEDED); | |
1350 } | 1348 } |
1351 } | 1349 } |
1352 | 1350 |
1353 #if defined(OS_CHROMEOS) | 1351 #if defined(OS_CHROMEOS) |
1354 namespace { | 1352 namespace { |
1355 | 1353 |
1356 // defines a class to test the behavior of deprecated accelerators. | 1354 // defines a class to test the behavior of deprecated accelerators. |
1357 class DeprecatedAcceleratorTester : public AcceleratorControllerTest { | 1355 class DeprecatedAcceleratorTester : public AcceleratorControllerTest { |
1358 public: | 1356 public: |
1359 DeprecatedAcceleratorTester() {} | 1357 DeprecatedAcceleratorTester() {} |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1449 EXPECT_TRUE(IsMessageCenterEmpty()); | 1447 EXPECT_TRUE(IsMessageCenterEmpty()); |
1450 | 1448 |
1451 // If the action is LOCK_SCREEN, we must reset the state by unlocking the | 1449 // If the action is LOCK_SCREEN, we must reset the state by unlocking the |
1452 // screen before we proceed testing the rest of accelerators. | 1450 // screen before we proceed testing the rest of accelerators. |
1453 ResetStateIfNeeded(); | 1451 ResetStateIfNeeded(); |
1454 } | 1452 } |
1455 } | 1453 } |
1456 #endif // defined(OS_CHROMEOS) | 1454 #endif // defined(OS_CHROMEOS) |
1457 | 1455 |
1458 } // namespace ash | 1456 } // namespace ash |
OLD | NEW |