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

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

Issue 1287103004: Sync ui/events to chromium @ https://codereview.chromium.org/1210203002 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 4 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 2014 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 <errno.h>
6 #include <fcntl.h>
7 #include <linux/input.h>
8 #include <unistd.h>
9
10 #include <vector>
11
12 #include "base/bind.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/scoped_vector.h"
15 #include "base/posix/eintr_wrapper.h"
16 #include "base/run_loop.h"
17 #include "base/time/time.h"
18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "ui/events/event.h"
20 #include "ui/events/ozone/device/device_manager.h"
21 #include "ui/events/ozone/evdev/event_converter_test_util.h"
22 #include "ui/events/ozone/evdev/event_device_test_util.h"
23 #include "ui/events/ozone/evdev/event_factory_evdev.h"
24 #include "ui/events/ozone/evdev/tablet_event_converter_evdev.h"
25 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
26 #include "ui/events/platform/platform_event_dispatcher.h"
27 #include "ui/events/platform/platform_event_source.h"
28
29 namespace {
30
31 static int SetNonBlocking(int fd) {
32 int flags = fcntl(fd, F_GETFL, 0);
33 if (flags == -1)
34 flags = 0;
35 return fcntl(fd, F_SETFL, flags | O_NONBLOCK);
36 }
37
38 const char kTestDevicePath[] = "/dev/input/test-device";
39
40 const ui::DeviceAbsoluteAxis kWacomIntuos5SPenAbsAxes[] = {
41 {ABS_X, {0, 0, 31496, 4, 0, 200}},
42 {ABS_Y, {0, 0, 19685, 4, 0, 200}},
43 {ABS_Z, {0, -900, 899, 0, 0, 0}},
44 {ABS_RZ, {0, -900, 899, 0, 0, 0}},
45 {ABS_THROTTLE, {0, -1023, 1023, 0, 0, 0}},
46 {ABS_WHEEL, {0, 0, 1023, 0, 0, 0}},
47 {ABS_PRESSURE, {0, 0, 2047, 0, 0, 0}},
48 {ABS_DISTANCE, {0, 0, 63, 0, 0, 0}},
49 {ABS_TILT_X, {0, 0, 127, 0, 0, 0}},
50 {ABS_TILT_Y, {0, 0, 127, 0, 0, 0}},
51 {ABS_MISC, {0, 0, 0, 0, 0, 0}},
52 };
53
54 const ui::DeviceCapabilities kWacomIntuos5SPen = {
55 /* path */ "/sys/devices/pci0000:00/0000:00:14.0/usb1/"
56 "1-1/1-1:1.0/input/input19/event5",
57 /* name */ "Wacom Intuos5 touch S Pen",
58 /* phys */ "",
59 /* uniq */ "",
60 /* bustype */ "0003",
61 /* vendor */ "056a",
62 /* product */ "0026",
63 /* version */ "0107",
64 /* prop */ "1",
65 /* ev */ "1f",
66 /* key */ "1cdf 1f007f 0 0 0 0",
67 /* rel */ "100",
68 /* abs */ "1000f000167",
69 /* msc */ "1",
70 /* sw */ "0",
71 /* led */ "0",
72 /* ff */ "0",
73 kWacomIntuos5SPenAbsAxes,
74 arraysize(kWacomIntuos5SPenAbsAxes),
75 };
76
77 } // namespace
78
79 namespace ui {
80
81 class MockTabletEventConverterEvdev : public TabletEventConverterEvdev {
82 public:
83 MockTabletEventConverterEvdev(int fd,
84 base::FilePath path,
85 CursorDelegateEvdev* cursor,
86 const EventDeviceInfo& devinfo,
87 DeviceEventDispatcherEvdev* dispatcher);
88 ~MockTabletEventConverterEvdev() override {};
89
90 void ConfigureReadMock(struct input_event* queue,
91 long read_this_many,
92 long queue_index);
93
94 // Actually dispatch the event reader code.
95 void ReadNow() {
96 OnFileCanReadWithoutBlocking(read_pipe_);
97 base::RunLoop().RunUntilIdle();
98 }
99
100 private:
101 int read_pipe_;
102 int write_pipe_;
103
104 ScopedVector<Event> dispatched_events_;
105
106 DISALLOW_COPY_AND_ASSIGN(MockTabletEventConverterEvdev);
107 };
108
109 class MockTabletCursorEvdev : public CursorDelegateEvdev {
110 public:
111 MockTabletCursorEvdev() { cursor_confined_bounds_ = gfx::Rect(1024, 768); }
112 ~MockTabletCursorEvdev() override {}
113
114 // CursorDelegateEvdev:
115 void MoveCursorTo(gfx::AcceleratedWidget widget,
116 const gfx::PointF& location) override {
117 NOTREACHED();
118 }
119 void MoveCursorTo(const gfx::PointF& location) override {
120 cursor_location_ = location;
121 }
122 void MoveCursor(const gfx::Vector2dF& delta) override { NOTREACHED(); }
123 bool IsCursorVisible() override { return 1; }
124 gfx::PointF GetLocation() override { return cursor_location_; }
125 gfx::Rect GetCursorConfinedBounds() override {
126 return cursor_confined_bounds_;
127 }
128
129 private:
130 gfx::PointF cursor_location_;
131 gfx::Rect cursor_confined_bounds_;
132 DISALLOW_COPY_AND_ASSIGN(MockTabletCursorEvdev);
133 };
134
135 MockTabletEventConverterEvdev::MockTabletEventConverterEvdev(
136 int fd,
137 base::FilePath path,
138 CursorDelegateEvdev* cursor,
139 const EventDeviceInfo& devinfo,
140 DeviceEventDispatcherEvdev* dispatcher)
141 : TabletEventConverterEvdev(fd,
142 path,
143 1,
144 INPUT_DEVICE_UNKNOWN,
145 cursor,
146 devinfo,
147 dispatcher) {
148 int fds[2];
149
150 if (pipe(fds))
151 PLOG(FATAL) << "failed pipe";
152
153 EXPECT_FALSE(SetNonBlocking(fds[0]) || SetNonBlocking(fds[1]))
154 << "failed to set non-blocking: " << strerror(errno);
155
156 read_pipe_ = fds[0];
157 write_pipe_ = fds[1];
158 }
159
160 void MockTabletEventConverterEvdev::ConfigureReadMock(struct input_event* queue,
161 long read_this_many,
162 long queue_index) {
163 int nwrite = HANDLE_EINTR(write(write_pipe_, queue + queue_index,
164 sizeof(struct input_event) * read_this_many));
165 DCHECK(nwrite ==
166 static_cast<int>(sizeof(struct input_event) * read_this_many))
167 << "write() failed, errno: " << errno;
168 }
169
170 } // namespace ui
171
172 // Test fixture.
173 class TabletEventConverterEvdevTest : public testing::Test {
174 public:
175 TabletEventConverterEvdevTest() {}
176
177 // Overridden from testing::Test:
178 void SetUp() override {
179 // Set up pipe to satisfy message pump (unused).
180 int evdev_io[2];
181 if (pipe(evdev_io))
182 PLOG(FATAL) << "failed pipe";
183 events_in_ = evdev_io[0];
184 events_out_ = evdev_io[1];
185
186 cursor_.reset(new ui::MockTabletCursorEvdev());
187 device_manager_ = ui::CreateDeviceManagerForTest();
188 event_factory_ = ui::CreateEventFactoryEvdevForTest(
189 cursor_.get(), device_manager_.get(),
190 ui::KeyboardLayoutEngineManager::GetKeyboardLayoutEngine(),
191 base::Bind(&TabletEventConverterEvdevTest::DispatchEventForTest,
192 base::Unretained(this)));
193 dispatcher_ =
194 ui::CreateDeviceEventDispatcherEvdevForTest(event_factory_.get());
195 }
196
197 void TearDown() override {
198 cursor_.reset();
199 }
200
201 ui::MockTabletEventConverterEvdev* CreateDevice(
202 const ui::DeviceCapabilities& caps) {
203 ui::EventDeviceInfo devinfo;
204 CapabilitiesToDeviceInfo(caps, &devinfo);
205 return new ui::MockTabletEventConverterEvdev(
206 events_in_, base::FilePath(kTestDevicePath), cursor_.get(), devinfo,
207 dispatcher_.get());
208 }
209
210 ui::CursorDelegateEvdev* cursor() { return cursor_.get(); }
211
212 unsigned size() { return dispatched_events_.size(); }
213 ui::MouseEvent* dispatched_event(unsigned index) {
214 DCHECK_GT(dispatched_events_.size(), index);
215 ui::Event* ev = dispatched_events_[index];
216 DCHECK(ev->IsMouseEvent());
217 return static_cast<ui::MouseEvent*>(ev);
218 }
219
220 void DispatchEventForTest(ui::Event* event) {
221 scoped_ptr<ui::Event> cloned_event = ui::Event::Clone(*event);
222 dispatched_events_.push_back(cloned_event.Pass());
223 }
224
225 private:
226 scoped_ptr<ui::MockTabletCursorEvdev> cursor_;
227 scoped_ptr<ui::DeviceManager> device_manager_;
228 scoped_ptr<ui::EventFactoryEvdev> event_factory_;
229 scoped_ptr<ui::DeviceEventDispatcherEvdev> dispatcher_;
230
231 ScopedVector<ui::Event> dispatched_events_;
232
233 int events_out_;
234 int events_in_;
235
236 DISALLOW_COPY_AND_ASSIGN(TabletEventConverterEvdevTest);
237 };
238
239 #define EPSILON 20
240
241 // Uses real data captured from Wacom Intuos 5 Pen
242 TEST_F(TabletEventConverterEvdevTest, MoveTopLeft) {
243 scoped_ptr<ui::MockTabletEventConverterEvdev> dev =
244 make_scoped_ptr(CreateDevice(kWacomIntuos5SPen));
245
246 struct input_event mock_kernel_queue[] = {
247 {{0, 0}, EV_ABS, ABS_DISTANCE, 63},
248 {{0, 0}, EV_ABS, ABS_X, 477},
249 {{0, 0}, EV_ABS, ABS_TILT_X, 66},
250 {{0, 0}, EV_ABS, ABS_TILT_Y, 62},
251 {{0, 0}, EV_ABS, ABS_MISC, 1050626},
252 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1},
253 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
254 {{0, 0}, EV_SYN, SYN_REPORT, 0},
255 {{0, 0}, EV_ABS, ABS_DISTANCE, 0},
256 {{0, 0}, EV_ABS, ABS_TILT_X, 0},
257 {{0, 0}, EV_ABS, ABS_TILT_Y, 0},
258 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0},
259 {{0, 0}, EV_ABS, ABS_MISC, 0},
260 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
261 {{0, 0}, EV_SYN, SYN_REPORT, 0},
262 };
263
264 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
265 EXPECT_EQ(1u, size());
266
267 ui::MouseEvent* event = dispatched_event(0);
268 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
269
270 EXPECT_LT(cursor()->GetLocation().x(), EPSILON);
271 EXPECT_LT(cursor()->GetLocation().y(), EPSILON);
272 }
273
274 TEST_F(TabletEventConverterEvdevTest, MoveTopRight) {
275 scoped_ptr<ui::MockTabletEventConverterEvdev> dev =
276 make_scoped_ptr(CreateDevice(kWacomIntuos5SPen));
277
278 struct input_event mock_kernel_queue[] = {
279 {{0, 0}, EV_ABS, ABS_DISTANCE, 63},
280 {{0, 0}, EV_ABS, ABS_X, 31496},
281 {{0, 0}, EV_ABS, ABS_Y, 109},
282 {{0, 0}, EV_ABS, ABS_TILT_X, 66},
283 {{0, 0}, EV_ABS, ABS_TILT_Y, 61},
284 {{0, 0}, EV_ABS, ABS_MISC, 1050626},
285 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1},
286 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
287 {{0, 0}, EV_SYN, SYN_REPORT, 0},
288 {{0, 0}, EV_ABS, ABS_X, 0},
289 {{0, 0}, EV_ABS, ABS_DISTANCE, 0},
290 {{0, 0}, EV_ABS, ABS_TILT_X, 0},
291 {{0, 0}, EV_ABS, ABS_TILT_Y, 0},
292 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0},
293 {{0, 0}, EV_ABS, ABS_MISC, 0},
294 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
295 {{0, 0}, EV_SYN, SYN_REPORT, 0},
296 };
297
298 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
299 EXPECT_EQ(1u, size());
300
301 ui::MouseEvent* event = dispatched_event(0);
302 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
303
304 EXPECT_GT(cursor()->GetLocation().x(),
305 cursor()->GetCursorConfinedBounds().width() - EPSILON);
306 EXPECT_LT(cursor()->GetLocation().y(), EPSILON);
307 }
308
309 TEST_F(TabletEventConverterEvdevTest, MoveBottomLeft) {
310 scoped_ptr<ui::MockTabletEventConverterEvdev> dev =
311 make_scoped_ptr(CreateDevice(kWacomIntuos5SPen));
312
313 struct input_event mock_kernel_queue[] = {
314 {{0, 0}, EV_ABS, ABS_DISTANCE, 63},
315 {{0, 0}, EV_ABS, ABS_Y, 19685},
316 {{0, 0}, EV_ABS, ABS_TILT_X, 64},
317 {{0, 0}, EV_ABS, ABS_TILT_Y, 61},
318 {{0, 0}, EV_ABS, ABS_MISC, 1050626},
319 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1},
320 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
321 {{0, 0}, EV_SYN, SYN_REPORT, 0},
322 {{0, 0}, EV_ABS, ABS_X, 0},
323 {{0, 0}, EV_ABS, ABS_Y, 0},
324 {{0, 0}, EV_ABS, ABS_DISTANCE, 0},
325 {{0, 0}, EV_ABS, ABS_TILT_X, 0},
326 {{0, 0}, EV_ABS, ABS_TILT_Y, 0},
327 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0},
328 {{0, 0}, EV_ABS, ABS_MISC, 0},
329 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
330 {{0, 0}, EV_SYN, SYN_REPORT, 0},
331 };
332
333 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
334 EXPECT_EQ(1u, size());
335
336 ui::MouseEvent* event = dispatched_event(0);
337 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
338
339 EXPECT_LT(cursor()->GetLocation().x(), EPSILON);
340 EXPECT_GT(cursor()->GetLocation().y(),
341 cursor()->GetCursorConfinedBounds().height() - EPSILON);
342 }
343
344 TEST_F(TabletEventConverterEvdevTest, MoveBottomRight) {
345 scoped_ptr<ui::MockTabletEventConverterEvdev> dev =
346 make_scoped_ptr(CreateDevice(kWacomIntuos5SPen));
347
348 struct input_event mock_kernel_queue[] = {
349 {{0, 0}, EV_ABS, ABS_DISTANCE, 63},
350 {{0, 0}, EV_ABS, ABS_X, 31496},
351 {{0, 0}, EV_ABS, ABS_Y, 19685},
352 {{0, 0}, EV_ABS, ABS_TILT_X, 67},
353 {{0, 0}, EV_ABS, ABS_TILT_Y, 63},
354 {{0, 0}, EV_ABS, ABS_MISC, 1050626},
355 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1},
356 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
357 {{0, 0}, EV_SYN, SYN_REPORT, 0},
358 {{0, 0}, EV_ABS, ABS_X, 0},
359 {{0, 0}, EV_ABS, ABS_Y, 0},
360 {{0, 0}, EV_ABS, ABS_DISTANCE, 0},
361 {{0, 0}, EV_ABS, ABS_TILT_X, 0},
362 {{0, 0}, EV_ABS, ABS_TILT_Y, 0},
363 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0},
364 {{0, 0}, EV_ABS, ABS_MISC, 0},
365 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
366 {{0, 0}, EV_SYN, SYN_REPORT, 0},
367 };
368
369 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
370 EXPECT_EQ(1u, size());
371
372 ui::MouseEvent* event = dispatched_event(0);
373 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
374
375 EXPECT_GT(cursor()->GetLocation().x(),
376 cursor()->GetCursorConfinedBounds().height() - EPSILON);
377 EXPECT_GT(cursor()->GetLocation().y(),
378 cursor()->GetCursorConfinedBounds().height() - EPSILON);
379 }
380
381 TEST_F(TabletEventConverterEvdevTest, Tap) {
382 scoped_ptr<ui::MockTabletEventConverterEvdev> dev =
383 make_scoped_ptr(CreateDevice(kWacomIntuos5SPen));
384
385 struct input_event mock_kernel_queue[] = {
386 {{0, 0}, EV_ABS, ABS_X, 15456},
387 {{0, 0}, EV_ABS, ABS_Y, 8605},
388 {{0, 0}, EV_ABS, ABS_DISTANCE, 49},
389 {{0, 0}, EV_ABS, ABS_TILT_X, 68},
390 {{0, 0}, EV_ABS, ABS_TILT_Y, 64},
391 {{0, 0}, EV_ABS, ABS_MISC, 1050626},
392 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1},
393 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
394 {{0, 0}, EV_SYN, SYN_REPORT, 0},
395 {{0, 0}, EV_ABS, ABS_X, 15725},
396 {{0, 0}, EV_ABS, ABS_Y, 8755},
397 {{0, 0}, EV_ABS, ABS_DISTANCE, 29},
398 {{0, 0}, EV_ABS, ABS_PRESSURE, 992},
399 {{0, 0}, EV_KEY, BTN_TOUCH, 1},
400 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
401 {{0, 0}, EV_SYN, SYN_REPORT, 0},
402 {{0, 0}, EV_ABS, ABS_X, 15922},
403 {{0, 0}, EV_ABS, ABS_Y, 8701},
404 {{0, 0}, EV_ABS, ABS_DISTANCE, 32},
405 {{0, 0}, EV_ABS, ABS_PRESSURE, 0},
406 {{0, 0}, EV_KEY, BTN_TOUCH, 0},
407 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
408 {{0, 0}, EV_SYN, SYN_REPORT, 0},
409 {{0, 0}, EV_ABS, ABS_X, 0},
410 {{0, 0}, EV_ABS, ABS_Y, 0},
411 {{0, 0}, EV_ABS, ABS_DISTANCE, 0},
412 {{0, 0}, EV_ABS, ABS_TILT_X, 0},
413 {{0, 0}, EV_ABS, ABS_TILT_Y, 0},
414 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0},
415 {{0, 0}, EV_ABS, ABS_MISC, 0},
416 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
417 {{0, 0}, EV_SYN, SYN_REPORT, 0},
418 };
419
420 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
421 EXPECT_EQ(3u, size());
422
423 ui::MouseEvent* event = dispatched_event(0);
424 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
425 event = dispatched_event(1);
426 EXPECT_EQ(ui::ET_MOUSE_PRESSED, event->type());
427 EXPECT_EQ(true, event->IsLeftMouseButton());
428 event = dispatched_event(2);
429 EXPECT_EQ(ui::ET_MOUSE_RELEASED, event->type());
430 EXPECT_EQ(true, event->IsLeftMouseButton());
431 }
432
433 TEST_F(TabletEventConverterEvdevTest, StylusButtonPress) {
434 scoped_ptr<ui::MockTabletEventConverterEvdev> dev =
435 make_scoped_ptr(CreateDevice(kWacomIntuos5SPen));
436
437 struct input_event mock_kernel_queue[] = {
438 {{0, 0}, EV_ABS, ABS_DISTANCE, 63},
439 {{0, 0}, EV_ABS, ABS_X, 18372},
440 {{0, 0}, EV_ABS, ABS_Y, 9880},
441 {{0, 0}, EV_ABS, ABS_DISTANCE, 61},
442 {{0, 0}, EV_ABS, ABS_TILT_X, 60},
443 {{0, 0}, EV_ABS, ABS_TILT_Y, 63},
444 {{0, 0}, EV_ABS, ABS_MISC, 1050626},
445 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 1},
446 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
447 {{0, 0}, EV_SYN, SYN_REPORT, 0},
448 {{0, 0}, EV_ABS, ABS_X, 18294},
449 {{0, 0}, EV_ABS, ABS_Y, 9723},
450 {{0, 0}, EV_ABS, ABS_DISTANCE, 20},
451 {{0, 0}, EV_ABS, ABS_PRESSURE, 1015},
452 {{0, 0}, EV_KEY, BTN_STYLUS2, 1},
453 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
454 {{0, 0}, EV_SYN, SYN_REPORT, 0},
455 {{0, 0}, EV_ABS, ABS_X, 18516},
456 {{0, 0}, EV_ABS, ABS_Y, 9723},
457 {{0, 0}, EV_ABS, ABS_DISTANCE, 23},
458 {{0, 0}, EV_KEY, BTN_STYLUS2, 0},
459 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
460 {{0, 0}, EV_SYN, SYN_REPORT, 0},
461 {{0, 0}, EV_ABS, ABS_X, 0},
462 {{0, 0}, EV_ABS, ABS_Y, 0},
463 {{0, 0}, EV_ABS, ABS_DISTANCE, 0},
464 {{0, 0}, EV_ABS, ABS_TILT_X, 0},
465 {{0, 0}, EV_ABS, ABS_TILT_Y, 0},
466 {{0, 0}, EV_KEY, BTN_TOOL_PEN, 0},
467 {{0, 0}, EV_ABS, ABS_MISC, 0},
468 {{0, 0}, EV_MSC, MSC_SERIAL, 897618290},
469 {{0, 0}, EV_SYN, SYN_REPORT, 0},
470 };
471
472 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
473 EXPECT_EQ(3u, size());
474
475 ui::MouseEvent* event = dispatched_event(0);
476 EXPECT_EQ(ui::ET_MOUSE_MOVED, event->type());
477 event = dispatched_event(1);
478 EXPECT_EQ(ui::ET_MOUSE_PRESSED, event->type());
479 EXPECT_EQ(true, event->IsRightMouseButton());
480 event = dispatched_event(2);
481 EXPECT_EQ(ui::ET_MOUSE_RELEASED, event->type());
482 EXPECT_EQ(true, event->IsRightMouseButton());
483 }
484
485 // Should only get an event if BTN_TOOL received
486 TEST_F(TabletEventConverterEvdevTest, CheckStylusFiltering) {
487 scoped_ptr<ui::MockTabletEventConverterEvdev> dev =
488 make_scoped_ptr(CreateDevice(kWacomIntuos5SPen));
489
490 struct input_event mock_kernel_queue[] = {
491 {{0, 0}, EV_ABS, ABS_X, 0},
492 {{0, 0}, EV_ABS, ABS_Y, 0},
493 {{0, 0}, EV_SYN, SYN_REPORT, 0},
494 };
495
496 dev->ProcessEvents(mock_kernel_queue, arraysize(mock_kernel_queue));
497 EXPECT_EQ(0u, size());
498 }
OLDNEW
« no previous file with comments | « ui/events/ozone/evdev/tablet_event_converter_evdev.cc ('k') | ui/events/ozone/evdev/touch_evdev_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698