diff options
| author | Giulio Camuffo <giuliocamuffo@gmail.com> | 2016-08-09 12:46:53 +0200 |
|---|---|---|
| committer | Pekka Paalanen <pekka.paalanen@collabora.co.uk> | 2016-08-11 15:52:15 +0300 |
| commit | 596024f728b0a1292ee69a80dd72a85167870936 (patch) | |
| tree | 4f2ea7daf3a7b3b6353f62158c2022e90b9de957 /tests | |
| parent | Add API to retrieve the interface name of a wl_resource (diff) | |
| download | wayland-596024f728b0a1292ee69a80dd72a85167870936.tar wayland-596024f728b0a1292ee69a80dd72a85167870936.tar.gz wayland-596024f728b0a1292ee69a80dd72a85167870936.tar.bz2 wayland-596024f728b0a1292ee69a80dd72a85167870936.tar.lz wayland-596024f728b0a1292ee69a80dd72a85167870936.tar.xz wayland-596024f728b0a1292ee69a80dd72a85167870936.tar.zst wayland-596024f728b0a1292ee69a80dd72a85167870936.zip | |
Add API to get the list of connected clients
This patch chooses the wl_list_for_each-style of iterating over
the clients, instead of using an iterator function, because i think
it is easier to use.
Signed-off-by: Giulio Camuffo <giulio.camuffo@kdab.com>
Reviewed-by: Jonas Ã…dahl <jadahl@gmail.com>
Reviewed-by: Pekka Paalanen <pekka.paalanen@collabora.co.uk>
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/compositor-introspection-test.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/compositor-introspection-test.c b/tests/compositor-introspection-test.c index 5d2085d..50ff1dd 100644 --- a/tests/compositor-introspection-test.c +++ b/tests/compositor-introspection-test.c @@ -58,6 +58,26 @@ client_created(struct wl_listener *listener, void *data) c->client = data; } +static void +check_client_list(struct compositor *compositor) +{ + struct wl_list *client_list; + struct wl_client *client, *client_it; + int num_clients = 0; + + client_list = wl_display_get_client_list(compositor->display); + wl_client_for_each(client_it, client_list) { + num_clients++; + client = client_it; + } + assert(num_clients == 1); + /* 'client_it' is not valid here, so we took a copy of the client in the loop. + * We could also do this assert in the loop directly, but in case it fails it is + * easier to understand the problem when we know that the previous assert passed, + * so that there is only one client but the wrong one. */ + assert(compositor->client == client); +} + TEST(new_client_connect) { const char *socket; @@ -80,6 +100,8 @@ TEST(new_client_connect) assert(compositor.client != NULL); + check_client_list(&compositor); + wl_display_disconnect(client.display); wl_client_destroy(compositor.client); |
