aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2010-07-09 11:00:38 -0500
committerTed Gould <ted@gould.cx>2010-07-09 11:00:38 -0500
commitb0a56e9ed95f2d96e89733a5d7ffbf77a49b90aa (patch)
treefe5907d41f0b6f13c97d94bcc2ade7e31a7340c9
parentb973537a64b23358b471604c14374b50adef4898 (diff)
parentb43f81d0ece9bb9c150ccbeba793f385bef6ce3b (diff)
downloadlibayatana-indicator-b0a56e9ed95f2d96e89733a5d7ffbf77a49b90aa.tar.gz
libayatana-indicator-b0a56e9ed95f2d96e89733a5d7ffbf77a49b90aa.tar.bz2
libayatana-indicator-b0a56e9ed95f2d96e89733a5d7ffbf77a49b90aa.zip
Adding in the unwatching test
-rw-r--r--.bzrignore3
-rw-r--r--tests/Makefile.am40
-rw-r--r--tests/service-version-multiwatch-manager.c63
-rw-r--r--tests/service-version-multiwatch-service.c48
4 files changed, 154 insertions, 0 deletions
diff --git a/.bzrignore b/.bzrignore
index 38d60ed..cef9d4e 100644
--- a/.bzrignore
+++ b/.bzrignore
@@ -152,3 +152,6 @@ tests/test-desktop-shortcuts
tests/test-desktop-shortcuts-tester
tests/test-desktop-shortcuts-touch-test
libindicator/libindicator_la-indicator-image-helper.lo
+tests/service-version-multiwatch-manager
+tests/service-version-multiwatch-tester
+tests/service-version-multiwatch-service
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 13fef2d..852a963 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -304,6 +304,46 @@ TESTS += service-version-tester
DISTCLEANFILES += service-version-tester service-version-bad.service service-version-good.service
#############################
+# Service Versions
+#############################
+
+check_PROGRAMS += service-version-multiwatch-manager
+
+service_version_manager_SOURCES = \
+ service-version-values.h \
+ service-version-multiwatch-manager.c
+
+service_version_multiwatch_manager_CFLAGS = \
+ -Wall -Werror \
+ $(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
+
+service_version_multiwatch_manager_LDADD = \
+ $(LIBINDICATOR_LIBS) \
+ $(top_builddir)/libindicator/.libs/libindicator.a
+
+check_PROGRAMS += service-version-multiwatch-service
+
+service_version_multiwatch_service_SOURCES = \
+ service-version-values.h \
+ service-version-multiwatch-service.c
+
+service_version_multiwatch_service_CFLAGS = \
+ -Wall -Werror \
+ $(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
+
+service_version_multiwatch_service_LDADD = \
+ $(LIBINDICATOR_LIBS) \
+ $(top_builddir)/libindicator/.libs/libindicator.a
+
+service-version-multiwatch-tester: service-version-multiwatch-manager service-version-multiwatch-service Makefile.am
+ @echo "#!/bin/sh" > $@
+ @echo dbus-test-runner --task ./service-version-multiwatch-service --task-name Service --task ./service-version-multiwatch-manager --task-name Manager1 --task ./service-version-multiwatch-manager --task-name Manager2 --task ./service-version-multiwatch-manager --task-name Manager3 --task ./service-version-multiwatch-manager --task-name Manager4 --task ./service-version-multiwatch-manager --task-name Manager5 >> $@
+ @chmod +x $@
+
+TESTS += service-version-multiwatch-tester
+DISTCLEANFILES += service-version-multiwatch-tester
+
+#############################
# Service Manager Shutdown
#############################
diff --git a/tests/service-version-multiwatch-manager.c b/tests/service-version-multiwatch-manager.c
new file mode 100644
index 0000000..771426f
--- /dev/null
+++ b/tests/service-version-multiwatch-manager.c
@@ -0,0 +1,63 @@
+
+#include <glib.h>
+#include "libindicator/indicator-service-manager.h"
+#include "service-version-values.h"
+
+static GMainLoop * mainloop = NULL;
+static gboolean passed = FALSE;
+static IndicatorServiceManager * goodis = NULL;
+
+gboolean
+timeout (gpointer data)
+{
+ g_debug("Timeout.");
+ passed = FALSE;
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+void
+connection_good (IndicatorServiceManager * sm, gboolean connected, gpointer user_data)
+{
+ if (!connected) return;
+ g_debug("Connection From Service.");
+ passed = TRUE;
+ g_main_loop_quit(mainloop);
+ return;
+}
+
+gboolean
+delay_start (gpointer data)
+{
+ g_debug("Starting Manager");
+
+ goodis = indicator_service_manager_new_version("org.ayatana.version.good", SERVICE_VERSION_GOOD);
+ g_signal_connect(G_OBJECT(goodis), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_good), NULL);
+
+ g_timeout_add_seconds(1, timeout, NULL);
+
+ return FALSE;
+}
+
+int
+main (int argc, char ** argv)
+{
+ g_type_init();
+ g_log_set_always_fatal(G_LOG_LEVEL_CRITICAL);
+ g_print("Manager: DBUS_SESSION_BUS_ADDRESS = %s\n", g_getenv("DBUS_SESSION_BUS_ADDRESS"));
+
+ g_timeout_add(500, delay_start, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ g_object_unref(goodis);
+
+ g_debug("Quiting");
+ if (passed) {
+ g_debug("Passed");
+ return 0;
+ }
+ g_debug("Failed");
+ return 1;
+}
diff --git a/tests/service-version-multiwatch-service.c b/tests/service-version-multiwatch-service.c
new file mode 100644
index 0000000..9920306
--- /dev/null
+++ b/tests/service-version-multiwatch-service.c
@@ -0,0 +1,48 @@
+
+#include <glib.h>
+#include "libindicator/indicator-service.h"
+#include "service-version-values.h"
+
+static GMainLoop * mainloop = NULL;
+static gboolean passed = FALSE;
+
+gboolean
+timeout (gpointer data)
+{
+ passed = FALSE;
+ g_debug("Timeout with no shutdown.");
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+void
+shutdown (void)
+{
+ g_debug("Shutdown");
+ passed = TRUE;
+ g_main_loop_quit(mainloop);
+ return;
+}
+
+int
+main (int argc, char ** argv)
+{
+ g_type_init();
+ g_debug("Service starting");
+
+ IndicatorService * is = indicator_service_new_version("org.ayatana.version.good", SERVICE_VERSION_GOOD);
+ g_signal_connect(G_OBJECT(is), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, shutdown, NULL);
+
+ g_timeout_add_seconds(2, timeout, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ g_debug("Quiting");
+ if (passed) {
+ g_debug("Passed");
+ return 0;
+ }
+ g_debug("Failed");
+ return 1;
+}