aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2009-12-03 16:03:17 -0600
committerTed Gould <ted@gould.cx>2009-12-03 16:03:17 -0600
commit873b502fb3f519492a7ec0a1e2dea434d866f3d8 (patch)
tree8efe6297eea53e98aa81fd97436e28deea3c726a /tests
parent360ae7addef07b1fc137984e1ada7d1a2a6ba960 (diff)
parentea29a8effb3c9ebcb7d2f469add8eaff462d29c5 (diff)
downloadlibayatana-indicator-873b502fb3f519492a7ec0a1e2dea434d866f3d8.tar.gz
libayatana-indicator-873b502fb3f519492a7ec0a1e2dea434d866f3d8.tar.bz2
libayatana-indicator-873b502fb3f519492a7ec0a1e2dea434d866f3d8.zip
Service version numbers.
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am80
-rw-r--r--tests/service-version-bad-service.c47
-rw-r--r--tests/service-version-bad.service.in3
-rw-r--r--tests/service-version-good-service.c47
-rw-r--r--tests/service-version-good.service.in3
-rw-r--r--tests/service-version-manager.c64
-rw-r--r--tests/service-version-values.h4
7 files changed, 241 insertions, 7 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 09a227d..7fcccb6 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1,13 +1,7 @@
TESTS =
DISTCLEANFILES =
-check_PROGRAMS = \
- test-loader \
- service-manager-no-connect \
- service-manager-connect \
- service-manager-connect-service \
- service-manager-nostart-connect \
- service-shutdown-timeout
+check_PROGRAMS =
lib_LTLIBRARIES = \
libdummy-indicator-blank.la \
@@ -21,6 +15,8 @@ DBUS_RUNNER=dbus-test-runner --dbus-config /usr/share/dbus-test-runner/session.c
# Test Loader
#############################
+check_PROGRAMS += test-loader
+
test_loader_SOURCES = \
test-loader.c
@@ -118,6 +114,8 @@ libdummy_indicator_simple_la_LDFLAGS = \
# Service Shutdown Timeout
#############################
+check_PROGRAMS += service-shutdown-timeout
+
service_shutdown_timeout_SOURCES = \
service-shutdown-timeout.c
@@ -141,6 +139,8 @@ DISTCLEANFILES += service-shutdown-timeout-tester
# Service Manager No Connect
#############################
+check_PROGRAMS += service-manager-no-connect
+
service_manager_no_connect_SOURCES = \
service-manager-no-connect.c
@@ -170,6 +170,8 @@ session.conf: $(srcdir)/session.conf.in Makefile.am
service-manager-connect.service: $(srcdir)/service-manager-connect.service.in Makefile.am
sed -e "s|\@builddir\@|$(abspath $(builddir))|" $< > $@
+check_PROGRAMS += service-manager-connect
+
service_manager_connect_SOURCES = \
service-manager-connect.c
@@ -181,6 +183,8 @@ service_manager_connect_LDADD = \
$(LIBINDICATOR_LIBS) \
$(top_builddir)/libindicator/.libs/libindicator.a
+check_PROGRAMS += service-manager-connect-service
+
service_manager_connect_service_SOURCES = \
service-manager-connect-service.c
@@ -201,9 +205,71 @@ TESTS += service-manager-connect-tester
DISTCLEANFILES += service-manager-connect-tester session.conf service-manager-connect.service
#############################
+# Service Versions
+#############################
+
+service-version-good.service: $(srcdir)/service-version-good.service.in Makefile.am
+ sed -e "s|\@builddir\@|$(abspath $(builddir))|" $< > $@
+
+service-version-bad.service: $(srcdir)/service-version-bad.service.in Makefile.am
+ sed -e "s|\@builddir\@|$(abspath $(builddir))|" $< > $@
+
+check_PROGRAMS += service-version-manager
+
+service_version_manager_SOURCES = \
+ service-version-values.h \
+ service-version-manager.c
+
+service_version_manager_CFLAGS = \
+ -Wall -Werror \
+ $(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
+
+service_version_manager_LDADD = \
+ $(LIBINDICATOR_LIBS) \
+ $(top_builddir)/libindicator/.libs/libindicator.a
+
+check_PROGRAMS += service-version-bad-service
+
+service_version_bad_service_SOURCES = \
+ service-version-values.h \
+ service-version-bad-service.c
+
+service_version_bad_service_CFLAGS = \
+ -Wall -Werror \
+ $(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
+
+service_version_bad_service_LDADD = \
+ $(LIBINDICATOR_LIBS) \
+ $(top_builddir)/libindicator/.libs/libindicator.a
+
+check_PROGRAMS += service-version-good-service
+
+service_version_good_service_SOURCES = \
+ service-version-values.h \
+ service-version-good-service.c
+
+service_version_good_service_CFLAGS = \
+ -Wall -Werror \
+ $(LIBINDICATOR_CFLAGS) -I$(top_srcdir)
+
+service_version_good_service_LDADD = \
+ $(LIBINDICATOR_LIBS) \
+ $(top_builddir)/libindicator/.libs/libindicator.a
+
+service-version-tester: service-version-manager service-version-bad-service service-version-good-service session.conf service-version-bad.service service-version-good.service Makefile.am
+ @echo "#!/bin/sh" > $@
+ @echo dbus-test-runner --dbus-config $(builddir)/session.conf --task ./service-version-manager >> $@
+ @chmod +x $@
+
+TESTS += service-version-tester
+DISTCLEANFILES += service-version-tester service-version-bad.service service-version-good.service
+
+#############################
# Service Manager Shutdown
#############################
+check_PROGRAMS += service-manager-nostart-connect
+
service_manager_nostart_connect_SOURCES = \
service-manager-nostart-connect.c
diff --git a/tests/service-version-bad-service.c b/tests/service-version-bad-service.c
new file mode 100644
index 0000000..6057e74
--- /dev/null
+++ b/tests/service-version-bad-service.c
@@ -0,0 +1,47 @@
+
+#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();
+
+ IndicatorService * is = indicator_service_new_version("org.ayatana.version.bad", SERVICE_VERSION_BAD);
+ g_signal_connect(G_OBJECT(is), INDICATOR_SERVICE_SIGNAL_SHUTDOWN, shutdown, NULL);
+
+ g_timeout_add_seconds(1, 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;
+}
diff --git a/tests/service-version-bad.service.in b/tests/service-version-bad.service.in
new file mode 100644
index 0000000..1e763eb
--- /dev/null
+++ b/tests/service-version-bad.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.ayatana.version.bad
+Exec=@builddir@/service-version-bad-service
diff --git a/tests/service-version-good-service.c b/tests/service-version-good-service.c
new file mode 100644
index 0000000..bcfe46d
--- /dev/null
+++ b/tests/service-version-good-service.c
@@ -0,0 +1,47 @@
+
+#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();
+
+ 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(1, 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;
+}
diff --git a/tests/service-version-good.service.in b/tests/service-version-good.service.in
new file mode 100644
index 0000000..c57a04f
--- /dev/null
+++ b/tests/service-version-good.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.ayatana.version.good
+Exec=@builddir@/service-version-good-service
diff --git a/tests/service-version-manager.c b/tests/service-version-manager.c
new file mode 100644
index 0000000..aedc0ed
--- /dev/null
+++ b/tests/service-version-manager.c
@@ -0,0 +1,64 @@
+
+#include <glib.h>
+#include "libindicator/indicator-service-manager.h"
+#include "service-version-values.h"
+
+static GMainLoop * mainloop = NULL;
+static gboolean con_good = FALSE;
+static gboolean con_bad = FALSE;
+
+gboolean
+timeout (gpointer data)
+{
+ g_debug("Timeout.");
+ g_main_loop_quit(mainloop);
+ return FALSE;
+}
+
+void
+connection_bad (IndicatorServiceManager * sm, gboolean connected, gpointer user_data)
+{
+ if (!connected) return;
+ g_debug("Connection From Bad!");
+ con_bad = TRUE;
+ return;
+}
+
+void
+connection_good (IndicatorServiceManager * sm, gboolean connected, gpointer user_data)
+{
+ if (!connected) return;
+ g_debug("Connection From Good.");
+ con_good = TRUE;
+ return;
+}
+
+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"));
+
+ IndicatorServiceManager * 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);
+
+ IndicatorServiceManager * badis = indicator_service_manager_new_version("org.ayatana.version.bad", SERVICE_VERSION_GOOD);
+ g_signal_connect(G_OBJECT(badis), INDICATOR_SERVICE_MANAGER_SIGNAL_CONNECTION_CHANGE, G_CALLBACK(connection_bad), NULL);
+
+ g_timeout_add_seconds(1, timeout, NULL);
+
+ mainloop = g_main_loop_new(NULL, FALSE);
+ g_main_loop_run(mainloop);
+
+ g_object_unref(goodis);
+ g_object_unref(badis);
+
+ g_debug("Quiting");
+ if (con_good && !con_bad) {
+ g_debug("Passed");
+ return 0;
+ }
+ g_debug("Failed");
+ return 1;
+}
diff --git a/tests/service-version-values.h b/tests/service-version-values.h
new file mode 100644
index 0000000..e9fb087
--- /dev/null
+++ b/tests/service-version-values.h
@@ -0,0 +1,4 @@
+
+#define SERVICE_VERSION_GOOD 1342
+#define SERVICE_VERSION_BAD 543
+