[PATCH weston 6/8] tests: Support weston_test request for adding a test seat

Pekka Paalanen ppaalanen at gmail.com
Wed Jan 31 14:29:05 UTC 2018


On Fri, 26 Jan 2018 18:48:00 +0200
Alexandros Frantzis <alexandros.frantzis at collabora.com> wrote:

> Support adding a test seat using the weston_test.device_add request.
> This will be used in tests in upcoming commits where we will need to
> re-add the seat after having it removed.
> 
> We only support one test seat at the moment, so this commit also
> introduces checks to ensure the client doesn't try to create multiple
> test seats or try to remove an already removed test seat.
> 
> Signed-off-by: Alexandros Frantzis <alexandros.frantzis at collabora.com>
> ---
>  tests/weston-test.c | 32 +++++++++++++++++++++++++-------
>  1 file changed, 25 insertions(+), 7 deletions(-)
> 
> diff --git a/tests/weston-test.c b/tests/weston-test.c
> index 80b3d65b..9a2fd286 100644
> --- a/tests/weston-test.c
> +++ b/tests/weston-test.c
> @@ -50,6 +50,7 @@ struct weston_test {
>  	struct weston_layer layer;
>  	struct weston_process process;
>  	struct weston_seat seat;
> +	bool is_seat_initialized;
>  };
>  
>  struct weston_test_surface {
> @@ -76,6 +77,22 @@ test_client_sigchld(struct weston_process *process, int status)
>  	wl_display_terminate(test->compositor->wl_display);
>  }
>  
> +static int
> +test_seat_init(struct weston_test *test)
> +{
> +	/* create our own seat */
> +	weston_seat_init(&test->seat, test->compositor, "test-seat");
> +	test->is_seat_initialized = true;
> +
> +	/* add devices */
> +	weston_seat_init_pointer(&test->seat);
> +	if (weston_seat_init_keyboard(&test->seat, NULL) < 0)
> +		return -1;
> +	weston_seat_init_touch(&test->seat);
> +
> +	return 0;
> +}
> +
>  static struct weston_seat *
>  get_seat(struct weston_test *test)
>  {
> @@ -253,7 +270,10 @@ device_release(struct wl_client *client,
>  	} else if (strcmp(device, "touch") == 0) {
>  		weston_seat_release_touch(seat);
>  	} else if (strcmp(device, "seat") == 0) {
> +		assert(test->is_seat_initialized &&
> +		       "Trying to release already released test seat");
>  		weston_seat_release(seat);
> +		test->is_seat_initialized = false;
>  	} else {
>  		assert(0 && "Unsupported device");
>  	}
> @@ -272,6 +292,10 @@ device_add(struct wl_client *client,
>  		weston_seat_init_keyboard(seat, NULL);
>  	} else if (strcmp(device, "touch") == 0) {
>  		weston_seat_init_touch(seat);
> +	} else if (strcmp(device, "seat") == 0) {
> +		assert(!test->is_seat_initialized &&
> +		       "Trying to add already added test seat");
> +		test_seat_init(test);
>  	} else {
>  		assert(0 && "Unsupported device");
>  	}
> @@ -611,14 +635,8 @@ wet_module_init(struct weston_compositor *ec,
>  			     test, bind_test) == NULL)
>  		return -1;
>  
> -	/* create our own seat */
> -	weston_seat_init(&test->seat, ec, "test-seat");
> -
> -	/* add devices */
> -	weston_seat_init_pointer(&test->seat);
> -	if (weston_seat_init_keyboard(&test->seat, NULL) < 0)
> +	if (test_seat_init(test) == -1)
>  		return -1;
> -	weston_seat_init_touch(&test->seat);
>  
>  	loop = wl_display_get_event_loop(ec->wl_display);
>  	wl_event_loop_add_idle(loop, idle_launch_client, test);

Looks good.

Reviewed-by: Pekka Paalanen <pekka.paalanen at collabora.co.uk>


Thanks,
pq
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/wayland-devel/attachments/20180131/e9e0bfae/attachment-0001.sig>


More information about the wayland-devel mailing list