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 <emilio.pozuelo@collabora.co.uk>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Reviewed-by: Daniel Stone <daniels@collabora.com>
dev
Emilio Pozuelo Monfort 8 years ago committed by Daniel Stone
parent 85d55540cb
commit 5c3f3575d5
  1. 29
      tests/weston-test-client-helper.c
  2. 3
      tests/weston-test-client-helper.h

@ -864,18 +864,13 @@ create_client(void)
return client; return client;
} }
struct client * struct surface *
create_client_and_test_surface(int x, int y, int width, int height) create_test_surface(struct client *client)
{ {
struct client *client;
struct surface *surface; 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 = xzalloc(sizeof *surface);
surface->wl_surface = surface->wl_surface =
wl_compositor_create_surface(client->wl_compositor); wl_compositor_create_surface(client->wl_compositor);
assert(surface->wl_surface); 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, wl_surface_add_listener(surface->wl_surface, &surface_listener,
surface); surface);
client->surface = surface;
wl_surface_set_user_data(surface->wl_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->width = width;
surface->height = height; surface->height = height;
surface->buffer = create_shm_buffer_a8r8g8b8(client, width, height); surface->buffer = create_shm_buffer_a8r8g8b8(client, width, height);

@ -155,6 +155,9 @@ struct rectangle {
struct client * struct client *
create_client(void); create_client(void);
struct surface *
create_test_surface(struct client *client);
struct client * struct client *
create_client_and_test_surface(int x, int y, int width, int height); create_client_and_test_surface(int x, int y, int width, int height);

Loading…
Cancel
Save