2 * Copyright © 2014 Red Hat, Inc.
4 * Permission to use, copy, modify, distribute, and sell this software and
5 * its documentation for any purpose is hereby granted without fee, provided
6 * that the above copyright notice appear in all copies and that both that
7 * copyright notice and this permission notice appear in supporting
8 * documentation, and that the name of the copyright holders not be used in
9 * advertising or publicity pertaining to distribution of the software
10 * without specific, written prior permission. The copyright holders make
11 * no representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
15 * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
16 * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
17 * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
18 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
19 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
20 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
31 #include "libinput-util.h"
34 START_TEST(touchpad_1fg_motion)
36 struct litest_device *dev = litest_current_device();
37 struct libinput *li = dev->libinput;
38 struct libinput_event *event;
39 struct libinput_event_pointer *ptrev;
41 litest_drain_events(li);
43 litest_touch_down(dev, 0, 50, 50);
44 litest_touch_move_to(dev, 0, 50, 50, 80, 50, 5);
45 litest_touch_up(dev, 0);
47 libinput_dispatch(li);
49 event = libinput_get_event(li);
50 ck_assert(event != NULL);
53 ck_assert_int_eq(libinput_event_get_type(event),
54 LIBINPUT_EVENT_POINTER_MOTION);
56 ptrev = libinput_event_get_pointer_event(event);
57 ck_assert_int_ge(libinput_event_pointer_get_dx(ptrev), 0);
58 ck_assert_int_eq(libinput_event_pointer_get_dy(ptrev), 0);
59 libinput_event_destroy(event);
60 event = libinput_get_event(li);
65 START_TEST(touchpad_2fg_no_motion)
67 struct litest_device *dev = litest_current_device();
68 struct libinput *li = dev->libinput;
69 struct libinput_event *event;
71 litest_drain_events(li);
73 litest_touch_down(dev, 0, 20, 20);
74 litest_touch_down(dev, 1, 70, 20);
75 litest_touch_move_to(dev, 0, 20, 20, 80, 80, 5);
76 litest_touch_move_to(dev, 1, 70, 20, 80, 50, 5);
77 litest_touch_up(dev, 1);
78 litest_touch_up(dev, 0);
80 libinput_dispatch(li);
82 event = libinput_get_event(li);
84 ck_assert_int_ne(libinput_event_get_type(event),
85 LIBINPUT_EVENT_POINTER_MOTION);
86 libinput_event_destroy(event);
87 event = libinput_get_event(li);
93 assert_button_event(struct libinput *li, unsigned int button,
94 enum libinput_button_state state)
96 struct libinput_event *event;
97 struct libinput_event_pointer *ptrev;
99 libinput_dispatch(li);
100 event = libinput_get_event(li);
102 ck_assert(event != NULL);
103 ck_assert_int_eq(libinput_event_get_type(event),
104 LIBINPUT_EVENT_POINTER_BUTTON);
105 ptrev = libinput_event_get_pointer_event(event);
106 ck_assert_int_eq(libinput_event_pointer_get_button(ptrev),
108 ck_assert_int_eq(libinput_event_pointer_get_button_state(ptrev),
110 libinput_event_destroy(event);
113 START_TEST(touchpad_1fg_tap)
115 struct litest_device *dev = litest_current_device();
116 struct libinput *li = dev->libinput;
117 struct libinput_event *event;
119 libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
121 litest_drain_events(li);
123 litest_touch_down(dev, 0, 50, 50);
124 litest_touch_up(dev, 0);
126 libinput_dispatch(li);
128 assert_button_event(li, BTN_LEFT,
129 LIBINPUT_BUTTON_STATE_PRESSED);
130 msleep(300); /* tap-n-drag timeout */
131 assert_button_event(li, BTN_LEFT,
132 LIBINPUT_BUTTON_STATE_RELEASED);
134 libinput_dispatch(li);
135 event = libinput_get_event(li);
136 ck_assert(event == NULL);
140 START_TEST(touchpad_1fg_tap_n_drag)
142 struct litest_device *dev = litest_current_device();
143 struct libinput *li = dev->libinput;
144 struct libinput_event *event;
146 libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
148 litest_drain_events(li);
150 litest_touch_down(dev, 0, 50, 50);
151 litest_touch_up(dev, 0);
152 litest_touch_down(dev, 0, 50, 50);
153 litest_touch_move_to(dev, 0, 50, 50, 80, 80, 5);
154 litest_touch_up(dev, 0);
156 libinput_dispatch(li);
158 assert_button_event(li, BTN_LEFT,
159 LIBINPUT_BUTTON_STATE_PRESSED);
161 libinput_dispatch(li);
162 while (libinput_next_event_type(li) == LIBINPUT_EVENT_POINTER_MOTION) {
163 event = libinput_get_event(li);
164 libinput_event_destroy(event);
165 libinput_dispatch(li);
168 ck_assert_int_eq(libinput_next_event_type(li), LIBINPUT_EVENT_NONE);
170 /* lift finger, set down again, should continue dragging */
171 litest_touch_down(dev, 0, 50, 50);
172 litest_touch_move_to(dev, 0, 50, 50, 80, 80, 5);
173 litest_touch_up(dev, 0);
175 libinput_dispatch(li);
176 while (libinput_next_event_type(li) == LIBINPUT_EVENT_POINTER_MOTION) {
177 event = libinput_get_event(li);
178 libinput_event_destroy(event);
179 libinput_dispatch(li);
182 ck_assert_int_eq(libinput_next_event_type(li), LIBINPUT_EVENT_NONE);
184 msleep(300); /* tap-n-drag timeout */
186 assert_button_event(li, BTN_LEFT,
187 LIBINPUT_BUTTON_STATE_RELEASED);
189 litest_assert_empty_queue(li);
193 START_TEST(touchpad_2fg_tap)
195 struct litest_device *dev = litest_current_device();
196 struct libinput *li = dev->libinput;
198 libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
200 litest_drain_events(dev->libinput);
202 litest_touch_down(dev, 0, 50, 50);
203 litest_touch_down(dev, 1, 70, 70);
204 litest_touch_up(dev, 0);
205 litest_touch_up(dev, 1);
207 libinput_dispatch(li);
209 assert_button_event(li, BTN_RIGHT,
210 LIBINPUT_BUTTON_STATE_PRESSED);
211 msleep(300); /* tap-n-drag timeout */
212 assert_button_event(li, BTN_RIGHT,
213 LIBINPUT_BUTTON_STATE_RELEASED);
215 litest_assert_empty_queue(li);
219 START_TEST(touchpad_2fg_tap_inverted)
221 struct litest_device *dev = litest_current_device();
222 struct libinput *li = dev->libinput;
224 libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
226 litest_drain_events(dev->libinput);
228 litest_touch_down(dev, 0, 50, 50);
229 litest_touch_down(dev, 1, 70, 70);
230 litest_touch_up(dev, 1);
231 litest_touch_up(dev, 0);
233 libinput_dispatch(li);
235 assert_button_event(li, BTN_RIGHT,
236 LIBINPUT_BUTTON_STATE_PRESSED);
237 msleep(300); /* tap-n-drag timeout */
238 assert_button_event(li, BTN_RIGHT,
239 LIBINPUT_BUTTON_STATE_RELEASED);
241 litest_assert_empty_queue(li);
245 START_TEST(touchpad_1fg_tap_click)
247 struct litest_device *dev = litest_current_device();
248 struct libinput *li = dev->libinput;
250 libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
252 litest_drain_events(dev->libinput);
254 /* finger down, button click, finger up
255 -> only one button left event pair */
256 litest_touch_down(dev, 0, 50, 50);
257 litest_event(dev, EV_KEY, BTN_LEFT, 1);
258 litest_event(dev, EV_SYN, SYN_REPORT, 0);
259 litest_event(dev, EV_KEY, BTN_LEFT, 0);
260 litest_event(dev, EV_SYN, SYN_REPORT, 0);
261 litest_touch_up(dev, 0);
263 libinput_dispatch(li);
265 assert_button_event(li, BTN_LEFT,
266 LIBINPUT_BUTTON_STATE_PRESSED);
267 assert_button_event(li, BTN_LEFT,
268 LIBINPUT_BUTTON_STATE_RELEASED);
270 litest_assert_empty_queue(li);
274 START_TEST(touchpad_2fg_tap_click)
276 struct litest_device *dev = litest_current_device();
277 struct libinput *li = dev->libinput;
279 libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
281 litest_drain_events(dev->libinput);
283 /* two fingers down, button click, fingers up
284 -> only one button left event pair */
285 litest_touch_down(dev, 0, 50, 50);
286 litest_touch_down(dev, 1, 70, 50);
287 litest_event(dev, EV_KEY, BTN_LEFT, 1);
288 litest_event(dev, EV_SYN, SYN_REPORT, 0);
289 litest_event(dev, EV_KEY, BTN_LEFT, 0);
290 litest_event(dev, EV_SYN, SYN_REPORT, 0);
291 litest_touch_up(dev, 1);
292 litest_touch_up(dev, 0);
294 libinput_dispatch(li);
296 assert_button_event(li, BTN_LEFT,
297 LIBINPUT_BUTTON_STATE_PRESSED);
298 assert_button_event(li, BTN_LEFT,
299 LIBINPUT_BUTTON_STATE_RELEASED);
301 litest_assert_empty_queue(li);
305 START_TEST(touchpad_2fg_tap_click_apple)
307 struct litest_device *dev = litest_current_device();
308 struct libinput *li = dev->libinput;
310 libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
312 litest_drain_events(dev->libinput);
314 /* two fingers down, button click, fingers up
315 -> only one button right event pair
316 (apple have clickfinger enabled by default) */
317 litest_touch_down(dev, 0, 50, 50);
318 litest_touch_down(dev, 1, 70, 50);
319 litest_event(dev, EV_KEY, BTN_LEFT, 1);
320 litest_event(dev, EV_SYN, SYN_REPORT, 0);
321 litest_event(dev, EV_KEY, BTN_LEFT, 0);
322 litest_event(dev, EV_SYN, SYN_REPORT, 0);
323 litest_touch_up(dev, 1);
324 litest_touch_up(dev, 0);
326 libinput_dispatch(li);
328 assert_button_event(li, BTN_RIGHT,
329 LIBINPUT_BUTTON_STATE_PRESSED);
330 assert_button_event(li, BTN_RIGHT,
331 LIBINPUT_BUTTON_STATE_RELEASED);
333 litest_assert_empty_queue(li);
337 START_TEST(touchpad_no_2fg_tap_after_move)
339 struct litest_device *dev = litest_current_device();
340 struct libinput *li = dev->libinput;
342 litest_drain_events(dev->libinput);
344 /* one finger down, move past threshold,
345 second finger down, first finger up
348 litest_touch_down(dev, 0, 50, 50);
349 litest_touch_move_to(dev, 0, 50, 50, 90, 90, 10);
350 litest_drain_events(dev->libinput);
352 litest_touch_down(dev, 1, 70, 50);
353 litest_touch_up(dev, 0);
355 litest_assert_empty_queue(li);
359 START_TEST(touchpad_no_2fg_tap_after_timeout)
361 struct litest_device *dev = litest_current_device();
362 struct libinput *li = dev->libinput;
364 litest_drain_events(dev->libinput);
366 /* one finger down, wait past tap timeout,
367 second finger down, first finger up
370 litest_touch_down(dev, 0, 50, 50);
371 libinput_dispatch(dev->libinput);
373 libinput_dispatch(dev->libinput);
374 litest_drain_events(dev->libinput);
376 litest_touch_down(dev, 1, 70, 50);
377 litest_touch_up(dev, 0);
379 litest_assert_empty_queue(li);
383 START_TEST(touchpad_no_first_fg_tap_after_move)
385 struct litest_device *dev = litest_current_device();
386 struct libinput *li = dev->libinput;
387 struct libinput_event *event;
389 litest_drain_events(dev->libinput);
391 /* one finger down, second finger down,
392 second finger moves beyond threshold,
396 litest_touch_down(dev, 0, 50, 50);
397 litest_touch_down(dev, 1, 70, 50);
398 libinput_dispatch(dev->libinput);
399 litest_touch_move_to(dev, 1, 70, 50, 90, 90, 10);
400 libinput_dispatch(dev->libinput);
401 litest_touch_up(dev, 0);
402 litest_touch_up(dev, 1);
403 libinput_dispatch(dev->libinput);
405 while ((event = libinput_get_event(li))) {
406 ck_assert_int_ne(libinput_event_get_type(event),
407 LIBINPUT_EVENT_POINTER_BUTTON);
408 libinput_event_destroy(event);
413 START_TEST(touchpad_1fg_double_tap_click)
415 struct litest_device *dev = litest_current_device();
416 struct libinput *li = dev->libinput;
418 libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
420 litest_drain_events(dev->libinput);
422 /* one finger down, up, down, button click, finger up
423 -> two button left event pairs */
424 litest_touch_down(dev, 0, 50, 50);
425 litest_touch_up(dev, 0);
426 litest_touch_down(dev, 0, 50, 50);
427 litest_event(dev, EV_KEY, BTN_LEFT, 1);
428 litest_event(dev, EV_SYN, SYN_REPORT, 0);
429 litest_event(dev, EV_KEY, BTN_LEFT, 0);
430 litest_event(dev, EV_SYN, SYN_REPORT, 0);
431 litest_touch_up(dev, 0);
433 libinput_dispatch(li);
435 assert_button_event(li, BTN_LEFT,
436 LIBINPUT_BUTTON_STATE_PRESSED);
437 assert_button_event(li, BTN_LEFT,
438 LIBINPUT_BUTTON_STATE_RELEASED);
439 assert_button_event(li, BTN_LEFT,
440 LIBINPUT_BUTTON_STATE_PRESSED);
441 assert_button_event(li, BTN_LEFT,
442 LIBINPUT_BUTTON_STATE_RELEASED);
444 litest_assert_empty_queue(li);
448 START_TEST(touchpad_1fg_tap_n_drag_click)
450 struct litest_device *dev = litest_current_device();
451 struct libinput *li = dev->libinput;
452 struct libinput_event *event;
454 libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
456 litest_drain_events(dev->libinput);
458 /* one finger down, up, down, move, button click, finger up
459 -> two button left event pairs, motion allowed */
460 litest_touch_down(dev, 0, 50, 50);
461 litest_touch_up(dev, 0);
462 litest_touch_down(dev, 0, 50, 50);
463 litest_touch_move_to(dev, 0, 50, 50, 80, 50, 10);
465 assert_button_event(li, BTN_LEFT,
466 LIBINPUT_BUTTON_STATE_PRESSED);
468 libinput_dispatch(li);
470 ck_assert_int_eq(libinput_next_event_type(li),
471 LIBINPUT_EVENT_POINTER_MOTION);
472 while (libinput_next_event_type(li) == LIBINPUT_EVENT_POINTER_MOTION) {
473 event = libinput_get_event(li);
474 libinput_event_destroy(event);
475 libinput_dispatch(li);
478 litest_event(dev, EV_KEY, BTN_LEFT, 1);
479 litest_event(dev, EV_SYN, SYN_REPORT, 0);
481 assert_button_event(li, BTN_LEFT,
482 LIBINPUT_BUTTON_STATE_RELEASED);
483 assert_button_event(li, BTN_LEFT,
484 LIBINPUT_BUTTON_STATE_PRESSED);
486 litest_event(dev, EV_KEY, BTN_LEFT, 0);
487 litest_event(dev, EV_SYN, SYN_REPORT, 0);
488 litest_touch_up(dev, 0);
490 libinput_dispatch(li);
492 assert_button_event(li, BTN_LEFT,
493 LIBINPUT_BUTTON_STATE_RELEASED);
495 litest_assert_empty_queue(li);
499 START_TEST(touchpad_3fg_tap)
501 struct litest_device *dev = litest_current_device();
502 struct libinput *li = dev->libinput;
503 struct libinput_event *event;
506 libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
508 for (i = 0; i < 3; i++) {
509 litest_drain_events(li);
511 litest_touch_down(dev, 0, 50, 50);
512 litest_touch_down(dev, 1, 70, 50);
513 litest_touch_down(dev, 2, 80, 50);
515 litest_touch_up(dev, (i + 2) % 3);
516 litest_touch_up(dev, (i + 1) % 3);
517 litest_touch_up(dev, (i + 0) % 3);
519 libinput_dispatch(li);
521 assert_button_event(li, BTN_MIDDLE,
522 LIBINPUT_BUTTON_STATE_PRESSED);
523 msleep(300); /* tap-n-drag timeout */
524 assert_button_event(li, BTN_MIDDLE,
525 LIBINPUT_BUTTON_STATE_RELEASED);
527 libinput_dispatch(li);
528 event = libinput_get_event(li);
529 ck_assert(event == NULL);
534 START_TEST(touchpad_3fg_tap_btntool)
536 struct litest_device *dev = litest_current_device();
537 struct libinput *li = dev->libinput;
538 struct libinput_event *event;
540 libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
542 litest_drain_events(li);
544 litest_touch_down(dev, 0, 50, 50);
545 litest_touch_down(dev, 1, 70, 50);
546 litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 1);
547 litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0);
548 litest_event(dev, EV_SYN, SYN_REPORT, 0);
549 litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 0);
550 litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 1);
551 litest_event(dev, EV_SYN, SYN_REPORT, 0);
552 litest_touch_up(dev, 1);
553 litest_touch_up(dev, 0);
555 libinput_dispatch(li);
557 assert_button_event(li, BTN_MIDDLE,
558 LIBINPUT_BUTTON_STATE_PRESSED);
559 msleep(300); /* tap-n-drag timeout */
560 assert_button_event(li, BTN_MIDDLE,
561 LIBINPUT_BUTTON_STATE_RELEASED);
563 libinput_dispatch(li);
564 event = libinput_get_event(li);
565 ck_assert(event == NULL);
569 START_TEST(touchpad_3fg_tap_btntool_inverted)
571 struct litest_device *dev = litest_current_device();
572 struct libinput *li = dev->libinput;
573 struct libinput_event *event;
575 libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
577 litest_drain_events(li);
579 litest_touch_down(dev, 0, 50, 50);
580 litest_touch_down(dev, 1, 70, 50);
581 litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 1);
582 litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0);
583 litest_event(dev, EV_SYN, SYN_REPORT, 0);
584 litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 0);
585 litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 1);
586 litest_event(dev, EV_SYN, SYN_REPORT, 0);
587 litest_touch_up(dev, 0);
588 litest_touch_up(dev, 1);
590 libinput_dispatch(li);
592 assert_button_event(li, BTN_MIDDLE,
593 LIBINPUT_BUTTON_STATE_PRESSED);
594 msleep(300); /* tap-n-drag timeout */
595 assert_button_event(li, BTN_MIDDLE,
596 LIBINPUT_BUTTON_STATE_RELEASED);
598 libinput_dispatch(li);
599 event = libinput_get_event(li);
600 ck_assert(event == NULL);
604 START_TEST(touchpad_1fg_clickfinger)
606 struct litest_device *dev = litest_create_device(LITEST_BCM5974);
607 struct libinput *li = dev->libinput;
609 litest_drain_events(li);
611 litest_touch_down(dev, 0, 50, 50);
612 litest_event(dev, EV_KEY, BTN_LEFT, 1);
613 litest_event(dev, EV_SYN, SYN_REPORT, 0);
614 litest_event(dev, EV_KEY, BTN_LEFT, 0);
615 litest_event(dev, EV_SYN, SYN_REPORT, 0);
616 litest_touch_up(dev, 0);
618 libinput_dispatch(li);
620 assert_button_event(li, BTN_LEFT,
621 LIBINPUT_BUTTON_STATE_PRESSED);
622 assert_button_event(li, BTN_LEFT,
623 LIBINPUT_BUTTON_STATE_RELEASED);
625 litest_delete_device(dev);
629 START_TEST(touchpad_2fg_clickfinger)
631 struct litest_device *dev = litest_create_device(LITEST_BCM5974);
632 struct libinput *li = dev->libinput;
634 litest_drain_events(li);
636 litest_touch_down(dev, 0, 50, 50);
637 litest_touch_down(dev, 1, 70, 70);
638 litest_event(dev, EV_KEY, BTN_LEFT, 1);
639 litest_event(dev, EV_SYN, SYN_REPORT, 0);
640 litest_event(dev, EV_KEY, BTN_LEFT, 0);
641 litest_event(dev, EV_SYN, SYN_REPORT, 0);
642 litest_touch_up(dev, 0);
643 litest_touch_up(dev, 1);
645 libinput_dispatch(li);
647 assert_button_event(li, BTN_RIGHT,
648 LIBINPUT_BUTTON_STATE_PRESSED);
649 assert_button_event(li, BTN_RIGHT,
650 LIBINPUT_BUTTON_STATE_RELEASED);
652 litest_delete_device(dev);
656 START_TEST(touchpad_btn_left)
658 struct litest_device *dev = litest_current_device();
659 struct libinput *li = dev->libinput;
661 litest_drain_events(li);
663 litest_event(dev, EV_KEY, BTN_LEFT, 1);
664 litest_event(dev, EV_SYN, SYN_REPORT, 0);
665 litest_event(dev, EV_KEY, BTN_LEFT, 0);
666 litest_event(dev, EV_SYN, SYN_REPORT, 0);
668 libinput_dispatch(li);
670 assert_button_event(li, BTN_LEFT,
671 LIBINPUT_BUTTON_STATE_PRESSED);
672 assert_button_event(li, BTN_LEFT,
673 LIBINPUT_BUTTON_STATE_RELEASED);
677 START_TEST(clickpad_btn_left)
679 struct litest_device *dev = litest_current_device();
680 struct libinput *li = dev->libinput;
682 litest_drain_events(li);
684 /* A clickpad always needs a finger down to tell where the
686 litest_event(dev, EV_KEY, BTN_LEFT, 1);
687 litest_event(dev, EV_SYN, SYN_REPORT, 0);
688 litest_event(dev, EV_KEY, BTN_LEFT, 0);
689 litest_event(dev, EV_SYN, SYN_REPORT, 0);
691 libinput_dispatch(li);
692 ck_assert_int_eq(libinput_next_event_type(li), LIBINPUT_EVENT_NONE);
696 START_TEST(clickpad_click_n_drag)
698 struct litest_device *dev = litest_current_device();
699 struct libinput *li = dev->libinput;
700 struct libinput_event *event;
702 litest_drain_events(li);
704 litest_touch_down(dev, 0, 50, 50);
705 litest_event(dev, EV_KEY, BTN_LEFT, 1);
706 litest_event(dev, EV_SYN, SYN_REPORT, 0);
708 libinput_dispatch(li);
709 assert_button_event(li, BTN_LEFT,
710 LIBINPUT_BUTTON_STATE_PRESSED);
712 libinput_dispatch(li);
713 ck_assert_int_eq(libinput_next_event_type(li), LIBINPUT_EVENT_NONE);
715 /* now put a second finger down */
716 litest_touch_down(dev, 1, 70, 70);
717 litest_touch_move_to(dev, 1, 70, 70, 80, 50, 5);
718 litest_touch_up(dev, 1);
720 libinput_dispatch(li);
721 ck_assert_int_eq(libinput_next_event_type(li),
722 LIBINPUT_EVENT_POINTER_MOTION);
724 event = libinput_get_event(li);
725 libinput_event_destroy(event);
726 libinput_dispatch(li);
727 } while (libinput_next_event_type(li) == LIBINPUT_EVENT_POINTER_MOTION);
729 litest_event(dev, EV_KEY, BTN_LEFT, 0);
730 litest_event(dev, EV_SYN, SYN_REPORT, 0);
731 litest_touch_up(dev, 0);
733 assert_button_event(li, BTN_LEFT,
734 LIBINPUT_BUTTON_STATE_RELEASED);
738 START_TEST(clickpad_softbutton_left)
740 struct litest_device *dev = litest_current_device();
741 struct libinput *li = dev->libinput;
743 litest_drain_events(li);
745 litest_touch_down(dev, 0, 10, 90);
746 litest_event(dev, EV_KEY, BTN_LEFT, 1);
747 litest_event(dev, EV_SYN, SYN_REPORT, 0);
749 assert_button_event(li,
751 LIBINPUT_BUTTON_STATE_PRESSED);
753 litest_event(dev, EV_KEY, BTN_LEFT, 0);
754 litest_event(dev, EV_SYN, SYN_REPORT, 0);
755 litest_touch_up(dev, 0);
757 assert_button_event(li,
759 LIBINPUT_BUTTON_STATE_RELEASED);
761 libinput_dispatch(li);
763 litest_assert_empty_queue(li);
767 START_TEST(clickpad_softbutton_right)
769 struct litest_device *dev = litest_current_device();
770 struct libinput *li = dev->libinput;
772 litest_drain_events(li);
774 litest_touch_down(dev, 0, 90, 90);
775 litest_event(dev, EV_KEY, BTN_LEFT, 1);
776 litest_event(dev, EV_SYN, SYN_REPORT, 0);
778 assert_button_event(li,
780 LIBINPUT_BUTTON_STATE_PRESSED);
782 litest_event(dev, EV_KEY, BTN_LEFT, 0);
783 litest_event(dev, EV_SYN, SYN_REPORT, 0);
784 litest_touch_up(dev, 0);
786 assert_button_event(li,
788 LIBINPUT_BUTTON_STATE_RELEASED);
790 libinput_dispatch(li);
792 litest_assert_empty_queue(li);
796 START_TEST(clickpad_softbutton_left_tap_n_drag)
798 struct litest_device *dev = litest_current_device();
799 struct libinput *li = dev->libinput;
801 libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
803 litest_drain_events(li);
805 /* Tap in left button area, then finger down, button click
806 -> expect left button press/release and left button press
807 Release button, finger up
808 -> expect right button release
810 litest_touch_down(dev, 0, 20, 90);
811 litest_touch_up(dev, 0);
812 litest_touch_down(dev, 0, 20, 90);
813 litest_event(dev, EV_KEY, BTN_LEFT, 1);
814 litest_event(dev, EV_SYN, SYN_REPORT, 0);
816 assert_button_event(li,
818 LIBINPUT_BUTTON_STATE_PRESSED);
819 assert_button_event(li,
821 LIBINPUT_BUTTON_STATE_RELEASED);
822 assert_button_event(li,
824 LIBINPUT_BUTTON_STATE_PRESSED);
825 litest_assert_empty_queue(li);
827 litest_event(dev, EV_KEY, BTN_LEFT, 0);
828 litest_event(dev, EV_SYN, SYN_REPORT, 0);
829 litest_touch_up(dev, 0);
831 assert_button_event(li,
833 LIBINPUT_BUTTON_STATE_RELEASED);
834 litest_assert_empty_queue(li);
838 START_TEST(clickpad_softbutton_right_tap_n_drag)
840 struct litest_device *dev = litest_current_device();
841 struct libinput *li = dev->libinput;
843 libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
845 litest_drain_events(li);
847 /* Tap in right button area, then finger down, button click
848 -> expect left button press/release and right button press
849 Release button, finger up
850 -> expect right button release
852 litest_touch_down(dev, 0, 90, 90);
853 litest_touch_up(dev, 0);
854 litest_touch_down(dev, 0, 90, 90);
855 litest_event(dev, EV_KEY, BTN_LEFT, 1);
856 litest_event(dev, EV_SYN, SYN_REPORT, 0);
858 assert_button_event(li,
860 LIBINPUT_BUTTON_STATE_PRESSED);
861 assert_button_event(li,
863 LIBINPUT_BUTTON_STATE_RELEASED);
864 assert_button_event(li,
866 LIBINPUT_BUTTON_STATE_PRESSED);
867 litest_assert_empty_queue(li);
869 litest_event(dev, EV_KEY, BTN_LEFT, 0);
870 litest_event(dev, EV_SYN, SYN_REPORT, 0);
871 litest_touch_up(dev, 0);
873 assert_button_event(li,
875 LIBINPUT_BUTTON_STATE_RELEASED);
876 litest_assert_empty_queue(li);
880 START_TEST(clickpad_softbutton_left_1st_fg_move)
882 struct litest_device *dev = litest_current_device();
883 struct libinput *li = dev->libinput;
884 struct libinput_event *event;
888 litest_drain_events(li);
890 /* One finger down in the left button area, button press
891 -> expect a button event
892 Move finger up out of the area, wait for timeout
893 Move finger around diagonally down left
894 -> expect motion events down left
896 -> expect a button event */
898 /* finger down, press in left button */
899 litest_touch_down(dev, 0, 20, 90);
900 litest_event(dev, EV_KEY, BTN_LEFT, 1);
901 litest_event(dev, EV_SYN, SYN_REPORT, 0);
903 assert_button_event(li,
905 LIBINPUT_BUTTON_STATE_PRESSED);
906 litest_assert_empty_queue(li);
908 /* move out of the area, then wait for softbutton timer */
909 litest_touch_move_to(dev, 0, 20, 90, 90, 20, 10);
910 libinput_dispatch(li);
912 libinput_dispatch(li);
913 litest_drain_events(li);
915 /* move down left, expect motion */
916 litest_touch_move_to(dev, 0, 90, 20, 20, 90, 10);
918 libinput_dispatch(li);
919 event = libinput_get_event(li);
920 ck_assert(event != NULL);
922 struct libinput_event_pointer *p;
924 ck_assert_int_eq(libinput_event_get_type(event),
925 LIBINPUT_EVENT_POINTER_MOTION);
926 p = libinput_event_get_pointer_event(event);
928 /* we moved up/right, now down/left so the pointer accel
929 code may lag behind with the dx/dy vectors. Hence, add up
930 the x/y movements and expect that on average we moved
932 x += libinput_event_pointer_get_dx(p);
933 y += libinput_event_pointer_get_dy(p);
936 libinput_event_destroy(event);
937 libinput_dispatch(li);
938 event = libinput_get_event(li);
941 ck_assert(x/nevents < 0);
942 ck_assert(y/nevents > 0);
944 litest_event(dev, EV_KEY, BTN_LEFT, 0);
945 litest_event(dev, EV_SYN, SYN_REPORT, 0);
946 litest_touch_up(dev, 0);
948 assert_button_event(li,
950 LIBINPUT_BUTTON_STATE_RELEASED);
952 litest_assert_empty_queue(li);
956 START_TEST(clickpad_softbutton_left_2nd_fg_move)
958 struct litest_device *dev = litest_current_device();
959 struct libinput *li = dev->libinput;
960 struct libinput_event *event;
962 litest_drain_events(li);
964 /* One finger down in the left button area, button press
965 -> expect a button event
966 Put a second finger down in the area, move it right, release
967 -> expect motion events right
968 Put a second finger down in the area, move it down, release
969 -> expect motion events down
970 Release second finger, release first finger
971 -> expect a button event */
972 litest_touch_down(dev, 0, 20, 90);
973 litest_event(dev, EV_KEY, BTN_LEFT, 1);
974 litest_event(dev, EV_SYN, SYN_REPORT, 0);
976 assert_button_event(li,
978 LIBINPUT_BUTTON_STATE_PRESSED);
979 litest_assert_empty_queue(li);
981 litest_touch_down(dev, 1, 20, 20);
982 litest_touch_move_to(dev, 1, 20, 20, 80, 20, 10);
984 libinput_dispatch(li);
985 event = libinput_get_event(li);
986 ck_assert(event != NULL);
988 struct libinput_event_pointer *p;
991 ck_assert_int_eq(libinput_event_get_type(event),
992 LIBINPUT_EVENT_POINTER_MOTION);
993 p = libinput_event_get_pointer_event(event);
995 x = libinput_event_pointer_get_dx(p);
996 y = libinput_event_pointer_get_dy(p);
1001 libinput_event_destroy(event);
1002 libinput_dispatch(li);
1003 event = libinput_get_event(li);
1005 litest_touch_up(dev, 1);
1007 /* second finger down */
1008 litest_touch_down(dev, 1, 20, 20);
1009 litest_touch_move_to(dev, 1, 20, 20, 20, 80, 10);
1011 libinput_dispatch(li);
1012 event = libinput_get_event(li);
1013 ck_assert(event != NULL);
1015 struct libinput_event_pointer *p;
1018 ck_assert_int_eq(libinput_event_get_type(event),
1019 LIBINPUT_EVENT_POINTER_MOTION);
1020 p = libinput_event_get_pointer_event(event);
1022 x = libinput_event_pointer_get_dx(p);
1023 y = libinput_event_pointer_get_dy(p);
1028 libinput_event_destroy(event);
1029 libinput_dispatch(li);
1030 event = libinput_get_event(li);
1033 litest_touch_up(dev, 1);
1035 litest_event(dev, EV_KEY, BTN_LEFT, 0);
1036 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1037 litest_touch_up(dev, 0);
1039 assert_button_event(li,
1041 LIBINPUT_BUTTON_STATE_RELEASED);
1043 litest_assert_empty_queue(li);
1047 START_TEST(clickpad_softbutton_left_to_right)
1049 struct litest_device *dev = litest_current_device();
1050 struct libinput *li = dev->libinput;
1052 litest_drain_events(li);
1054 /* One finger down in left software button area,
1055 move to right button area immediately, click
1056 -> expect right button event
1059 litest_touch_down(dev, 0, 20, 90);
1060 litest_touch_move_to(dev, 0, 20, 90, 90, 90, 10);
1061 litest_event(dev, EV_KEY, BTN_LEFT, 1);
1062 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1064 assert_button_event(li,
1066 LIBINPUT_BUTTON_STATE_PRESSED);
1067 litest_assert_empty_queue(li);
1069 litest_event(dev, EV_KEY, BTN_LEFT, 0);
1070 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1071 litest_touch_up(dev, 0);
1073 assert_button_event(li,
1075 LIBINPUT_BUTTON_STATE_RELEASED);
1077 litest_assert_empty_queue(li);
1081 START_TEST(clickpad_softbutton_right_to_left)
1083 struct litest_device *dev = litest_current_device();
1084 struct libinput *li = dev->libinput;
1086 litest_drain_events(li);
1088 /* One finger down in right software button area,
1089 move to left button area immediately, click
1090 -> expect left button event
1093 litest_touch_down(dev, 0, 90, 90);
1094 litest_touch_move_to(dev, 0, 90, 90, 20, 90, 10);
1095 litest_event(dev, EV_KEY, BTN_LEFT, 1);
1096 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1098 assert_button_event(li,
1100 LIBINPUT_BUTTON_STATE_PRESSED);
1101 litest_assert_empty_queue(li);
1103 litest_event(dev, EV_KEY, BTN_LEFT, 0);
1104 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1105 litest_touch_up(dev, 0);
1107 assert_button_event(li,
1109 LIBINPUT_BUTTON_STATE_RELEASED);
1111 litest_assert_empty_queue(li);
1115 START_TEST(clickpad_topsoftbuttons_left)
1117 struct litest_device *dev = litest_current_device();
1118 struct libinput *li = dev->libinput;
1120 litest_drain_events(li);
1122 litest_touch_down(dev, 0, 10, 5);
1123 litest_event(dev, EV_KEY, BTN_LEFT, 1);
1124 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1126 assert_button_event(li,
1128 LIBINPUT_BUTTON_STATE_PRESSED);
1129 litest_assert_empty_queue(li);
1131 litest_event(dev, EV_KEY, BTN_LEFT, 0);
1132 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1133 litest_touch_up(dev, 0);
1135 assert_button_event(li,
1137 LIBINPUT_BUTTON_STATE_RELEASED);
1139 litest_assert_empty_queue(li);
1143 START_TEST(clickpad_topsoftbuttons_right)
1145 struct litest_device *dev = litest_current_device();
1146 struct libinput *li = dev->libinput;
1148 litest_drain_events(li);
1150 litest_touch_down(dev, 0, 90, 5);
1151 litest_event(dev, EV_KEY, BTN_LEFT, 1);
1152 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1154 assert_button_event(li,
1156 LIBINPUT_BUTTON_STATE_PRESSED);
1157 litest_assert_empty_queue(li);
1159 litest_event(dev, EV_KEY, BTN_LEFT, 0);
1160 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1161 litest_touch_up(dev, 0);
1163 assert_button_event(li,
1165 LIBINPUT_BUTTON_STATE_RELEASED);
1167 litest_assert_empty_queue(li);
1171 START_TEST(clickpad_topsoftbuttons_middle)
1173 struct litest_device *dev = litest_current_device();
1174 struct libinput *li = dev->libinput;
1176 litest_drain_events(li);
1178 litest_touch_down(dev, 0, 50, 5);
1179 litest_event(dev, EV_KEY, BTN_LEFT, 1);
1180 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1182 assert_button_event(li,
1184 LIBINPUT_BUTTON_STATE_PRESSED);
1185 litest_assert_empty_queue(li);
1187 litest_event(dev, EV_KEY, BTN_LEFT, 0);
1188 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1189 litest_touch_up(dev, 0);
1191 assert_button_event(li,
1193 LIBINPUT_BUTTON_STATE_RELEASED);
1195 litest_assert_empty_queue(li);
1199 START_TEST(clickpad_topsoftbuttons_move_out_ignore)
1201 struct litest_device *dev = litest_current_device();
1202 struct libinput *li = dev->libinput;
1204 /* Finger down in top button area, wait past enter timeout
1205 Move into main area, wait past leave timeout
1210 litest_drain_events(li);
1212 litest_touch_down(dev, 0, 50, 5);
1213 libinput_dispatch(li);
1215 libinput_dispatch(li);
1216 litest_assert_empty_queue(li);
1218 litest_touch_move_to(dev, 0, 50, 5, 80, 90, 20);
1219 libinput_dispatch(li);
1221 libinput_dispatch(li);
1223 litest_event(dev, EV_KEY, BTN_LEFT, 1);
1224 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1225 litest_event(dev, EV_KEY, BTN_LEFT, 0);
1226 litest_event(dev, EV_SYN, SYN_REPORT, 0);
1228 litest_touch_up(dev, 0);
1230 litest_assert_empty_queue(li);
1235 test_2fg_scroll(struct litest_device *dev, double dx, double dy, int sleep)
1237 struct libinput *li = dev->libinput;
1239 litest_touch_down(dev, 0, 47, 50);
1240 litest_touch_down(dev, 1, 53, 50);
1242 litest_touch_move_to(dev, 0, 47, 50, 47 + dx, 50 + dy, 5);
1243 litest_touch_move_to(dev, 1, 53, 50, 53 + dx, 50 + dy, 5);
1245 /* Avoid a small scroll being seen as a tap */
1247 libinput_dispatch(li);
1249 libinput_dispatch(li);
1252 litest_touch_up(dev, 1);
1253 litest_touch_up(dev, 0);
1255 libinput_dispatch(li);
1259 check_2fg_scroll(struct litest_device *dev, unsigned int axis, int dir)
1261 struct libinput *li = dev->libinput;
1262 struct libinput_event *event, *next_event;
1263 struct libinput_event_pointer *ptrev;
1265 event = libinput_get_event(li);
1266 next_event = libinput_get_event(li);
1267 ck_assert(next_event != NULL); /* At least 1 scroll + stop scroll */
1270 ck_assert_int_eq(libinput_event_get_type(event),
1271 LIBINPUT_EVENT_POINTER_AXIS);
1272 ptrev = libinput_event_get_pointer_event(event);
1273 ck_assert(ptrev != NULL);
1274 ck_assert_int_eq(libinput_event_pointer_get_axis(ptrev), axis);
1277 /* Normal scroll event, check dir */
1280 libinput_event_pointer_get_axis_value(ptrev),
1284 libinput_event_pointer_get_axis_value(ptrev),
1288 /* Last scroll event, must be 0 */
1290 libinput_event_pointer_get_axis_value(ptrev),
1293 libinput_event_destroy(event);
1295 next_event = libinput_get_event(li);
1299 START_TEST(touchpad_2fg_scroll)
1301 struct litest_device *dev = litest_current_device();
1302 struct libinput *li = dev->libinput;
1304 litest_drain_events(li);
1306 test_2fg_scroll(dev, 0.1, 40, 0);
1307 check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, 10);
1308 test_2fg_scroll(dev, 0.1, -40, 0);
1309 check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, -10);
1310 test_2fg_scroll(dev, 40, 0.1, 0);
1311 check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, 10);
1312 test_2fg_scroll(dev, -40, 0.1, 0);
1313 check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, -10);
1315 /* 2fg scroll smaller than the threshold should not generate events */
1316 test_2fg_scroll(dev, 0.1, 0.1, 200);
1317 litest_assert_empty_queue(li);
1321 START_TEST(touchpad_tap_is_available)
1323 struct litest_device *dev = litest_current_device();
1325 ck_assert_int_ge(libinput_device_config_tap_get_finger_count(dev->libinput_device), 1);
1326 ck_assert_int_eq(libinput_device_config_tap_get_enabled(dev->libinput_device), 0);
1330 START_TEST(touchpad_tap_is_not_available)
1332 struct litest_device *dev = litest_current_device();
1334 ck_assert_int_eq(libinput_device_config_tap_get_finger_count(dev->libinput_device), 0);
1335 ck_assert_int_eq(libinput_device_config_tap_get_enabled(dev->libinput_device), 0);
1336 ck_assert_int_eq(libinput_device_config_tap_set_enabled(dev->libinput_device, 1),
1337 LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
1341 START_TEST(touchpad_tap_default)
1343 struct litest_device *dev = litest_current_device();
1345 ck_assert_int_eq(libinput_device_config_tap_get_default_enabled(dev->libinput_device), 0);
1350 touchpad_has_palm_detect_size(struct litest_device *dev)
1352 double width, height;
1355 if (libinput_device_get_id_vendor(dev->libinput_device) == 0x5ac) /* Apple */
1358 rc = libinput_device_get_size(dev->libinput_device, &width, &height);
1360 return rc == 0 && width >= 80;
1363 START_TEST(touchpad_palm_detect_at_edge)
1365 struct litest_device *dev = litest_current_device();
1366 struct libinput *li = dev->libinput;
1368 if (!touchpad_has_palm_detect_size(dev))
1371 litest_drain_events(li);
1373 litest_touch_down(dev, 0, 99, 50);
1374 litest_touch_move_to(dev, 0, 99, 50, 99, 70, 5);
1375 litest_touch_up(dev, 0);
1377 litest_assert_empty_queue(li);
1379 litest_touch_down(dev, 0, 5, 50);
1380 litest_touch_move_to(dev, 0, 5, 50, 5, 70, 5);
1381 litest_touch_up(dev, 0);
1385 START_TEST(touchpad_palm_detect_at_bottom_corners)
1387 struct litest_device *dev = litest_current_device();
1388 struct libinput *li = dev->libinput;
1390 if (!touchpad_has_palm_detect_size(dev))
1393 /* Run for non-clickpads only: make sure the bottom corners trigger
1394 palm detection too */
1395 litest_drain_events(li);
1397 litest_touch_down(dev, 0, 99, 95);
1398 litest_touch_move_to(dev, 0, 99, 95, 99, 99, 10);
1399 litest_touch_up(dev, 0);
1401 litest_assert_empty_queue(li);
1403 litest_touch_down(dev, 0, 5, 95);
1404 litest_touch_move_to(dev, 0, 5, 95, 5, 99, 5);
1405 litest_touch_up(dev, 0);
1409 START_TEST(touchpad_palm_detect_at_top_corners)
1411 struct litest_device *dev = litest_current_device();
1412 struct libinput *li = dev->libinput;
1414 if (!touchpad_has_palm_detect_size(dev))
1417 /* Run for non-clickpads only: make sure the bottom corners trigger
1418 palm detection too */
1419 litest_drain_events(li);
1421 litest_touch_down(dev, 0, 99, 5);
1422 litest_touch_move_to(dev, 0, 99, 5, 99, 9, 10);
1423 litest_touch_up(dev, 0);
1425 litest_assert_empty_queue(li);
1427 litest_touch_down(dev, 0, 5, 5);
1428 litest_touch_move_to(dev, 0, 5, 5, 5, 9, 5);
1429 litest_touch_up(dev, 0);
1433 START_TEST(touchpad_palm_detect_palm_stays_palm)
1435 struct litest_device *dev = litest_current_device();
1436 struct libinput *li = dev->libinput;
1438 if (!touchpad_has_palm_detect_size(dev))
1441 litest_drain_events(li);
1443 litest_touch_down(dev, 0, 99, 20);
1444 litest_touch_move_to(dev, 0, 99, 20, 75, 99, 5);
1445 litest_touch_up(dev, 0);
1446 litest_assert_empty_queue(li);
1450 START_TEST(touchpad_palm_detect_palm_becomes_pointer)
1452 struct litest_device *dev = litest_current_device();
1453 struct libinput *li = dev->libinput;
1454 struct libinput_event *ev;
1455 enum libinput_event_type type;
1457 if (!touchpad_has_palm_detect_size(dev))
1460 litest_drain_events(li);
1462 litest_touch_down(dev, 0, 99, 50);
1463 litest_touch_move_to(dev, 0, 99, 70, 0, 70, 5);
1464 litest_touch_up(dev, 0);
1466 libinput_dispatch(li);
1468 ev = libinput_get_event(li);
1469 ck_assert_notnull(ev);
1471 type = libinput_event_get_type(ev);
1472 ck_assert_int_eq(type, LIBINPUT_EVENT_POINTER_MOTION);
1474 libinput_event_destroy(ev);
1475 ev = libinput_get_event(li);
1478 litest_assert_empty_queue(li);
1482 START_TEST(touchpad_palm_detect_no_palm_moving_into_edges)
1484 struct litest_device *dev = litest_current_device();
1485 struct libinput *li = dev->libinput;
1486 struct libinput_event *ev;
1487 enum libinput_event_type type;
1489 if (!touchpad_has_palm_detect_size(dev))
1492 /* moving non-palm into the edge does not label it as palm */
1493 litest_drain_events(li);
1495 litest_touch_down(dev, 0, 50, 50);
1496 litest_touch_move_to(dev, 0, 50, 50, 99, 50, 5);
1498 litest_drain_events(li);
1500 litest_touch_move_to(dev, 0, 99, 50, 99, 90, 5);
1501 libinput_dispatch(li);
1503 type = libinput_next_event_type(li);
1506 ck_assert_int_eq(type, LIBINPUT_EVENT_POINTER_MOTION);
1507 ev = libinput_get_event(li);
1508 libinput_event_destroy(ev);
1510 type = libinput_next_event_type(li);
1511 libinput_dispatch(li);
1512 } while (type != LIBINPUT_EVENT_NONE);
1514 litest_touch_up(dev, 0);
1515 libinput_dispatch(li);
1516 litest_assert_empty_queue(li);
1520 int main(int argc, char **argv) {
1522 litest_add("touchpad:motion", touchpad_1fg_motion, LITEST_TOUCHPAD, LITEST_ANY);
1523 litest_add("touchpad:motion", touchpad_2fg_no_motion, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1525 litest_add("touchpad:tap", touchpad_1fg_tap, LITEST_TOUCHPAD, LITEST_ANY);
1526 litest_add("touchpad:tap", touchpad_1fg_tap_n_drag, LITEST_TOUCHPAD, LITEST_ANY);
1527 litest_add("touchpad:tap", touchpad_2fg_tap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1528 litest_add("touchpad:tap", touchpad_2fg_tap_inverted, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1529 litest_add("touchpad:tap", touchpad_1fg_tap_click, LITEST_TOUCHPAD, LITEST_ANY);
1530 litest_add("touchpad:tap", touchpad_2fg_tap_click, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_APPLE_CLICKPAD);
1531 litest_add("touchpad:tap", touchpad_2fg_tap_click_apple, LITEST_APPLE_CLICKPAD, LITEST_ANY);
1532 litest_add("touchpad:tap", touchpad_no_2fg_tap_after_move, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1533 litest_add("touchpad:tap", touchpad_no_2fg_tap_after_timeout, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1534 litest_add("touchpad:tap", touchpad_no_first_fg_tap_after_move, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1535 litest_add("touchpad:tap", touchpad_no_first_fg_tap_after_move, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1536 /* apple is the only one with real 3-finger support */
1537 litest_add("touchpad:tap", touchpad_3fg_tap_btntool, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_APPLE_CLICKPAD);
1538 litest_add("touchpad:tap", touchpad_3fg_tap_btntool_inverted, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_APPLE_CLICKPAD);
1539 litest_add("touchpad:tap", touchpad_3fg_tap, LITEST_APPLE_CLICKPAD, LITEST_ANY);
1541 /* Real buttons don't interfere with tapping, so don't run those for
1542 pads with buttons */
1543 litest_add("touchpad:tap", touchpad_1fg_double_tap_click, LITEST_CLICKPAD, LITEST_ANY);
1544 litest_add("touchpad:tap", touchpad_1fg_tap_n_drag_click, LITEST_CLICKPAD, LITEST_ANY);
1546 litest_add("touchpad:tap", touchpad_tap_default, LITEST_TOUCHPAD, LITEST_ANY);
1547 litest_add("touchpad:tap", touchpad_tap_is_available, LITEST_TOUCHPAD, LITEST_ANY);
1548 litest_add("touchpad:tap", touchpad_tap_is_not_available, LITEST_ANY, LITEST_TOUCHPAD);
1550 litest_add_no_device("touchpad:clickfinger", touchpad_1fg_clickfinger);
1551 litest_add_no_device("touchpad:clickfinger", touchpad_2fg_clickfinger);
1553 litest_add("touchpad:click", touchpad_btn_left, LITEST_TOUCHPAD, LITEST_CLICKPAD);
1554 litest_add("touchpad:click", clickpad_btn_left, LITEST_CLICKPAD, LITEST_ANY);
1555 litest_add("touchpad:click", clickpad_click_n_drag, LITEST_CLICKPAD, LITEST_SINGLE_TOUCH);
1557 litest_add("touchpad:softbutton", clickpad_softbutton_left, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1558 litest_add("touchpad:softbutton", clickpad_softbutton_right, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1559 litest_add("touchpad:softbutton", clickpad_softbutton_left_tap_n_drag, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1560 litest_add("touchpad:softbutton", clickpad_softbutton_right_tap_n_drag, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1561 litest_add("touchpad:softbutton", clickpad_softbutton_left_1st_fg_move, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1562 litest_add("touchpad:softbutton", clickpad_softbutton_left_2nd_fg_move, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1563 litest_add("touchpad:softbutton", clickpad_softbutton_left_to_right, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1564 litest_add("touchpad:softbutton", clickpad_softbutton_right_to_left, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1566 litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_left, LITEST_TOPBUTTONPAD, LITEST_ANY);
1567 litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_right, LITEST_TOPBUTTONPAD, LITEST_ANY);
1568 litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_middle, LITEST_TOPBUTTONPAD, LITEST_ANY);
1569 litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_move_out_ignore, LITEST_TOPBUTTONPAD, LITEST_ANY);
1571 litest_add("touchpad:scroll", touchpad_2fg_scroll, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1573 litest_add("touchpad:palm", touchpad_palm_detect_at_edge, LITEST_TOUCHPAD, LITEST_ANY);
1574 litest_add("touchpad:palm", touchpad_palm_detect_at_bottom_corners, LITEST_TOUCHPAD, LITEST_CLICKPAD);
1575 litest_add("touchpad:palm", touchpad_palm_detect_at_top_corners, LITEST_TOUCHPAD, LITEST_TOPBUTTONPAD);
1576 litest_add("touchpad:palm", touchpad_palm_detect_palm_becomes_pointer, LITEST_TOUCHPAD, LITEST_ANY);
1577 litest_add("touchpad:palm", touchpad_palm_detect_palm_stays_palm, LITEST_TOUCHPAD, LITEST_ANY);
1578 litest_add("touchpad:palm", touchpad_palm_detect_no_palm_moving_into_edges, LITEST_TOUCHPAD, LITEST_ANY);
1580 return litest_run(argc, argv);