2 * Copyright © 2012 Intel Corporation
4 * Permission to use, copy, modify, distribute, and sell this software and its
5 * documentation for any purpose is hereby granted without fee, provided that
6 * the above copyright notice appear in all copies and that both that copyright
7 * notice and this permission notice appear in supporting documentation, and
8 * that the name of the copyright holders not be used in advertising or
9 * publicity pertaining to distribution of the software without specific,
10 * written prior permission. The copyright holders make no representations
11 * about the suitability of this software for any purpose. It is provided "as
12 * is" without express or implied warranty.
14 * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
15 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
16 * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
17 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
18 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
19 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
28 #include <sys/socket.h>
31 #include <sys/types.h>
34 #include "../src/wayland-server.h"
35 #include "test-runner.h"
37 struct client_destroy_listener {
38 struct wl_listener listener;
43 client_destroy_notify(struct wl_listener *l, void *data)
45 struct client_destroy_listener *listener =
46 container_of(l, struct client_destroy_listener, listener);
51 TEST(client_destroy_listener)
53 struct wl_display *display;
54 struct wl_client *client;
55 struct client_destroy_listener a, b;
58 assert(socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, s) == 0);
59 display = wl_display_create();
61 client = wl_client_create(display, s[0]);
64 a.listener.notify = client_destroy_notify;
66 wl_client_add_destroy_listener(client, &a.listener);
68 assert(wl_client_get_destroy_listener(client, client_destroy_notify) ==
71 b.listener.notify = client_destroy_notify;
73 wl_client_add_destroy_listener(client, &b.listener);
75 wl_list_remove(&a.listener.link);
77 wl_client_destroy(client);
85 wl_display_destroy(display);