summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2014-03-17 16:45:07 +0100
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2014-03-17 17:28:35 +0100
commitbee5b30275907199e284625311bcd4fa6fc3097f (patch)
treebf77e1f022ae6d2e828fb4a0adbdba6572f79122
parente8b9fc31f0f4fee539dd6248bde70c2c505a6df4 (diff)
downloadtelepathy-glib-bee5b30275907199e284625311bcd4fa6fc3097f.tar.gz
tp_list_connection_managers_async: terminate properly if there is no CM
Fix fdo#68892.
-rw-r--r--telepathy-glib/connection-manager.c6
-rw-r--r--tests/dbus/Makefile.am3
-rw-r--r--tests/dbus/list-cm-no-cm.c88
3 files changed, 97 insertions, 0 deletions
diff --git a/telepathy-glib/connection-manager.c b/telepathy-glib/connection-manager.c
index 34b3889e0..2d7fe73f5 100644
--- a/telepathy-glib/connection-manager.c
+++ b/telepathy-glib/connection-manager.c
@@ -1918,6 +1918,12 @@ tp_list_connection_managers_got_names (TpDBusDaemon *bus_daemon,
DEBUG ("Total of %" G_GSIZE_FORMAT " CMs to be prepared",
list_context->cms_to_ready);
+ if (list_context->cms_to_ready == 0)
+ {
+ all_cms_prepared (list_context);
+ return;
+ }
+
for (i = 0; i < list_context->cms_to_ready; i++)
{
TpConnectionManager *cm = g_ptr_array_index (list_context->arr, i);
diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am
index 0476442c0..71f974c82 100644
--- a/tests/dbus/Makefile.am
+++ b/tests/dbus/Makefile.am
@@ -45,6 +45,7 @@ tests_list = \
test-handle-repo \
test-handle-set \
test-invalidated-while-invoking-signals \
+ test-list-cm-no-cm \
test-long-connection-name \
test-message-mixin \
test-params-cm \
@@ -130,6 +131,8 @@ test_cli_group_SOURCES = cli-group.c
test_cm_SOURCES = cm.c
+test_list_cm_no_cm_SOURCES = list-cm-no-cm.c
+
test_connection_SOURCES = connection.c
test_contact_lists_SOURCES = contact-lists.c
diff --git a/tests/dbus/list-cm-no-cm.c b/tests/dbus/list-cm-no-cm.c
new file mode 100644
index 000000000..87f312ab9
--- /dev/null
+++ b/tests/dbus/list-cm-no-cm.c
@@ -0,0 +1,88 @@
+/* Feature test for https://bugs.freedesktop.org/show_bug.cgi?id=68892
+ *
+ * Copyright (C) 2014 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 <glib/gstdio.h>
+#include <telepathy-glib/telepathy-glib.h>
+
+#include "tests/lib/util.h"
+
+typedef struct {
+ GMainLoop *mainloop;
+ TpDBusDaemon *dbus;
+ GError *error;
+} Test;
+
+static void
+setup (Test *test,
+ gconstpointer data)
+{
+ tp_debug_set_flags ("all");
+
+ test->mainloop = g_main_loop_new (NULL, FALSE);
+ test->dbus = tp_tests_dbus_daemon_dup_or_die ();
+
+ test->error = NULL;
+}
+
+static void
+teardown (Test *test,
+ gconstpointer data)
+{
+ g_clear_object (&test->dbus);
+ g_main_loop_unref (test->mainloop);
+ test->mainloop = NULL;
+}
+
+static void
+test_list_cm_no_cm (Test *test,
+ gconstpointer data)
+{
+ GAsyncResult *res = NULL;
+ GList *cms;
+
+ tp_list_connection_managers_async (test->dbus, tp_tests_result_ready_cb,
+ &res);
+ tp_tests_run_until_result (&res);
+ cms = tp_list_connection_managers_finish (res, &test->error);
+ g_assert_no_error (test->error);
+ g_assert_cmpuint (g_list_length (cms), ==, 0);
+
+ g_object_unref (res);
+ g_list_free (cms);
+}
+
+int
+main (int argc,
+ char **argv)
+{
+ gchar *dir;
+ GError *error = NULL;
+ int result;
+
+ /* This test relies on D-Bus not finding any service file so tweak
+ * TP_TESTS_SERVICES_DIR to point to an empty directory. */
+ dir = g_dir_make_tmp ("tp-glib-tests.XXXXXX", &error);
+ g_assert_no_error (error);
+ g_setenv ("TP_TESTS_SERVICES_DIR", dir, TRUE);
+
+ tp_tests_init (&argc, &argv);
+ g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
+
+ g_test_add ("/cm/list-cm-no-cm", Test, NULL, setup, test_list_cm_no_cm,
+ teardown);
+
+ result = tp_tests_run_with_bus ();
+
+ g_rmdir (dir);
+ g_free (dir);
+
+ return result;
+}