diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Makefile.am | 25 | ||||
-rw-r--r-- | tests/test-simple-client.c | 30 | ||||
-rw-r--r-- | tests/test-simple-server.c | 39 | ||||
-rwxr-xr-x | tests/test_simple | 5 |
4 files changed, 87 insertions, 12 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am index 8f290f9..9f1c6d3 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,29 +1,30 @@ -DBUS_RUNNER=/home/ted/Development/dbus-fun/dbus-test-runner --dbus-config /home/ted/Development/dbus-fun/session.conf - TESTS = \ test_simple -test_simple: test_simple_c test_simple_s - $(DBUS_RUNNER) --task ./test_simple_c --task-name Client --task ./test_simple_s --task-name Server +libexec_PROGRAMS = \ + test-simple-client \ + test-simple-server + +test_simple: test-simple-client test-simple-server -test_simple_c_SOURCES = \ - test-simple-c.c +test_simple_client_SOURCES = \ + test-simple-client.c -test_simple_c_CFLAGS = \ +test_simple_client_CFLAGS = \ $(LIBINDICATE_CFLAGS) -I$(srcdir)/.. -test_simple_c_LDADD = \ +test_simple_client_LDADD = \ ../libindicate/libindicate.la \ $(LIBINDICATE_LIBS) -test_simple_s_SOURCES = \ - test-simple-s.c +test_simple_server_SOURCES = \ + test-simple-server.c -test_simple_s_CFLAGS = \ +test_simple_server_CFLAGS = \ $(LIBINDICATE_CFLAGS) -I$(srcdir)/.. -test_simple_s_LDADD = \ +test_simple_server_LDADD = \ ../libindicate/libindicate.la \ $(LIBINDICATE_LIBS) diff --git a/tests/test-simple-client.c b/tests/test-simple-client.c new file mode 100644 index 0000000..f8db55a --- /dev/null +++ b/tests/test-simple-client.c @@ -0,0 +1,30 @@ + +#include <glib.h> +#include "libindicate/indicator.h" + +static gboolean passed = TRUE; +static GMainLoop * mainloop = NULL; + +static gboolean +done_timeout_cb (gpointer data) +{ + g_debug("All done."); + g_main_loop_quit(mainloop); + return FALSE; +} + +int +main (int argc, char * argv) +{ + g_type_init(); + + IndicateIndicator * indicator = indicate_indicator_new(); + indicate_indicator_show(indicator); + + g_timeout_add_seconds(2, done_timeout_cb, indicator); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return !passed; +} diff --git a/tests/test-simple-server.c b/tests/test-simple-server.c new file mode 100644 index 0000000..0a04e85 --- /dev/null +++ b/tests/test-simple-server.c @@ -0,0 +1,39 @@ + +#include <glib.h> +#include "libindicate/listener.h" + +static gboolean passed = TRUE; +static GMainLoop * mainloop = NULL; + +static void +server_added (IndicateListener * listener, IndicateListenerServer * server, gchar * type, gpointer data) +{ + g_debug("Indicator Server Added: %s %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), type); + g_main_loop_quit(mainloop); +} + +static gboolean +failed_cb (gpointer data) +{ + g_debug("Failed to get a server in 5 seconds."); + passed = FALSE; + g_main_loop_quit(mainloop); + return FALSE; +} + +int +main (int argc, char * argv) +{ + g_type_init(); + + IndicateListener * listener = indicate_listener_ref_default(); + + g_signal_connect(listener, INDICATE_LISTENER_SIGNAL_SERVER_ADDED, G_CALLBACK(server_added), NULL); + + g_timeout_add_seconds(5, failed_cb, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return !passed; +} diff --git a/tests/test_simple b/tests/test_simple new file mode 100755 index 0000000..8c4263e --- /dev/null +++ b/tests/test_simple @@ -0,0 +1,5 @@ +#!/bin/sh + +DBUS_RUNNER="/home/ted/Development/dbus-play/dbus-test-runner --dbus-config /home/ted/Development/dbus-play/session.conf" + +${DBUS_RUNNER} --task ./test-simple-client --task-name Client --task ./test-simple-server --task-name Server |