| 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 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 #if defined(USE_X11) | 838 #if defined(USE_X11) |
| 839 TEST_F(AcceleratorControllerTest, ProcessOnce) { | 839 TEST_F(AcceleratorControllerTest, ProcessOnce) { |
| 840 // The IME event filter interferes with the basic key event propagation we | 840 // The IME event filter interferes with the basic key event propagation we |
| 841 // attempt to do here, so we disable it. | 841 // attempt to do here, so we disable it. |
| 842 DisableIME(); | 842 DisableIME(); |
| 843 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); | 843 ui::Accelerator accelerator_a(ui::VKEY_A, ui::EF_NONE); |
| 844 TestTarget target; | 844 TestTarget target; |
| 845 GetController()->Register({accelerator_a}, &target); | 845 GetController()->Register({accelerator_a}, &target); |
| 846 | 846 |
| 847 // The accelerator is processed only once. | 847 // The accelerator is processed only once. |
| 848 ui::EventProcessor* dispatcher = | 848 ui::EventSink* sink = Shell::GetPrimaryRootWindow()->GetHost()->event_sink(); |
| 849 Shell::GetPrimaryRootWindow()->GetHost()->event_processor(); | |
| 850 | 849 |
| 851 ui::ScopedXI2Event key_event; | 850 ui::ScopedXI2Event key_event; |
| 852 key_event.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0); | 851 key_event.InitKeyEvent(ui::ET_KEY_PRESSED, ui::VKEY_A, 0); |
| 853 ui::KeyEvent key_event1(key_event); | 852 ui::KeyEvent key_event1(key_event); |
| 854 ui::EventDispatchDetails details = dispatcher->OnEventFromSource(&key_event1); | 853 ui::EventDispatchDetails details = sink->OnEventFromSource(&key_event1); |
| 855 EXPECT_TRUE(key_event1.handled() || details.dispatcher_destroyed); | 854 EXPECT_TRUE(key_event1.handled() || details.dispatcher_destroyed); |
| 856 | 855 |
| 857 ui::KeyEvent key_event2('A', ui::VKEY_A, ui::EF_NONE); | 856 ui::KeyEvent key_event2('A', ui::VKEY_A, ui::EF_NONE); |
| 858 details = dispatcher->OnEventFromSource(&key_event2); | 857 details = sink->OnEventFromSource(&key_event2); |
| 859 EXPECT_FALSE(key_event2.handled() || details.dispatcher_destroyed); | 858 EXPECT_FALSE(key_event2.handled() || details.dispatcher_destroyed); |
| 860 | 859 |
| 861 key_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0); | 860 key_event.InitKeyEvent(ui::ET_KEY_RELEASED, ui::VKEY_A, 0); |
| 862 ui::KeyEvent key_event3(key_event); | 861 ui::KeyEvent key_event3(key_event); |
| 863 details = dispatcher->OnEventFromSource(&key_event3); | 862 details = sink->OnEventFromSource(&key_event3); |
| 864 EXPECT_FALSE(key_event3.handled() || details.dispatcher_destroyed); | 863 EXPECT_FALSE(key_event3.handled() || details.dispatcher_destroyed); |
| 865 EXPECT_EQ(1, target.accelerator_pressed_count()); | 864 EXPECT_EQ(1, target.accelerator_pressed_count()); |
| 866 } | 865 } |
| 867 #endif | 866 #endif |
| 868 | 867 |
| 869 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { | 868 TEST_F(AcceleratorControllerTest, GlobalAccelerators) { |
| 870 // TODO: TestScreenshotDelegate is null in mash http://crbug.com/632111. | 869 // TODO: TestScreenshotDelegate is null in mash http://crbug.com/632111. |
| 871 if (WmShell::Get()->IsRunningInMash()) | 870 if (WmShell::Get()->IsRunningInMash()) |
| 872 return; | 871 return; |
| 873 | 872 |
| (...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1565 // Expect no notifications from the new accelerators. | 1564 // Expect no notifications from the new accelerators. |
| 1566 EXPECT_TRUE(IsMessageCenterEmpty()); | 1565 EXPECT_TRUE(IsMessageCenterEmpty()); |
| 1567 | 1566 |
| 1568 // If the action is LOCK_SCREEN, we must reset the state by unlocking the | 1567 // If the action is LOCK_SCREEN, we must reset the state by unlocking the |
| 1569 // screen before we proceed testing the rest of accelerators. | 1568 // screen before we proceed testing the rest of accelerators. |
| 1570 ResetStateIfNeeded(); | 1569 ResetStateIfNeeded(); |
| 1571 } | 1570 } |
| 1572 } | 1571 } |
| 1573 | 1572 |
| 1574 } // namespace ash | 1573 } // namespace ash |
| OLD | NEW |