| 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 27 matching lines...) Expand all Loading... |
| 38 #include "ui/aura/test/test_window_delegate.h" | 38 #include "ui/aura/test/test_window_delegate.h" |
| 39 #include "ui/aura/test/test_windows.h" | 39 #include "ui/aura/test/test_windows.h" |
| 40 #include "ui/aura/window.h" | 40 #include "ui/aura/window.h" |
| 41 #include "ui/base/ime/chromeos/fake_ime_keyboard.h" | 41 #include "ui/base/ime/chromeos/fake_ime_keyboard.h" |
| 42 #include "ui/base/ime/chromeos/ime_keyboard.h" | 42 #include "ui/base/ime/chromeos/ime_keyboard.h" |
| 43 #include "ui/base/ime/chromeos/input_method_manager.h" | 43 #include "ui/base/ime/chromeos/input_method_manager.h" |
| 44 #include "ui/base/ime/chromeos/mock_input_method_manager.h" | 44 #include "ui/base/ime/chromeos/mock_input_method_manager.h" |
| 45 #include "ui/display/manager/display_manager.h" | 45 #include "ui/display/manager/display_manager.h" |
| 46 #include "ui/display/screen.h" | 46 #include "ui/display/screen.h" |
| 47 #include "ui/events/event.h" | 47 #include "ui/events/event.h" |
| 48 #include "ui/events/event_processor.h" | 48 #include "ui/events/event_sink.h" |
| 49 #include "ui/events/test/event_generator.h" | 49 #include "ui/events/test/event_generator.h" |
| 50 #include "ui/message_center/message_center.h" | 50 #include "ui/message_center/message_center.h" |
| 51 #include "ui/views/widget/widget.h" | 51 #include "ui/views/widget/widget.h" |
| 52 | 52 |
| 53 #if defined(USE_X11) | 53 #if defined(USE_X11) |
| 54 #include <X11/Xlib.h> | 54 #include <X11/Xlib.h> |
| 55 #include "ui/events/test/events_test_utils_x11.h" | 55 #include "ui/events/test/events_test_utils_x11.h" |
| 56 #endif | 56 #endif |
| 57 | 57 |
| 58 namespace ash { | 58 namespace ash { |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 #if defined(USE_X11) | 634 #if defined(USE_X11) |
| 635 TEST_F(AcceleratorControllerTest, ProcessOnce) { | 635 TEST_F(AcceleratorControllerTest, ProcessOnce) { |
| 636 // The IME event filter interferes with the basic key event propagation we | 636 // The IME event filter interferes with the basic key event propagation we |
| 637 // attempt to do here, so we disable it. | 637 // attempt to do here, so we disable it. |
| 638 DisableIME(); | 638 DisableIME(); |
| 639 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); | 639 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); |
| 640 TestTarget target; | 640 TestTarget target; |
| 641 GetController()->Register({accelerator_a}, &target); | 641 GetController()->Register({accelerator_a}, &target); |
| 642 | 642 |
| 643 // The accelerator is processed only once. | 643 // The accelerator is processed only once. |
| 644 ui::EventProcessor* dispatcher = | 644 ui::EventSink* sink = Shell::GetPrimaryRootWindow()->GetHost()->event_sink(); |
| 645 Shell::GetPrimaryRootWindow()->GetHost()->event_processor(); | |
| 646 | 645 |
| 647 ui::ScopedXI2Event key_event; | 646 ui::ScopedXI2Event key_event; |
| 648 key_event.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0); | 647 key_event.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0); |
| 649 ui::KeyEvent key_event1(key_event); | 648 ui::KeyEvent key_event1(key_event); |
| 650 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&key_event1); | 649 ui::EventDispatchDetails details = sink->OnEventFromSource(&key_event1); |
| 651 EXPECT_TRUE(key_event1.handled() || details.dispatcher_destroyed); | 650 EXPECT_TRUE(key_event1.handled() || details.dispatcher_destroyed); |
| 652 | 651 |
| 653 ui::KeyEvent key_event2('A', ui::VKEY_A, ui::EF_NONE); | 652 ui::KeyEvent key_event2('A', ui::VKEY_A, ui::EF_NONE); |
| 654 details = dispatcher->OnEventFromSource(&key_event2); | 653 details = sink->OnEventFromSource(&key_event2); |
| 655 EXPECT_FALSE(key_event2.handled() || details.dispatcher_destroyed); | 654 EXPECT_FALSE(key_event2.handled() || details.dispatcher_destroyed); |
| 656 | 655 |
| 657 key_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0); | 656 key_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0); |
| 658 ui::KeyEvent key_event3(key_event); | 657 ui::KeyEvent key_event3(key_event); |
| 659 details = dispatcher->OnEventFromSource(&key_event3); | 658 details = sink->OnEventFromSource(&key_event3); |
| 660 EXPECT_FALSE(key_event3.handled() || details.dispatcher_destroyed); | 659 EXPECT_FALSE(key_event3.handled() || details.dispatcher_destroyed); |
| 661 EXPECT_EQ(1, target.accelerator_pressed_count()); | 660 EXPECT_EQ(1, target.accelerator_pressed_count()); |
| 662 } | 661 } |
| 663 #endif | 662 #endif |
| 664 | 663 |
| 665 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { | 664 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { |
| 666 // TODO: TestScreenshotDelegate is null in mash http://crbug.com/632111. | 665 // TODO: TestScreenshotDelegate is null in mash http://crbug.com/632111. |
| 667 if (WmShell::Get()->IsRunningInMash()) | 666 if (WmShell::Get()->IsRunningInMash()) |
| 668 return; | 667 return; |
| 669 | 668 |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1361 // Expect no notifications from the new accelerators. | 1360 // Expect no notifications from the new accelerators. |
| 1362 EXPECT_TRUE(IsMessageCenterEmpty()); | 1361 EXPECT_TRUE(IsMessageCenterEmpty()); |
| 1363 | 1362 |
| 1364 // If the action is LOCK_SCREEN, we must reset the state by unlocking the | 1363 // If the action is LOCK_SCREEN, we must reset the state by unlocking the |
| 1365 // screen before we proceed testing the rest of accelerators. | 1364 // screen before we proceed testing the rest of accelerators. |
| 1366 ResetStateIfNeeded(); | 1365 ResetStateIfNeeded(); |
| 1367 } | 1366 } |
| 1368 } | 1367 } |
| 1369 | 1368 |
| 1370 } // namespace ash | 1369 } // namespace ash |
| OLD | NEW |