[PATCH 10/11] test: Add litest_button_scroll helper function

Peter Hutterer peter.hutterer at who-t.net
Thu Nov 6 18:00:49 PST 2014


On Thu, Nov 06, 2014 at 04:37:39PM +0100, Hans de Goede wrote:
> Turn test_trackpoint_scroll into a generic helper function for testing
> "button scrolling".
> 
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
>  test/litest.c     | 28 ++++++++++++++++++++++++++++
>  test/litest.h     |  3 +++
>  test/trackpoint.c | 40 +++++++---------------------------------
>  3 files changed, 38 insertions(+), 33 deletions(-)
> 
> diff --git a/test/litest.c b/test/litest.c
> index dc6a630..92a0535 100644
> --- a/test/litest.c
> +++ b/test/litest.c
> @@ -792,6 +792,34 @@ litest_button_click(struct litest_device *d, unsigned int button, bool is_press)
>  }
>  
>  void
> +litest_button_scroll(struct litest_device *dev,
> +		     unsigned int button,
> +		     double dx, double dy)
> +{
> +	struct libinput *li = dev->libinput;
> +
> +	litest_button_click(dev, button, 1);
> +
> +	libinput_dispatch(li);
> +	msleep(300);

while you're at it, please either add a comment here or a
litest_timeout_foo() helper.

Rest of the series looks good, most of this is only minor nitpicks anyway.
Thanks.

Cheers,
   Peter

> +	libinput_dispatch(li);
> +
> +	/* Send two deltas, as the first one may be eaten up by an
> +	 * acceleration filter. */
> +	litest_event(dev, EV_REL, REL_X, dx);
> +	litest_event(dev, EV_REL, REL_Y, dy);
> +	litest_event(dev, EV_SYN, SYN_REPORT, 0);
> +
> +	litest_event(dev, EV_REL, REL_X, dx);
> +	litest_event(dev, EV_REL, REL_Y, dy);
> +	litest_event(dev, EV_SYN, SYN_REPORT, 0);
> +
> +	litest_button_click(dev, button, 0);
> +
> +	libinput_dispatch(li);
> +}
> +
> +void
>  litest_keyboard_key(struct litest_device *d, unsigned int key, bool is_press)
>  {
>  	litest_button_click(d, key, is_press);
> diff --git a/test/litest.h b/test/litest.h
> index 173d0f4..8e3c323 100644
> --- a/test/litest.h
> +++ b/test/litest.h
> @@ -140,6 +140,9 @@ void litest_touch_move_to(struct litest_device *d,
>  void litest_button_click(struct litest_device *d,
>  			 unsigned int button,
>  			 bool is_press);
> +void litest_button_scroll(struct litest_device *d,
> +			 unsigned int button,
> +			 double dx, double dy);
>  void litest_keyboard_key(struct litest_device *d,
>  			 unsigned int key,
>  			 bool is_press);
> diff --git a/test/trackpoint.c b/test/trackpoint.c
> index 7a36370..69c8284 100644
> --- a/test/trackpoint.c
> +++ b/test/trackpoint.c
> @@ -49,32 +49,6 @@ START_TEST(trackpoint_middlebutton)
>  }
>  END_TEST
>  
> -static void
> -test_trackpoint_scroll(struct litest_device *dev, double dx, double dy)
> -{
> -	struct libinput *li = dev->libinput;
> -
> -	litest_button_click(dev, BTN_MIDDLE, 1);
> -
> -	libinput_dispatch(li);
> -	msleep(300);
> -	libinput_dispatch(li);
> -
> -	/* Send two deltas, as the first one may be eaten up by an
> -	 * acceleration filter. */
> -	litest_event(dev, EV_REL, REL_X, dx);
> -	litest_event(dev, EV_REL, REL_Y, dy);
> -	litest_event(dev, EV_SYN, SYN_REPORT, 0);
> -
> -	litest_event(dev, EV_REL, REL_X, dx);
> -	litest_event(dev, EV_REL, REL_Y, dy);
> -	litest_event(dev, EV_SYN, SYN_REPORT, 0);
> -
> -	litest_button_click(dev, BTN_MIDDLE, 0);
> -
> -	libinput_dispatch(li);
> -}
> -
>  START_TEST(trackpoint_scroll)
>  {
>  	struct litest_device *dev = litest_current_device();
> @@ -82,19 +56,19 @@ START_TEST(trackpoint_scroll)
>  
>  	litest_drain_events(li);
>  
> -	test_trackpoint_scroll(dev, 1, 6);
> +	litest_button_scroll(dev, BTN_MIDDLE, 1, 6);
>  	litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, 6);
> -	test_trackpoint_scroll(dev, 1, -7);
> +	litest_button_scroll(dev, BTN_MIDDLE, 1, -7);
>  	litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, -7);
> -	test_trackpoint_scroll(dev, 8, 1);
> +	litest_button_scroll(dev, BTN_MIDDLE, 8, 1);
>  	litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, 8);
> -	test_trackpoint_scroll(dev, -9, 1);
> +	litest_button_scroll(dev, BTN_MIDDLE, -9, 1);
>  	litest_assert_scroll(li, LIBINPUT_POINTER_AXIS_SCROLL_HORIZONTAL, -9);
>  
>  	/* scroll smaller than the threshold should not generate events */
> -	test_trackpoint_scroll(dev, 1, 1);
> +	litest_button_scroll(dev, BTN_MIDDLE, 1, 1);
>  	/* long middle press without movement should not generate events */
> -	test_trackpoint_scroll(dev, 0, 0);
> +	litest_button_scroll(dev, BTN_MIDDLE, 0, 0);
>  
>  	litest_assert_empty_queue(li);
>  }
> @@ -113,7 +87,7 @@ START_TEST(trackpoint_middlebutton_noscroll)
>  	litest_drain_events(li);
>  
>  	/* A long middle button click + motion should get reported normally now */
> -	test_trackpoint_scroll(dev, 0, 10);
> +	litest_button_scroll(dev, BTN_MIDDLE, 0, 10);
>  
>  	litest_assert_button_event(li, BTN_MIDDLE, 1);
>  
> -- 
> 2.1.0
> 
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
> 


More information about the wayland-devel mailing list