test: Test handling of many touch points
authorJonas Ådahl <jadahl@gmail.com>
Mon, 24 Mar 2014 21:37:00 +0000 (22:37 +0100)
committerJonas Ådahl <jadahl@gmail.com>
Tue, 22 Apr 2014 22:07:37 +0000 (00:07 +0200)
libinput currently handles 16 per device touch points. Test that we
behave as expected when a device has an even higher number of active
touch points.

Signed-off-by: Jonas Ådahl <jadahl@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
test/touch.c

index 27eb143ce42a91619ff70ff48cb5478d7474a419..e2a5a4e310fc473bb554366519573445351c16fe 100644 (file)
@@ -113,11 +113,66 @@ START_TEST(touch_abs_transform)
 END_TEST
 
 
+START_TEST(touch_many_slots)
+{
+       struct libinput *libinput;
+       struct litest_device *dev;
+       struct libinput_event *ev;
+       int slot;
+       const int num_tps = 100;
+       int slot_count = 0;
+       enum libinput_event_type type;
+
+       struct input_absinfo abs[] = {
+               { ABS_MT_SLOT, 0, num_tps - 1, 0, 0, 0 },
+               { .value = -1 },
+       };
+
+       dev = litest_create_device_with_overrides(LITEST_WACOM_TOUCH,
+                                                 "Multi-touch device",
+                                                 NULL, abs, NULL);
+       libinput = dev->libinput;
+
+       for (slot = 0; slot < num_tps; ++slot)
+               litest_touch_down(dev, slot, 0, 0);
+       for (slot = 0; slot < num_tps; ++slot)
+               litest_touch_up(dev, slot);
+
+       libinput_dispatch(libinput);
+       while ((ev = libinput_get_event(libinput))) {
+               type = libinput_event_get_type(ev);
+
+               if (type == LIBINPUT_EVENT_TOUCH_DOWN)
+                       slot_count++;
+               else if (type == LIBINPUT_EVENT_TOUCH_UP)
+                       break;
+
+               libinput_dispatch(libinput);
+       }
+
+       ck_assert_notnull(ev);
+       ck_assert_int_gt(slot_count, 0);
+
+       libinput_dispatch(libinput);
+       do {
+               type = libinput_event_get_type(ev);
+               ck_assert_int_ne(type, LIBINPUT_EVENT_TOUCH_DOWN);
+               if (type == LIBINPUT_EVENT_TOUCH_UP)
+                       slot_count--;
+
+               libinput_dispatch(libinput);
+       } while ((ev = libinput_get_event(libinput)));
+
+       ck_assert_int_eq(slot_count, 0);
+}
+END_TEST
+
 int
 main(int argc, char **argv)
 {
        litest_add("touch:frame", touch_frame_events, LITEST_TOUCH, LITEST_ANY);
        litest_add_no_device("touch:abs-transform", touch_abs_transform);
+       litest_add_no_device("touch:many-slots", touch_many_slots);
 
        return litest_run(argc, argv);
 }