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 <jad...@gmail.com>
---
 test/touch.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/test/touch.c b/test/touch.c
index e1a8146..ae881b0 100644
--- a/test/touch.c
+++ b/test/touch.c
@@ -292,6 +292,54 @@ START_TEST(touch_seat_slot_drop)
 }
 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;
+
+       dev = litest_current_device();
+       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)
 {
@@ -299,6 +347,7 @@ main(int argc, char **argv)
        litest_add_no_device("touch:abs-transform", touch_abs_transform);
        litest_add_no_device("touch:seat-slot", touch_seat_slots);
        litest_add_no_device("touch:seat-slot-drop", touch_seat_slot_drop);
+       litest_add("touch:many-slots", touch_many_slots, LITEST_TOUCH, 
LITEST_ANY);
 
        return litest_run(argc, argv);
 }
-- 
1.8.3.2

_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to