[PATCH libinput 4/8] test: Test handling of many touch points

Peter Hutterer peter.hutterer at who-t.net
Wed Mar 26 01:32:21 PDT 2014


On Wed, Mar 26, 2014 at 09:24:08AM +0100, Jonas Ådahl wrote:
> On Wed, Mar 26, 2014 at 06:02:46PM +1000, Peter Hutterer wrote:
> > On Tue, Mar 25, 2014 at 09:45:55PM +0100, Jonas Ådahl wrote:
> > > 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 at gmail.com>
> > > ---
> > >  test/touch.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 50 insertions(+)
> > > 
> > > diff --git a/test/touch.c b/test/touch.c
> > > index 9354c25..61d8762 100644
> > > --- a/test/touch.c
> > > +++ b/test/touch.c
> > > @@ -275,6 +275,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)
> > >  {
> > > @@ -283,6 +331,8 @@ main(int argc, char **argv)
> > >  		   LITEST_TOUCH, LITEST_ANY);
> > >  	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);
> > 
> > even though it breaks the 80 char width, I'd really prefer it if the tests
> > would just be on one line, it's a lot easier to view them on screens that
> > are less than 10 years old :)
> 
> I tend to use vertical split screen on a laptop and in those cases 80
> char length limit makes code more readable. I guess I could change it to
> ignore the 80 char limit for test case adding lines, albeit reluctantly.

thanks. I'm not proposing to change it for the rest of the code, but it really
makes the code nicer to look at. this isn't code that gets edited
frequently, so the exception shouldn't hurt too much.

Cheers,
   Peter


More information about the wayland-devel mailing list