telepathy-glib: add test-debug-client
Guillaume Desmottes
gdesmott at kemper.freedesktop.org
Wed Apr 18 00:08:56 PDT 2012
Module: telepathy-glib
Branch: master
Commit: f7217554dc69fa2682f3d88e7166b75686f4a4ff
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=f7217554dc69fa2682f3d88e7166b75686f4a4ff
Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date: Fri Apr 13 09:50:25 2012 +0200
add test-debug-client
---
tests/dbus/Makefile.am | 3 +
tests/dbus/debug-client.c | 110 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 113 insertions(+), 0 deletions(-)
diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am
index f4a31e7..f638dfc 100644
--- a/tests/dbus/Makefile.am
+++ b/tests/dbus/Makefile.am
@@ -33,6 +33,7 @@ tests_list = \
test-contacts-slow-path \
test-dbus \
test-dbus-tube \
+ test-debug-client \
test-disconnection \
test-error-enum \
test-example-no-protocols \
@@ -251,6 +252,8 @@ test_text_channel_LDADD = \
$(LDADD) \
$(top_builddir)/examples/cm/echo-message-parts/libexample-cm-echo-2.la
+test_debug_client_SOURCES = debug-client.c
+
check_c_sources = *.c
include $(top_srcdir)/tools/check-coding-style.mk
check-local: check-coding-style
diff --git a/tests/dbus/debug-client.c b/tests/dbus/debug-client.c
new file mode 100644
index 0000000..cf5727a
--- /dev/null
+++ b/tests/dbus/debug-client.c
@@ -0,0 +1,110 @@
+/* Tests of TpTextChannel
+ *
+ * Copyright © 2010 Collabora Ltd. <http://www.collabora.co.uk/>
+ *
+ * Copying and distribution of this file, with or without modification,
+ * are permitted in any medium without royalty provided the copyright
+ * notice and this notice are preserved.
+ */
+
+#include "config.h"
+
+#include <string.h>
+
+#include <telepathy-glib/telepathy-glib.h>
+#include <telepathy-glib/debug-sender.h>
+
+#include "tests/lib/util.h"
+
+typedef struct {
+ GMainLoop *mainloop;
+ TpDBusDaemon *dbus;
+
+ /* Service side object */
+ TpDebugSender *sender;
+
+ /* Client side object */
+ TpDebugClient *client;
+
+ GError *error /* initialized where needed */;
+ gint wait;
+} Test;
+
+static void
+setup (Test *test,
+ gconstpointer data)
+{
+ test->mainloop = g_main_loop_new (NULL, FALSE);
+ test->dbus = tp_tests_dbus_daemon_dup_or_die ();
+
+ test->error = NULL;
+
+ test->sender = tp_debug_sender_dup ();
+ g_assert (test->sender != NULL);
+
+ test->client = tp_debug_client_new (test->dbus,
+ tp_dbus_daemon_get_unique_name (test->dbus), &test->error);
+ g_assert_no_error (test->error);
+}
+
+static void
+teardown (Test *test,
+ gconstpointer data)
+{
+ g_clear_error (&test->error);
+
+ tp_clear_object (&test->dbus);
+ g_main_loop_unref (test->mainloop);
+ test->mainloop = NULL;
+
+ tp_clear_object (&test->sender);
+ tp_clear_object (&test->client);
+}
+
+static void
+test_creation (Test *test,
+ gconstpointer data G_GNUC_UNUSED)
+{
+ g_assert (TP_IS_DEBUG_CLIENT (test->client));
+}
+
+static void
+invalidated_cb (TpProxy *proxy,
+ guint domain,
+ gint code,
+ gchar *message,
+ Test *test)
+{
+ test->wait--;
+ if (test->wait <= 0)
+ g_main_loop_quit (test->mainloop);
+}
+
+static void
+test_invalidated (Test *test,
+ gconstpointer data G_GNUC_UNUSED)
+{
+ g_signal_connect (test->client, "invalidated",
+ G_CALLBACK (invalidated_cb), test);
+
+ tp_clear_object (&test->sender);
+
+ test->wait = 1;
+ g_main_loop_run (test->mainloop);
+ g_assert_no_error (test->error);
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ tp_tests_init (&argc, &argv);
+ g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
+
+ g_test_add ("/debug-client/creation", Test, NULL, setup,
+ test_creation, teardown);
+ g_test_add ("/debug-client/invalidated", Test, NULL, setup,
+ test_invalidated, teardown);
+
+ return g_test_run ();
+}
More information about the telepathy-commits
mailing list