bd5d71eb8cf47a78b0d53ad431a51ddf739d5de0
[platform/upstream/libinput.git] / test / touchpad.c
1 /*
2  * Copyright © 2014 Red Hat, Inc.
3  *
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.
13  *
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.
21  */
22
23 #include <config.h>
24
25 #include <check.h>
26 #include <errno.h>
27 #include <fcntl.h>
28 #include <libinput.h>
29 #include <unistd.h>
30
31 #include "libinput-util.h"
32 #include "litest.h"
33
34 START_TEST(touchpad_1fg_motion)
35 {
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;
40
41         litest_drain_events(li);
42
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);
46
47         libinput_dispatch(li);
48
49         event = libinput_get_event(li);
50         ck_assert(event != NULL);
51
52         while (event) {
53                 ck_assert_int_eq(libinput_event_get_type(event),
54                                  LIBINPUT_EVENT_POINTER_MOTION);
55
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);
61         }
62 }
63 END_TEST
64
65 START_TEST(touchpad_2fg_no_motion)
66 {
67         struct litest_device *dev = litest_current_device();
68         struct libinput *li = dev->libinput;
69         struct libinput_event *event;
70
71         litest_drain_events(li);
72
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);
79
80         libinput_dispatch(li);
81
82         event = libinput_get_event(li);
83         while (event) {
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);
88         }
89 }
90 END_TEST
91
92 static void
93 assert_button_event(struct libinput *li, unsigned int button,
94                     enum libinput_button_state state)
95 {
96         struct libinput_event *event;
97         struct libinput_event_pointer *ptrev;
98
99         libinput_dispatch(li);
100         event = libinput_get_event(li);
101
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),
107                          button);
108         ck_assert_int_eq(libinput_event_pointer_get_button_state(ptrev),
109                          state);
110         libinput_event_destroy(event);
111 }
112
113 START_TEST(touchpad_1fg_tap)
114 {
115         struct litest_device *dev = litest_current_device();
116         struct libinput *li = dev->libinput;
117         struct libinput_event *event;
118
119         libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
120
121         litest_drain_events(li);
122
123         litest_touch_down(dev, 0, 50, 50);
124         litest_touch_up(dev, 0);
125
126         libinput_dispatch(li);
127
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);
133
134         libinput_dispatch(li);
135         event = libinput_get_event(li);
136         ck_assert(event == NULL);
137 }
138 END_TEST
139
140 START_TEST(touchpad_1fg_tap_n_drag)
141 {
142         struct litest_device *dev = litest_current_device();
143         struct libinput *li = dev->libinput;
144         struct libinput_event *event;
145
146         libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
147
148         litest_drain_events(li);
149
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);
155
156         libinput_dispatch(li);
157
158         assert_button_event(li, BTN_LEFT,
159                             LIBINPUT_BUTTON_STATE_PRESSED);
160
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);
166         }
167
168         ck_assert_int_eq(libinput_next_event_type(li), LIBINPUT_EVENT_NONE);
169
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);
174
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);
180         }
181
182         ck_assert_int_eq(libinput_next_event_type(li), LIBINPUT_EVENT_NONE);
183
184         msleep(300); /* tap-n-drag timeout */
185
186         assert_button_event(li, BTN_LEFT,
187                             LIBINPUT_BUTTON_STATE_RELEASED);
188
189         litest_assert_empty_queue(li);
190 }
191 END_TEST
192
193 START_TEST(touchpad_2fg_tap)
194 {
195         struct litest_device *dev = litest_current_device();
196         struct libinput *li = dev->libinput;
197
198         libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
199
200         litest_drain_events(dev->libinput);
201
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);
206
207         libinput_dispatch(li);
208
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);
214
215         litest_assert_empty_queue(li);
216 }
217 END_TEST
218
219 START_TEST(touchpad_2fg_tap_inverted)
220 {
221         struct litest_device *dev = litest_current_device();
222         struct libinput *li = dev->libinput;
223
224         libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
225
226         litest_drain_events(dev->libinput);
227
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);
232
233         libinput_dispatch(li);
234
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);
240
241         litest_assert_empty_queue(li);
242 }
243 END_TEST
244
245 START_TEST(touchpad_1fg_tap_click)
246 {
247         struct litest_device *dev = litest_current_device();
248         struct libinput *li = dev->libinput;
249
250         libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
251
252         litest_drain_events(dev->libinput);
253
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);
262
263         libinput_dispatch(li);
264
265         assert_button_event(li, BTN_LEFT,
266                             LIBINPUT_BUTTON_STATE_PRESSED);
267         assert_button_event(li, BTN_LEFT,
268                             LIBINPUT_BUTTON_STATE_RELEASED);
269
270         litest_assert_empty_queue(li);
271 }
272 END_TEST
273
274 START_TEST(touchpad_2fg_tap_click)
275 {
276         struct litest_device *dev = litest_current_device();
277         struct libinput *li = dev->libinput;
278
279         libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
280
281         litest_drain_events(dev->libinput);
282
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);
293
294         libinput_dispatch(li);
295
296         assert_button_event(li, BTN_LEFT,
297                             LIBINPUT_BUTTON_STATE_PRESSED);
298         assert_button_event(li, BTN_LEFT,
299                             LIBINPUT_BUTTON_STATE_RELEASED);
300
301         litest_assert_empty_queue(li);
302 }
303 END_TEST
304
305 START_TEST(touchpad_2fg_tap_click_apple)
306 {
307         struct litest_device *dev = litest_current_device();
308         struct libinput *li = dev->libinput;
309
310         libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
311
312         litest_drain_events(dev->libinput);
313
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);
325
326         libinput_dispatch(li);
327
328         assert_button_event(li, BTN_RIGHT,
329                             LIBINPUT_BUTTON_STATE_PRESSED);
330         assert_button_event(li, BTN_RIGHT,
331                             LIBINPUT_BUTTON_STATE_RELEASED);
332
333         litest_assert_empty_queue(li);
334 }
335 END_TEST
336
337 START_TEST(touchpad_no_2fg_tap_after_move)
338 {
339         struct litest_device *dev = litest_current_device();
340         struct libinput *li = dev->libinput;
341
342         litest_drain_events(dev->libinput);
343
344         /* one finger down, move past threshold,
345            second finger down, first finger up
346            -> no event
347          */
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);
351
352         litest_touch_down(dev, 1, 70, 50);
353         litest_touch_up(dev, 0);
354
355         litest_assert_empty_queue(li);
356 }
357 END_TEST
358
359 START_TEST(touchpad_no_2fg_tap_after_timeout)
360 {
361         struct litest_device *dev = litest_current_device();
362         struct libinput *li = dev->libinput;
363
364         litest_drain_events(dev->libinput);
365
366         /* one finger down, wait past tap timeout,
367            second finger down, first finger up
368            -> no event
369          */
370         litest_touch_down(dev, 0, 50, 50);
371         libinput_dispatch(dev->libinput);
372         msleep(300);
373         libinput_dispatch(dev->libinput);
374         litest_drain_events(dev->libinput);
375
376         litest_touch_down(dev, 1, 70, 50);
377         litest_touch_up(dev, 0);
378
379         litest_assert_empty_queue(li);
380 }
381 END_TEST
382
383 START_TEST(touchpad_no_first_fg_tap_after_move)
384 {
385         struct litest_device *dev = litest_current_device();
386         struct libinput *li = dev->libinput;
387         struct libinput_event *event;
388
389         litest_drain_events(dev->libinput);
390
391         /* one finger down, second finger down,
392            second finger moves beyond threshold,
393            first finger up
394            -> no event
395          */
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);
404
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);
409         }
410 }
411 END_TEST
412
413 START_TEST(touchpad_1fg_double_tap_click)
414 {
415         struct litest_device *dev = litest_current_device();
416         struct libinput *li = dev->libinput;
417
418         libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
419
420         litest_drain_events(dev->libinput);
421
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);
432
433         libinput_dispatch(li);
434
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);
443
444         litest_assert_empty_queue(li);
445 }
446 END_TEST
447
448 START_TEST(touchpad_1fg_tap_n_drag_click)
449 {
450         struct litest_device *dev = litest_current_device();
451         struct libinput *li = dev->libinput;
452         struct libinput_event *event;
453
454         libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
455
456         litest_drain_events(dev->libinput);
457
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);
464
465         assert_button_event(li, BTN_LEFT,
466                             LIBINPUT_BUTTON_STATE_PRESSED);
467
468         libinput_dispatch(li);
469
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);
476         }
477
478         litest_event(dev, EV_KEY, BTN_LEFT, 1);
479         litest_event(dev, EV_SYN, SYN_REPORT, 0);
480
481         assert_button_event(li, BTN_LEFT,
482                             LIBINPUT_BUTTON_STATE_RELEASED);
483         assert_button_event(li, BTN_LEFT,
484                             LIBINPUT_BUTTON_STATE_PRESSED);
485
486         litest_event(dev, EV_KEY, BTN_LEFT, 0);
487         litest_event(dev, EV_SYN, SYN_REPORT, 0);
488         litest_touch_up(dev, 0);
489
490         libinput_dispatch(li);
491
492         assert_button_event(li, BTN_LEFT,
493                             LIBINPUT_BUTTON_STATE_RELEASED);
494
495         litest_assert_empty_queue(li);
496 }
497 END_TEST
498
499 START_TEST(touchpad_1fg_clickfinger)
500 {
501         struct litest_device *dev = litest_create_device(LITEST_BCM5974);
502         struct libinput *li = dev->libinput;
503
504         litest_drain_events(li);
505
506         litest_touch_down(dev, 0, 50, 50);
507         litest_event(dev, EV_KEY, BTN_LEFT, 1);
508         litest_event(dev, EV_SYN, SYN_REPORT, 0);
509         litest_event(dev, EV_KEY, BTN_LEFT, 0);
510         litest_event(dev, EV_SYN, SYN_REPORT, 0);
511         litest_touch_up(dev, 0);
512
513         libinput_dispatch(li);
514
515         assert_button_event(li, BTN_LEFT,
516                             LIBINPUT_BUTTON_STATE_PRESSED);
517         assert_button_event(li, BTN_LEFT,
518                             LIBINPUT_BUTTON_STATE_RELEASED);
519
520         litest_delete_device(dev);
521 }
522 END_TEST
523
524 START_TEST(touchpad_2fg_clickfinger)
525 {
526         struct litest_device *dev = litest_create_device(LITEST_BCM5974);
527         struct libinput *li = dev->libinput;
528
529         litest_drain_events(li);
530
531         litest_touch_down(dev, 0, 50, 50);
532         litest_touch_down(dev, 1, 70, 70);
533         litest_event(dev, EV_KEY, BTN_LEFT, 1);
534         litest_event(dev, EV_SYN, SYN_REPORT, 0);
535         litest_event(dev, EV_KEY, BTN_LEFT, 0);
536         litest_event(dev, EV_SYN, SYN_REPORT, 0);
537         litest_touch_up(dev, 0);
538         litest_touch_up(dev, 1);
539
540         libinput_dispatch(li);
541
542         assert_button_event(li, BTN_RIGHT,
543                             LIBINPUT_BUTTON_STATE_PRESSED);
544         assert_button_event(li, BTN_RIGHT,
545                             LIBINPUT_BUTTON_STATE_RELEASED);
546
547         litest_delete_device(dev);
548 }
549 END_TEST
550
551 START_TEST(touchpad_btn_left)
552 {
553         struct litest_device *dev = litest_current_device();
554         struct libinput *li = dev->libinput;
555
556         litest_drain_events(li);
557
558         litest_event(dev, EV_KEY, BTN_LEFT, 1);
559         litest_event(dev, EV_SYN, SYN_REPORT, 0);
560         litest_event(dev, EV_KEY, BTN_LEFT, 0);
561         litest_event(dev, EV_SYN, SYN_REPORT, 0);
562
563         libinput_dispatch(li);
564
565         assert_button_event(li, BTN_LEFT,
566                             LIBINPUT_BUTTON_STATE_PRESSED);
567         assert_button_event(li, BTN_LEFT,
568                             LIBINPUT_BUTTON_STATE_RELEASED);
569 }
570 END_TEST
571
572 START_TEST(clickpad_btn_left)
573 {
574         struct litest_device *dev = litest_current_device();
575         struct libinput *li = dev->libinput;
576
577         litest_drain_events(li);
578
579         /* A clickpad always needs a finger down to tell where the
580            click happens */
581         litest_event(dev, EV_KEY, BTN_LEFT, 1);
582         litest_event(dev, EV_SYN, SYN_REPORT, 0);
583         litest_event(dev, EV_KEY, BTN_LEFT, 0);
584         litest_event(dev, EV_SYN, SYN_REPORT, 0);
585
586         libinput_dispatch(li);
587         ck_assert_int_eq(libinput_next_event_type(li), LIBINPUT_EVENT_NONE);
588 }
589 END_TEST
590
591 START_TEST(clickpad_click_n_drag)
592 {
593         struct litest_device *dev = litest_current_device();
594         struct libinput *li = dev->libinput;
595         struct libinput_event *event;
596
597         litest_drain_events(li);
598
599         litest_touch_down(dev, 0, 50, 50);
600         litest_event(dev, EV_KEY, BTN_LEFT, 1);
601         litest_event(dev, EV_SYN, SYN_REPORT, 0);
602
603         libinput_dispatch(li);
604         assert_button_event(li, BTN_LEFT,
605                             LIBINPUT_BUTTON_STATE_PRESSED);
606
607         libinput_dispatch(li);
608         ck_assert_int_eq(libinput_next_event_type(li), LIBINPUT_EVENT_NONE);
609
610         /* now put a second finger down */
611         litest_touch_down(dev, 1, 70, 70);
612         litest_touch_move_to(dev, 1, 70, 70, 80, 50, 5);
613         litest_touch_up(dev, 1);
614
615         libinput_dispatch(li);
616         ck_assert_int_eq(libinput_next_event_type(li),
617                          LIBINPUT_EVENT_POINTER_MOTION);
618         do {
619                 event = libinput_get_event(li);
620                 libinput_event_destroy(event);
621                 libinput_dispatch(li);
622         } while (libinput_next_event_type(li) == LIBINPUT_EVENT_POINTER_MOTION);
623
624         litest_event(dev, EV_KEY, BTN_LEFT, 0);
625         litest_event(dev, EV_SYN, SYN_REPORT, 0);
626         litest_touch_up(dev, 0);
627
628         assert_button_event(li, BTN_LEFT,
629                             LIBINPUT_BUTTON_STATE_RELEASED);
630 }
631 END_TEST
632
633 START_TEST(clickpad_softbutton_left)
634 {
635         struct litest_device *dev = litest_current_device();
636         struct libinput *li = dev->libinput;
637
638         litest_drain_events(li);
639
640         litest_touch_down(dev, 0, 10, 90);
641         litest_event(dev, EV_KEY, BTN_LEFT, 1);
642         litest_event(dev, EV_SYN, SYN_REPORT, 0);
643
644         assert_button_event(li,
645                             BTN_LEFT,
646                             LIBINPUT_BUTTON_STATE_PRESSED);
647
648         litest_event(dev, EV_KEY, BTN_LEFT, 0);
649         litest_event(dev, EV_SYN, SYN_REPORT, 0);
650         litest_touch_up(dev, 0);
651
652         assert_button_event(li,
653                             BTN_LEFT,
654                             LIBINPUT_BUTTON_STATE_RELEASED);
655
656         libinput_dispatch(li);
657
658         litest_assert_empty_queue(li);
659 }
660 END_TEST
661
662 START_TEST(clickpad_softbutton_right)
663 {
664         struct litest_device *dev = litest_current_device();
665         struct libinput *li = dev->libinput;
666
667         litest_drain_events(li);
668
669         litest_touch_down(dev, 0, 90, 90);
670         litest_event(dev, EV_KEY, BTN_LEFT, 1);
671         litest_event(dev, EV_SYN, SYN_REPORT, 0);
672
673         assert_button_event(li,
674                             BTN_RIGHT,
675                             LIBINPUT_BUTTON_STATE_PRESSED);
676
677         litest_event(dev, EV_KEY, BTN_LEFT, 0);
678         litest_event(dev, EV_SYN, SYN_REPORT, 0);
679         litest_touch_up(dev, 0);
680
681         assert_button_event(li,
682                             BTN_RIGHT,
683                             LIBINPUT_BUTTON_STATE_RELEASED);
684
685         libinput_dispatch(li);
686
687         litest_assert_empty_queue(li);
688 }
689 END_TEST
690
691 START_TEST(clickpad_softbutton_left_tap_n_drag)
692 {
693         struct litest_device *dev = litest_current_device();
694         struct libinput *li = dev->libinput;
695
696         libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
697
698         litest_drain_events(li);
699
700         /* Tap in left button area, then finger down, button click
701                 -> expect left button press/release and left button press
702            Release button, finger up
703                 -> expect right button release
704          */
705         litest_touch_down(dev, 0, 20, 90);
706         litest_touch_up(dev, 0);
707         litest_touch_down(dev, 0, 20, 90);
708         litest_event(dev, EV_KEY, BTN_LEFT, 1);
709         litest_event(dev, EV_SYN, SYN_REPORT, 0);
710
711         assert_button_event(li,
712                             BTN_LEFT,
713                             LIBINPUT_BUTTON_STATE_PRESSED);
714         assert_button_event(li,
715                             BTN_LEFT,
716                             LIBINPUT_BUTTON_STATE_RELEASED);
717         assert_button_event(li,
718                             BTN_LEFT,
719                             LIBINPUT_BUTTON_STATE_PRESSED);
720         litest_assert_empty_queue(li);
721
722         litest_event(dev, EV_KEY, BTN_LEFT, 0);
723         litest_event(dev, EV_SYN, SYN_REPORT, 0);
724         litest_touch_up(dev, 0);
725
726         assert_button_event(li,
727                             BTN_LEFT,
728                             LIBINPUT_BUTTON_STATE_RELEASED);
729         litest_assert_empty_queue(li);
730 }
731 END_TEST
732
733 START_TEST(clickpad_softbutton_right_tap_n_drag)
734 {
735         struct litest_device *dev = litest_current_device();
736         struct libinput *li = dev->libinput;
737
738         libinput_device_config_tap_set_enabled(dev->libinput_device, 1);
739
740         litest_drain_events(li);
741
742         /* Tap in right button area, then finger down, button click
743                 -> expect left button press/release and right button press
744            Release button, finger up
745                 -> expect right button release
746          */
747         litest_touch_down(dev, 0, 90, 90);
748         litest_touch_up(dev, 0);
749         litest_touch_down(dev, 0, 90, 90);
750         litest_event(dev, EV_KEY, BTN_LEFT, 1);
751         litest_event(dev, EV_SYN, SYN_REPORT, 0);
752
753         assert_button_event(li,
754                             BTN_LEFT,
755                             LIBINPUT_BUTTON_STATE_PRESSED);
756         assert_button_event(li,
757                             BTN_LEFT,
758                             LIBINPUT_BUTTON_STATE_RELEASED);
759         assert_button_event(li,
760                             BTN_RIGHT,
761                             LIBINPUT_BUTTON_STATE_PRESSED);
762         litest_assert_empty_queue(li);
763
764         litest_event(dev, EV_KEY, BTN_LEFT, 0);
765         litest_event(dev, EV_SYN, SYN_REPORT, 0);
766         litest_touch_up(dev, 0);
767
768         assert_button_event(li,
769                             BTN_RIGHT,
770                             LIBINPUT_BUTTON_STATE_RELEASED);
771         litest_assert_empty_queue(li);
772 }
773 END_TEST
774
775 START_TEST(clickpad_softbutton_left_1st_fg_move)
776 {
777         struct litest_device *dev = litest_current_device();
778         struct libinput *li = dev->libinput;
779         struct libinput_event *event;
780         double x = 0, y = 0;
781         int nevents = 0;
782
783         litest_drain_events(li);
784
785         /* One finger down in the left button area, button press
786                 -> expect a button event
787            Move finger up out of the area, wait for timeout
788            Move finger around diagonally down left
789                 -> expect motion events down left
790            Release finger
791                 -> expect a button event */
792
793         /* finger down, press in left button */
794         litest_touch_down(dev, 0, 20, 90);
795         litest_event(dev, EV_KEY, BTN_LEFT, 1);
796         litest_event(dev, EV_SYN, SYN_REPORT, 0);
797
798         assert_button_event(li,
799                             BTN_LEFT,
800                             LIBINPUT_BUTTON_STATE_PRESSED);
801         litest_assert_empty_queue(li);
802
803         /* move out of the area, then wait for softbutton timer */
804         litest_touch_move_to(dev, 0, 20, 90, 90, 20, 10);
805         libinput_dispatch(li);
806         msleep(400);
807         libinput_dispatch(li);
808         litest_drain_events(li);
809
810         /* move down left, expect motion */
811         litest_touch_move_to(dev, 0, 90, 20, 20, 90, 10);
812
813         libinput_dispatch(li);
814         event = libinput_get_event(li);
815         ck_assert(event != NULL);
816         while (event) {
817                 struct libinput_event_pointer *p;
818
819                 ck_assert_int_eq(libinput_event_get_type(event),
820                                  LIBINPUT_EVENT_POINTER_MOTION);
821                 p = libinput_event_get_pointer_event(event);
822
823                 /* we moved up/right, now down/left so the pointer accel
824                    code may lag behind with the dx/dy vectors. Hence, add up
825                    the x/y movements and expect that on average we moved
826                    left and down */
827                 x += libinput_event_pointer_get_dx(p);
828                 y += libinput_event_pointer_get_dy(p);
829                 nevents++;
830
831                 libinput_event_destroy(event);
832                 libinput_dispatch(li);
833                 event = libinput_get_event(li);
834         }
835
836         ck_assert(x/nevents < 0);
837         ck_assert(y/nevents > 0);
838
839         litest_event(dev, EV_KEY, BTN_LEFT, 0);
840         litest_event(dev, EV_SYN, SYN_REPORT, 0);
841         litest_touch_up(dev, 0);
842
843         assert_button_event(li,
844                             BTN_LEFT,
845                             LIBINPUT_BUTTON_STATE_RELEASED);
846
847         litest_assert_empty_queue(li);
848 }
849 END_TEST
850
851 START_TEST(clickpad_softbutton_left_2nd_fg_move)
852 {
853         struct litest_device *dev = litest_current_device();
854         struct libinput *li = dev->libinput;
855         struct libinput_event *event;
856
857         litest_drain_events(li);
858
859         /* One finger down in the left button area, button press
860                 -> expect a button event
861            Put a second finger down in the area, move it right, release
862                 -> expect motion events right
863            Put a second finger down in the area, move it down, release
864                 -> expect motion events down
865            Release second finger, release first finger
866                 -> expect a button event */
867         litest_touch_down(dev, 0, 20, 90);
868         litest_event(dev, EV_KEY, BTN_LEFT, 1);
869         litest_event(dev, EV_SYN, SYN_REPORT, 0);
870
871         assert_button_event(li,
872                             BTN_LEFT,
873                             LIBINPUT_BUTTON_STATE_PRESSED);
874         litest_assert_empty_queue(li);
875
876         litest_touch_down(dev, 1, 20, 20);
877         litest_touch_move_to(dev, 1, 20, 20, 80, 20, 10);
878
879         libinput_dispatch(li);
880         event = libinput_get_event(li);
881         ck_assert(event != NULL);
882         while (event) {
883                 struct libinput_event_pointer *p;
884                 double x, y;
885
886                 ck_assert_int_eq(libinput_event_get_type(event),
887                                  LIBINPUT_EVENT_POINTER_MOTION);
888                 p = libinput_event_get_pointer_event(event);
889
890                 x = libinput_event_pointer_get_dx(p);
891                 y = libinput_event_pointer_get_dy(p);
892
893                 ck_assert(x > 0);
894                 ck_assert(y == 0);
895
896                 libinput_event_destroy(event);
897                 libinput_dispatch(li);
898                 event = libinput_get_event(li);
899         }
900         litest_touch_up(dev, 1);
901
902         /* second finger down */
903         litest_touch_down(dev, 1, 20, 20);
904         litest_touch_move_to(dev, 1, 20, 20, 20, 80, 10);
905
906         libinput_dispatch(li);
907         event = libinput_get_event(li);
908         ck_assert(event != NULL);
909         while (event) {
910                 struct libinput_event_pointer *p;
911                 double x, y;
912
913                 ck_assert_int_eq(libinput_event_get_type(event),
914                                  LIBINPUT_EVENT_POINTER_MOTION);
915                 p = libinput_event_get_pointer_event(event);
916
917                 x = libinput_event_pointer_get_dx(p);
918                 y = libinput_event_pointer_get_dy(p);
919
920                 ck_assert(x == 0);
921                 ck_assert(y > 0);
922
923                 libinput_event_destroy(event);
924                 libinput_dispatch(li);
925                 event = libinput_get_event(li);
926         }
927
928         litest_touch_up(dev, 1);
929
930         litest_event(dev, EV_KEY, BTN_LEFT, 0);
931         litest_event(dev, EV_SYN, SYN_REPORT, 0);
932         litest_touch_up(dev, 0);
933
934         assert_button_event(li,
935                             BTN_LEFT,
936                             LIBINPUT_BUTTON_STATE_RELEASED);
937
938         litest_assert_empty_queue(li);
939 }
940 END_TEST
941
942 START_TEST(clickpad_softbutton_left_to_right)
943 {
944         struct litest_device *dev = litest_current_device();
945         struct libinput *li = dev->libinput;
946
947         litest_drain_events(li);
948
949         /* One finger down in left software button area,
950            move to right button area immediately, click
951                 -> expect right button event
952         */
953
954         litest_touch_down(dev, 0, 20, 90);
955         litest_touch_move_to(dev, 0, 20, 90, 90, 90, 10);
956         litest_event(dev, EV_KEY, BTN_LEFT, 1);
957         litest_event(dev, EV_SYN, SYN_REPORT, 0);
958
959         assert_button_event(li,
960                             BTN_RIGHT,
961                             LIBINPUT_BUTTON_STATE_PRESSED);
962         litest_assert_empty_queue(li);
963
964         litest_event(dev, EV_KEY, BTN_LEFT, 0);
965         litest_event(dev, EV_SYN, SYN_REPORT, 0);
966         litest_touch_up(dev, 0);
967
968         assert_button_event(li,
969                             BTN_RIGHT,
970                             LIBINPUT_BUTTON_STATE_RELEASED);
971
972         litest_assert_empty_queue(li);
973 }
974 END_TEST
975
976 START_TEST(clickpad_softbutton_right_to_left)
977 {
978         struct litest_device *dev = litest_current_device();
979         struct libinput *li = dev->libinput;
980
981         litest_drain_events(li);
982
983         /* One finger down in right software button area,
984            move to left button area immediately, click
985                 -> expect left button event
986         */
987
988         litest_touch_down(dev, 0, 90, 90);
989         litest_touch_move_to(dev, 0, 90, 90, 20, 90, 10);
990         litest_event(dev, EV_KEY, BTN_LEFT, 1);
991         litest_event(dev, EV_SYN, SYN_REPORT, 0);
992
993         assert_button_event(li,
994                             BTN_LEFT,
995                             LIBINPUT_BUTTON_STATE_PRESSED);
996         litest_assert_empty_queue(li);
997
998         litest_event(dev, EV_KEY, BTN_LEFT, 0);
999         litest_event(dev, EV_SYN, SYN_REPORT, 0);
1000         litest_touch_up(dev, 0);
1001
1002         assert_button_event(li,
1003                             BTN_LEFT,
1004                             LIBINPUT_BUTTON_STATE_RELEASED);
1005
1006         litest_assert_empty_queue(li);
1007 }
1008 END_TEST
1009
1010 START_TEST(clickpad_topsoftbuttons_left)
1011 {
1012         struct litest_device *dev = litest_current_device();
1013         struct libinput *li = dev->libinput;
1014
1015         litest_drain_events(li);
1016
1017         litest_touch_down(dev, 0, 10, 5);
1018         litest_event(dev, EV_KEY, BTN_LEFT, 1);
1019         litest_event(dev, EV_SYN, SYN_REPORT, 0);
1020
1021         assert_button_event(li,
1022                             BTN_LEFT,
1023                             LIBINPUT_BUTTON_STATE_PRESSED);
1024         litest_assert_empty_queue(li);
1025
1026         litest_event(dev, EV_KEY, BTN_LEFT, 0);
1027         litest_event(dev, EV_SYN, SYN_REPORT, 0);
1028         litest_touch_up(dev, 0);
1029
1030         assert_button_event(li,
1031                             BTN_LEFT,
1032                             LIBINPUT_BUTTON_STATE_RELEASED);
1033
1034         litest_assert_empty_queue(li);
1035 }
1036 END_TEST
1037
1038 START_TEST(clickpad_topsoftbuttons_right)
1039 {
1040         struct litest_device *dev = litest_current_device();
1041         struct libinput *li = dev->libinput;
1042
1043         litest_drain_events(li);
1044
1045         litest_touch_down(dev, 0, 90, 5);
1046         litest_event(dev, EV_KEY, BTN_LEFT, 1);
1047         litest_event(dev, EV_SYN, SYN_REPORT, 0);
1048
1049         assert_button_event(li,
1050                             BTN_RIGHT,
1051                             LIBINPUT_BUTTON_STATE_PRESSED);
1052         litest_assert_empty_queue(li);
1053
1054         litest_event(dev, EV_KEY, BTN_LEFT, 0);
1055         litest_event(dev, EV_SYN, SYN_REPORT, 0);
1056         litest_touch_up(dev, 0);
1057
1058         assert_button_event(li,
1059                             BTN_RIGHT,
1060                             LIBINPUT_BUTTON_STATE_RELEASED);
1061
1062         litest_assert_empty_queue(li);
1063 }
1064 END_TEST
1065
1066 START_TEST(clickpad_topsoftbuttons_middle)
1067 {
1068         struct litest_device *dev = litest_current_device();
1069         struct libinput *li = dev->libinput;
1070
1071         litest_drain_events(li);
1072
1073         litest_touch_down(dev, 0, 50, 5);
1074         litest_event(dev, EV_KEY, BTN_LEFT, 1);
1075         litest_event(dev, EV_SYN, SYN_REPORT, 0);
1076
1077         assert_button_event(li,
1078                             BTN_MIDDLE,
1079                             LIBINPUT_BUTTON_STATE_PRESSED);
1080         litest_assert_empty_queue(li);
1081
1082         litest_event(dev, EV_KEY, BTN_LEFT, 0);
1083         litest_event(dev, EV_SYN, SYN_REPORT, 0);
1084         litest_touch_up(dev, 0);
1085
1086         assert_button_event(li,
1087                             BTN_MIDDLE,
1088                             LIBINPUT_BUTTON_STATE_RELEASED);
1089
1090         litest_assert_empty_queue(li);
1091 }
1092 END_TEST
1093
1094 START_TEST(clickpad_topsoftbuttons_move_out_ignore)
1095 {
1096         struct litest_device *dev = litest_current_device();
1097         struct libinput *li = dev->libinput;
1098
1099         /* Finger down in top button area, wait past enter timeout
1100            Move into main area, wait past leave timeout
1101            Click
1102              -> expect no events
1103          */
1104
1105         litest_drain_events(li);
1106
1107         litest_touch_down(dev, 0, 50, 5);
1108         libinput_dispatch(li);
1109         msleep(200);
1110         libinput_dispatch(li);
1111         litest_assert_empty_queue(li);
1112
1113         litest_touch_move_to(dev, 0, 50, 5, 80, 90, 20);
1114         libinput_dispatch(li);
1115         msleep(400);
1116         libinput_dispatch(li);
1117
1118         litest_event(dev, EV_KEY, BTN_LEFT, 1);
1119         litest_event(dev, EV_SYN, SYN_REPORT, 0);
1120         litest_event(dev, EV_KEY, BTN_LEFT, 0);
1121         litest_event(dev, EV_SYN, SYN_REPORT, 0);
1122
1123         litest_touch_up(dev, 0);
1124
1125         litest_assert_empty_queue(li);
1126 }
1127 END_TEST
1128
1129 static void
1130 test_2fg_scroll(struct litest_device *dev, double dx, double dy, int sleep)
1131 {
1132         struct libinput *li = dev->libinput;
1133
1134         litest_touch_down(dev, 0, 47, 50);
1135         litest_touch_down(dev, 1, 53, 50);
1136
1137         litest_touch_move_to(dev, 0, 47, 50, 47 + dx, 50 + dy, 5);
1138         litest_touch_move_to(dev, 1, 53, 50, 53 + dx, 50 + dy, 5);
1139
1140         /* Avoid a small scroll being seen as a tap */
1141         if (sleep) {
1142                 libinput_dispatch(li);
1143                 msleep(sleep);
1144                 libinput_dispatch(li);
1145         }
1146
1147         litest_touch_up(dev, 1);
1148         litest_touch_up(dev, 0);
1149
1150         libinput_dispatch(li);
1151 }
1152
1153 static void
1154 check_2fg_scroll(struct litest_device *dev, unsigned int axis, int dir)
1155 {
1156         struct libinput *li = dev->libinput;
1157         struct libinput_event *event, *next_event;
1158         struct libinput_event_pointer *ptrev;
1159
1160         event = libinput_get_event(li);
1161         next_event = libinput_get_event(li);
1162         ck_assert(next_event != NULL); /* At least 1 scroll + stop scroll */
1163
1164         while (event) {
1165                 ck_assert_int_eq(libinput_event_get_type(event),
1166                                  LIBINPUT_EVENT_POINTER_AXIS);
1167                 ptrev = libinput_event_get_pointer_event(event);
1168                 ck_assert(ptrev != NULL);
1169                 ck_assert_int_eq(libinput_event_pointer_get_axis(ptrev), axis);
1170
1171                 if (next_event) {
1172                         /* Normal scroll event, check dir */
1173                         if (dir > 0) {
1174                                 ck_assert_int_ge(
1175                                         libinput_event_pointer_get_axis_value(ptrev),
1176                                         dir);
1177                         } else {
1178                                 ck_assert_int_le(
1179                                         libinput_event_pointer_get_axis_value(ptrev),
1180                                         dir);
1181                         }
1182                 } else {
1183                         /* Last scroll event, must be 0 */
1184                         ck_assert_int_eq(
1185                                 libinput_event_pointer_get_axis_value(ptrev),
1186                                 0);
1187                 }
1188                 libinput_event_destroy(event);
1189                 event = next_event;
1190                 next_event = libinput_get_event(li);
1191         }
1192 }
1193
1194 START_TEST(touchpad_2fg_scroll)
1195 {
1196         struct litest_device *dev = litest_current_device();
1197         struct libinput *li = dev->libinput;
1198
1199         litest_drain_events(li);
1200
1201         test_2fg_scroll(dev, 0.1, 40, 0);
1202         check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, 10);
1203         test_2fg_scroll(dev, 0.1, -40, 0);
1204         check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, -10);
1205         test_2fg_scroll(dev, 40, 0.1, 0);
1206         check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, 10);
1207         test_2fg_scroll(dev, -40, 0.1, 0);
1208         check_2fg_scroll(dev, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, -10);
1209
1210         /* 2fg scroll smaller than the threshold should not generate events */
1211         test_2fg_scroll(dev, 0.1, 0.1, 200);
1212         litest_assert_empty_queue(li);
1213 }
1214 END_TEST
1215
1216 START_TEST(touchpad_tap_is_available)
1217 {
1218         struct litest_device *dev = litest_current_device();
1219
1220         ck_assert_int_ge(libinput_device_config_tap_get_finger_count(dev->libinput_device), 1);
1221         ck_assert_int_eq(libinput_device_config_tap_get_enabled(dev->libinput_device), 0);
1222 }
1223 END_TEST
1224
1225 START_TEST(touchpad_tap_is_not_available)
1226 {
1227         struct litest_device *dev = litest_current_device();
1228
1229         ck_assert_int_eq(libinput_device_config_tap_get_finger_count(dev->libinput_device), 0);
1230         ck_assert_int_eq(libinput_device_config_tap_get_enabled(dev->libinput_device), 0);
1231         ck_assert_int_eq(libinput_device_config_tap_set_enabled(dev->libinput_device, 1),
1232                          LIBINPUT_CONFIG_STATUS_UNSUPPORTED);
1233 }
1234 END_TEST
1235
1236 START_TEST(touchpad_tap_default)
1237 {
1238         struct litest_device *dev = litest_current_device();
1239
1240         ck_assert_int_eq(libinput_device_config_tap_get_default_enabled(dev->libinput_device), 0);
1241 }
1242 END_TEST
1243
1244 int main(int argc, char **argv) {
1245
1246         litest_add("touchpad:motion", touchpad_1fg_motion, LITEST_TOUCHPAD, LITEST_ANY);
1247         litest_add("touchpad:motion", touchpad_2fg_no_motion, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1248
1249         litest_add("touchpad:tap", touchpad_1fg_tap, LITEST_TOUCHPAD, LITEST_ANY);
1250         litest_add("touchpad:tap", touchpad_1fg_tap_n_drag, LITEST_TOUCHPAD, LITEST_ANY);
1251         litest_add("touchpad:tap", touchpad_2fg_tap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1252         litest_add("touchpad:tap", touchpad_2fg_tap_inverted, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1253         litest_add("touchpad:tap", touchpad_1fg_tap_click, LITEST_TOUCHPAD, LITEST_ANY);
1254         litest_add("touchpad:tap", touchpad_2fg_tap_click, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_APPLE_CLICKPAD);
1255         litest_add("touchpad:tap", touchpad_2fg_tap_click_apple, LITEST_APPLE_CLICKPAD, LITEST_ANY);
1256         litest_add("touchpad:tap", touchpad_no_2fg_tap_after_move, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1257         litest_add("touchpad:tap", touchpad_no_2fg_tap_after_timeout, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1258         litest_add("touchpad:tap", touchpad_no_first_fg_tap_after_move, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1259         litest_add("touchpad:tap", touchpad_no_first_fg_tap_after_move, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1260
1261         /* Real buttons don't interfere with tapping, so don't run those for
1262            pads with buttons */
1263         litest_add("touchpad:tap", touchpad_1fg_double_tap_click, LITEST_CLICKPAD, LITEST_ANY);
1264         litest_add("touchpad:tap", touchpad_1fg_tap_n_drag_click, LITEST_CLICKPAD, LITEST_ANY);
1265
1266         litest_add("touchpad:tap", touchpad_tap_default, LITEST_TOUCHPAD, LITEST_ANY);
1267         litest_add("touchpad:tap", touchpad_tap_is_available, LITEST_TOUCHPAD, LITEST_ANY);
1268         litest_add("touchpad:tap", touchpad_tap_is_not_available, LITEST_ANY, LITEST_TOUCHPAD);
1269
1270         litest_add_no_device("touchpad:clickfinger", touchpad_1fg_clickfinger);
1271         litest_add_no_device("touchpad:clickfinger", touchpad_2fg_clickfinger);
1272
1273         litest_add("touchpad:click", touchpad_btn_left, LITEST_TOUCHPAD, LITEST_CLICKPAD);
1274         litest_add("touchpad:click", clickpad_btn_left, LITEST_CLICKPAD, LITEST_ANY);
1275         litest_add("touchpad:click", clickpad_click_n_drag, LITEST_CLICKPAD, LITEST_SINGLE_TOUCH);
1276
1277         litest_add("touchpad:softbutton", clickpad_softbutton_left, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1278         litest_add("touchpad:softbutton", clickpad_softbutton_right, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1279         litest_add("touchpad:softbutton", clickpad_softbutton_left_tap_n_drag, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1280         litest_add("touchpad:softbutton", clickpad_softbutton_right_tap_n_drag, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1281         litest_add("touchpad:softbutton", clickpad_softbutton_left_1st_fg_move, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1282         litest_add("touchpad:softbutton", clickpad_softbutton_left_2nd_fg_move, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1283         litest_add("touchpad:softbutton", clickpad_softbutton_left_to_right, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1284         litest_add("touchpad:softbutton", clickpad_softbutton_right_to_left, LITEST_CLICKPAD, LITEST_APPLE_CLICKPAD);
1285
1286         litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_left, LITEST_TOPBUTTONPAD, LITEST_ANY);
1287         litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_right, LITEST_TOPBUTTONPAD, LITEST_ANY);
1288         litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_middle, LITEST_TOPBUTTONPAD, LITEST_ANY);
1289         litest_add("touchpad:topsoftbuttons", clickpad_topsoftbuttons_move_out_ignore, LITEST_TOPBUTTONPAD, LITEST_ANY);
1290
1291         litest_add("touchpad:scroll", touchpad_2fg_scroll, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH);
1292
1293         return litest_run(argc, argv);
1294 }