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/accessibility_delegate.h" | 8 #include "ash/accessibility_delegate.h" |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
(...skipping 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1033 EXPECT_FALSE( | 1033 EXPECT_FALSE( |
1034 GetController()->Process(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1034 GetController()->Process(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
1035 EXPECT_EQ(ui::VKEY_LWIN, | 1035 EXPECT_EQ(ui::VKEY_LWIN, |
1036 GetController()->previous_accelerator_for_test().key_code()); | 1036 GetController()->previous_accelerator_for_test().key_code()); |
1037 | 1037 |
1038 EXPECT_TRUE( | 1038 EXPECT_TRUE( |
1039 GetController()->Process(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1039 GetController()->Process(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
1040 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | 1040 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
1041 | 1041 |
1042 // When spoken feedback is on, the AppList should not toggle. | 1042 // When spoken feedback is on, the AppList should not toggle. |
1043 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 1043 delegate->ToggleSpokenFeedback(ui::A11Y_NOTIFICATION_NONE); |
1044 EXPECT_FALSE( | 1044 EXPECT_FALSE( |
1045 GetController()->Process(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1045 GetController()->Process(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
1046 EXPECT_FALSE( | 1046 EXPECT_FALSE( |
1047 GetController()->Process(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1047 GetController()->Process(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
1048 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 1048 delegate->ToggleSpokenFeedback(ui::A11Y_NOTIFICATION_NONE); |
1049 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | 1049 EXPECT_TRUE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
1050 | 1050 |
1051 EXPECT_FALSE( | 1051 EXPECT_FALSE( |
1052 GetController()->Process(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1052 GetController()->Process(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
1053 EXPECT_TRUE( | 1053 EXPECT_TRUE( |
1054 GetController()->Process(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1054 GetController()->Process(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
1055 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | 1055 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
1056 | 1056 |
1057 // When spoken feedback is on, the AppList should not toggle. | 1057 // When spoken feedback is on, the AppList should not toggle. |
1058 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 1058 delegate->ToggleSpokenFeedback(ui::A11Y_NOTIFICATION_NONE); |
1059 EXPECT_FALSE( | 1059 EXPECT_FALSE( |
1060 GetController()->Process(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1060 GetController()->Process(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
1061 EXPECT_FALSE( | 1061 EXPECT_FALSE( |
1062 GetController()->Process(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1062 GetController()->Process(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
1063 delegate->ToggleSpokenFeedback(A11Y_NOTIFICATION_NONE); | 1063 delegate->ToggleSpokenFeedback(ui::A11Y_NOTIFICATION_NONE); |
1064 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); | 1064 EXPECT_FALSE(ash::Shell::GetInstance()->GetAppListTargetVisibility()); |
1065 } | 1065 } |
1066 | 1066 |
1067 TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { | 1067 TEST_F(AcceleratorControllerTest, ImeGlobalAccelerators) { |
1068 // Test IME shortcuts. | 1068 // Test IME shortcuts. |
1069 { | 1069 { |
1070 const ui::Accelerator control_space(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); | 1070 const ui::Accelerator control_space(ui::VKEY_SPACE, ui::EF_CONTROL_DOWN); |
1071 const ui::Accelerator convert(ui::VKEY_CONVERT, ui::EF_NONE); | 1071 const ui::Accelerator convert(ui::VKEY_CONVERT, ui::EF_NONE); |
1072 const ui::Accelerator non_convert(ui::VKEY_NONCONVERT, ui::EF_NONE); | 1072 const ui::Accelerator non_convert(ui::VKEY_NONCONVERT, ui::EF_NONE); |
1073 const ui::Accelerator wide_half_1(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE); | 1073 const ui::Accelerator wide_half_1(ui::VKEY_DBE_SBCSCHAR, ui::EF_NONE); |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1440 } | 1440 } |
1441 } | 1441 } |
1442 #endif | 1442 #endif |
1443 | 1443 |
1444 TEST_F(AcceleratorControllerTest, DisallowedWithNoWindow) { | 1444 TEST_F(AcceleratorControllerTest, DisallowedWithNoWindow) { |
1445 const ui::Accelerator dummy; | 1445 const ui::Accelerator dummy; |
1446 AccessibilityDelegate* delegate = | 1446 AccessibilityDelegate* delegate = |
1447 ash::Shell::GetInstance()->accessibility_delegate(); | 1447 ash::Shell::GetInstance()->accessibility_delegate(); |
1448 | 1448 |
1449 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { | 1449 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
1450 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); | 1450 delegate->TriggerAccessibilityAlert(ui::A11Y_ALERT_NONE); |
1451 EXPECT_TRUE( | 1451 EXPECT_TRUE( |
1452 GetController()->PerformAction(kActionsNeedingWindow[i], dummy)); | 1452 GetController()->PerformAction(kActionsNeedingWindow[i], dummy)); |
1453 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); | 1453 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), |
| 1454 ui::A11Y_ALERT_WINDOW_NEEDED); |
1454 } | 1455 } |
1455 | 1456 |
1456 // Make sure we don't alert if we do have a window. | 1457 // Make sure we don't alert if we do have a window. |
1457 scoped_ptr<aura::Window> window; | 1458 scoped_ptr<aura::Window> window; |
1458 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { | 1459 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
1459 window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 1460 window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
1460 wm::ActivateWindow(window.get()); | 1461 wm::ActivateWindow(window.get()); |
1461 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); | 1462 delegate->TriggerAccessibilityAlert(ui::A11Y_ALERT_NONE); |
1462 GetController()->PerformAction(kActionsNeedingWindow[i], dummy); | 1463 GetController()->PerformAction(kActionsNeedingWindow[i], dummy); |
1463 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); | 1464 EXPECT_NE(delegate->GetLastAccessibilityAlert(), |
| 1465 ui::A11Y_ALERT_WINDOW_NEEDED); |
1464 } | 1466 } |
1465 | 1467 |
1466 // Don't alert if we have a minimized window either. | 1468 // Don't alert if we have a minimized window either. |
1467 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { | 1469 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
1468 window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); | 1470 window.reset(CreateTestWindowInShellWithBounds(gfx::Rect(5, 5, 20, 20))); |
1469 wm::ActivateWindow(window.get()); | 1471 wm::ActivateWindow(window.get()); |
1470 GetController()->PerformAction(WINDOW_MINIMIZE, dummy); | 1472 GetController()->PerformAction(WINDOW_MINIMIZE, dummy); |
1471 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); | 1473 delegate->TriggerAccessibilityAlert(ui::A11Y_ALERT_NONE); |
1472 GetController()->PerformAction(kActionsNeedingWindow[i], dummy); | 1474 GetController()->PerformAction(kActionsNeedingWindow[i], dummy); |
1473 EXPECT_NE(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); | 1475 EXPECT_NE(delegate->GetLastAccessibilityAlert(), |
| 1476 ui::A11Y_ALERT_WINDOW_NEEDED); |
1474 } | 1477 } |
1475 } | 1478 } |
1476 | 1479 |
1477 } // namespace ash | 1480 } // namespace ash |
OLD | NEW |