Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(863)

Side by Side Diff: ui/events/ozone/evdev/event_converter_test_util.cc

Issue 874723002: [PATCH 9/11] ozone: evdev: Add a device event dispatcher that forwards to UI thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates for events_unittests Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "ui/events/ozone/evdev/event_converter_test_util.h"
6
7 #include "ui/events/ozone/device/device_manager.h"
8 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h"
9 #include "ui/events/ozone/evdev/event_factory_evdev.h"
10
11 namespace ui {
12
13 namespace {
14
15 class TestDeviceManager : public ui::DeviceManager {
16 public:
17 TestDeviceManager() {}
18 ~TestDeviceManager() override {}
19
20 // DeviceManager:
21 void ScanDevices(DeviceEventObserver* observer) override {}
22 void AddObserver(DeviceEventObserver* observer) override {}
23 void RemoveObserver(DeviceEventObserver* observer) override {}
24 };
25
26 class TestDeviceEventDispatcherEvdev : public DeviceEventDispatcherEvdev {
27 public:
28 TestDeviceEventDispatcherEvdev(EventFactoryEvdev* event_factory_evdev)
29 : event_factory_evdev_(event_factory_evdev) {}
30 ~TestDeviceEventDispatcherEvdev() override {}
31
32 // DeviceEventDispatcher:
33 void DispatchKeyEvent(int device_id, unsigned int code, bool down) override {
34 event_factory_evdev_->DispatchKeyEvent(device_id, code, down);
35 }
36
37 void DispatchMouseMoveEvent(int device_id,
38 const gfx::PointF& location) override {
39 event_factory_evdev_->DispatchMouseMoveEvent(device_id, location);
40 }
41
42 void DispatchMouseButtonEvent(int device_id,
43 const gfx::PointF& location,
44 unsigned int button,
45 bool down,
46 bool allow_remap) override {
47 event_factory_evdev_->DispatchMouseButtonEvent(device_id, location, button,
48 down, allow_remap);
49 }
50
51 void DispatchMouseWheelEvent(int device_id,
52 const gfx::PointF& location,
53 const gfx::Vector2d& delta) override {
54 event_factory_evdev_->DispatchMouseWheelEvent(device_id, location, delta);
55 }
56
57 void DispatchScrollEvent(const ScrollEventParams& params) override {
58 event_factory_evdev_->DispatchScrollEvent(params);
59 }
60
61 void DispatchTouchEvent(const TouchEventParams& params) override {
62 event_factory_evdev_->DispatchTouchEvent(params);
63 }
64
65 void DispatchKeyboardDevicesUpdated(
66 const std::vector<KeyboardDevice>& devices) override {
67 event_factory_evdev_->DispatchKeyboardDevicesUpdated(devices);
68 }
69 void DispatchTouchscreenDevicesUpdated(
70 const std::vector<TouchscreenDevice>& devices) override {
71 event_factory_evdev_->DispatchTouchscreenDevicesUpdated(devices);
72 }
73 void DispatchMouseDevicesUpdated(
74 const std::vector<InputDevice>& devices) override {
75 event_factory_evdev_->DispatchMouseDevicesUpdated(devices);
76 }
77 void DispatchTouchpadDevicesUpdated(
78 const std::vector<InputDevice>& devices) override {
79 event_factory_evdev_->DispatchTouchpadDevicesUpdated(devices);
80 }
81
82 private:
83 EventFactoryEvdev* event_factory_evdev_;
84 };
85
86 class TestEventFactoryEvdev : public EventFactoryEvdev {
87 public:
88 TestEventFactoryEvdev(CursorDelegateEvdev* cursor,
89 DeviceManager* device_manager,
90 KeyboardLayoutEngine* keyboard_layout_engine,
91 const EventDispatchCallback& callback)
92 : EventFactoryEvdev(cursor, device_manager, keyboard_layout_engine),
93 callback_(callback) {}
94 ~TestEventFactoryEvdev() override {}
95
96 private:
97 void PostUiEvent(scoped_ptr<Event> event) override {
98 callback_.Run(event.Pass());
99 }
100
101 EventDispatchCallback callback_;
102 };
103
104 } // namespace
105
106 scoped_ptr<DeviceEventDispatcherEvdev> CreateDeviceEventDispatcherEvdevForTest(
107 EventFactoryEvdev* event_factory) {
108 return make_scoped_ptr(new TestDeviceEventDispatcherEvdev(event_factory));
109 }
110
111 scoped_ptr<DeviceManager> CreateDeviceManagerForTest() {
112 return make_scoped_ptr(new TestDeviceManager());
113 }
114
115 scoped_ptr<EventFactoryEvdev> CreateEventFactoryEvdevForTest(
116 CursorDelegateEvdev* cursor,
117 DeviceManager* device_manager,
118 KeyboardLayoutEngine* keyboard_layout_engine,
119 const EventDispatchCallback& callback) {
120 return make_scoped_ptr(new TestEventFactoryEvdev(
121 cursor, device_manager, keyboard_layout_engine, callback));
122 }
123
124 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698