| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/events/ozone/evdev/input_injector_evdev.h" | 5 #include "ui/events/ozone/evdev/input_injector_evdev.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/events/ozone/device/device_manager.h" |
| 11 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" | 12 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" |
| 12 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" | 13 #include "ui/events/ozone/evdev/event_converter_test_util.h" |
| 13 #include "ui/events/ozone/evdev/keyboard_evdev.h" | 14 #include "ui/events/ozone/evdev/event_factory_evdev.h" |
| 14 #include "ui/events/ozone/events_ozone.h" | 15 #include "ui/events/ozone/events_ozone.h" |
| 15 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" | 16 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
| 16 | 17 |
| 17 namespace ui { | 18 namespace ui { |
| 18 | 19 |
| 19 using testing::AllOf; | 20 using testing::AllOf; |
| 20 using testing::InSequence; | 21 using testing::InSequence; |
| 21 using testing::Property; | 22 using testing::Property; |
| 22 | 23 |
| 23 class EventObserver { | 24 class EventObserver { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 | 102 |
| 102 class InputInjectorEvdevTest : public testing::Test { | 103 class InputInjectorEvdevTest : public testing::Test { |
| 103 public: | 104 public: |
| 104 InputInjectorEvdevTest(); | 105 InputInjectorEvdevTest(); |
| 105 | 106 |
| 106 protected: | 107 protected: |
| 107 void SimulateMouseClick(int x, int y, EventFlags button, int count); | 108 void SimulateMouseClick(int x, int y, EventFlags button, int count); |
| 108 void ExpectClick(int x, int y, int button, int count); | 109 void ExpectClick(int x, int y, int button, int count); |
| 109 | 110 |
| 110 EventObserver event_observer_; | 111 EventObserver event_observer_; |
| 111 EventModifiersEvdev modifiers_; | |
| 112 EventDispatchCallback dispatch_callback_; | 112 EventDispatchCallback dispatch_callback_; |
| 113 MockCursorEvdev cursor_; | 113 MockCursorEvdev cursor_; |
| 114 KeyboardEvdev keyboard_; | 114 |
| 115 scoped_ptr<DeviceManager> device_manager_; |
| 116 scoped_ptr<EventFactoryEvdev> event_factory_; |
| 115 | 117 |
| 116 InputInjectorEvdev injector_; | 118 InputInjectorEvdev injector_; |
| 117 | 119 |
| 118 base::MessageLoop message_loop_; | 120 base::MessageLoop message_loop_; |
| 119 base::RunLoop run_loop_; | 121 base::RunLoop run_loop_; |
| 120 | 122 |
| 121 private: | 123 private: |
| 122 DISALLOW_COPY_AND_ASSIGN(InputInjectorEvdevTest); | 124 DISALLOW_COPY_AND_ASSIGN(InputInjectorEvdevTest); |
| 123 }; | 125 }; |
| 124 | 126 |
| 125 InputInjectorEvdevTest::InputInjectorEvdevTest() | 127 InputInjectorEvdevTest::InputInjectorEvdevTest() |
| 126 : dispatch_callback_(base::Bind(&EventObserver::EventDispatchCallback, | 128 : dispatch_callback_(base::Bind(&EventObserver::EventDispatchCallback, |
| 127 base::Unretained(&event_observer_))), | 129 base::Unretained(&event_observer_))), |
| 128 keyboard_(&modifiers_, | 130 device_manager_(CreateDeviceManagerForTest()), |
| 129 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine(), | 131 event_factory_(CreateEventFactoryEvdevForTest( |
| 130 dispatch_callback_), | 132 &cursor_, |
| 131 injector_(&modifiers_, &cursor_, &keyboard_, dispatch_callback_) { | 133 device_manager_.get(), |
| 134 ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine(), |
| 135 dispatch_callback_)), |
| 136 injector_(CreateDeviceEventDispatcherEvdevForTest(event_factory_.get()), |
| 137 &cursor_) { |
| 132 } | 138 } |
| 133 | 139 |
| 134 void InputInjectorEvdevTest::SimulateMouseClick(int x, | 140 void InputInjectorEvdevTest::SimulateMouseClick(int x, |
| 135 int y, | 141 int y, |
| 136 EventFlags button, | 142 EventFlags button, |
| 137 int count) { | 143 int count) { |
| 138 injector_.MoveCursorTo(gfx::PointF(x, y)); | 144 injector_.MoveCursorTo(gfx::PointF(x, y)); |
| 139 for (int i = 0; i < count; i++) { | 145 for (int i = 0; i < count; i++) { |
| 140 injector_.InjectMouseButton(button, true); | 146 injector_.InjectMouseButton(button, true); |
| 141 injector_.InjectMouseButton(button, false); | 147 injector_.InjectMouseButton(button, false); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 MatchesMouseEvent(ET_MOUSEWHEEL, 0, 10, 20), | 216 MatchesMouseEvent(ET_MOUSEWHEEL, 0, 10, 20), |
| 211 Property(&MouseWheelEvent::x_offset, 100), | 217 Property(&MouseWheelEvent::x_offset, 100), |
| 212 Property(&MouseWheelEvent::y_offset, 0)))); | 218 Property(&MouseWheelEvent::y_offset, 0)))); |
| 213 injector_.MoveCursorTo(gfx::PointF(10, 20)); | 219 injector_.MoveCursorTo(gfx::PointF(10, 20)); |
| 214 injector_.InjectMouseWheel(0, 100); | 220 injector_.InjectMouseWheel(0, 100); |
| 215 injector_.InjectMouseWheel(100, 0); | 221 injector_.InjectMouseWheel(100, 0); |
| 216 run_loop_.RunUntilIdle(); | 222 run_loop_.RunUntilIdle(); |
| 217 } | 223 } |
| 218 | 224 |
| 219 } // namespace ui | 225 } // namespace ui |
| OLD | NEW |