From 8162f7196b7be52d014160b7559a98264e5f2b8a Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 20 Apr 2009 11:25:33 -0500 Subject: Adding in a simple test --- .bzrignore | 2 ++ tests/Makefile.am | 25 +++++++++++++------------ tests/test-simple-client.c | 30 ++++++++++++++++++++++++++++++ tests/test-simple-server.c | 39 +++++++++++++++++++++++++++++++++++++++ tests/test_simple | 5 +++++ 5 files changed, 89 insertions(+), 12 deletions(-) create mode 100644 tests/test-simple-client.c create mode 100644 tests/test-simple-server.c create mode 100755 tests/test_simple diff --git a/.bzrignore b/.bzrignore index 6d29896..f9d8412 100644 --- a/.bzrignore +++ b/.bzrignore @@ -67,3 +67,5 @@ examples/indicate-alot examples/indicate-and-crash examples/listen-and-print examples/show-hide-server +test-simple-client +test-simple-server 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 +#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 +#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 -- cgit v1.2.3