From a1ccd1a94e3b2ec2c7ce60c5b6b8824a2bf04076 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 20 Apr 2009 09:34:10 -0500 Subject: Moving tests to examples --- .bzrignore | 7 +++++++ 1 file changed, 7 insertions(+) (limited to '.bzrignore') diff --git a/.bzrignore b/.bzrignore index 2e5dd36..6d29896 100644 --- a/.bzrignore +++ b/.bzrignore @@ -60,3 +60,10 @@ libindicate/indicate-enum-types.h libindicate/libindicate_la-indicate-enum-types.lo libindicate/s-enum-types-c libindicate/s-enum-types-h +examples/.deps +examples/.libs +examples/im-client +examples/indicate-alot +examples/indicate-and-crash +examples/listen-and-print +examples/show-hide-server -- cgit v1.2.3 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 (limited to '.bzrignore') 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 From 38c6ce2a36d6416016f64e5963deee29bc02f8b3 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 20 Apr 2009 12:36:07 -0500 Subject: Adding an interests test --- .bzrignore | 2 ++ tests/Makefile.am | 27 ++++++++++++++++++- tests/test-interests-client.c | 63 +++++++++++++++++++++++++++++++++++++++++++ tests/test-interests-server.c | 45 +++++++++++++++++++++++++++++++ tests/test_interests | 5 ++++ 5 files changed, 141 insertions(+), 1 deletion(-) create mode 100644 tests/test-interests-client.c create mode 100644 tests/test-interests-server.c create mode 100755 tests/test_interests (limited to '.bzrignore') diff --git a/.bzrignore b/.bzrignore index f9d8412..b7d186d 100644 --- a/.bzrignore +++ b/.bzrignore @@ -69,3 +69,5 @@ examples/listen-and-print examples/show-hide-server test-simple-client test-simple-server +test-interests-client +test-interests-server diff --git a/tests/Makefile.am b/tests/Makefile.am index 36818b8..256a699 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,8 +1,11 @@ TESTS = \ - test_simple + test_simple \ + test_interests libexec_PROGRAMS = \ + test-interests-client \ + test-interests-server \ test-simple-client \ test-simple-server @@ -31,3 +34,25 @@ test_simple_server_LDADD = \ ../libindicate/libindicate.la \ $(LIBINDICATE_LIBS) +test_interests: test-interests-client test-interests-server + +test_interests_client_SOURCES = \ + test-interests-client.c + +test_interests_client_CFLAGS = \ + $(LIBINDICATE_CFLAGS) -I$(srcdir)/.. + +test_interests_client_LDADD = \ + ../libindicate/libindicate.la \ + $(LIBINDICATE_LIBS) + +test_interests_server_SOURCES = \ + test-interests-server.c + +test_interests_server_CFLAGS = \ + $(LIBINDICATE_CFLAGS) -I$(srcdir)/.. + +test_interests_server_LDADD = \ + ../libindicate/libindicate.la \ + $(LIBINDICATE_LIBS) + diff --git a/tests/test-interests-client.c b/tests/test-interests-client.c new file mode 100644 index 0000000..0fe8587 --- /dev/null +++ b/tests/test-interests-client.c @@ -0,0 +1,63 @@ + +#include +#include "libindicate/indicator.h" +#include "libindicate/server.h" +#include "libindicate/interests.h" + +static gboolean passed = TRUE; +static GMainLoop * mainloop = NULL; +static gboolean interests[INDICATE_INTEREST_LAST] = {0}; + +static gboolean +check_interests (void) +{ + guint i; + for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + if (!interests[i]) { + return FALSE; + } + } + + return TRUE; +} + +static void +interest_added (IndicateServer * server, IndicateInterests interest) +{ + g_debug("Oh, someone is interested in my for: %d", interest); + interests[interest] = TRUE; + + if (check_interests()) { + g_main_loop_quit(mainloop); + } + + return; +} + +static gboolean +done_timeout_cb (gpointer data) +{ + g_debug("All interests not set"); + passed = FALSE; + 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); + + IndicateServer * server = indicate_server_ref_default(); + g_signal_connect(G_OBJECT(server), INDICATE_SERVER_SIGNAL_INTEREST_ADDED, G_CALLBACK(interest_added), NULL); + + g_timeout_add_seconds(10, done_timeout_cb, indicator); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return !passed; +} diff --git a/tests/test-interests-server.c b/tests/test-interests-server.c new file mode 100644 index 0000000..82cab3c --- /dev/null +++ b/tests/test-interests-server.c @@ -0,0 +1,45 @@ + +#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); + + guint i; + for (i = INDICATE_INTEREST_NONE; i < INDICATE_INTEREST_LAST; i++) { + g_debug("Indicating Interests: %d", i); + indicate_listener_server_show_interest(listener, server, i); + } + + return; +} + +static gboolean +failed_cb (gpointer data) +{ + g_debug("Done indicatating interest"); + 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(2, failed_cb, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return !passed; +} diff --git a/tests/test_interests b/tests/test_interests new file mode 100755 index 0000000..b37189f --- /dev/null +++ b/tests/test_interests @@ -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-interests-client --task-name Client --task ./test-interests-server --task-name Server -- cgit v1.2.3 From ecad1e36dce18875461e76d2a47d8a0e11570ff6 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 20 Apr 2009 14:44:25 -0500 Subject: Adding in multiple servers connecting in to declare interest test --- .bzrignore | 5 ++++ tests/Makefile.am | 60 +++++++++++++++++++++++++++++++++++++++++- tests/test-interests-server1.c | 41 +++++++++++++++++++++++++++++ tests/test-interests-server2.c | 41 +++++++++++++++++++++++++++++ tests/test-interests-server3.c | 41 +++++++++++++++++++++++++++++ tests/test-interests-server4.c | 41 +++++++++++++++++++++++++++++ tests/test-interests-server5.c | 41 +++++++++++++++++++++++++++++ tests/test_interests_multi | 5 ++++ 8 files changed, 274 insertions(+), 1 deletion(-) create mode 100644 tests/test-interests-server1.c create mode 100644 tests/test-interests-server2.c create mode 100644 tests/test-interests-server3.c create mode 100644 tests/test-interests-server4.c create mode 100644 tests/test-interests-server5.c create mode 100755 tests/test_interests_multi (limited to '.bzrignore') diff --git a/.bzrignore b/.bzrignore index b7d186d..13cd507 100644 --- a/.bzrignore +++ b/.bzrignore @@ -71,3 +71,8 @@ test-simple-client test-simple-server test-interests-client test-interests-server +test-interests-server1 +test-interests-server2 +test-interests-server3 +test-interests-server4 +test-interests-server5 diff --git a/tests/Makefile.am b/tests/Makefile.am index 256a699..6117bee 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,11 +1,17 @@ TESTS = \ test_simple \ - test_interests + test_interests \ + test_interests_multi libexec_PROGRAMS = \ test-interests-client \ test-interests-server \ + test-interests-server1 \ + test-interests-server2 \ + test-interests-server3 \ + test-interests-server4 \ + test-interests-server5 \ test-simple-client \ test-simple-server @@ -56,3 +62,55 @@ test_interests_server_LDADD = \ ../libindicate/libindicate.la \ $(LIBINDICATE_LIBS) +test_interests_multi: test-interests-client test-interests-server1 test-interests-server2 test-interests-server3 test-interests-server4 test-interests-server5 + +test_interests_server1_SOURCES = \ + test-interests-server1.c + +test_interests_server1_CFLAGS = \ + $(LIBINDICATE_CFLAGS) -I$(srcdir)/.. + +test_interests_server1_LDADD = \ + ../libindicate/libindicate.la \ + $(LIBINDICATE_LIBS) + +test_interests_server2_SOURCES = \ + test-interests-server2.c + +test_interests_server2_CFLAGS = \ + $(LIBINDICATE_CFLAGS) -I$(srcdir)/.. + +test_interests_server2_LDADD = \ + ../libindicate/libindicate.la \ + $(LIBINDICATE_LIBS) + +test_interests_server3_SOURCES = \ + test-interests-server3.c + +test_interests_server3_CFLAGS = \ + $(LIBINDICATE_CFLAGS) -I$(srcdir)/.. + +test_interests_server3_LDADD = \ + ../libindicate/libindicate.la \ + $(LIBINDICATE_LIBS) + +test_interests_server4_SOURCES = \ + test-interests-server4.c + +test_interests_server4_CFLAGS = \ + $(LIBINDICATE_CFLAGS) -I$(srcdir)/.. + +test_interests_server4_LDADD = \ + ../libindicate/libindicate.la \ + $(LIBINDICATE_LIBS) + +test_interests_server5_SOURCES = \ + test-interests-server5.c + +test_interests_server5_CFLAGS = \ + $(LIBINDICATE_CFLAGS) -I$(srcdir)/.. + +test_interests_server5_LDADD = \ + ../libindicate/libindicate.la \ + $(LIBINDICATE_LIBS) + diff --git a/tests/test-interests-server1.c b/tests/test-interests-server1.c new file mode 100644 index 0000000..e0d77f3 --- /dev/null +++ b/tests/test-interests-server1.c @@ -0,0 +1,41 @@ + +#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); + #define INTEREST 1 + g_debug("Setting Interest: %d", INTEREST); + indicate_listener_server_show_interest(listener, server, INTEREST); + return; +} + +static gboolean +failed_cb (gpointer data) +{ + g_debug("Done indicatating interest"); + 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(2, failed_cb, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return !passed; +} diff --git a/tests/test-interests-server2.c b/tests/test-interests-server2.c new file mode 100644 index 0000000..0416c21 --- /dev/null +++ b/tests/test-interests-server2.c @@ -0,0 +1,41 @@ + +#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); + #define INTEREST 2 + g_debug("Setting Interest: %d", INTEREST); + indicate_listener_server_show_interest(listener, server, INTEREST); + return; +} + +static gboolean +failed_cb (gpointer data) +{ + g_debug("Done indicatating interest"); + 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(2, failed_cb, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return !passed; +} diff --git a/tests/test-interests-server3.c b/tests/test-interests-server3.c new file mode 100644 index 0000000..7d889b1 --- /dev/null +++ b/tests/test-interests-server3.c @@ -0,0 +1,41 @@ + +#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); + #define INTEREST 3 + g_debug("Setting Interest: %d", INTEREST); + indicate_listener_server_show_interest(listener, server, INTEREST); + return; +} + +static gboolean +failed_cb (gpointer data) +{ + g_debug("Done indicatating interest"); + 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(2, failed_cb, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return !passed; +} diff --git a/tests/test-interests-server4.c b/tests/test-interests-server4.c new file mode 100644 index 0000000..50e6db1 --- /dev/null +++ b/tests/test-interests-server4.c @@ -0,0 +1,41 @@ + +#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); + #define INTEREST 4 + g_debug("Setting Interest: %d", INTEREST); + indicate_listener_server_show_interest(listener, server, INTEREST); + return; +} + +static gboolean +failed_cb (gpointer data) +{ + g_debug("Done indicatating interest"); + 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(2, failed_cb, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return !passed; +} diff --git a/tests/test-interests-server5.c b/tests/test-interests-server5.c new file mode 100644 index 0000000..d415716 --- /dev/null +++ b/tests/test-interests-server5.c @@ -0,0 +1,41 @@ + +#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); + #define INTEREST 5 + g_debug("Setting Interest: %d", INTEREST); + indicate_listener_server_show_interest(listener, server, INTEREST); + return; +} + +static gboolean +failed_cb (gpointer data) +{ + g_debug("Done indicatating interest"); + 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(2, failed_cb, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return !passed; +} diff --git a/tests/test_interests_multi b/tests/test_interests_multi new file mode 100755 index 0000000..96b23c9 --- /dev/null +++ b/tests/test_interests_multi @@ -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-interests-client --task-name Client --task ./test-interests-server1 --task-name Server1 --task ./test-interests-server2 --task-name Server2 --task ./test-interests-server3 --task-name Server3 --task ./test-interests-server4 --task-name Server4 --task ./test-interests-server5 --task-name Server5 -- cgit v1.2.3 From 6f87e9c09f9894db7fd6f42f65c8eb147c42a6e8 Mon Sep 17 00:00:00 2001 From: Ted Gould Date: Mon, 20 Apr 2009 15:39:42 -0500 Subject: Adding a test to build a bunch of indicators --- .bzrignore | 2 ++ tests/Makefile.am | 27 ++++++++++++++++++++- tests/test-thousand-indicators-client.c | 34 ++++++++++++++++++++++++++ tests/test-thousand-indicators-server.c | 43 +++++++++++++++++++++++++++++++++ tests/test_thousand_indicators | 5 ++++ 5 files changed, 110 insertions(+), 1 deletion(-) create mode 100644 tests/test-thousand-indicators-client.c create mode 100644 tests/test-thousand-indicators-server.c create mode 100755 tests/test_thousand_indicators (limited to '.bzrignore') diff --git a/.bzrignore b/.bzrignore index 13cd507..a3a1e57 100644 --- a/.bzrignore +++ b/.bzrignore @@ -76,3 +76,5 @@ test-interests-server2 test-interests-server3 test-interests-server4 test-interests-server5 +test-thousand-indicators-server +test-thousand-indicators-client diff --git a/tests/Makefile.am b/tests/Makefile.am index 6117bee..7d72047 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -2,7 +2,8 @@ TESTS = \ test_simple \ test_interests \ - test_interests_multi + test_interests_multi \ + test_thousand_indicators libexec_PROGRAMS = \ test-interests-client \ @@ -12,6 +13,8 @@ libexec_PROGRAMS = \ test-interests-server3 \ test-interests-server4 \ test-interests-server5 \ + test-thousand-indicators-client \ + test-thousand-indicators-server test-simple-client \ test-simple-server @@ -114,3 +117,25 @@ test_interests_server5_LDADD = \ ../libindicate/libindicate.la \ $(LIBINDICATE_LIBS) +test_thousand_indicators: test-thousand-indicators-client test-thousand-indicators-server + +test_thousand_indicators_client_SOURCES = \ + test-thousand-indicators-client.c + +test_thousand_indicators_client_CFLAGS = \ + $(LIBINDICATE_CFLAGS) -I$(srcdir)/.. + +test_thousand_indicators_client_LDADD = \ + ../libindicate/libindicate.la \ + $(LIBINDICATE_LIBS) + +test_thousand_indicators_server_SOURCES = \ + test-thousand-indicators-server.c + +test_thousand_indicators_server_CFLAGS = \ + $(LIBINDICATE_CFLAGS) -I$(srcdir)/.. + +test_thousand_indicators_server_LDADD = \ + ../libindicate/libindicate.la \ + $(LIBINDICATE_LIBS) + diff --git a/tests/test-thousand-indicators-client.c b/tests/test-thousand-indicators-client.c new file mode 100644 index 0000000..0ac7305 --- /dev/null +++ b/tests/test-thousand-indicators-client.c @@ -0,0 +1,34 @@ + +#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(); + + int i; + for (i = 0; i < 1000; i++) { + /* Memory leak :) */ + IndicateIndicator * indicator = indicate_indicator_new(); + indicate_indicator_show(indicator); + } + + g_timeout_add_seconds(2, done_timeout_cb, NULL); + + mainloop = g_main_loop_new(NULL, FALSE); + g_main_loop_run(mainloop); + + return !passed; +} diff --git a/tests/test-thousand-indicators-server.c b/tests/test-thousand-indicators-server.c new file mode 100644 index 0000000..285e56b --- /dev/null +++ b/tests/test-thousand-indicators-server.c @@ -0,0 +1,43 @@ + +#include +#include "libindicate/listener.h" + +static gboolean passed = TRUE; +static GMainLoop * mainloop = NULL; +static guint indicator_count = 0; + +static void +indicator_added (IndicateListener * listener, IndicateListenerServer * server, IndicateListenerIndicator * indicator, gchar * type, gpointer data) +{ + g_debug("Indicator Added: %s %d %s", INDICATE_LISTENER_SERVER_DBUS_NAME(server), INDICATE_LISTENER_INDICATOR_ID(indicator), type); + indicator_count++; + if (indicator_count == 1000) { + 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_INDICATOR_ADDED, G_CALLBACK(indicator_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_thousand_indicators b/tests/test_thousand_indicators new file mode 100755 index 0000000..4dd7fae --- /dev/null +++ b/tests/test_thousand_indicators @@ -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-thousand-indicators-client --task-name Client --task ./test-thousand-indicators-server --task-name Server -- cgit v1.2.3