summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJason Ekstrand <jason@jlekstrand.net>2013-01-11 21:01:47 -0600
committerKristian Høgsberg <krh@bitplanet.net>2013-01-15 14:05:27 -0500
commit2423497b999c999528a7d2380a13fcb3e3412d0a (patch)
tree3428a59502eda4bbba3bd320bc856a0a41bd0d49 /tests
parent31511d0ea08e9419bf6a3169ea196a551b4a94be (diff)
Add a destroy signal to the wl_event_loop object
Diffstat (limited to 'tests')
-rw-r--r--tests/event-loop-test.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/tests/event-loop-test.c b/tests/event-loop-test.c
index 2f3dcd4..c46d3b0 100644
--- a/tests/event-loop-test.c
+++ b/tests/event-loop-test.c
@@ -1,5 +1,6 @@
/*
* Copyright © 2012 Intel Corporation
+ * Copyright © 2012 Jason Ekstrand
*
* Permission to use, copy, modify, distribute, and sell this software and its
* documentation for any purpose is hereby granted without fee, provided that
@@ -25,6 +26,7 @@
#include <unistd.h>
#include <signal.h>
#include "wayland-server.h"
+#include "wayland-private.h"
#include "test-runner.h"
static int
@@ -190,3 +192,58 @@ TEST(event_loop_timer)
wl_event_source_remove(source);
wl_event_loop_destroy(loop);
}
+
+struct event_loop_destroy_listener {
+ struct wl_listener listener;
+ int done;
+};
+
+static void
+event_loop_destroy_notify(struct wl_listener *l, void *data)
+{
+ struct event_loop_destroy_listener *listener =
+ container_of(l, struct event_loop_destroy_listener, listener);
+
+ listener->done = 1;
+}
+
+TEST(event_loop_destroy)
+{
+ struct wl_event_loop *loop;
+ struct wl_display * display;
+ struct event_loop_destroy_listener a, b;
+
+ loop = wl_event_loop_create();
+ assert(loop);
+
+ a.listener.notify = &event_loop_destroy_notify;
+ a.done = 0;
+ wl_event_loop_add_destroy_listener(loop, &a.listener);
+
+ assert(wl_event_loop_get_destroy_listener(loop,
+ event_loop_destroy_notify) == &a.listener);
+
+ b.listener.notify = &event_loop_destroy_notify;
+ b.done = 0;
+ wl_event_loop_add_destroy_listener(loop, &b.listener);
+
+ wl_list_remove(&a.listener.link);
+ wl_event_loop_destroy(loop);
+
+ assert(!a.done);
+ assert(b.done);
+
+ /* Test to make sure it gets fired on display destruction */
+ display = wl_display_create();
+ assert(display);
+ loop = wl_display_get_event_loop(display);
+ assert(loop);
+
+ a.done = 0;
+ wl_event_loop_add_destroy_listener(loop, &a.listener);
+
+ wl_display_destroy(display);
+
+ assert(a.done);
+}
+