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/accessibility_delegate.h" | 7 #include "ash/accessibility_delegate.h" |
8 #include "ash/caps_lock_delegate.h" | 8 #include "ash/caps_lock_delegate.h" |
9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
10 #include "ash/ime_control_delegate.h" | 10 #include "ash/ime_control_delegate.h" |
(...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); | 608 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); |
609 TestTarget target; | 609 TestTarget target; |
610 GetController()->Register(accelerator_a, &target); | 610 GetController()->Register(accelerator_a, &target); |
611 | 611 |
612 // The accelerator is processed only once. | 612 // The accelerator is processed only once. |
613 aura::WindowEventDispatcher* dispatcher = | 613 aura::WindowEventDispatcher* dispatcher = |
614 Shell::GetPrimaryRootWindow()->GetDispatcher(); | 614 Shell::GetPrimaryRootWindow()->GetDispatcher(); |
615 #if defined(OS_WIN) | 615 #if defined(OS_WIN) |
616 MSG msg1 = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 }; | 616 MSG msg1 = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 }; |
617 ui::TranslatedKeyEvent key_event1(msg1, false); | 617 ui::TranslatedKeyEvent key_event1(msg1, false); |
618 EXPECT_TRUE(dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent( | 618 EXPECT_TRUE(dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent( |
619 &key_event1)); | 619 &key_event1)); |
620 | 620 |
621 MSG msg2 = { NULL, WM_CHAR, L'A', 0 }; | 621 MSG msg2 = { NULL, WM_CHAR, L'A', 0 }; |
622 ui::TranslatedKeyEvent key_event2(msg2, true); | 622 ui::TranslatedKeyEvent key_event2(msg2, true); |
623 EXPECT_FALSE(dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent( | 623 EXPECT_FALSE(dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent( |
624 &key_event2)); | 624 &key_event2)); |
625 | 625 |
626 MSG msg3 = { NULL, WM_KEYUP, ui::VKEY_A, 0 }; | 626 MSG msg3 = { NULL, WM_KEYUP, ui::VKEY_A, 0 }; |
627 ui::TranslatedKeyEvent key_event3(msg3, false); | 627 ui::TranslatedKeyEvent key_event3(msg3, false); |
628 EXPECT_FALSE(dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent( | 628 EXPECT_FALSE(dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent( |
629 &key_event3)); | 629 &key_event3)); |
630 #elif defined(USE_X11) | 630 #elif defined(USE_X11) |
631 XEvent key_event; | 631 XEvent key_event; |
632 ui::InitXKeyEventForTesting(ui::ET_KEY_PRESSED, | 632 ui::InitXKeyEventForTesting(ui::ET_KEY_PRESSED, |
633 ui::VKEY_A, | 633 ui::VKEY_A, |
634 0, | 634 0, |
635 &key_event); | 635 &key_event); |
636 ui::TranslatedKeyEvent key_event1(&key_event, false); | 636 ui::TranslatedKeyEvent key_event1(&key_event, false); |
637 EXPECT_TRUE(dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent( | 637 EXPECT_TRUE(dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent( |
638 &key_event1)); | 638 &key_event1)); |
639 | 639 |
640 ui::TranslatedKeyEvent key_event2(&key_event, true); | 640 ui::TranslatedKeyEvent key_event2(&key_event, true); |
641 EXPECT_FALSE(dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent( | 641 EXPECT_FALSE(dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent( |
642 &key_event2)); | 642 &key_event2)); |
643 | 643 |
644 ui::InitXKeyEventForTesting(ui::ET_KEY_RELEASED, | 644 ui::InitXKeyEventForTesting(ui::ET_KEY_RELEASED, |
645 ui::VKEY_A, | 645 ui::VKEY_A, |
646 0, | 646 0, |
647 &key_event); | 647 &key_event); |
648 ui::TranslatedKeyEvent key_event3(&key_event, false); | 648 ui::TranslatedKeyEvent key_event3(&key_event, false); |
649 EXPECT_FALSE(dispatcher->AsWindowTreeHostDelegate()->OnHostKeyEvent( | 649 EXPECT_FALSE(dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent( |
650 &key_event3)); | 650 &key_event3)); |
651 #endif | 651 #endif |
652 EXPECT_EQ(1, target.accelerator_pressed_count()); | 652 EXPECT_EQ(1, target.accelerator_pressed_count()); |
653 } | 653 } |
654 #endif | 654 #endif |
655 | 655 |
656 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { | 656 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { |
657 // CycleBackward | 657 // CycleBackward |
658 EXPECT_TRUE(ProcessWithContext( | 658 EXPECT_TRUE(ProcessWithContext( |
659 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); | 659 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); |
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 EXPECT_EQ(volume_down, delegate->last_accelerator()); | 1319 EXPECT_EQ(volume_down, delegate->last_accelerator()); |
1320 EXPECT_EQ(0, delegate->handle_volume_up_count()); | 1320 EXPECT_EQ(0, delegate->handle_volume_up_count()); |
1321 EXPECT_TRUE(ProcessWithContext(volume_up)); | 1321 EXPECT_TRUE(ProcessWithContext(volume_up)); |
1322 EXPECT_EQ(1, delegate->handle_volume_up_count()); | 1322 EXPECT_EQ(1, delegate->handle_volume_up_count()); |
1323 EXPECT_EQ(volume_up, delegate->last_accelerator()); | 1323 EXPECT_EQ(volume_up, delegate->last_accelerator()); |
1324 } | 1324 } |
1325 } | 1325 } |
1326 #endif | 1326 #endif |
1327 | 1327 |
1328 } // namespace ash | 1328 } // namespace ash |
OLD | NEW |