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/memory/scoped_vector.h"
16 #include "base/posix/eintr_wrapper.h"
17 #include "base/run_loop.h"
18 #include "base/time/time.h"
19 #include "testing/gtest/include/gtest/gtest.h"
20 #include "ui/events/devices/device_data_manager.h"
21 #include "ui/events/event_switches.h"
22 #include "ui/events/ozone/evdev/device_event_dispatcher_evdev.h"
23 #include "ui/events/ozone/evdev/event_device_test_util.h"
24 #include "ui/events/ozone/evdev/touch_evdev_types.h"
25 #include "ui/events/ozone/evdev/touch_event_converter_evdev.h"
26 #include "ui/events/ozone/evdev/touch_noise/touch_noise_filter.h"
27 #include "ui/events/ozone/evdev/touch_noise/touch_noise_finder.h"
28 #include "ui/events/platform/platform_event_dispatcher.h"
29 #include "ui/events/platform/platform_event_source.h"
35 static int SetNonBlocking(int fd
) {
36 int flags
= fcntl(fd
, F_GETFL
, 0);
39 return fcntl(fd
, F_SETFL
, flags
| O_NONBLOCK
);
42 const char kTestDevicePath
[] = "/dev/input/test-device";
44 void InitPixelTouchscreen(TouchEventConverterEvdev
* device
) {
45 EventDeviceInfo devinfo
;
46 EXPECT_TRUE(CapabilitiesToDeviceInfo(kLinkTouchscreen
, &devinfo
));
47 device
->Initialize(devinfo
);
50 void InitEloTouchscreen(TouchEventConverterEvdev
* device
) {
51 EventDeviceInfo devinfo
;
52 EXPECT_TRUE(CapabilitiesToDeviceInfo(kElo_TouchSystems_2700
, &devinfo
));
53 device
->Initialize(devinfo
);
58 class MockTouchEventConverterEvdev
: public TouchEventConverterEvdev
{
60 MockTouchEventConverterEvdev(int fd
,
62 const EventDeviceInfo
& devinfo
,
63 DeviceEventDispatcherEvdev
* dispatcher
);
64 ~MockTouchEventConverterEvdev() override
;
66 void ConfigureReadMock(struct input_event
* queue
,
70 // Actually dispatch the event reader code.
72 OnFileCanReadWithoutBlocking(read_pipe_
);
73 base::RunLoop().RunUntilIdle();
76 void SimulateReinitialize(const EventDeviceInfo
& devinfo
) {
80 void Reinitialize() override
{}
82 TouchNoiseFinder
* touch_noise_finder() { return touch_noise_finder_
.get(); }
88 DISALLOW_COPY_AND_ASSIGN(MockTouchEventConverterEvdev
);
91 class MockDeviceEventDispatcherEvdev
: public DeviceEventDispatcherEvdev
{
93 MockDeviceEventDispatcherEvdev(
94 const base::Callback
<void(const TouchEventParams
& params
)>& callback
)
95 : callback_(callback
) {}
96 ~MockDeviceEventDispatcherEvdev() override
{}
98 // DeviceEventDispatcherEvdev:
99 void DispatchKeyEvent(const KeyEventParams
& params
) override
{}
100 void DispatchMouseMoveEvent(const MouseMoveEventParams
& params
) override
{}
101 void DispatchMouseButtonEvent(const MouseButtonEventParams
& params
) override
{
103 void DispatchMouseWheelEvent(const MouseWheelEventParams
& params
) override
{}
104 void DispatchScrollEvent(const ScrollEventParams
& params
) override
{}
105 void DispatchTouchEvent(const TouchEventParams
& params
) override
{
106 callback_
.Run(params
);
109 void DispatchKeyboardDevicesUpdated(
110 const std::vector
<KeyboardDevice
>& devices
) override
{}
111 void DispatchTouchscreenDevicesUpdated(
112 const std::vector
<TouchscreenDevice
>& devices
) override
{}
113 void DispatchMouseDevicesUpdated(
114 const std::vector
<InputDevice
>& devices
) override
{}
115 void DispatchTouchpadDevicesUpdated(
116 const std::vector
<InputDevice
>& devices
) override
{}
117 void DispatchDeviceListsComplete() override
{}
120 base::Callback
<void(const TouchEventParams
& params
)> callback_
;
123 MockTouchEventConverterEvdev::MockTouchEventConverterEvdev(
126 const EventDeviceInfo
& devinfo
,
127 DeviceEventDispatcherEvdev
* dispatcher
)
128 : TouchEventConverterEvdev(fd
,
136 PLOG(FATAL
) << "failed pipe";
138 EXPECT_FALSE(SetNonBlocking(fds
[0]) || SetNonBlocking(fds
[1]))
139 << "failed to set non-blocking: " << strerror(errno
);
142 write_pipe_
= fds
[1];
144 events_
.resize(ui::kNumTouchEvdevSlots
);
145 for (size_t i
= 0; i
< events_
.size(); ++i
)
151 MockTouchEventConverterEvdev::~MockTouchEventConverterEvdev() {
155 void MockTouchEventConverterEvdev::ConfigureReadMock(struct input_event
* queue
,
158 int nwrite
= HANDLE_EINTR(write(write_pipe_
,
160 sizeof(struct input_event
) * read_this_many
));
162 static_cast<int>(sizeof(struct input_event
) * read_this_many
))
163 << "write() failed, errno: " << errno
;
167 class TouchEventConverterEvdevTest
: public testing::Test
{
169 TouchEventConverterEvdevTest() {}
171 // Overridden from testing::Test:
172 void SetUp() override
{
173 // Set up pipe to satisfy message pump (unused).
176 PLOG(FATAL
) << "failed pipe";
177 events_in_
= evdev_io
[0];
178 events_out_
= evdev_io
[1];
180 // Device creation happens on a worker thread since it may involve blocking
181 // operations. Simulate that by creating it before creating a UI message
183 EventDeviceInfo devinfo
;
184 dispatcher_
.reset(new ui::MockDeviceEventDispatcherEvdev(
185 base::Bind(&TouchEventConverterEvdevTest::DispatchCallback
,
186 base::Unretained(this))));
187 device_
.reset(new ui::MockTouchEventConverterEvdev(
188 events_in_
, base::FilePath(kTestDevicePath
), devinfo
,
190 loop_
= new base::MessageLoopForUI
;
192 ui::DeviceDataManager::CreateInstance();
195 void TearDown() override
{
200 ui::MockTouchEventConverterEvdev
* device() { return device_
.get(); }
202 unsigned size() { return dispatched_events_
.size(); }
203 const ui::TouchEventParams
& dispatched_event(unsigned index
) {
204 DCHECK_GT(dispatched_events_
.size(), index
);
205 return dispatched_events_
[index
];
208 void ClearDispatchedEvents() { dispatched_events_
.clear(); }
210 void DestroyDevice() { device_
.reset(); }
213 base::MessageLoop
* loop_
;
214 scoped_ptr
<ui::MockTouchEventConverterEvdev
> device_
;
215 scoped_ptr
<ui::MockDeviceEventDispatcherEvdev
> dispatcher_
;
220 void DispatchCallback(const ui::TouchEventParams
& params
) {
221 dispatched_events_
.push_back(params
);
223 std::vector
<ui::TouchEventParams
> dispatched_events_
;
225 DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdevTest
);
228 TEST_F(TouchEventConverterEvdevTest
, NoEvents
) {
229 ui::MockTouchEventConverterEvdev
* dev
= device();
230 dev
->ConfigureReadMock(NULL
, 0, 0);
231 EXPECT_EQ(0u, size());
234 TEST_F(TouchEventConverterEvdevTest
, TouchMove
) {
235 ui::MockTouchEventConverterEvdev
* dev
= device();
237 InitPixelTouchscreen(dev
);
239 // Captured from Chromebook Pixel (Link).
241 time
= {1427323282, 19203};
242 struct input_event mock_kernel_queue_press
[] = {
243 {time
, EV_ABS
, ABS_MT_TRACKING_ID
, 3},
244 {time
, EV_ABS
, ABS_MT_POSITION_X
, 295},
245 {time
, EV_ABS
, ABS_MT_POSITION_Y
, 421},
246 {time
, EV_ABS
, ABS_MT_PRESSURE
, 34},
247 {time
, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 116},
248 {time
, EV_KEY
, BTN_TOUCH
, 1},
249 {time
, EV_ABS
, ABS_X
, 295},
250 {time
, EV_ABS
, ABS_Y
, 421},
251 {time
, EV_ABS
, ABS_PRESSURE
, 34},
252 {time
, EV_SYN
, SYN_REPORT
, 0},
254 time
= {1427323282, 34693};
255 struct input_event mock_kernel_queue_move
[] = {
256 {time
, EV_ABS
, ABS_MT_POSITION_X
, 312},
257 {time
, EV_ABS
, ABS_MT_POSITION_Y
, 432},
258 {time
, EV_ABS
, ABS_MT_PRESSURE
, 43},
259 {time
, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 100},
260 {time
, EV_ABS
, ABS_X
, 312},
261 {time
, EV_ABS
, ABS_Y
, 432},
262 {time
, EV_ABS
, ABS_PRESSURE
, 43},
263 {time
, EV_SYN
, SYN_REPORT
, 0},
265 time
= {1427323282, 144540};
266 struct input_event mock_kernel_queue_release
[] = {
267 {time
, EV_ABS
, ABS_MT_TRACKING_ID
, -1},
268 {time
, EV_KEY
, BTN_TOUCH
, 0},
269 {time
, EV_ABS
, ABS_PRESSURE
, 0},
270 {time
, EV_SYN
, SYN_REPORT
, 0},
274 dev
->ConfigureReadMock(mock_kernel_queue_press
,
275 arraysize(mock_kernel_queue_press
), 0);
277 EXPECT_EQ(1u, size());
278 ui::TouchEventParams event
= dispatched_event(0);
279 EXPECT_EQ(ui::ET_TOUCH_PRESSED
, event
.type
);
280 EXPECT_EQ(base::TimeDelta::FromMicroseconds(1427323282019203),
282 EXPECT_EQ(295, event
.location
.x());
283 EXPECT_EQ(421, event
.location
.y());
284 EXPECT_EQ(0, event
.slot
);
285 EXPECT_FLOAT_EQ(58.f
, event
.radii
.x());
286 EXPECT_FLOAT_EQ(0.13333334f
, event
.pressure
);
289 dev
->ConfigureReadMock(mock_kernel_queue_move
,
290 arraysize(mock_kernel_queue_move
), 0);
292 EXPECT_EQ(2u, size());
293 event
= dispatched_event(1);
294 EXPECT_EQ(ui::ET_TOUCH_MOVED
, event
.type
);
295 EXPECT_EQ(base::TimeDelta::FromMicroseconds(1427323282034693),
297 EXPECT_EQ(312, event
.location
.x());
298 EXPECT_EQ(432, event
.location
.y());
299 EXPECT_EQ(0, event
.slot
);
300 EXPECT_FLOAT_EQ(50.f
, event
.radii
.x());
301 EXPECT_FLOAT_EQ(0.16862745f
, event
.pressure
);
304 dev
->ConfigureReadMock(mock_kernel_queue_release
,
305 arraysize(mock_kernel_queue_release
), 0);
307 EXPECT_EQ(3u, size());
308 event
= dispatched_event(2);
309 EXPECT_EQ(ui::ET_TOUCH_RELEASED
, event
.type
);
310 EXPECT_EQ(base::TimeDelta::FromMicroseconds(1427323282144540),
312 EXPECT_EQ(312, event
.location
.x());
313 EXPECT_EQ(432, event
.location
.y());
314 EXPECT_EQ(0, event
.slot
);
315 EXPECT_FLOAT_EQ(50.f
, event
.radii
.x());
316 EXPECT_FLOAT_EQ(0.16862745f
, event
.pressure
);
319 TEST_F(TouchEventConverterEvdevTest
, TwoFingerGesture
) {
320 ui::MockTouchEventConverterEvdev
* dev
= device();
322 InitPixelTouchscreen(dev
);
324 struct input_event mock_kernel_queue_press0
[] = {
325 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 684},
326 {{0, 0}, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 3},
327 {{0, 0}, EV_ABS
, ABS_MT_PRESSURE
, 45},
328 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 42},
329 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 51}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
331 // Setup and discard a press.
332 dev
->ConfigureReadMock(mock_kernel_queue_press0
, 6, 0);
334 EXPECT_EQ(1u, size());
336 struct input_event mock_kernel_queue_move0
[] = {
337 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 40}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
339 // Setup and discard a move.
340 dev
->ConfigureReadMock(mock_kernel_queue_move0
, 2, 0);
342 EXPECT_EQ(2u, size());
344 struct input_event mock_kernel_queue_move0press1
[] = {
345 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 40}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
346 {{0, 0}, EV_ABS
, ABS_MT_SLOT
, 1}, {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 686},
347 {{0, 0}, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 3},
348 {{0, 0}, EV_ABS
, ABS_MT_PRESSURE
, 45},
349 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 101},
350 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 102}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
352 // Move on 0, press on 1.
353 dev
->ConfigureReadMock(mock_kernel_queue_move0press1
, 9, 0);
355 EXPECT_EQ(4u, size());
356 ui::TouchEventParams ev0
= dispatched_event(2);
357 ui::TouchEventParams ev1
= dispatched_event(3);
360 EXPECT_EQ(ui::ET_TOUCH_MOVED
, ev0
.type
);
361 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev0
.timestamp
);
362 EXPECT_EQ(40, ev0
.location
.x());
363 EXPECT_EQ(51, ev0
.location
.y());
364 EXPECT_EQ(0, ev0
.slot
);
365 EXPECT_FLOAT_EQ(0.17647059f
, ev0
.pressure
);
368 EXPECT_EQ(ui::ET_TOUCH_PRESSED
, ev1
.type
);
369 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev1
.timestamp
);
370 EXPECT_EQ(101, ev1
.location
.x());
371 EXPECT_EQ(102, ev1
.location
.y());
372 EXPECT_EQ(1, ev1
.slot
);
373 EXPECT_FLOAT_EQ(0.17647059f
, ev1
.pressure
);
375 // Stationary 0, Moves 1.
376 struct input_event mock_kernel_queue_stationary0_move1
[] = {
377 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 40}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
379 dev
->ConfigureReadMock(mock_kernel_queue_stationary0_move1
, 2, 0);
381 EXPECT_EQ(5u, size());
382 ev1
= dispatched_event(4);
384 EXPECT_EQ(ui::ET_TOUCH_MOVED
, ev1
.type
);
385 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev1
.timestamp
);
386 EXPECT_EQ(40, ev1
.location
.x());
387 EXPECT_EQ(102, ev1
.location
.y());
388 EXPECT_EQ(1, ev1
.slot
);
389 EXPECT_FLOAT_EQ(0.17647059f
, ev1
.pressure
);
391 // Move 0, stationary 1.
392 struct input_event mock_kernel_queue_move0_stationary1
[] = {
393 {{0, 0}, EV_ABS
, ABS_MT_SLOT
, 0}, {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 39},
394 {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
396 dev
->ConfigureReadMock(mock_kernel_queue_move0_stationary1
, 3, 0);
398 EXPECT_EQ(6u, size());
399 ev0
= dispatched_event(5);
401 EXPECT_EQ(ui::ET_TOUCH_MOVED
, ev0
.type
);
402 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev0
.timestamp
);
403 EXPECT_EQ(39, ev0
.location
.x());
404 EXPECT_EQ(51, ev0
.location
.y());
405 EXPECT_EQ(0, ev0
.slot
);
406 EXPECT_FLOAT_EQ(0.17647059f
, ev0
.pressure
);
408 // Release 0, move 1.
409 struct input_event mock_kernel_queue_release0_move1
[] = {
410 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, -1}, {{0, 0}, EV_ABS
, ABS_MT_SLOT
, 1},
411 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 38}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
413 dev
->ConfigureReadMock(mock_kernel_queue_release0_move1
, 4, 0);
415 EXPECT_EQ(8u, size());
416 ev0
= dispatched_event(6);
417 ev1
= dispatched_event(7);
419 EXPECT_EQ(ui::ET_TOUCH_RELEASED
, ev0
.type
);
420 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev0
.timestamp
);
421 EXPECT_EQ(39, ev0
.location
.x());
422 EXPECT_EQ(51, ev0
.location
.y());
423 EXPECT_EQ(0, ev0
.slot
);
424 EXPECT_FLOAT_EQ(0.17647059f
, ev0
.pressure
);
426 EXPECT_EQ(ui::ET_TOUCH_MOVED
, ev1
.type
);
427 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev1
.timestamp
);
428 EXPECT_EQ(38, ev1
.location
.x());
429 EXPECT_EQ(102, ev1
.location
.y());
430 EXPECT_EQ(1, ev1
.slot
);
431 EXPECT_FLOAT_EQ(0.17647059f
, ev1
.pressure
);
434 struct input_event mock_kernel_queue_release1
[] = {
435 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, -1}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
437 dev
->ConfigureReadMock(mock_kernel_queue_release1
, 2, 0);
439 EXPECT_EQ(9u, size());
440 ev1
= dispatched_event(8);
442 EXPECT_EQ(ui::ET_TOUCH_RELEASED
, ev1
.type
);
443 EXPECT_EQ(base::TimeDelta::FromMicroseconds(0), ev1
.timestamp
);
444 EXPECT_EQ(38, ev1
.location
.x());
445 EXPECT_EQ(102, ev1
.location
.y());
446 EXPECT_EQ(1, ev1
.slot
);
447 EXPECT_FLOAT_EQ(0.17647059f
, ev1
.pressure
);
450 TEST_F(TouchEventConverterEvdevTest
, Unsync
) {
451 ui::MockTouchEventConverterEvdev
* dev
= device();
453 InitPixelTouchscreen(dev
);
455 struct input_event mock_kernel_queue_press0
[] = {
456 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 684},
457 {{0, 0}, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 3},
458 {{0, 0}, EV_ABS
, ABS_MT_PRESSURE
, 45},
459 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 42},
460 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 51}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
463 dev
->ConfigureReadMock(mock_kernel_queue_press0
, 6, 0);
465 EXPECT_EQ(1u, size());
467 // Prepare a move with a drop.
468 struct input_event mock_kernel_queue_move0
[] = {
469 {{0, 0}, EV_SYN
, SYN_DROPPED
, 0},
470 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 40}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
473 // Verify that we didn't receive it/
474 dev
->ConfigureReadMock(mock_kernel_queue_move0
, 3, 0);
476 EXPECT_EQ(1u, size());
478 struct input_event mock_kernel_queue_move1
[] = {
479 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 40}, {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
482 // Verify that it re-syncs after a SYN_REPORT.
483 dev
->ConfigureReadMock(mock_kernel_queue_move1
, 2, 0);
485 EXPECT_EQ(2u, size());
488 TEST_F(TouchEventConverterEvdevTest
, ShouldResumeExistingContactsOnStart
) {
489 ui::MockTouchEventConverterEvdev
* dev
= device();
491 EventDeviceInfo devinfo
;
492 EXPECT_TRUE(CapabilitiesToDeviceInfo(kLinkTouchscreen
, &devinfo
));
494 // Set up an existing contact in slot 0.
495 devinfo
.SetAbsMtSlot(ABS_MT_TRACKING_ID
, 0, 1);
496 devinfo
.SetAbsMtSlot(ABS_MT_TOUCH_MAJOR
, 0, 100);
497 devinfo
.SetAbsMtSlot(ABS_MT_POSITION_X
, 0, 100);
498 devinfo
.SetAbsMtSlot(ABS_MT_POSITION_Y
, 0, 100);
499 devinfo
.SetAbsMtSlot(ABS_MT_PRESSURE
, 0, 128);
501 // Initialize the device.
502 dev
->Initialize(devinfo
);
504 // Any report should suffice to dispatch the update.. do an empty one.
505 struct input_event mock_kernel_queue_empty_report
[] = {
506 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
509 dev
->ConfigureReadMock(mock_kernel_queue_empty_report
,
510 arraysize(mock_kernel_queue_empty_report
), 0);
512 EXPECT_EQ(1u, size());
514 ui::TouchEventParams ev
= dispatched_event(0);
515 EXPECT_EQ(ET_TOUCH_PRESSED
, ev
.type
);
516 EXPECT_EQ(0, ev
.slot
);
517 EXPECT_FLOAT_EQ(50.f
, ev
.radii
.x());
518 EXPECT_FLOAT_EQ(0.f
, ev
.radii
.y());
519 EXPECT_FLOAT_EQ(0.50196081f
, ev
.pressure
);
522 TEST_F(TouchEventConverterEvdevTest
, ShouldReleaseContactsOnStop
) {
523 ui::MockTouchEventConverterEvdev
* dev
= device();
525 InitPixelTouchscreen(dev
);
527 // Captured from Chromebook Pixel (Link).
529 time
= {1429651083, 686882};
530 struct input_event mock_kernel_queue_press
[] = {
531 {time
, EV_ABS
, ABS_MT_TRACKING_ID
, 0},
532 {time
, EV_ABS
, ABS_MT_POSITION_X
, 1003},
533 {time
, EV_ABS
, ABS_MT_POSITION_Y
, 749},
534 {time
, EV_ABS
, ABS_MT_PRESSURE
, 50},
535 {time
, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 116},
536 {time
, EV_KEY
, BTN_TOUCH
, 1},
537 {time
, EV_ABS
, ABS_X
, 1003},
538 {time
, EV_ABS
, ABS_Y
, 749},
539 {time
, EV_ABS
, ABS_PRESSURE
, 50},
540 {time
, EV_SYN
, SYN_REPORT
, 0},
543 dev
->ConfigureReadMock(mock_kernel_queue_press
,
544 arraysize(mock_kernel_queue_press
), 0);
546 EXPECT_EQ(1u, size());
548 ui::TouchEventParams ev1
= dispatched_event(0);
549 EXPECT_EQ(ET_TOUCH_PRESSED
, ev1
.type
);
550 EXPECT_EQ(0, ev1
.slot
);
553 EXPECT_EQ(2u, size());
555 ui::TouchEventParams ev2
= dispatched_event(1);
556 EXPECT_EQ(ET_TOUCH_RELEASED
, ev2
.type
);
557 EXPECT_EQ(0, ev2
.slot
);
560 TEST_F(TouchEventConverterEvdevTest
, ShouldRemoveContactsWhenDisabled
) {
561 ui::MockTouchEventConverterEvdev
* dev
= device();
563 EventDeviceInfo devinfo
;
564 EXPECT_TRUE(CapabilitiesToDeviceInfo(kLinkTouchscreen
, &devinfo
));
566 // Captured from Chromebook Pixel (Link).
568 time
= {1429651083, 686882};
569 struct input_event mock_kernel_queue_press
[] = {
570 {time
, EV_ABS
, ABS_MT_TRACKING_ID
, 0},
571 {time
, EV_ABS
, ABS_MT_POSITION_X
, 1003},
572 {time
, EV_ABS
, ABS_MT_POSITION_Y
, 749},
573 {time
, EV_ABS
, ABS_MT_PRESSURE
, 50},
574 {time
, EV_ABS
, ABS_MT_TOUCH_MAJOR
, 116},
575 {time
, EV_KEY
, BTN_TOUCH
, 1},
576 {time
, EV_ABS
, ABS_X
, 1003},
577 {time
, EV_ABS
, ABS_Y
, 749},
578 {time
, EV_ABS
, ABS_PRESSURE
, 50},
579 {time
, EV_SYN
, SYN_REPORT
, 0},
582 // Initialize the device.
583 dev
->Initialize(devinfo
);
585 dev
->ConfigureReadMock(mock_kernel_queue_press
,
586 arraysize(mock_kernel_queue_press
), 0);
588 EXPECT_EQ(1u, size());
590 ui::TouchEventParams ev1
= dispatched_event(0);
591 EXPECT_EQ(ET_TOUCH_PRESSED
, ev1
.type
);
592 EXPECT_EQ(0, ev1
.slot
);
593 EXPECT_EQ(1003, ev1
.location
.x());
594 EXPECT_EQ(749, ev1
.location
.y());
596 // Disable the device (should release the contact).
597 dev
->SetEnabled(false);
598 EXPECT_EQ(2u, size());
600 ui::TouchEventParams ev2
= dispatched_event(1);
601 EXPECT_EQ(ET_TOUCH_RELEASED
, ev2
.type
);
602 EXPECT_EQ(0, ev2
.slot
);
604 // Set up the previous contact in slot 0.
605 devinfo
.SetAbsMtSlot(ABS_MT_TRACKING_ID
, 0, 0);
606 devinfo
.SetAbsMtSlot(ABS_MT_TOUCH_MAJOR
, 0, 116);
607 devinfo
.SetAbsMtSlot(ABS_MT_POSITION_X
, 0, 1003);
608 devinfo
.SetAbsMtSlot(ABS_MT_POSITION_Y
, 0, 749);
609 devinfo
.SetAbsMtSlot(ABS_MT_PRESSURE
, 0, 50);
611 // Re-enable the device (should re-apply the contact).
612 dev
->SimulateReinitialize(devinfo
);
613 dev
->SetEnabled(true);
614 EXPECT_EQ(3u, size());
616 ui::TouchEventParams ev3
= dispatched_event(2);
617 EXPECT_EQ(ET_TOUCH_PRESSED
, ev3
.type
);
618 EXPECT_EQ(0, ev3
.slot
);
619 EXPECT_EQ(1003, ev3
.location
.x());
620 EXPECT_EQ(749, ev3
.location
.y());
624 TEST_F(TouchEventConverterEvdevTest
, ShouldUseLeftButtonIfNoTouchButton
) {
625 ui::MockTouchEventConverterEvdev
* dev
= device();
627 InitEloTouchscreen(dev
);
629 // Captured from Elo TouchSystems 2700.
631 time
= {1433965490, 837958};
632 struct input_event mock_kernel_queue_press
[] = {
633 {time
, EV_ABS
, ABS_X
, 3654},
634 {time
, EV_ABS
, ABS_Y
, 1054},
635 {time
, EV_ABS
, ABS_MISC
, 18},
636 {time
, EV_SYN
, SYN_REPORT
, 0},
638 {time
, EV_MSC
, MSC_SCAN
, 90001},
639 {time
, EV_KEY
, BTN_LEFT
, 1},
640 {time
, EV_ABS
, ABS_Y
, 1055},
641 {time
, EV_ABS
, ABS_MISC
, 25},
642 {time
, EV_SYN
, SYN_REPORT
, 0},
644 time
= {1433965491, 1953};
645 struct input_event mock_kernel_queue_move
[] = {
646 {time
, EV_ABS
, ABS_X
, 3644},
647 {time
, EV_ABS
, ABS_Y
, 1059},
648 {time
, EV_ABS
, ABS_MISC
, 36},
649 {time
, EV_SYN
, SYN_REPORT
, 0},
651 time
= {1433965491, 225959};
652 struct input_event mock_kernel_queue_release
[] = {
653 {time
, EV_MSC
, MSC_SCAN
, 90001},
654 {time
, EV_KEY
, BTN_LEFT
, 0},
655 {time
, EV_ABS
, ABS_MISC
, 0},
656 {time
, EV_SYN
, SYN_REPORT
, 0},
660 dev
->ConfigureReadMock(mock_kernel_queue_press
,
661 arraysize(mock_kernel_queue_press
), 0);
663 EXPECT_EQ(1u, size());
664 ui::TouchEventParams event
= dispatched_event(0);
665 EXPECT_EQ(ui::ET_TOUCH_PRESSED
, event
.type
);
666 EXPECT_EQ(base::TimeDelta::FromMicroseconds(1433965490837958),
668 EXPECT_EQ(3654, event
.location
.x());
669 EXPECT_EQ(1055, event
.location
.y());
670 EXPECT_EQ(0, event
.slot
);
671 EXPECT_FLOAT_EQ(0.f
, event
.radii
.x());
672 EXPECT_FLOAT_EQ(0.f
, event
.pressure
);
675 dev
->ConfigureReadMock(mock_kernel_queue_move
,
676 arraysize(mock_kernel_queue_move
), 0);
678 EXPECT_EQ(2u, size());
679 event
= dispatched_event(1);
680 EXPECT_EQ(ui::ET_TOUCH_MOVED
, event
.type
);
681 EXPECT_EQ(base::TimeDelta::FromMicroseconds(1433965491001953),
683 EXPECT_EQ(3644, event
.location
.x());
684 EXPECT_EQ(1059, event
.location
.y());
685 EXPECT_EQ(0, event
.slot
);
686 EXPECT_FLOAT_EQ(0.f
, event
.radii
.x());
687 EXPECT_FLOAT_EQ(0.f
, event
.pressure
);
690 dev
->ConfigureReadMock(mock_kernel_queue_release
,
691 arraysize(mock_kernel_queue_release
), 0);
693 EXPECT_EQ(3u, size());
694 event
= dispatched_event(2);
695 EXPECT_EQ(ui::ET_TOUCH_RELEASED
, event
.type
);
696 EXPECT_EQ(base::TimeDelta::FromMicroseconds(1433965491225959),
698 EXPECT_EQ(3644, event
.location
.x());
699 EXPECT_EQ(1059, event
.location
.y());
700 EXPECT_EQ(0, event
.slot
);
701 EXPECT_FLOAT_EQ(0.f
, event
.radii
.x());
702 EXPECT_FLOAT_EQ(0.f
, event
.pressure
);
704 // No dispatch on destruction.
706 EXPECT_EQ(3u, size());
710 TEST_F(TouchEventConverterEvdevTest
,
711 DontChangeMultitouchPositionFromLegacyAxes
) {
712 ui::MockTouchEventConverterEvdev
* dev
= device();
714 InitPixelTouchscreen(dev
);
716 struct input_event mock_kernel_queue
[] = {
717 {{0, 0}, EV_ABS
, ABS_MT_SLOT
, 0},
718 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 100},
719 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 999},
720 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 888},
721 {{0, 0}, EV_ABS
, ABS_MT_PRESSURE
, 55},
722 {{0, 0}, EV_ABS
, ABS_MT_SLOT
, 1},
723 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 200},
724 {{0, 0}, EV_ABS
, ABS_MT_PRESSURE
, 44},
725 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 777},
726 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 666},
727 {{0, 0}, EV_ABS
, ABS_X
, 999},
728 {{0, 0}, EV_ABS
, ABS_Y
, 888},
729 {{0, 0}, EV_ABS
, ABS_PRESSURE
, 55},
730 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
733 // Check that two events are generated.
734 dev
->ConfigureReadMock(mock_kernel_queue
, arraysize(mock_kernel_queue
), 0);
737 const unsigned int kExpectedEventCount
= 2;
738 EXPECT_EQ(kExpectedEventCount
, size());
739 if (kExpectedEventCount
!= size())
742 ui::TouchEventParams ev0
= dispatched_event(0);
743 ui::TouchEventParams ev1
= dispatched_event(1);
745 EXPECT_EQ(0, ev0
.slot
);
746 EXPECT_EQ(999, ev0
.location
.x());
747 EXPECT_EQ(888, ev0
.location
.y());
748 EXPECT_FLOAT_EQ(0.21568628f
, ev0
.pressure
);
750 EXPECT_EQ(1, ev1
.slot
);
751 EXPECT_EQ(777, ev1
.location
.x());
752 EXPECT_EQ(666, ev1
.location
.y());
753 EXPECT_FLOAT_EQ(0.17254902f
, ev1
.pressure
);
757 TEST_F(TouchEventConverterEvdevTest
, CheckSlotLimit
) {
758 ui::MockTouchEventConverterEvdev
* dev
= device();
760 struct input_event mock_kernel_queue
[] = {
761 {{0, 0}, EV_ABS
, ABS_MT_SLOT
, 0},
762 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 100},
763 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 999},
764 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 888},
765 {{0, 0}, EV_ABS
, ABS_MT_SLOT
, ui::kNumTouchEvdevSlots
},
766 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 200},
767 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 777},
768 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 666},
769 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
772 // Check that one 1 event is generated
773 dev
->ConfigureReadMock(mock_kernel_queue
, arraysize(mock_kernel_queue
), 0);
775 EXPECT_EQ(1u, size());
780 // TouchNoiseFilter which:
781 // - Considers all events of type |noise_event_type| as noise.
782 // - Keeps track of the events that it receives.
783 class EventTypeTouchNoiseFilter
: public TouchNoiseFilter
{
785 explicit EventTypeTouchNoiseFilter(EventType noise_event_type
)
786 : noise_event_type_(noise_event_type
) {}
787 ~EventTypeTouchNoiseFilter() override
{}
790 void Filter(const std::vector
<InProgressTouchEvdev
>& touches
,
791 base::TimeDelta time
,
792 std::bitset
<kNumTouchEvdevSlots
>* slots_with_noise
) override
{
793 for (const InProgressTouchEvdev
& touch
: touches
) {
794 EventType event_type
= EventTypeFromTouch(touch
);
795 ++counts_
[event_type
];
796 if (event_type
== noise_event_type_
)
797 slots_with_noise
->set(touch
.slot
);
801 // Returns the number of received events of |type|.
802 size_t num_events(EventType type
) const {
803 std::map
<EventType
, size_t>::const_iterator it
= counts_
.find(type
);
804 return it
== counts_
.end() ? 0u : it
->second
;
808 EventType
EventTypeFromTouch(const InProgressTouchEvdev
& touch
) const {
810 return touch
.was_touching
? ET_TOUCH_MOVED
: ET_TOUCH_PRESSED
;
811 return touch
.was_touching
? ET_TOUCH_RELEASED
: ET_UNKNOWN
;
814 EventType noise_event_type_
;
815 std::map
<EventType
, size_t> counts_
;
817 DISALLOW_COPY_AND_ASSIGN(EventTypeTouchNoiseFilter
);
822 class TouchEventConverterEvdevTouchNoiseTest
823 : public TouchEventConverterEvdevTest
{
825 TouchEventConverterEvdevTouchNoiseTest() {}
826 ~TouchEventConverterEvdevTouchNoiseTest() override
{}
828 // Makes the TouchNoiseFinder use |filter| and only |filter| to filter out
830 void SetTouchNoiseFilter(scoped_ptr
<TouchNoiseFilter
> filter
) {
831 TouchNoiseFinder
* finder
= device()->touch_noise_finder();
832 finder
->filters_
.clear();
833 finder
->filters_
.push_back(filter
.release());
836 // Returns the first of TouchNoiseFinder's filters.
837 ui::TouchNoiseFilter
* first_filter() {
838 TouchNoiseFinder
* finder
= device()->touch_noise_finder();
839 return finder
->filters_
.empty() ? nullptr : *finder
->filters_
.begin();
842 // TouchEventConverterEvdevTest:
843 void SetUp() override
{
844 base::CommandLine::ForCurrentProcess()->AppendSwitch(
845 switches::kExtraTouchNoiseFiltering
);
846 TouchEventConverterEvdevTest::SetUp();
850 DISALLOW_COPY_AND_ASSIGN(TouchEventConverterEvdevTouchNoiseTest
);
853 // Test that if TouchNoiseFinder identifies an event for an in-progress touch as
854 // noise, that the event is converted to ET_TOUCH_CANCELLED and that all
855 // subsequent events for the in-progress touch are cancelled.
856 TEST_F(TouchEventConverterEvdevTouchNoiseTest
, TouchNoiseFiltering
) {
857 struct input_event mock_kernel_queue
[] = {
858 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 684},
859 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 40},
860 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 41},
861 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
863 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 42},
864 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 43},
865 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
867 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, -1},
868 {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
871 MockTouchEventConverterEvdev
* dev
= device();
872 SetTouchNoiseFilter(scoped_ptr
<TouchNoiseFilter
>(
873 new EventTypeTouchNoiseFilter(ET_TOUCH_PRESSED
)));
874 dev
->ConfigureReadMock(mock_kernel_queue
, arraysize(mock_kernel_queue
), 0);
876 ASSERT_EQ(0u, size());
878 ClearDispatchedEvents();
879 SetTouchNoiseFilter(scoped_ptr
<TouchNoiseFilter
>(
880 new EventTypeTouchNoiseFilter(ET_TOUCH_MOVED
)));
881 dev
->ConfigureReadMock(mock_kernel_queue
, arraysize(mock_kernel_queue
), 0);
883 ASSERT_EQ(2u, size());
884 TouchEventParams event0
= dispatched_event(0);
885 EXPECT_EQ(ET_TOUCH_PRESSED
, event0
.type
);
886 EXPECT_EQ(40, event0
.location
.x());
887 EXPECT_EQ(41, event0
.location
.y());
888 EXPECT_EQ(ET_TOUCH_CANCELLED
, dispatched_event(1).type
);
890 ClearDispatchedEvents();
891 SetTouchNoiseFilter(scoped_ptr
<TouchNoiseFilter
>(
892 new EventTypeTouchNoiseFilter(ET_TOUCH_RELEASED
)));
893 dev
->ConfigureReadMock(mock_kernel_queue
, arraysize(mock_kernel_queue
), 0);
895 ASSERT_EQ(3u, size());
896 event0
= dispatched_event(0);
897 EXPECT_EQ(ET_TOUCH_PRESSED
, event0
.type
);
898 EXPECT_EQ(40, event0
.location
.x());
899 EXPECT_EQ(41, event0
.location
.y());
900 TouchEventParams event1
= dispatched_event(1);
901 EXPECT_EQ(ET_TOUCH_MOVED
, event1
.type
);
902 EXPECT_EQ(42, event1
.location
.x());
903 EXPECT_EQ(43, event1
.location
.y());
904 EXPECT_EQ(ET_TOUCH_CANCELLED
, dispatched_event(2).type
);
907 // Test that TouchEventConverterEvdev keeps sending events to
908 // TouchNoiseFinder after the touch is canceled.
909 TEST_F(TouchEventConverterEvdevTouchNoiseTest
,
910 DoNotSendTouchCancelsToTouchNoiseFinder
) {
911 struct input_event mock_kernel_queue
[] = {
912 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, 684},
913 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 40},
914 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 41},
915 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
917 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 42},
918 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 43},
919 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
921 {{0, 0}, EV_ABS
, ABS_MT_POSITION_X
, 43},
922 {{0, 0}, EV_ABS
, ABS_MT_POSITION_Y
, 44},
923 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
925 {{0, 0}, EV_ABS
, ABS_MT_TRACKING_ID
, -1},
926 {{0, 0}, EV_SYN
, SYN_REPORT
, 0}
929 MockTouchEventConverterEvdev
* dev
= device();
930 SetTouchNoiseFilter(scoped_ptr
<TouchNoiseFilter
>(
931 new EventTypeTouchNoiseFilter(ET_TOUCH_PRESSED
)));
932 dev
->ConfigureReadMock(mock_kernel_queue
, arraysize(mock_kernel_queue
), 0);
934 ASSERT_EQ(0u, size());
936 EventTypeTouchNoiseFilter
* filter
=
937 static_cast<EventTypeTouchNoiseFilter
*>(first_filter());
938 EXPECT_EQ(1u, filter
->num_events(ET_TOUCH_PRESSED
));
939 EXPECT_EQ(2u, filter
->num_events(ET_TOUCH_MOVED
));
940 EXPECT_EQ(1u, filter
->num_events(ET_TOUCH_RELEASED
));
943 TEST_F(TouchEventConverterEvdevTest
, ActiveStylusTouchAndRelease
) {
944 ui::MockTouchEventConverterEvdev
* dev
= device();
945 EventDeviceInfo devinfo
;
946 EXPECT_TRUE(CapabilitiesToDeviceInfo(kWilsonBeachActiveStylus
, &devinfo
));
947 dev
->Initialize(devinfo
);
949 struct input_event mock_kernel_queue
[]{
950 {{0, 0}, EV_KEY
, BTN_TOOL_PEN
, 1},
951 {{0, 0}, EV_ABS
, ABS_X
, 9170},
952 {{0, 0}, EV_ABS
, ABS_Y
, 3658},
953 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
954 {{0, 0}, EV_KEY
, BTN_TOUCH
, 1},
955 {{0, 0}, EV_ABS
, ABS_PRESSURE
, 60},
956 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
957 {{0, 0}, EV_KEY
, BTN_TOUCH
, 0},
958 {{0, 0}, EV_ABS
, ABS_X
, 9173},
959 {{0, 0}, EV_ABS
, ABS_Y
, 3906},
960 {{0, 0}, EV_ABS
, ABS_PRESSURE
, 0},
961 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
962 {{0, 0}, EV_KEY
, BTN_TOOL_PEN
, 0},
963 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
966 dev
->ConfigureReadMock(mock_kernel_queue
, arraysize(mock_kernel_queue
), 0);
968 EXPECT_EQ(2u, size());
970 ui::TouchEventParams event
= dispatched_event(0);
971 EXPECT_EQ(ui::ET_TOUCH_PRESSED
, event
.type
);
972 EXPECT_EQ(9170, event
.location
.x());
973 EXPECT_EQ(3658, event
.location
.y());
974 EXPECT_EQ(60.f
/ 1024, event
.pressure
);
976 event
= dispatched_event(1);
977 EXPECT_EQ(ui::ET_TOUCH_RELEASED
, event
.type
);
978 EXPECT_EQ(9173, event
.location
.x());
979 EXPECT_EQ(3906, event
.location
.y());
980 EXPECT_EQ(0.f
/ 1024, event
.pressure
);
983 TEST_F(TouchEventConverterEvdevTest
, ActiveStylusMotion
) {
984 ui::MockTouchEventConverterEvdev
* dev
= device();
985 EventDeviceInfo devinfo
;
986 EXPECT_TRUE(CapabilitiesToDeviceInfo(kWilsonBeachActiveStylus
, &devinfo
));
987 dev
->Initialize(devinfo
);
989 struct input_event mock_kernel_queue
[]{
990 {{0, 0}, EV_KEY
, BTN_TOOL_PEN
, 1},
991 {{0, 0}, EV_ABS
, ABS_X
, 8921},
992 {{0, 0}, EV_ABS
, ABS_Y
, 1072},
993 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
994 {{0, 0}, EV_KEY
, BTN_TOUCH
, 1},
995 {{0, 0}, EV_ABS
, ABS_PRESSURE
, 35},
996 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
997 {{0, 0}, EV_ABS
, ABS_X
, 8934},
998 {{0, 0}, EV_ABS
, ABS_Y
, 981},
999 {{0, 0}, EV_ABS
, ABS_PRESSURE
, 184},
1000 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
1001 {{0, 0}, EV_ABS
, ABS_X
, 8930},
1002 {{0, 0}, EV_ABS
, ABS_Y
, 980},
1003 {{0, 0}, EV_ABS
, ABS_PRESSURE
, 348},
1004 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
1005 {{0, 0}, EV_KEY
, BTN_TOUCH
, 0},
1006 {{0, 0}, EV_ABS
, ABS_PRESSURE
, 0},
1007 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
1008 {{0, 0}, EV_KEY
, BTN_TOOL_PEN
, 0},
1009 {{0, 0}, EV_SYN
, SYN_REPORT
, 0},
1012 dev
->ConfigureReadMock(mock_kernel_queue
, arraysize(mock_kernel_queue
), 0);
1014 EXPECT_EQ(4u, size());
1016 ui::TouchEventParams event
= dispatched_event(0);
1017 EXPECT_EQ(ui::ET_TOUCH_PRESSED
, event
.type
);
1018 EXPECT_EQ(8921, event
.location
.x());
1019 EXPECT_EQ(1072, event
.location
.y());
1020 EXPECT_EQ(35.f
/ 1024, event
.pressure
);
1022 event
= dispatched_event(1);
1023 EXPECT_EQ(ui::ET_TOUCH_MOVED
, event
.type
);
1024 EXPECT_EQ(8934, event
.location
.x());
1025 EXPECT_EQ(981, event
.location
.y());
1026 EXPECT_EQ(184.f
/ 1024, event
.pressure
);
1028 event
= dispatched_event(2);
1029 EXPECT_EQ(ui::ET_TOUCH_MOVED
, event
.type
);
1030 EXPECT_EQ(8930, event
.location
.x());
1031 EXPECT_EQ(980, event
.location
.y());
1032 EXPECT_EQ(348.f
/ 1024, event
.pressure
);
1034 event
= dispatched_event(3);
1035 EXPECT_EQ(ui::ET_TOUCH_RELEASED
, event
.type
);
1036 EXPECT_EQ(8930, event
.location
.x());
1037 EXPECT_EQ(980, event
.location
.y());
1038 EXPECT_EQ(0.f
/ 1024, event
.pressure
);