Drive: Add BatchableRequest subclass.
[chromium-blink-merge.git] / ui / events / ozone / evdev / event_converter_test_util.cc
blobb4a28a2fb9d84e0956ea55250a87181c29c68a07
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.
5 #include "ui/events/ozone/evdev/event_converter_test_util.h"
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 #include "ui/events/platform/platform_event_dispatcher.h"
12 namespace ui {
14 namespace {
16 class TestDeviceManager : public ui::DeviceManager {
17 public:
18 TestDeviceManager() {}
19 ~TestDeviceManager() override {}
21 // DeviceManager:
22 void ScanDevices(DeviceEventObserver* observer) override {}
23 void AddObserver(DeviceEventObserver* observer) override {}
24 void RemoveObserver(DeviceEventObserver* observer) override {}
27 class TestDeviceEventDispatcherEvdev : public DeviceEventDispatcherEvdev {
28 public:
29 TestDeviceEventDispatcherEvdev(EventFactoryEvdev* event_factory_evdev)
30 : event_factory_evdev_(event_factory_evdev) {}
31 ~TestDeviceEventDispatcherEvdev() override {}
33 // DeviceEventDispatcher:
34 void DispatchKeyEvent(const KeyEventParams& params) override {
35 event_factory_evdev_->DispatchKeyEvent(params);
38 void DispatchMouseMoveEvent(const MouseMoveEventParams& params) override {
39 event_factory_evdev_->DispatchMouseMoveEvent(params);
42 void DispatchMouseButtonEvent(const MouseButtonEventParams& params) override {
43 event_factory_evdev_->DispatchMouseButtonEvent(params);
46 void DispatchMouseWheelEvent(const MouseWheelEventParams& params) override {
47 event_factory_evdev_->DispatchMouseWheelEvent(params);
50 void DispatchScrollEvent(const ScrollEventParams& params) override {
51 event_factory_evdev_->DispatchScrollEvent(params);
54 void DispatchTouchEvent(const TouchEventParams& params) override {
55 event_factory_evdev_->DispatchTouchEvent(params);
58 void DispatchKeyboardDevicesUpdated(
59 const std::vector<KeyboardDevice>& devices) override {
60 event_factory_evdev_->DispatchKeyboardDevicesUpdated(devices);
62 void DispatchTouchscreenDevicesUpdated(
63 const std::vector<TouchscreenDevice>& devices) override {
64 event_factory_evdev_->DispatchTouchscreenDevicesUpdated(devices);
66 void DispatchMouseDevicesUpdated(
67 const std::vector<InputDevice>& devices) override {
68 event_factory_evdev_->DispatchMouseDevicesUpdated(devices);
70 void DispatchTouchpadDevicesUpdated(
71 const std::vector<InputDevice>& devices) override {
72 event_factory_evdev_->DispatchTouchpadDevicesUpdated(devices);
75 private:
76 EventFactoryEvdev* event_factory_evdev_;
79 class TestEventFactoryEvdev : public EventFactoryEvdev {
80 public:
81 TestEventFactoryEvdev(CursorDelegateEvdev* cursor,
82 DeviceManager* device_manager,
83 KeyboardLayoutEngine* keyboard_layout_engine,
84 const EventDispatchCallback& callback)
85 : EventFactoryEvdev(cursor, device_manager, keyboard_layout_engine),
86 callback_(callback) {}
87 ~TestEventFactoryEvdev() override {}
89 private:
90 uint32_t DispatchEvent(PlatformEvent platform_event) override {
91 Event* event = static_cast<Event*>(platform_event);
92 callback_.Run(event);
93 return POST_DISPATCH_NONE;
96 EventDispatchCallback callback_;
99 } // namespace
101 scoped_ptr<DeviceEventDispatcherEvdev> CreateDeviceEventDispatcherEvdevForTest(
102 EventFactoryEvdev* event_factory) {
103 return make_scoped_ptr(new TestDeviceEventDispatcherEvdev(event_factory));
106 scoped_ptr<DeviceManager> CreateDeviceManagerForTest() {
107 return make_scoped_ptr(new TestDeviceManager());
110 scoped_ptr<EventFactoryEvdev> CreateEventFactoryEvdevForTest(
111 CursorDelegateEvdev* cursor,
112 DeviceManager* device_manager,
113 KeyboardLayoutEngine* keyboard_layout_engine,
114 const EventDispatchCallback& callback) {
115 return make_scoped_ptr(new TestEventFactoryEvdev(
116 cursor, device_manager, keyboard_layout_engine, callback));
119 } // namespace ui