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>
This commit is contained in:
Emilio Pozuelo Monfort 2017-02-03 16:10:37 +01:00 committed by Daniel Stone
parent 85d55540cb
commit 5c3f3575d5
2 changed files with 23 additions and 9 deletions

View File

@ -864,6 +864,25 @@ create_client(void)
return client;
}
struct surface *
create_test_surface(struct client *client)
{
struct surface *surface;
surface = xzalloc(sizeof *surface);
surface->wl_surface =
wl_compositor_create_surface(client->wl_compositor);
assert(surface->wl_surface);
wl_surface_add_listener(surface->wl_surface, &surface_listener,
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)
{
@ -875,16 +894,8 @@ create_client_and_test_surface(int x, int y, int width, int height)
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);
wl_surface_add_listener(surface->wl_surface, &surface_listener,
surface);
surface = create_test_surface(client);
client->surface = surface;
wl_surface_set_user_data(surface->wl_surface, surface);
surface->width = width;
surface->height = height;

View File

@ -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);