| 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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 596 EXPECT_FALSE(window_state->IsMaximized()); | 596 EXPECT_FALSE(window_state->IsMaximized()); |
| 597 } | 597 } |
| 598 | 598 |
| 599 #if defined(OS_WIN) || defined(USE_X11) | 599 #if defined(OS_WIN) || defined(USE_X11) |
| 600 TEST_F(AcceleratorControllerTest, ProcessOnce) { | 600 TEST_F(AcceleratorControllerTest, ProcessOnce) { |
| 601 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); | 601 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); |
| 602 TestTarget target; | 602 TestTarget target; |
| 603 GetController()->Register(accelerator_a, &target); | 603 GetController()->Register(accelerator_a, &target); |
| 604 | 604 |
| 605 // The accelerator is processed only once. | 605 // The accelerator is processed only once. |
| 606 aura::WindowEventDispatcher* dispatcher = |
| 607 Shell::GetPrimaryRootWindow()->GetDispatcher(); |
| 606 #if defined(OS_WIN) | 608 #if defined(OS_WIN) |
| 607 MSG msg1 = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 }; | 609 MSG msg1 = { NULL, WM_KEYDOWN, ui::VKEY_A, 0 }; |
| 608 ui::TranslatedKeyEvent key_event1(msg1, false); | 610 ui::TranslatedKeyEvent key_event1(msg1, false); |
| 609 EXPECT_TRUE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> | 611 EXPECT_TRUE(dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent( |
| 610 OnHostKeyEvent(&key_event1)); | 612 &key_event1)); |
| 611 | 613 |
| 612 MSG msg2 = { NULL, WM_CHAR, L'A', 0 }; | 614 MSG msg2 = { NULL, WM_CHAR, L'A', 0 }; |
| 613 ui::TranslatedKeyEvent key_event2(msg2, true); | 615 ui::TranslatedKeyEvent key_event2(msg2, true); |
| 614 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> | 616 EXPECT_FALSE(dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent( |
| 615 OnHostKeyEvent(&key_event2)); | 617 &key_event2)); |
| 616 | 618 |
| 617 MSG msg3 = { NULL, WM_KEYUP, ui::VKEY_A, 0 }; | 619 MSG msg3 = { NULL, WM_KEYUP, ui::VKEY_A, 0 }; |
| 618 ui::TranslatedKeyEvent key_event3(msg3, false); | 620 ui::TranslatedKeyEvent key_event3(msg3, false); |
| 619 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> | 621 EXPECT_FALSE(dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent( |
| 620 OnHostKeyEvent(&key_event3)); | 622 &key_event3)); |
| 621 #elif defined(USE_X11) | 623 #elif defined(USE_X11) |
| 622 XEvent key_event; | 624 XEvent key_event; |
| 623 ui::InitXKeyEventForTesting(ui::ET_KEY_PRESSED, | 625 ui::InitXKeyEventForTesting(ui::ET_KEY_PRESSED, |
| 624 ui::VKEY_A, | 626 ui::VKEY_A, |
| 625 0, | 627 0, |
| 626 &key_event); | 628 &key_event); |
| 627 ui::TranslatedKeyEvent key_event1(&key_event, false); | 629 ui::TranslatedKeyEvent key_event1(&key_event, false); |
| 628 EXPECT_TRUE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> | 630 EXPECT_TRUE(dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent( |
| 629 OnHostKeyEvent(&key_event1)); | 631 &key_event1)); |
| 630 | 632 |
| 631 ui::TranslatedKeyEvent key_event2(&key_event, true); | 633 ui::TranslatedKeyEvent key_event2(&key_event, true); |
| 632 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> | 634 EXPECT_FALSE(dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent( |
| 633 OnHostKeyEvent(&key_event2)); | 635 &key_event2)); |
| 634 | 636 |
| 635 ui::InitXKeyEventForTesting(ui::ET_KEY_RELEASED, | 637 ui::InitXKeyEventForTesting(ui::ET_KEY_RELEASED, |
| 636 ui::VKEY_A, | 638 ui::VKEY_A, |
| 637 0, | 639 0, |
| 638 &key_event); | 640 &key_event); |
| 639 ui::TranslatedKeyEvent key_event3(&key_event, false); | 641 ui::TranslatedKeyEvent key_event3(&key_event, false); |
| 640 EXPECT_FALSE(Shell::GetPrimaryRootWindow()->AsRootWindowHostDelegate()-> | 642 EXPECT_FALSE(dispatcher->AsRootWindowHostDelegate()->OnHostKeyEvent( |
| 641 OnHostKeyEvent(&key_event3)); | 643 &key_event3)); |
| 642 #endif | 644 #endif |
| 643 EXPECT_EQ(1, target.accelerator_pressed_count()); | 645 EXPECT_EQ(1, target.accelerator_pressed_count()); |
| 644 } | 646 } |
| 645 #endif | 647 #endif |
| 646 | 648 |
| 647 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { | 649 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { |
| 648 // CycleBackward | 650 // CycleBackward |
| 649 EXPECT_TRUE(ProcessWithContext( | 651 EXPECT_TRUE(ProcessWithContext( |
| 650 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); | 652 ui::Accelerator(ui::VKEY_TAB, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN))); |
| 651 // CycleForward | 653 // CycleForward |
| (...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1310 EXPECT_EQ(volume_down, delegate->last_accelerator()); | 1312 EXPECT_EQ(volume_down, delegate->last_accelerator()); |
| 1311 EXPECT_EQ(0, delegate->handle_volume_up_count()); | 1313 EXPECT_EQ(0, delegate->handle_volume_up_count()); |
| 1312 EXPECT_TRUE(ProcessWithContext(volume_up)); | 1314 EXPECT_TRUE(ProcessWithContext(volume_up)); |
| 1313 EXPECT_EQ(1, delegate->handle_volume_up_count()); | 1315 EXPECT_EQ(1, delegate->handle_volume_up_count()); |
| 1314 EXPECT_EQ(volume_up, delegate->last_accelerator()); | 1316 EXPECT_EQ(volume_up, delegate->last_accelerator()); |
| 1315 } | 1317 } |
| 1316 } | 1318 } |
| 1317 #endif | 1319 #endif |
| 1318 | 1320 |
| 1319 } // namespace ash | 1321 } // namespace ash |
| OLD | NEW |