tests: add a create_test_surface function
authorEmilio Pozuelo Monfort <pochu27@gmail.com>
Fri, 3 Feb 2017 15:10:37 +0000 (16:10 +0100)
committerDaniel Stone <daniels@collabora.com>
Mon, 4 Dec 2017 21:58:00 +0000 (21:58 +0000)
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>
tests/weston-test-client-helper.c
tests/weston-test-client-helper.h

index fd6d5c8..ee50845 100644 (file)
@@ -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);
index a288af7..880f47a 100644 (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);