[PATCH weston v1 12/17] tests: make client_roundtrip universal

Pekka Paalanen ppaalanen at gmail.com
Mon Dec 15 00:20:46 PST 2014


On Fri,  5 Dec 2014 14:36:45 +0100
Marek Chalupa <mchqwerty at gmail.com> wrote:

> Make client_roundtrip a function instead of macro and
> make it work with both - normal clients and toytoolkit clients.
> 
> Signed-off-by: Marek Chalupa <mchqwerty at gmail.com>
> ---
>  tests/weston-test-client-helper.c | 17 +++++++++++++++++
>  tests/weston-test-client-helper.h |  5 ++---
>  2 files changed, 19 insertions(+), 3 deletions(-)
> 
> diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c
> index 23b2048..ae104a8 100644
> --- a/tests/weston-test-client-helper.c
> +++ b/tests/weston-test-client-helper.c
> @@ -82,6 +82,23 @@ frame_callback_wait_nofail(struct client *client, int *done)
>  }
>  
>  void
> +client_roundtrip(struct client *client)
> +{
> +	struct wl_callback *cb;
> +	int done = 0;
> +
> +	if (client->toytoolkit) {
> +		cb = wl_display_sync(client->wl_display);
> +		/* use frame_listener, it does exactly what we need */
> +		wl_callback_add_listener(cb, &frame_listener, &done);

Ahh, first I got very confused here, then realized you are simply
repurposing a variable. How about this comment instead:
/* Abuse frame_listener for the sync callback. */

Or better yet, just rename frame_listener to callback_listener.

Otherwise looks good, so with either change:
R-b: Pekka Paalanen <pekka.paalanen at collabora.co.uk>


Thanks,
pq

> +
> +		while(!done)
> +			assert(display_dispatch(client->toytoolkit->display, -1) > 0);
> +	} else
> +		assert(wl_display_roundtrip(client->wl_display) >= 0);
> +}
> +
> +void
>  move_client(struct client *client, int x, int y)
>  {
>  	struct surface *surface = client->surface;
> diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h
> index 3998c6d..bdd8cd9 100644
> --- a/tests/weston-test-client-helper.h
> +++ b/tests/weston-test-client-helper.h
> @@ -132,9 +132,8 @@ surface_contains(struct surface *surface, int x, int y);
>  void
>  move_client(struct client *client, int x, int y);
>  
> -#define client_roundtrip(c) do { \
> -	assert(wl_display_roundtrip((c)->wl_display) >= 0); \
> -} while (0)
> +void
> +client_roundtrip(struct client *client);
>  
>  struct wl_callback *
>  frame_callback_set(struct wl_surface *surface, int *done);



More information about the wayland-devel mailing list