touchpad: normalize the touchpad resolution to 400dpi, not 10 units/mm
[platform/upstream/libinput.git] / test / path.c
1
2 /*
3  * Copyright © 2013 Red Hat, Inc.
4  *
5  * Permission to use, copy, modify, distribute, and sell this software and
6  * its documentation for any purpose is hereby granted without fee, provided
7  * that the above copyright notice appear in all copies and that both that
8  * copyright notice and this permission notice appear in supporting
9  * documentation, and that the name of the copyright holders not be used in
10  * advertising or publicity pertaining to distribution of the software
11  * without specific, written prior permission.  The copyright holders make
12  * no representations about the suitability of this software for any
13  * purpose.  It is provided "as is" without express or implied warranty.
14  *
15  * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
16  * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
18  * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
19  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
20  * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  */
23
24 #include <config.h>
25
26 #include <check.h>
27 #include <errno.h>
28 #include <fcntl.h>
29 #include <libinput.h>
30 #include <libudev.h>
31 #include <unistd.h>
32
33 #include "litest.h"
34
35 static int open_func_count = 0;
36 static int close_func_count = 0;
37
38 static int open_restricted(const char *path, int flags, void *data)
39 {
40         int fd;
41         open_func_count++;
42         fd = open(path, flags);
43         return fd < 0 ? -errno : fd;
44 }
45 static void close_restricted(int fd, void *data)
46 {
47         close_func_count++;
48         close(fd);
49 }
50
51 const struct libinput_interface simple_interface = {
52         .open_restricted = open_restricted,
53         .close_restricted = close_restricted,
54 };
55
56
57 START_TEST(path_create_NULL)
58 {
59         struct libinput *li;
60
61         open_func_count = 0;
62         close_func_count = 0;
63
64         li = libinput_path_create_context(NULL, NULL);
65         ck_assert(li == NULL);
66         li = libinput_path_create_context(&simple_interface, NULL);
67         ck_assert(li != NULL);
68         libinput_unref(li);
69
70         ck_assert_int_eq(open_func_count, 0);
71         ck_assert_int_eq(close_func_count, 0);
72
73         open_func_count = 0;
74         close_func_count = 0;
75 }
76 END_TEST
77
78 START_TEST(path_create_invalid)
79 {
80         struct libinput *li;
81         struct libinput_device *device;
82         const char *path = "/tmp";
83
84         open_func_count = 0;
85         close_func_count = 0;
86
87         li = libinput_path_create_context(&simple_interface, NULL);
88         ck_assert(li != NULL);
89         device = libinput_path_add_device(li, path);
90         ck_assert(device == NULL);
91
92         ck_assert_int_eq(open_func_count, 0);
93         ck_assert_int_eq(close_func_count, 0);
94
95         libinput_unref(li);
96         ck_assert_int_eq(close_func_count, 0);
97
98         open_func_count = 0;
99         close_func_count = 0;
100 }
101 END_TEST
102
103 START_TEST(path_create_destroy)
104 {
105         struct libinput *li;
106         struct libinput_device *device;
107         struct libevdev_uinput *uinput;
108         int rc;
109         void *userdata = &rc;
110
111         uinput = litest_create_uinput_device("test device", NULL,
112                                              EV_KEY, BTN_LEFT,
113                                              EV_KEY, BTN_RIGHT,
114                                              EV_REL, REL_X,
115                                              EV_REL, REL_Y,
116                                              -1);
117
118         li = libinput_path_create_context(&simple_interface, userdata);
119         ck_assert(li != NULL);
120         ck_assert(libinput_get_user_data(li) == userdata);
121
122         device = libinput_path_add_device(li,
123                                           libevdev_uinput_get_devnode(uinput));
124         ck_assert(device != NULL);
125
126         ck_assert_int_eq(open_func_count, 1);
127
128         libevdev_uinput_destroy(uinput);
129         libinput_unref(li);
130         ck_assert_int_eq(close_func_count, 1);
131
132         open_func_count = 0;
133         close_func_count = 0;
134 }
135 END_TEST
136
137 START_TEST(path_added_seat)
138 {
139         struct litest_device *dev = litest_current_device();
140         struct libinput *li = dev->libinput;
141         struct libinput_event *event;
142         struct libinput_device *device;
143         struct libinput_seat *seat;
144         const char *seat_name;
145         enum libinput_event_type type;
146
147         libinput_dispatch(li);
148
149         event = libinput_get_event(li);
150         ck_assert(event != NULL);
151
152         type = libinput_event_get_type(event);
153         ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_ADDED);
154
155         device = libinput_event_get_device(event);
156         seat = libinput_device_get_seat(device);
157         ck_assert(seat != NULL);
158
159         seat_name = libinput_seat_get_logical_name(seat);
160         ck_assert_str_eq(seat_name, "default");
161
162         libinput_event_destroy(event);
163 }
164 END_TEST
165
166 START_TEST(path_added_device)
167 {
168         struct litest_device *dev = litest_current_device();
169         struct libinput *li = dev->libinput;
170         struct libinput_event *event;
171         struct libinput_device *device;
172
173         libinput_dispatch(li);
174
175         while ((event = libinput_get_event(li))) {
176                 enum libinput_event_type type;
177                 type = libinput_event_get_type(event);
178
179                 if (type == LIBINPUT_EVENT_DEVICE_ADDED) {
180                         break;
181                 }
182
183                 libinput_event_destroy(event);
184         }
185
186         ck_assert(event != NULL);
187
188         device = libinput_event_get_device(event);
189         ck_assert(device != NULL);
190
191         libinput_event_destroy(event);
192 }
193 END_TEST
194
195 START_TEST(path_add_device)
196 {
197         struct litest_device *dev = litest_current_device();
198         struct libinput *li = dev->libinput;
199         struct libinput_event *event;
200         struct libinput_device *device;
201         const char *sysname1 = NULL, *sysname2 = NULL;
202
203         libinput_dispatch(li);
204
205         while ((event = libinput_get_event(li))) {
206                 enum libinput_event_type type;
207                 type = libinput_event_get_type(event);
208
209                 if (type == LIBINPUT_EVENT_DEVICE_ADDED) {
210                         ck_assert(sysname1 == NULL);
211                         device = libinput_event_get_device(event);
212                         ck_assert(device != NULL);
213                         sysname1 = libinput_device_get_sysname(device);
214                 }
215
216                 libinput_event_destroy(event);
217         }
218
219         device = libinput_path_add_device(li,
220                                           libevdev_uinput_get_devnode(dev->uinput));
221         ck_assert(device != NULL);
222
223         libinput_dispatch(li);
224
225         while ((event = libinput_get_event(li))) {
226                 enum libinput_event_type type;
227                 type = libinput_event_get_type(event);
228
229                 if (type == LIBINPUT_EVENT_DEVICE_ADDED) {
230                         ck_assert(sysname2 == NULL);
231                         device = libinput_event_get_device(event);
232                         ck_assert(device != NULL);
233                         sysname2 = libinput_device_get_sysname(device);
234                 }
235
236                 libinput_event_destroy(event);
237         }
238
239         ck_assert_str_eq(sysname1, sysname2);
240
241         libinput_event_destroy(event);
242 }
243 END_TEST
244
245 START_TEST(path_add_invalid_path)
246 {
247         struct litest_device *dev = litest_current_device();
248         struct libinput *li = dev->libinput;
249         struct libinput_event *event;
250         struct libinput_device *device;
251
252         litest_drain_events(li);
253
254         device = libinput_path_add_device(li, "/tmp/");
255         ck_assert(device == NULL);
256
257         libinput_dispatch(li);
258
259         while ((event = libinput_get_event(li)))
260                 ck_abort();
261 }
262 END_TEST
263
264 START_TEST(path_device_sysname)
265 {
266         struct litest_device *dev = litest_current_device();
267         struct libinput_event *ev;
268         struct libinput_device *device;
269         const char *sysname;
270
271         libinput_dispatch(dev->libinput);
272
273         while ((ev = libinput_get_event(dev->libinput))) {
274                 if (libinput_event_get_type(ev) != LIBINPUT_EVENT_DEVICE_ADDED)
275                         continue;
276
277                 device = libinput_event_get_device(ev);
278                 sysname = libinput_device_get_sysname(device);
279                 ck_assert(sysname != NULL && strlen(sysname) > 1);
280                 ck_assert(strchr(sysname, '/') == NULL);
281                 ck_assert_int_eq(strncmp(sysname, "event", 5), 0);
282
283                 libinput_event_destroy(ev);
284         }
285 }
286 END_TEST
287
288 START_TEST(path_remove_device)
289 {
290         struct litest_device *dev = litest_current_device();
291         struct libinput *li = dev->libinput;
292         struct libinput_event *event;
293         struct libinput_device *device;
294         int remove_event = 0;
295
296         device = libinput_path_add_device(li,
297                                           libevdev_uinput_get_devnode(dev->uinput));
298         ck_assert(device != NULL);
299         litest_drain_events(li);
300
301         libinput_path_remove_device(device);
302         libinput_dispatch(li);
303
304         while ((event = libinput_get_event(li))) {
305                 enum libinput_event_type type;
306                 type = libinput_event_get_type(event);
307
308                 if (type == LIBINPUT_EVENT_DEVICE_REMOVED)
309                         remove_event++;
310
311                 libinput_event_destroy(event);
312         }
313
314         ck_assert_int_eq(remove_event, 1);
315 }
316 END_TEST
317
318 START_TEST(path_double_remove_device)
319 {
320         struct litest_device *dev = litest_current_device();
321         struct libinput *li = dev->libinput;
322         struct libinput_event *event;
323         struct libinput_device *device;
324         int remove_event = 0;
325
326         device = libinput_path_add_device(li,
327                                           libevdev_uinput_get_devnode(dev->uinput));
328         ck_assert(device != NULL);
329         litest_drain_events(li);
330
331         libinput_path_remove_device(device);
332         libinput_path_remove_device(device);
333         libinput_dispatch(li);
334
335         while ((event = libinput_get_event(li))) {
336                 enum libinput_event_type type;
337                 type = libinput_event_get_type(event);
338
339                 if (type == LIBINPUT_EVENT_DEVICE_REMOVED)
340                         remove_event++;
341
342                 libinput_event_destroy(event);
343         }
344
345         ck_assert_int_eq(remove_event, 1);
346 }
347 END_TEST
348
349 START_TEST(path_suspend)
350 {
351         struct libinput *li;
352         struct libinput_device *device;
353         struct libevdev_uinput *uinput;
354         int rc;
355         void *userdata = &rc;
356
357         uinput = litest_create_uinput_device("test device", NULL,
358                                              EV_KEY, BTN_LEFT,
359                                              EV_KEY, BTN_RIGHT,
360                                              EV_REL, REL_X,
361                                              EV_REL, REL_Y,
362                                              -1);
363
364         li = libinput_path_create_context(&simple_interface, userdata);
365         ck_assert(li != NULL);
366
367         device = libinput_path_add_device(li,
368                                           libevdev_uinput_get_devnode(uinput));
369         ck_assert(device != NULL);
370
371         libinput_suspend(li);
372         libinput_resume(li);
373
374         libevdev_uinput_destroy(uinput);
375         libinput_unref(li);
376
377         open_func_count = 0;
378         close_func_count = 0;
379 }
380 END_TEST
381
382 START_TEST(path_double_suspend)
383 {
384         struct libinput *li;
385         struct libinput_device *device;
386         struct libevdev_uinput *uinput;
387         int rc;
388         void *userdata = &rc;
389
390         uinput = litest_create_uinput_device("test device", NULL,
391                                              EV_KEY, BTN_LEFT,
392                                              EV_KEY, BTN_RIGHT,
393                                              EV_REL, REL_X,
394                                              EV_REL, REL_Y,
395                                              -1);
396
397         li = libinput_path_create_context(&simple_interface, userdata);
398         ck_assert(li != NULL);
399
400         device = libinput_path_add_device(li,
401                                           libevdev_uinput_get_devnode(uinput));
402         ck_assert(device != NULL);
403
404         libinput_suspend(li);
405         libinput_suspend(li);
406         libinput_resume(li);
407
408         libevdev_uinput_destroy(uinput);
409         libinput_unref(li);
410
411         open_func_count = 0;
412         close_func_count = 0;
413 }
414 END_TEST
415
416 START_TEST(path_double_resume)
417 {
418         struct libinput *li;
419         struct libinput_device *device;
420         struct libevdev_uinput *uinput;
421         int rc;
422         void *userdata = &rc;
423
424         uinput = litest_create_uinput_device("test device", NULL,
425                                              EV_KEY, BTN_LEFT,
426                                              EV_KEY, BTN_RIGHT,
427                                              EV_REL, REL_X,
428                                              EV_REL, REL_Y,
429                                              -1);
430
431         li = libinput_path_create_context(&simple_interface, userdata);
432         ck_assert(li != NULL);
433
434         device = libinput_path_add_device(li,
435                                           libevdev_uinput_get_devnode(uinput));
436         ck_assert(device != NULL);
437
438         libinput_suspend(li);
439         libinput_resume(li);
440         libinput_resume(li);
441
442         libevdev_uinput_destroy(uinput);
443         libinput_unref(li);
444
445         open_func_count = 0;
446         close_func_count = 0;
447 }
448 END_TEST
449
450 START_TEST(path_add_device_suspend_resume)
451 {
452         struct libinput *li;
453         struct libinput_device *device;
454         struct libinput_event *event;
455         struct libevdev_uinput *uinput1, *uinput2;
456         int rc;
457         int nevents;
458         void *userdata = &rc;
459
460         uinput1 = litest_create_uinput_device("test device", NULL,
461                                               EV_KEY, BTN_LEFT,
462                                               EV_KEY, BTN_RIGHT,
463                                               EV_REL, REL_X,
464                                               EV_REL, REL_Y,
465                                               -1);
466         uinput2 = litest_create_uinput_device("test device 2", NULL,
467                                               EV_KEY, BTN_LEFT,
468                                               EV_KEY, BTN_RIGHT,
469                                               EV_REL, REL_X,
470                                               EV_REL, REL_Y,
471                                               -1);
472
473         li = libinput_path_create_context(&simple_interface, userdata);
474         ck_assert(li != NULL);
475
476         device = libinput_path_add_device(li,
477                                           libevdev_uinput_get_devnode(uinput1));
478         ck_assert(device != NULL);
479         device = libinput_path_add_device(li,
480                                           libevdev_uinput_get_devnode(uinput2));
481
482         libinput_dispatch(li);
483
484         nevents = 0;
485         while ((event = libinput_get_event(li))) {
486                 enum libinput_event_type type;
487                 type = libinput_event_get_type(event);
488                 ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_ADDED);
489                 libinput_event_destroy(event);
490                 nevents++;
491         }
492
493         ck_assert_int_eq(nevents, 2);
494
495
496         libinput_suspend(li);
497         libinput_dispatch(li);
498
499         nevents = 0;
500         while ((event = libinput_get_event(li))) {
501                 enum libinput_event_type type;
502                 type = libinput_event_get_type(event);
503                 ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_REMOVED);
504                 libinput_event_destroy(event);
505                 nevents++;
506         }
507
508         ck_assert_int_eq(nevents, 2);
509
510         libinput_resume(li);
511         libinput_dispatch(li);
512
513         nevents = 0;
514         while ((event = libinput_get_event(li))) {
515                 enum libinput_event_type type;
516                 type = libinput_event_get_type(event);
517                 ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_ADDED);
518                 libinput_event_destroy(event);
519                 nevents++;
520         }
521
522         ck_assert_int_eq(nevents, 2);
523
524         libevdev_uinput_destroy(uinput1);
525         libevdev_uinput_destroy(uinput2);
526         libinput_unref(li);
527
528         open_func_count = 0;
529         close_func_count = 0;
530 }
531 END_TEST
532
533 START_TEST(path_add_device_suspend_resume_fail)
534 {
535         struct libinput *li;
536         struct libinput_device *device;
537         struct libinput_event *event;
538         struct libevdev_uinput *uinput1, *uinput2;
539         int rc;
540         int nevents;
541         void *userdata = &rc;
542
543         uinput1 = litest_create_uinput_device("test device", NULL,
544                                               EV_KEY, BTN_LEFT,
545                                               EV_KEY, BTN_RIGHT,
546                                               EV_REL, REL_X,
547                                               EV_REL, REL_Y,
548                                               -1);
549         uinput2 = litest_create_uinput_device("test device 2", NULL,
550                                               EV_KEY, BTN_LEFT,
551                                               EV_KEY, BTN_RIGHT,
552                                               EV_REL, REL_X,
553                                               EV_REL, REL_Y,
554                                               -1);
555
556         li = libinput_path_create_context(&simple_interface, userdata);
557         ck_assert(li != NULL);
558
559         device = libinput_path_add_device(li,
560                                           libevdev_uinput_get_devnode(uinput1));
561         ck_assert(device != NULL);
562         device = libinput_path_add_device(li,
563                                           libevdev_uinput_get_devnode(uinput2));
564         ck_assert(device != NULL);
565
566         libinput_dispatch(li);
567
568         nevents = 0;
569         while ((event = libinput_get_event(li))) {
570                 enum libinput_event_type type;
571                 type = libinput_event_get_type(event);
572                 ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_ADDED);
573                 libinput_event_destroy(event);
574                 nevents++;
575         }
576
577         ck_assert_int_eq(nevents, 2);
578
579
580         libinput_suspend(li);
581         libinput_dispatch(li);
582
583         nevents = 0;
584         while ((event = libinput_get_event(li))) {
585                 enum libinput_event_type type;
586                 type = libinput_event_get_type(event);
587                 ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_REMOVED);
588                 libinput_event_destroy(event);
589                 nevents++;
590         }
591
592         ck_assert_int_eq(nevents, 2);
593
594         /* now drop one of the devices */
595         libevdev_uinput_destroy(uinput1);
596         rc = libinput_resume(li);
597         ck_assert_int_eq(rc, -1);
598
599         libinput_dispatch(li);
600
601         nevents = 0;
602         while ((event = libinput_get_event(li))) {
603                 enum libinput_event_type type;
604                 type = libinput_event_get_type(event);
605                 /* We expect one device being added, second one fails,
606                  * causing a removed event for the first one */
607                 if (type != LIBINPUT_EVENT_DEVICE_ADDED &&
608                     type != LIBINPUT_EVENT_DEVICE_REMOVED)
609                         ck_abort();
610                 libinput_event_destroy(event);
611                 nevents++;
612         }
613
614         ck_assert_int_eq(nevents, 2);
615
616         libevdev_uinput_destroy(uinput2);
617         libinput_unref(li);
618
619         open_func_count = 0;
620         close_func_count = 0;
621 }
622 END_TEST
623
624 START_TEST(path_add_device_suspend_resume_remove_device)
625 {
626         struct libinput *li;
627         struct libinput_device *device;
628         struct libinput_event *event;
629         struct libevdev_uinput *uinput1, *uinput2;
630         int rc;
631         int nevents;
632         void *userdata = &rc;
633
634         uinput1 = litest_create_uinput_device("test device", NULL,
635                                               EV_KEY, BTN_LEFT,
636                                               EV_KEY, BTN_RIGHT,
637                                               EV_REL, REL_X,
638                                               EV_REL, REL_Y,
639                                               -1);
640         uinput2 = litest_create_uinput_device("test device 2", NULL,
641                                               EV_KEY, BTN_LEFT,
642                                               EV_KEY, BTN_RIGHT,
643                                               EV_REL, REL_X,
644                                               EV_REL, REL_Y,
645                                               -1);
646
647         li = libinput_path_create_context(&simple_interface, userdata);
648         ck_assert(li != NULL);
649
650         device = libinput_path_add_device(li,
651                                           libevdev_uinput_get_devnode(uinput1));
652         ck_assert(device != NULL);
653         device = libinput_path_add_device(li,
654                                           libevdev_uinput_get_devnode(uinput2));
655
656         libinput_device_ref(device);
657         libinput_dispatch(li);
658
659         nevents = 0;
660         while ((event = libinput_get_event(li))) {
661                 enum libinput_event_type type;
662                 type = libinput_event_get_type(event);
663                 ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_ADDED);
664                 libinput_event_destroy(event);
665                 nevents++;
666         }
667
668         ck_assert_int_eq(nevents, 2);
669
670
671         libinput_suspend(li);
672         libinput_dispatch(li);
673
674         nevents = 0;
675         while ((event = libinput_get_event(li))) {
676                 enum libinput_event_type type;
677                 type = libinput_event_get_type(event);
678                 ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_REMOVED);
679                 libinput_event_destroy(event);
680                 nevents++;
681         }
682
683         ck_assert_int_eq(nevents, 2);
684
685         /* now drop and remove one of the devices */
686         libevdev_uinput_destroy(uinput2);
687         libinput_path_remove_device(device);
688         libinput_device_unref(device);
689
690         rc = libinput_resume(li);
691         ck_assert_int_eq(rc, 0);
692
693         libinput_dispatch(li);
694
695         nevents = 0;
696         while ((event = libinput_get_event(li))) {
697                 enum libinput_event_type type;
698                 type = libinput_event_get_type(event);
699                 ck_assert_int_eq(type, LIBINPUT_EVENT_DEVICE_ADDED);
700                 libinput_event_destroy(event);
701                 nevents++;
702         }
703
704         ck_assert_int_eq(nevents, 1);
705
706         libevdev_uinput_destroy(uinput1);
707         libinput_unref(li);
708
709         open_func_count = 0;
710         close_func_count = 0;
711 }
712 END_TEST
713
714 START_TEST(path_seat_recycle)
715 {
716         struct libinput *li;
717         struct libevdev_uinput *uinput;
718         int rc;
719         void *userdata = &rc;
720         struct libinput_event *ev;
721         struct libinput_device *device;
722         struct libinput_seat *saved_seat = NULL;
723         struct libinput_seat *seat;
724         int data = 0;
725         int found = 0;
726         void *user_data;
727
728         uinput = litest_create_uinput_device("test device", NULL,
729                                              EV_KEY, BTN_LEFT,
730                                              EV_KEY, BTN_RIGHT,
731                                              EV_REL, REL_X,
732                                              EV_REL, REL_Y,
733                                              -1);
734
735         li = libinput_path_create_context(&simple_interface, userdata);
736         ck_assert(li != NULL);
737
738         device = libinput_path_add_device(li,
739                                           libevdev_uinput_get_devnode(uinput));
740         ck_assert(device != NULL);
741
742         libinput_dispatch(li);
743         while ((ev = libinput_get_event(li))) {
744                 switch (libinput_event_get_type(ev)) {
745                 case LIBINPUT_EVENT_DEVICE_ADDED:
746                         if (saved_seat)
747                                 break;
748
749                         device = libinput_event_get_device(ev);
750                         ck_assert(device != NULL);
751                         saved_seat = libinput_device_get_seat(device);
752                         libinput_seat_set_user_data(saved_seat, &data);
753                         libinput_seat_ref(saved_seat);
754                         break;
755                 default:
756                         break;
757                 }
758
759                 libinput_event_destroy(ev);
760         }
761
762         ck_assert(saved_seat != NULL);
763
764         libinput_suspend(li);
765
766         litest_drain_events(li);
767
768         libinput_resume(li);
769
770         libinput_dispatch(li);
771         while ((ev = libinput_get_event(li))) {
772                 switch (libinput_event_get_type(ev)) {
773                 case LIBINPUT_EVENT_DEVICE_ADDED:
774                         device = libinput_event_get_device(ev);
775                         ck_assert(device != NULL);
776
777                         seat = libinput_device_get_seat(device);
778                         user_data = libinput_seat_get_user_data(seat);
779                         if (user_data == &data) {
780                                 found = 1;
781                                 ck_assert(seat == saved_seat);
782                         }
783                         break;
784                 default:
785                         break;
786                 }
787
788                 libinput_event_destroy(ev);
789         }
790
791         ck_assert(found == 1);
792
793         libinput_unref(li);
794
795         libevdev_uinput_destroy(uinput);
796 }
797 END_TEST
798
799 int main (int argc, char **argv) {
800
801         litest_add("path:create", path_create_NULL, LITEST_ANY, LITEST_ANY);
802         litest_add("path:create", path_create_invalid, LITEST_ANY, LITEST_ANY);
803         litest_add("path:create", path_create_destroy, LITEST_ANY, LITEST_ANY);
804         litest_add("path:suspend", path_suspend, LITEST_ANY, LITEST_ANY);
805         litest_add("path:suspend", path_double_suspend, LITEST_ANY, LITEST_ANY);
806         litest_add("path:suspend", path_double_resume, LITEST_ANY, LITEST_ANY);
807         litest_add("path:suspend", path_add_device_suspend_resume, LITEST_ANY, LITEST_ANY);
808         litest_add("path:suspend", path_add_device_suspend_resume_fail, LITEST_ANY, LITEST_ANY);
809         litest_add("path:suspend", path_add_device_suspend_resume_remove_device, LITEST_ANY, LITEST_ANY);
810         litest_add("path:seat events", path_added_seat, LITEST_ANY, LITEST_ANY);
811         litest_add("path:device events", path_added_device, LITEST_ANY, LITEST_ANY);
812         litest_add("path:device events", path_device_sysname, LITEST_ANY, LITEST_ANY);
813         litest_add("path:device events", path_add_device, LITEST_ANY, LITEST_ANY);
814         litest_add("path:device events", path_add_invalid_path, LITEST_ANY, LITEST_ANY);
815         litest_add("path:device events", path_remove_device, LITEST_ANY, LITEST_ANY);
816         litest_add("path:device events", path_double_remove_device, LITEST_ANY, LITEST_ANY);
817         litest_add("path:seat", path_seat_recycle,
818                    LITEST_DISABLE_DEVICE, LITEST_DISABLE_DEVICE);
819
820         return litest_run(argc, argv);
821 }