[PATCH weston v1 16/17] test-helpers: add functions that simulate pointer actions

Derek Foreman derekf at osg.samsung.com
Tue Dec 9 12:40:24 PST 2014


On 05/12/14 07:36 AM, Marek Chalupa wrote:
> Add functions that simulate pointer movement, draging and clicking.
> These functions will be handy in more tests, so add them to helpers.
> 
> Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
> ---
>  tests/weston-test-client-helper.c | 57 +++++++++++++++++++++++++++++++++++++++
>  tests/weston-test-client-helper.h |  9 +++++++
>  2 files changed, 66 insertions(+)
> 
> diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c
> index dc34fc4..7f7f4f5 100644
> --- a/tests/weston-test-client-helper.c
> +++ b/tests/weston-test-client-helper.c
> @@ -28,6 +28,7 @@
>  #include <unistd.h>
>  #include <errno.h>
>  #include <sys/mman.h>
> +#include <linux/input.h>
>  
>  #include "../shared/os-compatibility.h"
>  #include "../clients/window.h"
> @@ -130,6 +131,62 @@ move_client(struct client *client, int x, int y)
>  	}
>  }
>  
> +void
> +pointer_simulate_move(struct client *client, int x1, int y1, int x2, int y2)
> +{
> +	struct wl_test *wl_test = client->test->wl_test;
> +
> +	wl_test_move_pointer(wl_test, x1, y1);
> +	client_roundtrip(client);
> +
> +	while (x1 != x2 || y1 != y2) {
> +		if (x2 < x1)
> +			--x1;
> +		else if (x2 > x1)
> +			++x1;
> +
> +		if (y2 < y1)
> +			--y1;
> +		else if (y2 > y1)
> +			++y1;
> +
> +		wl_test_move_pointer(wl_test, x1, y1);
> +		client_roundtrip(client);
> +	}
> +}
> +
> +void
> +pointer_simulate_drag(struct client *client, int x1, int y1, int x2, int y2)
> +{
> +	struct wl_test *wl_test = client->test->wl_test;
> +
> +	pointer_simulate_move(client, x1 - 50, y1 - 50, x1, y1);
> +
> +	wl_test_send_button(wl_test, BTN_LEFT, WL_POINTER_BUTTON_STATE_PRESSED);
> +	client_roundtrip(client);
> +
> +	pointer_simulate_move(client, x1, y1, x2, y2);
> +
> +	wl_test_send_button(wl_test, BTN_LEFT, WL_POINTER_BUTTON_STATE_RELEASED);
> +	client_roundtrip(client);
> +}
> +
> +#define MSEC_TO_USEC(n) ((n) * 1000)

Not sure I like the #define here...  but that's just me


More information about the wayland-devel mailing list