From 5c3f3575d56702c71b44b612eb3a8cdf8f674f1a Mon Sep 17 00:00:00 2001 From: Emilio Pozuelo Monfort Date: Fri, 3 Feb 2017 16:10:37 +0100 Subject: [PATCH] tests: add a create_test_surface function This doesn't attach a buffer to the surface. This is needed for the next commit, where we have a test case with a surface that doesn't have a buffer attached. Signed-off-by: Emilio Pozuelo Monfort Reviewed-by: Pekka Paalanen Reviewed-by: Daniel Stone --- tests/weston-test-client-helper.c | 29 ++++++++++++++++++++--------- tests/weston-test-client-helper.h | 3 +++ 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/tests/weston-test-client-helper.c b/tests/weston-test-client-helper.c index fd6d5c8..ee50845 100644 --- a/tests/weston-test-client-helper.c +++ b/tests/weston-test-client-helper.c @@ -864,18 +864,13 @@ create_client(void) return client; } -struct client * -create_client_and_test_surface(int x, int y, int width, int height) +struct surface * +create_test_surface(struct client *client) { - struct client *client; struct surface *surface; - pixman_color_t color = { 16384, 16384, 16384, 16384 }; /* uint16_t */ - pixman_image_t *solid; - - client = create_client(); - /* initialize the client surface */ surface = xzalloc(sizeof *surface); + surface->wl_surface = wl_compositor_create_surface(client->wl_compositor); assert(surface->wl_surface); @@ -883,9 +878,25 @@ create_client_and_test_surface(int x, int y, int width, int height) wl_surface_add_listener(surface->wl_surface, &surface_listener, surface); - client->surface = surface; wl_surface_set_user_data(surface->wl_surface, surface); + return surface; +} + +struct client * +create_client_and_test_surface(int x, int y, int width, int height) +{ + struct client *client; + struct surface *surface; + pixman_color_t color = { 16384, 16384, 16384, 16384 }; /* uint16_t */ + pixman_image_t *solid; + + client = create_client(); + + /* initialize the client surface */ + surface = create_test_surface(client); + client->surface = surface; + surface->width = width; surface->height = height; surface->buffer = create_shm_buffer_a8r8g8b8(client, width, height); diff --git a/tests/weston-test-client-helper.h b/tests/weston-test-client-helper.h index a288af7..880f47a 100644 --- a/tests/weston-test-client-helper.h +++ b/tests/weston-test-client-helper.h @@ -155,6 +155,9 @@ struct rectangle { struct client * create_client(void); +struct surface * +create_test_surface(struct client *client); + struct client * create_client_and_test_surface(int x, int y, int width, int height); -- 2.7.4