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/evdev/cursor_delegate_evdev.h" | 11 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" |
12 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" | 12 #include "ui/events/ozone/evdev/event_modifiers_evdev.h" |
13 #include "ui/events/ozone/evdev/keyboard_evdev.h" | 13 #include "ui/events/ozone/evdev/keyboard_evdev.h" |
14 #include "ui/events/ozone/events_ozone.h" | 14 #include "ui/events/ozone/events_ozone.h" |
| 15 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
15 | 16 |
16 namespace ui { | 17 namespace ui { |
17 | 18 |
18 using testing::AllOf; | 19 using testing::AllOf; |
19 using testing::InSequence; | 20 using testing::InSequence; |
20 using testing::Property; | 21 using testing::Property; |
21 | 22 |
22 class EventObserver { | 23 class EventObserver { |
23 public: | 24 public: |
24 void EventDispatchCallback(scoped_ptr<Event> event) { | 25 void EventDispatchCallback(scoped_ptr<Event> event) { |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 base::MessageLoop message_loop_; | 118 base::MessageLoop message_loop_; |
118 base::RunLoop run_loop_; | 119 base::RunLoop run_loop_; |
119 | 120 |
120 private: | 121 private: |
121 DISALLOW_COPY_AND_ASSIGN(InputInjectorEvdevTest); | 122 DISALLOW_COPY_AND_ASSIGN(InputInjectorEvdevTest); |
122 }; | 123 }; |
123 | 124 |
124 InputInjectorEvdevTest::InputInjectorEvdevTest() | 125 InputInjectorEvdevTest::InputInjectorEvdevTest() |
125 : dispatch_callback_(base::Bind(&EventObserver::EventDispatchCallback, | 126 : dispatch_callback_(base::Bind(&EventObserver::EventDispatchCallback, |
126 base::Unretained(&event_observer_))), | 127 base::Unretained(&event_observer_))), |
127 keyboard_(&modifiers_, dispatch_callback_), | 128 keyboard_(&modifiers_, |
| 129 KeyboardLayoutEngineManager::GetKeyboardLayoutEngine(), |
| 130 dispatch_callback_), |
128 injector_(&modifiers_, &cursor_, &keyboard_, dispatch_callback_) { | 131 injector_(&modifiers_, &cursor_, &keyboard_, dispatch_callback_) { |
129 } | 132 } |
130 | 133 |
131 void InputInjectorEvdevTest::SimulateMouseClick(int x, | 134 void InputInjectorEvdevTest::SimulateMouseClick(int x, |
132 int y, | 135 int y, |
133 EventFlags button, | 136 EventFlags button, |
134 int count) { | 137 int count) { |
135 injector_.MoveCursorTo(gfx::PointF(x, y)); | 138 injector_.MoveCursorTo(gfx::PointF(x, y)); |
136 for (int i = 0; i < count; i++) { | 139 for (int i = 0; i < count; i++) { |
137 injector_.InjectMouseButton(button, true); | 140 injector_.InjectMouseButton(button, true); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 EXPECT_CALL(event_observer_, OnMouseWheelEvent(AllOf( | 209 EXPECT_CALL(event_observer_, OnMouseWheelEvent(AllOf( |
207 MatchesMouseEvent(ET_MOUSEWHEEL, 0, 10, 20), | 210 MatchesMouseEvent(ET_MOUSEWHEEL, 0, 10, 20), |
208 Property(&MouseWheelEvent::x_offset, 100), | 211 Property(&MouseWheelEvent::x_offset, 100), |
209 Property(&MouseWheelEvent::y_offset, 0)))); | 212 Property(&MouseWheelEvent::y_offset, 0)))); |
210 injector_.MoveCursorTo(gfx::PointF(10, 20)); | 213 injector_.MoveCursorTo(gfx::PointF(10, 20)); |
211 injector_.InjectMouseWheel(0, 100); | 214 injector_.InjectMouseWheel(0, 100); |
212 injector_.InjectMouseWheel(100, 0); | 215 injector_.InjectMouseWheel(100, 0); |
213 run_loop_.RunUntilIdle(); | 216 run_loop_.RunUntilIdle(); |
214 } | 217 } |
215 | 218 |
216 } // namespace ui | 219 } // namespace ui |
OLD | NEW |