| 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 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1015 // tested before the sequence below is invoked because it causes a side | 1015 // tested before the sequence below is invoked because it causes a side |
| 1016 // effect of locking the screen. | 1016 // effect of locking the screen. |
| 1017 EXPECT_TRUE( | 1017 EXPECT_TRUE( |
| 1018 ProcessInController(ui::Accelerator(ui::VKEY_L, ui::EF_COMMAND_DOWN))); | 1018 ProcessInController(ui::Accelerator(ui::VKEY_L, ui::EF_COMMAND_DOWN))); |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 TEST_F(AcceleratorControllerTest, GlobalAcceleratorsToggleAppList) { | 1021 TEST_F(AcceleratorControllerTest, GlobalAcceleratorsToggleAppList) { |
| 1022 app_list::test::TestAppListPresenter test_app_list_presenter; | 1022 app_list::test::TestAppListPresenter test_app_list_presenter; |
| 1023 WmShell::Get()->app_list()->SetAppListPresenter( | 1023 WmShell::Get()->app_list()->SetAppListPresenter( |
| 1024 test_app_list_presenter.CreateInterfacePtrAndBind()); | 1024 test_app_list_presenter.CreateInterfacePtrAndBind()); |
| 1025 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); | 1025 AccessibilityDelegate* delegate = |
| 1026 Shell::GetInstance()->accessibility_delegate(); |
| 1026 | 1027 |
| 1027 // The press event should not toggle the AppList, the release should instead. | 1028 // The press event should not toggle the AppList, the release should instead. |
| 1028 EXPECT_FALSE( | 1029 EXPECT_FALSE( |
| 1029 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1030 ProcessInController(ui::Accelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| 1030 RunAllPendingInMessageLoop(); | 1031 RunAllPendingInMessageLoop(); |
| 1031 EXPECT_EQ(ui::VKEY_LWIN, GetCurrentAccelerator().key_code()); | 1032 EXPECT_EQ(ui::VKEY_LWIN, GetCurrentAccelerator().key_code()); |
| 1032 EXPECT_EQ(0u, test_app_list_presenter.toggle_count()); | 1033 EXPECT_EQ(0u, test_app_list_presenter.toggle_count()); |
| 1033 | 1034 |
| 1034 EXPECT_TRUE( | 1035 EXPECT_TRUE( |
| 1035 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); | 1036 ProcessInController(ReleaseAccelerator(ui::VKEY_LWIN, ui::EF_NONE))); |
| (...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1429 EXPECT_EQ(volume_down, history->current_accelerator()); | 1430 EXPECT_EQ(volume_down, history->current_accelerator()); |
| 1430 | 1431 |
| 1431 EXPECT_EQ(0, user_action_tester.GetActionCount("Accel_VolumeUp_F10")); | 1432 EXPECT_EQ(0, user_action_tester.GetActionCount("Accel_VolumeUp_F10")); |
| 1432 EXPECT_TRUE(ProcessInController(volume_up)); | 1433 EXPECT_TRUE(ProcessInController(volume_up)); |
| 1433 EXPECT_EQ(volume_up, history->current_accelerator()); | 1434 EXPECT_EQ(volume_up, history->current_accelerator()); |
| 1434 EXPECT_EQ(1, user_action_tester.GetActionCount("Accel_VolumeUp_F10")); | 1435 EXPECT_EQ(1, user_action_tester.GetActionCount("Accel_VolumeUp_F10")); |
| 1435 } | 1436 } |
| 1436 } | 1437 } |
| 1437 | 1438 |
| 1438 TEST_F(AcceleratorControllerTest, DisallowedWithNoWindow) { | 1439 TEST_F(AcceleratorControllerTest, DisallowedWithNoWindow) { |
| 1439 AccessibilityDelegate* delegate = WmShell::Get()->accessibility_delegate(); | 1440 AccessibilityDelegate* delegate = |
| 1441 Shell::GetInstance()->accessibility_delegate(); |
| 1440 | 1442 |
| 1441 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { | 1443 for (size_t i = 0; i < kActionsNeedingWindowLength; ++i) { |
| 1442 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); | 1444 delegate->TriggerAccessibilityAlert(A11Y_ALERT_NONE); |
| 1443 EXPECT_TRUE( | 1445 EXPECT_TRUE( |
| 1444 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i])); | 1446 GetController()->PerformActionIfEnabled(kActionsNeedingWindow[i])); |
| 1445 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); | 1447 EXPECT_EQ(delegate->GetLastAccessibilityAlert(), A11Y_ALERT_WINDOW_NEEDED); |
| 1446 } | 1448 } |
| 1447 | 1449 |
| 1448 // Make sure we don't alert if we do have a window. | 1450 // Make sure we don't alert if we do have a window. |
| 1449 std::unique_ptr<aura::Window> window; | 1451 std::unique_ptr<aura::Window> window; |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 // Expect no notifications from the new accelerators. | 1568 // Expect no notifications from the new accelerators. |
| 1567 EXPECT_TRUE(IsMessageCenterEmpty()); | 1569 EXPECT_TRUE(IsMessageCenterEmpty()); |
| 1568 | 1570 |
| 1569 // If the action is LOCK_SCREEN, we must reset the state by unlocking the | 1571 // If the action is LOCK_SCREEN, we must reset the state by unlocking the |
| 1570 // screen before we proceed testing the rest of accelerators. | 1572 // screen before we proceed testing the rest of accelerators. |
| 1571 ResetStateIfNeeded(); | 1573 ResetStateIfNeeded(); |
| 1572 } | 1574 } |
| 1573 } | 1575 } |
| 1574 | 1576 |
| 1575 } // namespace ash | 1577 } // namespace ash |
| OLD | NEW |