[PATCH weston 5/9] tests: Add weston test client helper methods

Pekka Paalanen ppaalanen at gmail.com
Wed Dec 5 00:42:44 PST 2012


On Tue,  4 Dec 2012 14:22:11 -0800
"U. Artie Eoff" <ullysses.a.eoff at intel.com> wrote:

> From: "U. Artie Eoff" <ullysses.a.eoff at intel.com>
> 
> Add client boiler plate methods to simplify writing tests that use
> the weston test extension.
> 
> Signed-off-by: U. Artie Eoff <ullysses.a.eoff at intel.com>
> ---
>  tests/weston-test-client-helper.c | 488 ++++++++++++++++++++++++++++++++++++++
>  tests/weston-test-client-helper.h | 109 +++++++++
>  2 files changed, 597 insertions(+)
>  create mode 100644 tests/weston-test-client-helper.c
>  create mode 100644 tests/weston-test-client-helper.h
> 
> diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c
> new file mode 100644
> index 0000000..1859356
> --- /dev/null
> +++ b/tests/weston-test-client-helper.c
> @@ -0,0 +1,488 @@
> +/*
> + * Copyright © 2012 Intel Corporation
> + *
> + * Permission to use, copy, modify, distribute, and sell this software and its
> + * documentation for any purpose is hereby granted without fee, provided that
> + * the above copyright notice appear in all copies and that both that copyright
> + * notice and this permission notice appear in supporting documentation, and
> + * that the name of the copyright holders not be used in advertising or
> + * publicity pertaining to distribution of the software without specific,
> + * written prior permission.  The copyright holders make no representations
> + * about the suitability of this software for any purpose.  It is provided "as
> + * is" without express or implied warranty.
> + *
> + * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
> + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
> + * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
> + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
> + * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
> + * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
> + * OF THIS SOFTWARE.
> + */
> +
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <unistd.h>
> +#include <sys/mman.h>
> +
> +#include "../shared/os-compatibility.h"
> +#include "weston-test-client-helper.h"
> +
> +int
> +surface_contains(struct surface *surface, int x, int y)
> +{
> +	/* test whether a global x,y point is contained in the surface */
> +	int sx = surface->x;
> +	int sy = surface->y;
> +	int sw = surface->width;
> +	int sh = surface->height;
> +	return x >= sx && y >= sy && x < sx + sw && y < sy + sh;
> +}
> +
> +void
> +yield(struct client *client)
> +{
> +	/*
> +	 * FIXME: ugh! how do we ensure all events have finished
> +	 * propagating to the client.  The calls to usleep seem to do a
> +	 * pretty reasonable job... and without them, tests can fail
> +	 * intermittently.
> +	 */
> +	usleep(0.02 * 1e6);
> +	wl_display_flush(client->wl_display);
> +	wl_display_roundtrip(client->wl_display);
> +	usleep(0.02 * 1e6);

Hi Artie,

am I guessing the problem here right?

A roundtrip is not enough, because Weston does some of the processing
only during output repaint, like updating surface transforms and
something about input. Therefore you really want to wait until the next
repaint has completed (and hit the screen?).

Maybe you could add a callback request in the test protocol extension,
that works like roundtrip, except it is triggered only after repaint in
the compositor? Kind of like the frame callback, except without the
surface.

> +}
> +
> +void
> +move_pointer(struct client *client, int x, int y)
> +{
> +	wl_test_move_pointer(client->test->wl_test, x, y);
> +
> +	yield(client);
> +}
> +
> +void
> +move_client(struct client *client, int x, int y)
> +{
> +	struct surface *surface = client->surface;
> +
> +	client->surface->x = x;
> +	client->surface->y = y;
> +	wl_test_move_surface(client->test->wl_test, surface->wl_surface,
> +			     surface->x, surface->y);
> +	wl_surface_damage(surface->wl_surface, 0, 0, surface->width,
> +			  surface->height);
> +	wl_surface_commit(surface->wl_surface);
> +
> +	yield(client);
> +	yield(client);
> +}


Thanks,
pq


More information about the wayland-devel mailing list