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

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

Issue 869613003: [PATCH 5/11] ozone: evdev: Replace dispatch callbacks with an interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: namespace ui Created 5 years, 10 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
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 <linux/input.h> 5 #include <linux/input.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/memory/scoped_vector.h" 9 #include "base/memory/scoped_vector.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/events/event.h" 12 #include "ui/events/event.h"
13 #include "ui/events/keycodes/keyboard_codes.h" 13 #include "ui/events/keycodes/keyboard_codes.h"
14 #include "ui/events/ozone/device/device_manager.h" 14 #include "ui/events/ozone/device/device_manager.h"
15 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h" 15 #include "ui/events/ozone/evdev/cursor_delegate_evdev.h"
16 #include "ui/events/ozone/evdev/event_converter_evdev_impl.h" 16 #include "ui/events/ozone/evdev/event_converter_evdev_impl.h"
17 #include "ui/events/ozone/evdev/event_factory_evdev.h" 17 #include "ui/events/ozone/evdev/event_factory_evdev.h"
18 #include "ui/events/ozone/evdev/keyboard_evdev.h" 18 #include "ui/events/ozone/evdev/keyboard_evdev.h"
19 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" 19 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
20 20
21 namespace ui { 21 namespace ui {
22 22
23 const char kTestDevicePath[] = "/dev/input/test-device"; 23 const char kTestDevicePath[] = "/dev/input/test-device";
24 24
25 class MockEventConverterEvdevImpl : public EventConverterEvdevImpl { 25 class MockEventConverterEvdevImpl : public EventConverterEvdevImpl {
26 public: 26 public:
27 MockEventConverterEvdevImpl( 27 MockEventConverterEvdevImpl(int fd,
28 int fd, 28 CursorDelegateEvdev* cursor,
29 CursorDelegateEvdev* cursor, 29 DeviceEventDispatcherEvdev* dispatcher)
30 const KeyEventDispatchCallback& key_callback,
31 const MouseMoveEventDispatchCallback& mouse_move_callback,
32 const MouseButtonEventDispatchCallback& mouse_button_callback)
33 : EventConverterEvdevImpl(fd, 30 : EventConverterEvdevImpl(fd,
34 base::FilePath(kTestDevicePath), 31 base::FilePath(kTestDevicePath),
35 1, 32 1,
36 INPUT_DEVICE_UNKNOWN, 33 INPUT_DEVICE_UNKNOWN,
37 EventDeviceInfo(), 34 EventDeviceInfo(),
38 cursor, 35 cursor,
39 key_callback, 36 dispatcher) {
40 mouse_move_callback,
41 mouse_button_callback) {
42 Start(); 37 Start();
43 } 38 }
44 ~MockEventConverterEvdevImpl() override {} 39 ~MockEventConverterEvdevImpl() override {}
45 40
46 private: 41 private:
47 DISALLOW_COPY_AND_ASSIGN(MockEventConverterEvdevImpl); 42 DISALLOW_COPY_AND_ASSIGN(MockEventConverterEvdevImpl);
48 }; 43 };
49 44
50 class MockCursorEvdev : public CursorDelegateEvdev { 45 class MockCursorEvdev : public CursorDelegateEvdev {
51 public: 46 public:
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 events_out_ = evdev_io[1]; 118 events_out_ = evdev_io[1];
124 119
125 cursor_.reset(new ui::MockCursorEvdev()); 120 cursor_.reset(new ui::MockCursorEvdev());
126 device_manager_.reset(new ui::MockDeviceManager()); 121 device_manager_.reset(new ui::MockDeviceManager());
127 event_factory_.reset(new ui::TestEventFactoryEvdev( 122 event_factory_.reset(new ui::TestEventFactoryEvdev(
128 cursor_.get(), device_manager_.get(), 123 cursor_.get(), device_manager_.get(),
129 ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine(), 124 ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine(),
130 base::Bind(&EventConverterEvdevImplTest::DispatchEventForTest, 125 base::Bind(&EventConverterEvdevImplTest::DispatchEventForTest,
131 base::Unretained(this)))); 126 base::Unretained(this))));
132 127
133 device_.reset(new ui::MockEventConverterEvdevImpl( 128 device_.reset(new ui::MockEventConverterEvdevImpl(events_in_, cursor_.get(),
134 events_in_, cursor_.get(), 129 event_factory_.get()));
135 base::Bind(&ui::EventFactoryEvdev::PostKeyEvent,
136 base::Unretained(event_factory_.get())),
137 base::Bind(&ui::EventFactoryEvdev::PostMouseMoveEvent,
138 base::Unretained(event_factory_.get())),
139 base::Bind(&ui::EventFactoryEvdev::PostMouseButtonEvent,
140 base::Unretained(event_factory_.get()))));
141 } 130 }
142 void TearDown() override { 131 void TearDown() override {
143 device_.reset(); 132 device_.reset();
144 cursor_.reset(); 133 cursor_.reset();
145 close(events_in_); 134 close(events_in_);
146 close(events_out_); 135 close(events_out_);
147 } 136 }
148 137
149 ui::MockCursorEvdev* cursor() { return cursor_.get(); } 138 ui::MockCursorEvdev* cursor() { return cursor_.get(); }
150 ui::MockEventConverterEvdevImpl* device() { return device_.get(); } 139 ui::MockEventConverterEvdevImpl* device() { return device_.get(); }
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 {{0, 0}, EV_KEY, BTN_TOUCH, 1}, 472 {{0, 0}, EV_KEY, BTN_TOUCH, 1},
484 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 473 {{0, 0}, EV_SYN, SYN_REPORT, 0},
485 474
486 {{0, 0}, EV_KEY, BTN_TOUCH, 0}, 475 {{0, 0}, EV_KEY, BTN_TOUCH, 0},
487 {{0, 0}, EV_SYN, SYN_REPORT, 0}, 476 {{0, 0}, EV_SYN, SYN_REPORT, 0},
488 }; 477 };
489 478
490 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue)); 479 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
491 EXPECT_EQ(0u, size()); 480 EXPECT_EQ(0u, size());
492 } 481 }
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/event_converter_evdev_impl.cc ('k') | ui/events/ozone/evdev/event_dispatch_callback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698