On Thu, Nov 06, 2014 at 04:37:38PM +0100, Hans de Goede wrote:
> Signed-off-by: Hans de Goede <hdego...@redhat.com>
> ---
>  test/trackpoint.c | 39 +++++++++++++++++++++++++++++++++++++++
>  1 file changed, 39 insertions(+)
> 
> diff --git a/test/trackpoint.c b/test/trackpoint.c
> index eb9ddfb..7a36370 100644
> --- a/test/trackpoint.c
> +++ b/test/trackpoint.c
> @@ -60,6 +60,12 @@ test_trackpoint_scroll(struct litest_device *dev, double 
> dx, double dy)
>       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);
> @@ -94,9 +100,42 @@ START_TEST(trackpoint_scroll)
>  }
>  END_TEST
>  
> +START_TEST(trackpoint_middlebutton_noscroll)
> +{
> +     struct litest_device *dev = litest_current_device();
> +     struct libinput *li = dev->libinput;
> +     struct libinput_event *event;
> +
> +     /* Disable middle button scrolling */
> +     libinput_device_config_scroll_set_mode(dev->libinput_device,
> +                                     LIBINPUT_CONFIG_SCROLL_NO_SCROLL);
> +
> +     litest_drain_events(li);
> +
> +     /* A long middle button click + motion should get reported normally now 
> */
> +     test_trackpoint_scroll(dev, 0, 10);
> +
> +     litest_assert_button_event(li, BTN_MIDDLE, 1);
> +
> +     event = libinput_get_event(li);
> +     ck_assert(event != NULL);
> +     ck_assert_int_eq(libinput_event_get_type(event), 
> LIBINPUT_EVENT_POINTER_MOTION);
> +
> +     litest_assert_button_event(li, BTN_MIDDLE, 0);
> +
> +     litest_assert_empty_queue(li);
> +
> +     /* Restore default scroll behavior */
> +     libinput_device_config_scroll_set_mode(dev->libinput_device,
> +             libinput_device_config_scroll_get_default_mode(
> +                     dev->libinput_device));

just in case this isn't clear to others, this isn't technically needed, the
device is destroyed after each test. what it does test though is for
potential memory leaks (all tests run through valgrind)

Cheers,
   Peter

> +}
> +END_TEST
> +
>  int main(int argc, char **argv) {
>  
>       litest_add("trackpoint:middlebutton", trackpoint_middlebutton, 
> LITEST_POINTINGSTICK, LITEST_ANY);
> +     litest_add("trackpoint:middlebutton", trackpoint_middlebutton_noscroll, 
> LITEST_POINTINGSTICK, LITEST_ANY);
>       litest_add("trackpoint:scroll", trackpoint_scroll, 
> LITEST_POINTINGSTICK, LITEST_ANY);
>  
>       return litest_run(argc, argv);
> -- 
> 2.1.0
_______________________________________________
wayland-devel mailing list
wayland-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to