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.
7 #include <linux/input.h>
12 #include "base/bind.h"
13 #include "base/command_line.h"
14 #include "base/memory/scoped_ptr.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/devices/device_data_manager.h"
20 #include "ui/events/event_switches.h"
21 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h"
22 #include "ui/events/ozone/evdev/event_device_test_util.h"
23 #include "ui/events/ozone/evdev/touch_evdev_types.h"
24 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h"
25 #include "ui/events/ozone/evdev/touch_noise/touch_noise_filter.h"
26 #include "ui/events/ozone/evdev/touch_noise/touch_noise_finder.h"
27 #include "ui/events/platform/platform_event_dispatcher.h"
28 #include "ui/events/platform/platform_event_source.h"
34 static int SetNonBlocking(int fd
) {
35 int flags
= fcntl(fd
, F_GETFL
, 0);
38 return fcntl(fd
, F_SETFL
, flags
| O_NONBLOCK
);
41 const char kTestDevicePath
[] = "/dev/input/test-device";
43 void InitPixelTouchscreen(TouchEventConverterEvdev
* device
) {
44 EventDeviceInfo devinfo
;
45 EXPECT_TRUE(CapabilitiesToDeviceInfo(kLinkTouchscreen
, &devinfo
));
46 device
->Initialize(devinfo
);
49 void InitEloTouchscreen(TouchEventConverterEvdev
* device
) {
50 EventDeviceInfo devinfo
;
51 EXPECT_TRUE(CapabilitiesToDeviceInfo(kElo_TouchSystems_2700
, &devinfo
));
52 device
->Initialize(devinfo
);
57 class MockTouchEventConverterEvdev
: public TouchEventConverterEvdev
{
59 MockTouchEventConverterEvdev(int fd
,
61 const EventDeviceInfo
& devinfo
,
62 DeviceEventDispatcherEvdev
* dispatcher
);
63 ~MockTouchEventConverterEvdev() override
;
65 void ConfigureReadMock(struct input_event
* queue
,
69 // Actually dispatch the event reader code.
71 OnFileCanReadWithoutBlocking(read_pipe_
);
72 base::RunLoop().RunUntilIdle();
75 void SimulateReinitialize(const EventDeviceInfo
& devinfo
) {
79 void Reinitialize() override
{}
81 TouchNoiseFinder
* touch_noise_finder() { return touch_noise_finder_
.get(); }
87 DISALLOW_COPY_AND_ASSIGN(MockTouchEventConverterEvdev
);
90 class MockDeviceEventDispatcherEvdev
: public DeviceEventDispatcherEvdev
{
92 MockDeviceEventDispatcherEvdev(
93 const base::Callback
<void(const TouchEventParams
& params
)>& callback
)
94 : callback_(callback
) {}
95 ~MockDeviceEventDispatcherEvdev() override
{}
97 // DeviceEventDispatcherEvdev:
98 void DispatchKeyEvent(const KeyEventParams
& params
) override
{}
99 void DispatchMouseMoveEvent(const MouseMoveEventParams
& params
) override
{}
100 void DispatchMouseButtonEvent(const MouseButtonEventParams
& params
) override
{
102 void DispatchMouseWheelEvent(const MouseWheelEventParams
& params
) override
{}
103 void DispatchScrollEvent(const ScrollEventParams
& params
) override
{}
104 void DispatchTouchEvent(const TouchEventParams
& params
) override
{
105 callback_
.Run(params
);
108 void DispatchKeyboardDevicesUpdated(
109 const std::vector
<KeyboardDevice
>& devices
) override
{}
110 void DispatchTouchscreenDevicesUpdated(
111 const std::vector
<TouchscreenDevice
>& devices
) override
{}
112 void DispatchMouseDevicesUpdated(
113 const std::vector
<InputDevice
>& devices
) override
{}
114 void DispatchTouchpadDevicesUpdated(
115 const std::vector
<InputDevice
>& devices
) override
{}
116 void DispatchDeviceListsComplete() override
{}
119 base::Callback
<void(const TouchEventParams
& params
)> callback_
;
122 MockTouchEventConverterEvdev::MockTouchEventConverterEvdev(
125 const EventDeviceInfo
& devinfo
,
126 DeviceEventDispatcherEvdev
* dispatcher
)
127 : TouchEventConverterEvdev(fd
,
135 PLOG(FATAL
) << "failed pipe";
137 EXPECT_FALSE(SetNonBlocking(fds
[0]) || SetNonBlocking(fds
[1]))
138 << "failed to set non-blocking: " << strerror(errno
);
141 write_pipe_
= fds
[1];
143 events_
.resize(ui::kNumTouchEvdevSlots
);
144 for (size_t i
= 0; i
< events_
.size(); ++i
)
150 MockTouchEventConverterEvdev::~MockTouchEventConverterEvdev() {
154 void MockTouchEventConverterEvdev::ConfigureReadMock(struct input_event
* queue
,
157 int nwrite
= HANDLE_EINTR(write(write_pipe_
,
159 sizeof(struct input_event
) * read_this_many
));
161 static_cast<int>(sizeof(struct input_event
) * read_this_many
))
162 << "write() failed, errno: " << errno
;
166 class TouchEventConverterEvdevTest
: public testing::Test
{
168 TouchEventConverterEvdevTest() {}
170 // Overridden from testing::Test:
171 void SetUp() override
{
172 // Set up pipe to satisfy message pump (unused).
175 PLOG(FATAL
) << "failed pipe";
176 events_in_
= evdev_io
[0];
177 events_out_
= evdev_io
[1];
179 // Device creation happens on a worker thread since it may involve blocking
180 // operations. Simulate that by creating it before creating a UI message
182 EventDeviceInfo devinfo
;
183 dispatcher_
.reset(new ui::MockDeviceEventDispatcherEvdev(
184 base::Bind(&TouchEventConverterEvdevTest::DispatchCallback
,
185 base::Unretained(this))));
186 device_
.reset(new ui::MockTouchEventConverterEvdev(
187 events_in_
, base::FilePath(kTestDevicePath
), devinfo
,
189 loop_
= new base::MessageLoopForUI
;
191 ui::DeviceDataManager::CreateInstance();
194 void TearDown() override
{
199 ui::MockTouchEventConverterEvdev
* device() { return device_
.get(); }
201 unsigned size() { return dispatched_events_
.size(); }
202 const ui::TouchEventParams
& dispatched_event(unsigned index
) {
203 DCHECK_GT(dispatched_events_
.size(), index
);
204 return dispatched_events_
[index
];
207 void ClearDispatchedEvents() { dispatched_events_
.clear(); }
209 void DestroyDevice() { device_
.reset(); }
212 base::MessageLoop
* loop_
;
213 scoped_ptr
<ui::MockTouchEventConverterEvdev
> device_
;
214 scoped_ptr
<ui::MockDeviceEventDispatcherEvdev
> dispatcher_
;
219 void DispatchCallback(const ui::TouchEventParams
& params
) {
220 dispatched_events_
.push_back(params
);
222 std::vector
<ui::TouchEventParams
> dispatched_events_
;
224 DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdevTest
);
227 TEST_F(TouchEventConverterEvdevTest
, NoEvents
) {
228 ui::MockTouchEventConverterEvdev
* dev
= device();
229 dev
->ConfigureReadMock(NULL
, 0, 0);
230 EXPECT_EQ(0u, size());
233 TEST_F(TouchEventConverterEvdevTest
, TouchMove
) {
234 ui::MockTouchEventConverterEvdev
* dev
= device();
236 InitPixelTouchscreen(dev
);
238 // Captured from Chromebook Pixel (Link).
240 time
= {1427323282, 19203};
241 struct input_event mock_kernel_queue_press
[] = {
242 {time
, EV_ABS
, ABS_MT_TRACKING_ID
, 3},
243 {time
, EV_ABS
, ABS_MT_POSITION_X
, 295},
244 {time
, EV_ABS
, ABS_MT_POSITION_Y
, 421},
245 {time
, EV_ABS
, ABS_MT_PRESSURE
, 34},
246 {time
, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 116},
247 {time
, EV_KEY
, BTN_TOUCH
, 1},
248 {time
, EV_ABS
, ABS_X
, 295},
249 {time
, EV_ABS
, ABS_Y
, 421},
250 {time
, EV_ABS
, ABS_PRESSURE
, 34},
251 {time
, EV_SYN
, SYN_REPORT
, 0},
253 time
= {1427323282, 34693};
254 struct input_event mock_kernel_queue_move
[] = {
255 {time
, EV_ABS
, ABS_MT_POSITION_X
, 312},
256 {time
, EV_ABS
, ABS_MT_POSITION_Y
, 432},
257 {time
, EV_ABS
, ABS_MT_PRESSURE
, 43},
258 {time
, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 100},
259 {time
, EV_ABS
, ABS_X
, 312},
260 {time
, EV_ABS
, ABS_Y
, 432},
261 {time
, EV_ABS
, ABS_PRESSURE
, 43},
262 {time
, EV_SYN
, SYN_REPORT
, 0},
264 time
= {1427323282, 144540};
265 struct input_event mock_kernel_queue_release
[] = {
266 {time
, EV_ABS
, ABS_MT_TRACKING_ID
, -1},
267 {time
, EV_KEY
, BTN_TOUCH
, 0},
268 {time
, EV_ABS
, ABS_PRESSURE
, 0},
269 {time
, EV_SYN
, SYN_REPORT
, 0},
273 dev
->ConfigureReadMock(mock_kernel_queue_press
,
274 arraysize(mock_kernel_queue_press
), 0);
276 EXPECT_EQ(1u, size());
277 ui::TouchEventParams event
= dispatched_event(0);
278 EXPECT_EQ(ui::ET_TOUCH_PRESSED
, event
.type
);
279 EXPECT_EQ(base::TimeDelta::FromMicroseconds(1427323282019203),
281 EXPECT_EQ(295, event
.location
.x());
282 EXPECT_EQ(421, event
.location
.y());
283 EXPECT_EQ(0, event
.slot
);
284 EXPECT_FLOAT_EQ(58.f
, event
.radii
.x());
285 EXPECT_FLOAT_EQ(0.13333334f
, event
.pressure
);
288 dev
->ConfigureReadMock(mock_kernel_queue_move
,
289 arraysize(mock_kernel_queue_move
), 0);
291 EXPECT_EQ(2u, size());
292 event
= dispatched_event(1);
293 EXPECT_EQ(ui::ET_TOUCH_MOVED
, event
.type
);
294 EXPECT_EQ(base::TimeDelta::FromMicroseconds(1427323282034693),
296 EXPECT_EQ(312, event
.location
.x());
297 EXPECT_EQ(432, event
.location
.y());
298 EXPECT_EQ(0, event
.slot
);
299 EXPECT_FLOAT_EQ(50.f
, event
.radii
.x());
300 EXPECT_FLOAT_EQ(0.16862745f
, event
.pressure
);
303 dev
->ConfigureReadMock(mock_kernel_queue_release
,
304 arraysize(mock_kernel_queue_release
), 0);
306 EXPECT_EQ(3u, size());
307 event
= dispatched_event(2);
308 EXPECT_EQ(ui::ET_TOUCH_RELEASED
, event
.type
);
309 EXPECT_EQ(base::TimeDelta::FromMicroseconds(1427323282144540),
311 EXPECT_EQ(312, event
.location
.x());
312 EXPECT_EQ(432, event
.location
.y());
313 EXPECT_EQ(0, event
.slot
);
314 EXPECT_FLOAT_EQ(50.f
, event
.radii
.x());
315 EXPECT_FLOAT_EQ(0.16862745f
, event
.pressure
);
318 TEST_F(TouchEventConverterEvdevTest
, TwoFingerGesture
) {
319 ui::MockTouchEventConverterEvdev
* dev
= device();
321 InitPixelTouchscreen(dev
);
323 struct input_event mock_kernel_queue_press0
[] = {
324 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 684},
325 {{0, 0}, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 3},
326 {{0, 0}, EV_ABS
, ABS_MT_PRESSURE
, 45},
327 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 42},
328 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 51}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
330 // Setup and discard a press.
331 dev
->ConfigureReadMock(mock_kernel_queue_press0
, 6, 0);
333 EXPECT_EQ(1u, size());
335 struct input_event mock_kernel_queue_move0
[] = {
336 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 40}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
338 // Setup and discard a move.
339 dev
->ConfigureReadMock(mock_kernel_queue_move0
, 2, 0);
341 EXPECT_EQ(2u, size());
343 struct input_event mock_kernel_queue_move0press1
[] = {
344 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 40}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
345 {{0, 0}, EV_ABS
, ABS_MT_SLOT
, 1}, {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 686},
346 {{0, 0}, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 3},
347 {{0, 0}, EV_ABS
, ABS_MT_PRESSURE
, 45},
348 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 101},
349 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 102}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
351 // Move on 0, press on 1.
352 dev
->ConfigureReadMock(mock_kernel_queue_move0press1
, 9, 0);
354 EXPECT_EQ(4u, size());
355 ui::TouchEventParams ev0
= dispatched_event(2);
356 ui::TouchEventParams ev1
= dispatched_event(3);
359 EXPECT_EQ(ui::ET_TOUCH_MOVED
, ev0
.type
);
360 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev0
.timestamp
);
361 EXPECT_EQ(40, ev0
.location
.x());
362 EXPECT_EQ(51, ev0
.location
.y());
363 EXPECT_EQ(0, ev0
.slot
);
364 EXPECT_FLOAT_EQ(0.17647059f
, ev0
.pressure
);
367 EXPECT_EQ(ui::ET_TOUCH_PRESSED
, ev1
.type
);
368 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev1
.timestamp
);
369 EXPECT_EQ(101, ev1
.location
.x());
370 EXPECT_EQ(102, ev1
.location
.y());
371 EXPECT_EQ(1, ev1
.slot
);
372 EXPECT_FLOAT_EQ(0.17647059f
, ev1
.pressure
);
374 // Stationary 0, Moves 1.
375 struct input_event mock_kernel_queue_stationary0_move1
[] = {
376 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 40}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
378 dev
->ConfigureReadMock(mock_kernel_queue_stationary0_move1
, 2, 0);
380 EXPECT_EQ(5u, size());
381 ev1
= dispatched_event(4);
383 EXPECT_EQ(ui::ET_TOUCH_MOVED
, ev1
.type
);
384 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev1
.timestamp
);
385 EXPECT_EQ(40, ev1
.location
.x());
386 EXPECT_EQ(102, ev1
.location
.y());
387 EXPECT_EQ(1, ev1
.slot
);
388 EXPECT_FLOAT_EQ(0.17647059f
, ev1
.pressure
);
390 // Move 0, stationary 1.
391 struct input_event mock_kernel_queue_move0_stationary1
[] = {
392 {{0, 0}, EV_ABS
, ABS_MT_SLOT
, 0}, {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 39},
393 {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
395 dev
->ConfigureReadMock(mock_kernel_queue_move0_stationary1
, 3, 0);
397 EXPECT_EQ(6u, size());
398 ev0
= dispatched_event(5);
400 EXPECT_EQ(ui::ET_TOUCH_MOVED
, ev0
.type
);
401 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev0
.timestamp
);
402 EXPECT_EQ(39, ev0
.location
.x());
403 EXPECT_EQ(51, ev0
.location
.y());
404 EXPECT_EQ(0, ev0
.slot
);
405 EXPECT_FLOAT_EQ(0.17647059f
, ev0
.pressure
);
407 // Release 0, move 1.
408 struct input_event mock_kernel_queue_release0_move1
[] = {
409 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, -1}, {{0, 0}, EV_ABS
, ABS_MT_SLOT
, 1},
410 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 38}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
412 dev
->ConfigureReadMock(mock_kernel_queue_release0_move1
, 4, 0);
414 EXPECT_EQ(8u, size());
415 ev0
= dispatched_event(6);
416 ev1
= dispatched_event(7);
418 EXPECT_EQ(ui::ET_TOUCH_RELEASED
, ev0
.type
);
419 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev0
.timestamp
);
420 EXPECT_EQ(39, ev0
.location
.x());
421 EXPECT_EQ(51, ev0
.location
.y());
422 EXPECT_EQ(0, ev0
.slot
);
423 EXPECT_FLOAT_EQ(0.17647059f
, ev0
.pressure
);
425 EXPECT_EQ(ui::ET_TOUCH_MOVED
, ev1
.type
);
426 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev1
.timestamp
);
427 EXPECT_EQ(38, ev1
.location
.x());
428 EXPECT_EQ(102, ev1
.location
.y());
429 EXPECT_EQ(1, ev1
.slot
);
430 EXPECT_FLOAT_EQ(0.17647059f
, ev1
.pressure
);
433 struct input_event mock_kernel_queue_release1
[] = {
434 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, -1}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
436 dev
->ConfigureReadMock(mock_kernel_queue_release1
, 2, 0);
438 EXPECT_EQ(9u, size());
439 ev1
= dispatched_event(8);
441 EXPECT_EQ(ui::ET_TOUCH_RELEASED
, ev1
.type
);
442 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev1
.timestamp
);
443 EXPECT_EQ(38, ev1
.location
.x());
444 EXPECT_EQ(102, ev1
.location
.y());
445 EXPECT_EQ(1, ev1
.slot
);
446 EXPECT_FLOAT_EQ(0.17647059f
, ev1
.pressure
);
449 TEST_F(TouchEventConverterEvdevTest
, Unsync
) {
450 ui::MockTouchEventConverterEvdev
* dev
= device();
452 InitPixelTouchscreen(dev
);
454 struct input_event mock_kernel_queue_press0
[] = {
455 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 684},
456 {{0, 0}, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 3},
457 {{0, 0}, EV_ABS
, ABS_MT_PRESSURE
, 45},
458 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 42},
459 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 51}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
462 dev
->ConfigureReadMock(mock_kernel_queue_press0
, 6, 0);
464 EXPECT_EQ(1u, size());
466 // Prepare a move with a drop.
467 struct input_event mock_kernel_queue_move0
[] = {
468 {{0, 0}, EV_SYN
, SYN_DROPPED
, 0},
469 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 40}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
472 // Verify that we didn't receive it/
473 dev
->ConfigureReadMock(mock_kernel_queue_move0
, 3, 0);
475 EXPECT_EQ(1u, size());
477 struct input_event mock_kernel_queue_move1
[] = {
478 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 40}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
481 // Verify that it re-syncs after a SYN_REPORT.
482 dev
->ConfigureReadMock(mock_kernel_queue_move1
, 2, 0);
484 EXPECT_EQ(2u, size());
487 TEST_F(TouchEventConverterEvdevTest
, ShouldResumeExistingContactsOnStart
) {
488 ui::MockTouchEventConverterEvdev
* dev
= device();
490 EventDeviceInfo devinfo
;
491 EXPECT_TRUE(CapabilitiesToDeviceInfo(kLinkTouchscreen
, &devinfo
));
493 // Set up an existing contact in slot 0.
494 devinfo
.SetAbsMtSlot(ABS_MT_TRACKING_ID
, 0, 1);
495 devinfo
.SetAbsMtSlot(ABS_MT_TOUCH_MAJOR
, 0, 100);
496 devinfo
.SetAbsMtSlot(ABS_MT_POSITION_X
, 0, 100);
497 devinfo
.SetAbsMtSlot(ABS_MT_POSITION_Y
, 0, 100);
498 devinfo
.SetAbsMtSlot(ABS_MT_PRESSURE
, 0, 128);
500 // Initialize the device.
501 dev
->Initialize(devinfo
);
503 // Any report should suffice to dispatch the update.. do an empty one.
504 struct input_event mock_kernel_queue_empty_report
[] = {
505 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
508 dev
->ConfigureReadMock(mock_kernel_queue_empty_report
,
509 arraysize(mock_kernel_queue_empty_report
), 0);
511 EXPECT_EQ(1u, size());
513 ui::TouchEventParams ev
= dispatched_event(0);
514 EXPECT_EQ(ET_TOUCH_PRESSED
, ev
.type
);
515 EXPECT_EQ(0, ev
.slot
);
516 EXPECT_FLOAT_EQ(50.f
, ev
.radii
.x());
517 EXPECT_FLOAT_EQ(0.f
, ev
.radii
.y());
518 EXPECT_FLOAT_EQ(0.50196081f
, ev
.pressure
);
521 TEST_F(TouchEventConverterEvdevTest
, ShouldReleaseContactsOnStop
) {
522 ui::MockTouchEventConverterEvdev
* dev
= device();
524 InitPixelTouchscreen(dev
);
526 // Captured from Chromebook Pixel (Link).
528 time
= {1429651083, 686882};
529 struct input_event mock_kernel_queue_press
[] = {
530 {time
, EV_ABS
, ABS_MT_TRACKING_ID
, 0},
531 {time
, EV_ABS
, ABS_MT_POSITION_X
, 1003},
532 {time
, EV_ABS
, ABS_MT_POSITION_Y
, 749},
533 {time
, EV_ABS
, ABS_MT_PRESSURE
, 50},
534 {time
, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 116},
535 {time
, EV_KEY
, BTN_TOUCH
, 1},
536 {time
, EV_ABS
, ABS_X
, 1003},
537 {time
, EV_ABS
, ABS_Y
, 749},
538 {time
, EV_ABS
, ABS_PRESSURE
, 50},
539 {time
, EV_SYN
, SYN_REPORT
, 0},
542 dev
->ConfigureReadMock(mock_kernel_queue_press
,
543 arraysize(mock_kernel_queue_press
), 0);
545 EXPECT_EQ(1u, size());
547 ui::TouchEventParams ev1
= dispatched_event(0);
548 EXPECT_EQ(ET_TOUCH_PRESSED
, ev1
.type
);
549 EXPECT_EQ(0, ev1
.slot
);
552 EXPECT_EQ(2u, size());
554 ui::TouchEventParams ev2
= dispatched_event(1);
555 EXPECT_EQ(ET_TOUCH_RELEASED
, ev2
.type
);
556 EXPECT_EQ(0, ev2
.slot
);
559 TEST_F(TouchEventConverterEvdevTest
, ShouldRemoveContactsWhenDisabled
) {
560 ui::MockTouchEventConverterEvdev
* dev
= device();
562 EventDeviceInfo devinfo
;
563 EXPECT_TRUE(CapabilitiesToDeviceInfo(kLinkTouchscreen
, &devinfo
));
565 // Captured from Chromebook Pixel (Link).
567 time
= {1429651083, 686882};
568 struct input_event mock_kernel_queue_press
[] = {
569 {time
, EV_ABS
, ABS_MT_TRACKING_ID
, 0},
570 {time
, EV_ABS
, ABS_MT_POSITION_X
, 1003},
571 {time
, EV_ABS
, ABS_MT_POSITION_Y
, 749},
572 {time
, EV_ABS
, ABS_MT_PRESSURE
, 50},
573 {time
, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 116},
574 {time
, EV_KEY
, BTN_TOUCH
, 1},
575 {time
, EV_ABS
, ABS_X
, 1003},
576 {time
, EV_ABS
, ABS_Y
, 749},
577 {time
, EV_ABS
, ABS_PRESSURE
, 50},
578 {time
, EV_SYN
, SYN_REPORT
, 0},
581 // Initialize the device.
582 dev
->Initialize(devinfo
);
584 dev
->ConfigureReadMock(mock_kernel_queue_press
,
585 arraysize(mock_kernel_queue_press
), 0);
587 EXPECT_EQ(1u, size());
589 ui::TouchEventParams ev1
= dispatched_event(0);
590 EXPECT_EQ(ET_TOUCH_PRESSED
, ev1
.type
);
591 EXPECT_EQ(0, ev1
.slot
);
592 EXPECT_EQ(1003, ev1
.location
.x());
593 EXPECT_EQ(749, ev1
.location
.y());
595 // Disable the device (should release the contact).
596 dev
->SetEnabled(false);
597 EXPECT_EQ(2u, size());
599 ui::TouchEventParams ev2
= dispatched_event(1);
600 EXPECT_EQ(ET_TOUCH_RELEASED
, ev2
.type
);
601 EXPECT_EQ(0, ev2
.slot
);
603 // Set up the previous contact in slot 0.
604 devinfo
.SetAbsMtSlot(ABS_MT_TRACKING_ID
, 0, 0);
605 devinfo
.SetAbsMtSlot(ABS_MT_TOUCH_MAJOR
, 0, 116);
606 devinfo
.SetAbsMtSlot(ABS_MT_POSITION_X
, 0, 1003);
607 devinfo
.SetAbsMtSlot(ABS_MT_POSITION_Y
, 0, 749);
608 devinfo
.SetAbsMtSlot(ABS_MT_PRESSURE
, 0, 50);
610 // Re-enable the device (should re-apply the contact).
611 dev
->SimulateReinitialize(devinfo
);
612 dev
->SetEnabled(true);
613 EXPECT_EQ(3u, size());
615 ui::TouchEventParams ev3
= dispatched_event(2);
616 EXPECT_EQ(ET_TOUCH_PRESSED
, ev3
.type
);
617 EXPECT_EQ(0, ev3
.slot
);
618 EXPECT_EQ(1003, ev3
.location
.x());
619 EXPECT_EQ(749, ev3
.location
.y());
623 TEST_F(TouchEventConverterEvdevTest
, ShouldUseLeftButtonIfNoTouchButton
) {
624 ui::MockTouchEventConverterEvdev
* dev
= device();
626 InitEloTouchscreen(dev
);
628 // Captured from Elo TouchSystems 2700.
630 time
= {1433965490, 837958};
631 struct input_event mock_kernel_queue_press
[] = {
632 {time
, EV_ABS
, ABS_X
, 3654},
633 {time
, EV_ABS
, ABS_Y
, 1054},
634 {time
, EV_ABS
, ABS_MISC
, 18},
635 {time
, EV_SYN
, SYN_REPORT
, 0},
637 {time
, EV_MSC
, MSC_SCAN
, 90001},
638 {time
, EV_KEY
, BTN_LEFT
, 1},
639 {time
, EV_ABS
, ABS_Y
, 1055},
640 {time
, EV_ABS
, ABS_MISC
, 25},
641 {time
, EV_SYN
, SYN_REPORT
, 0},
643 time
= {1433965491, 1953};
644 struct input_event mock_kernel_queue_move
[] = {
645 {time
, EV_ABS
, ABS_X
, 3644},
646 {time
, EV_ABS
, ABS_Y
, 1059},
647 {time
, EV_ABS
, ABS_MISC
, 36},
648 {time
, EV_SYN
, SYN_REPORT
, 0},
650 time
= {1433965491, 225959};
651 struct input_event mock_kernel_queue_release
[] = {
652 {time
, EV_MSC
, MSC_SCAN
, 90001},
653 {time
, EV_KEY
, BTN_LEFT
, 0},
654 {time
, EV_ABS
, ABS_MISC
, 0},
655 {time
, EV_SYN
, SYN_REPORT
, 0},
659 dev
->ConfigureReadMock(mock_kernel_queue_press
,
660 arraysize(mock_kernel_queue_press
), 0);
662 EXPECT_EQ(1u, size());
663 ui::TouchEventParams event
= dispatched_event(0);
664 EXPECT_EQ(ui::ET_TOUCH_PRESSED
, event
.type
);
665 EXPECT_EQ(base::TimeDelta::FromMicroseconds(1433965490837958),
667 EXPECT_EQ(3654, event
.location
.x());
668 EXPECT_EQ(1055, event
.location
.y());
669 EXPECT_EQ(0, event
.slot
);
670 EXPECT_FLOAT_EQ(0.f
, event
.radii
.x());
671 EXPECT_FLOAT_EQ(0.f
, event
.pressure
);
674 dev
->ConfigureReadMock(mock_kernel_queue_move
,
675 arraysize(mock_kernel_queue_move
), 0);
677 EXPECT_EQ(2u, size());
678 event
= dispatched_event(1);
679 EXPECT_EQ(ui::ET_TOUCH_MOVED
, event
.type
);
680 EXPECT_EQ(base::TimeDelta::FromMicroseconds(1433965491001953),
682 EXPECT_EQ(3644, event
.location
.x());
683 EXPECT_EQ(1059, event
.location
.y());
684 EXPECT_EQ(0, event
.slot
);
685 EXPECT_FLOAT_EQ(0.f
, event
.radii
.x());
686 EXPECT_FLOAT_EQ(0.f
, event
.pressure
);
689 dev
->ConfigureReadMock(mock_kernel_queue_release
,
690 arraysize(mock_kernel_queue_release
), 0);
692 EXPECT_EQ(3u, size());
693 event
= dispatched_event(2);
694 EXPECT_EQ(ui::ET_TOUCH_RELEASED
, event
.type
);
695 EXPECT_EQ(base::TimeDelta::FromMicroseconds(1433965491225959),
697 EXPECT_EQ(3644, event
.location
.x());
698 EXPECT_EQ(1059, event
.location
.y());
699 EXPECT_EQ(0, event
.slot
);
700 EXPECT_FLOAT_EQ(0.f
, event
.radii
.x());
701 EXPECT_FLOAT_EQ(0.f
, event
.pressure
);
703 // No dispatch on destruction.
705 EXPECT_EQ(3u, size());
709 TEST_F(TouchEventConverterEvdevTest
,
710 DontChangeMultitouchPositionFromLegacyAxes
) {
711 ui::MockTouchEventConverterEvdev
* dev
= device();
713 InitPixelTouchscreen(dev
);
715 struct input_event mock_kernel_queue
[] = {
716 {{0, 0}, EV_ABS
, ABS_MT_SLOT
, 0},
717 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 100},
718 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 999},
719 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 888},
720 {{0, 0}, EV_ABS
, ABS_MT_PRESSURE
, 55},
721 {{0, 0}, EV_ABS
, ABS_MT_SLOT
, 1},
722 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 200},
723 {{0, 0}, EV_ABS
, ABS_MT_PRESSURE
, 44},
724 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 777},
725 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 666},
726 {{0, 0}, EV_ABS
, ABS_X
, 999},
727 {{0, 0}, EV_ABS
, ABS_Y
, 888},
728 {{0, 0}, EV_ABS
, ABS_PRESSURE
, 55},
729 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
732 // Check that two events are generated.
733 dev
->ConfigureReadMock(mock_kernel_queue
, arraysize(mock_kernel_queue
), 0);
736 const unsigned int kExpectedEventCount
= 2;
737 EXPECT_EQ(kExpectedEventCount
, size());
738 if (kExpectedEventCount
!= size())
741 ui::TouchEventParams ev0
= dispatched_event(0);
742 ui::TouchEventParams ev1
= dispatched_event(1);
744 EXPECT_EQ(0, ev0
.slot
);
745 EXPECT_EQ(999, ev0
.location
.x());
746 EXPECT_EQ(888, ev0
.location
.y());
747 EXPECT_FLOAT_EQ(0.21568628f
, ev0
.pressure
);
749 EXPECT_EQ(1, ev1
.slot
);
750 EXPECT_EQ(777, ev1
.location
.x());
751 EXPECT_EQ(666, ev1
.location
.y());
752 EXPECT_FLOAT_EQ(0.17254902f
, ev1
.pressure
);
756 TEST_F(TouchEventConverterEvdevTest
, CheckSlotLimit
) {
757 ui::MockTouchEventConverterEvdev
* dev
= device();
759 struct input_event mock_kernel_queue
[] = {
760 {{0, 0}, EV_ABS
, ABS_MT_SLOT
, 0},
761 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 100},
762 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 999},
763 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 888},
764 {{0, 0}, EV_ABS
, ABS_MT_SLOT
, ui::kNumTouchEvdevSlots
},
765 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 200},
766 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 777},
767 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 666},
768 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
771 // Check that one 1 event is generated
772 dev
->ConfigureReadMock(mock_kernel_queue
, arraysize(mock_kernel_queue
), 0);
774 EXPECT_EQ(1u, size());
779 // TouchNoiseFilter which:
780 // - Considers all events of type |noise_event_type| as noise.
781 // - Keeps track of the events that it receives.
782 class EventTypeTouchNoiseFilter
: public TouchNoiseFilter
{
784 explicit EventTypeTouchNoiseFilter(EventType noise_event_type
)
785 : noise_event_type_(noise_event_type
) {}
786 ~EventTypeTouchNoiseFilter() override
{}
789 void Filter(const std::vector
<InProgressTouchEvdev
>& touches
,
790 base::TimeDelta time
,
791 std::bitset
<kNumTouchEvdevSlots
>* slots_with_noise
) override
{
792 for (const InProgressTouchEvdev
& touch
: touches
) {
793 EventType event_type
= EventTypeFromTouch(touch
);
794 ++counts_
[event_type
];
795 if (event_type
== noise_event_type_
)
796 slots_with_noise
->set(touch
.slot
);
800 // Returns the number of received events of |type|.
801 size_t num_events(EventType type
) const {
802 std::map
<EventType
, size_t>::const_iterator it
= counts_
.find(type
);
803 return it
== counts_
.end() ? 0u : it
->second
;
807 EventType
EventTypeFromTouch(const InProgressTouchEvdev
& touch
) const {
809 return touch
.was_touching
? ET_TOUCH_MOVED
: ET_TOUCH_PRESSED
;
810 return touch
.was_touching
? ET_TOUCH_RELEASED
: ET_UNKNOWN
;
813 EventType noise_event_type_
;
814 std::map
<EventType
, size_t> counts_
;
816 DISALLOW_COPY_AND_ASSIGN(EventTypeTouchNoiseFilter
);
821 class TouchEventConverterEvdevTouchNoiseTest
822 : public TouchEventConverterEvdevTest
{
824 TouchEventConverterEvdevTouchNoiseTest() {}
825 ~TouchEventConverterEvdevTouchNoiseTest() override
{}
827 // Makes the TouchNoiseFinder use |filter| and only |filter| to filter out
829 void SetTouchNoiseFilter(scoped_ptr
<TouchNoiseFilter
> filter
) {
830 TouchNoiseFinder
* finder
= device()->touch_noise_finder();
831 finder
->filters_
.clear();
832 finder
->filters_
.push_back(filter
.release());
835 // Returns the first of TouchNoiseFinder's filters.
836 ui::TouchNoiseFilter
* first_filter() {
837 TouchNoiseFinder
* finder
= device()->touch_noise_finder();
838 return finder
->filters_
.empty() ? nullptr : *finder
->filters_
.begin();
841 // TouchEventConverterEvdevTest:
842 void SetUp() override
{
843 base::CommandLine::ForCurrentProcess()->AppendSwitch(
844 switches::kExtraTouchNoiseFiltering
);
845 TouchEventConverterEvdevTest::SetUp();
849 DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdevTouchNoiseTest
);
852 // Test that if TouchNoiseFinder identifies an event for an in-progress touch as
853 // noise, that the event is converted to ET_TOUCH_CANCELLED and that all
854 // subsequent events for the in-progress touch are cancelled.
855 TEST_F(TouchEventConverterEvdevTouchNoiseTest
, TouchNoiseFiltering
) {
856 struct input_event mock_kernel_queue
[] = {
857 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 684},
858 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 40},
859 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 41},
860 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
862 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 42},
863 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 43},
864 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
866 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, -1},
867 {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
870 MockTouchEventConverterEvdev
* dev
= device();
871 SetTouchNoiseFilter(scoped_ptr
<TouchNoiseFilter
>(
872 new EventTypeTouchNoiseFilter(ET_TOUCH_PRESSED
)));
873 dev
->ConfigureReadMock(mock_kernel_queue
, arraysize(mock_kernel_queue
), 0);
875 ASSERT_EQ(0u, size());
877 ClearDispatchedEvents();
878 SetTouchNoiseFilter(scoped_ptr
<TouchNoiseFilter
>(
879 new EventTypeTouchNoiseFilter(ET_TOUCH_MOVED
)));
880 dev
->ConfigureReadMock(mock_kernel_queue
, arraysize(mock_kernel_queue
), 0);
882 ASSERT_EQ(2u, size());
883 TouchEventParams event0
= dispatched_event(0);
884 EXPECT_EQ(ET_TOUCH_PRESSED
, event0
.type
);
885 EXPECT_EQ(40, event0
.location
.x());
886 EXPECT_EQ(41, event0
.location
.y());
887 EXPECT_EQ(ET_TOUCH_CANCELLED
, dispatched_event(1).type
);
889 ClearDispatchedEvents();
890 SetTouchNoiseFilter(scoped_ptr
<TouchNoiseFilter
>(
891 new EventTypeTouchNoiseFilter(ET_TOUCH_RELEASED
)));
892 dev
->ConfigureReadMock(mock_kernel_queue
, arraysize(mock_kernel_queue
), 0);
894 ASSERT_EQ(3u, size());
895 event0
= dispatched_event(0);
896 EXPECT_EQ(ET_TOUCH_PRESSED
, event0
.type
);
897 EXPECT_EQ(40, event0
.location
.x());
898 EXPECT_EQ(41, event0
.location
.y());
899 TouchEventParams event1
= dispatched_event(1);
900 EXPECT_EQ(ET_TOUCH_MOVED
, event1
.type
);
901 EXPECT_EQ(42, event1
.location
.x());
902 EXPECT_EQ(43, event1
.location
.y());
903 EXPECT_EQ(ET_TOUCH_CANCELLED
, dispatched_event(2).type
);
906 // Test that TouchEventConverterEvdev keeps sending events to
907 // TouchNoiseFinder after the touch is canceled.
908 TEST_F(TouchEventConverterEvdevTouchNoiseTest
,
909 DoNotSendTouchCancelsToTouchNoiseFinder
) {
910 struct input_event mock_kernel_queue
[] = {
911 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 684},
912 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 40},
913 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 41},
914 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
916 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 42},
917 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 43},
918 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
920 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 43},
921 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 44},
922 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
924 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, -1},
925 {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
928 MockTouchEventConverterEvdev
* dev
= device();
929 SetTouchNoiseFilter(scoped_ptr
<TouchNoiseFilter
>(
930 new EventTypeTouchNoiseFilter(ET_TOUCH_PRESSED
)));
931 dev
->ConfigureReadMock(mock_kernel_queue
, arraysize(mock_kernel_queue
), 0);
933 ASSERT_EQ(0u, size());
935 EventTypeTouchNoiseFilter
* filter
=
936 static_cast<EventTypeTouchNoiseFilter
*>(first_filter());
937 EXPECT_EQ(1u, filter
->num_events(ET_TOUCH_PRESSED
));
938 EXPECT_EQ(2u, filter
->num_events(ET_TOUCH_MOVED
));
939 EXPECT_EQ(1u, filter
->num_events(ET_TOUCH_RELEASED
));
942 TEST_F(TouchEventConverterEvdevTest
, ActiveStylusTouchAndRelease
) {
943 ui::MockTouchEventConverterEvdev
* dev
= device();
944 EventDeviceInfo devinfo
;
945 EXPECT_TRUE(CapabilitiesToDeviceInfo(kWilsonBeachActiveStylus
, &devinfo
));
946 dev
->Initialize(devinfo
);
948 struct input_event mock_kernel_queue
[]{
949 {{0, 0}, EV_KEY
, BTN_TOOL_PEN
, 1},
950 {{0, 0}, EV_ABS
, ABS_X
, 9170},
951 {{0, 0}, EV_ABS
, ABS_Y
, 3658},
952 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
953 {{0, 0}, EV_KEY
, BTN_TOUCH
, 1},
954 {{0, 0}, EV_ABS
, ABS_PRESSURE
, 60},
955 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
956 {{0, 0}, EV_KEY
, BTN_TOUCH
, 0},
957 {{0, 0}, EV_ABS
, ABS_X
, 9173},
958 {{0, 0}, EV_ABS
, ABS_Y
, 3906},
959 {{0, 0}, EV_ABS
, ABS_PRESSURE
, 0},
960 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
961 {{0, 0}, EV_KEY
, BTN_TOOL_PEN
, 0},
962 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
965 dev
->ConfigureReadMock(mock_kernel_queue
, arraysize(mock_kernel_queue
), 0);
967 EXPECT_EQ(2u, size());
969 ui::TouchEventParams event
= dispatched_event(0);
970 EXPECT_EQ(ui::ET_TOUCH_PRESSED
, event
.type
);
971 EXPECT_EQ(9170, event
.location
.x());
972 EXPECT_EQ(3658, event
.location
.y());
973 EXPECT_EQ(60.f
/ 1024, event
.pressure
);
975 event
= dispatched_event(1);
976 EXPECT_EQ(ui::ET_TOUCH_RELEASED
, event
.type
);
977 EXPECT_EQ(9173, event
.location
.x());
978 EXPECT_EQ(3906, event
.location
.y());
979 EXPECT_EQ(0.f
/ 1024, event
.pressure
);
982 TEST_F(TouchEventConverterEvdevTest
, ActiveStylusMotion
) {
983 ui::MockTouchEventConverterEvdev
* dev
= device();
984 EventDeviceInfo devinfo
;
985 EXPECT_TRUE(CapabilitiesToDeviceInfo(kWilsonBeachActiveStylus
, &devinfo
));
986 dev
->Initialize(devinfo
);
988 struct input_event mock_kernel_queue
[]{
989 {{0, 0}, EV_KEY
, BTN_TOOL_PEN
, 1},
990 {{0, 0}, EV_ABS
, ABS_X
, 8921},
991 {{0, 0}, EV_ABS
, ABS_Y
, 1072},
992 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
993 {{0, 0}, EV_KEY
, BTN_TOUCH
, 1},
994 {{0, 0}, EV_ABS
, ABS_PRESSURE
, 35},
995 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
996 {{0, 0}, EV_ABS
, ABS_X
, 8934},
997 {{0, 0}, EV_ABS
, ABS_Y
, 981},
998 {{0, 0}, EV_ABS
, ABS_PRESSURE
, 184},
999 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
1000 {{0, 0}, EV_ABS
, ABS_X
, 8930},
1001 {{0, 0}, EV_ABS
, ABS_Y
, 980},
1002 {{0, 0}, EV_ABS
, ABS_PRESSURE
, 348},
1003 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
1004 {{0, 0}, EV_KEY
, BTN_TOUCH
, 0},
1005 {{0, 0}, EV_ABS
, ABS_PRESSURE
, 0},
1006 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
1007 {{0, 0}, EV_KEY
, BTN_TOOL_PEN
, 0},
1008 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
1011 dev
->ConfigureReadMock(mock_kernel_queue
, arraysize(mock_kernel_queue
), 0);
1013 EXPECT_EQ(4u, size());
1015 ui::TouchEventParams event
= dispatched_event(0);
1016 EXPECT_EQ(ui::ET_TOUCH_PRESSED
, event
.type
);
1017 EXPECT_EQ(8921, event
.location
.x());
1018 EXPECT_EQ(1072, event
.location
.y());
1019 EXPECT_EQ(35.f
/ 1024, event
.pressure
);
1021 event
= dispatched_event(1);
1022 EXPECT_EQ(ui::ET_TOUCH_MOVED
, event
.type
);
1023 EXPECT_EQ(8934, event
.location
.x());
1024 EXPECT_EQ(981, event
.location
.y());
1025 EXPECT_EQ(184.f
/ 1024, event
.pressure
);
1027 event
= dispatched_event(2);
1028 EXPECT_EQ(ui::ET_TOUCH_MOVED
, event
.type
);
1029 EXPECT_EQ(8930, event
.location
.x());
1030 EXPECT_EQ(980, event
.location
.y());
1031 EXPECT_EQ(348.f
/ 1024, event
.pressure
);
1033 event
= dispatched_event(3);
1034 EXPECT_EQ(ui::ET_TOUCH_RELEASED
, event
.type
);
1035 EXPECT_EQ(8930, event
.location
.x());
1036 EXPECT_EQ(980, event
.location
.y());
1037 EXPECT_EQ(0.f
/ 1024, event
.pressure
);