1 /* Feature test for https://bugs.freedesktop.org/show_bug.cgi?id=68892
2 *
3 * Copyright (C) 2014 Collabora Ltd. <http://www.collabora.co.uk/>
4 *
5 * Copying and distribution of this file, with or without modification,
6 * are permitted in any medium without royalty provided the copyright
7 * notice and this notice are preserved.
8 */
9
10 #include "config.h"
11
12 #include <glib/gstdio.h>
13 #include <telepathy-glib/telepathy-glib.h>
14
15 #include "tests/lib/util.h"
16
17 typedef struct {
18 GMainLoop *mainloop;
19 TpDBusDaemon *dbus;
20 GError *error;
21 } Test;
22
23 static void
setup(Test * test,gconstpointer data)24 setup (Test *test,
25 gconstpointer data)
26 {
27 tp_debug_set_flags ("all");
28
29 test->mainloop = g_main_loop_new (NULL, FALSE);
30 test->dbus = tp_tests_dbus_daemon_dup_or_die ();
31
32 test->error = NULL;
33 }
34
35 static void
teardown(Test * test,gconstpointer data)36 teardown (Test *test,
37 gconstpointer data)
38 {
39 g_clear_object (&test->dbus);
40 g_main_loop_unref (test->mainloop);
41 test->mainloop = NULL;
42 }
43
44 static void
test_list_cm_no_cm(Test * test,gconstpointer data)45 test_list_cm_no_cm (Test *test,
46 gconstpointer data)
47 {
48 GAsyncResult *res = NULL;
49 GList *cms;
50
51 tp_list_connection_managers_async (test->dbus, tp_tests_result_ready_cb,
52 &res);
53 tp_tests_run_until_result (&res);
54 cms = tp_list_connection_managers_finish (res, &test->error);
55 g_assert_no_error (test->error);
56 g_assert_cmpuint (g_list_length (cms), ==, 0);
57
58 g_object_unref (res);
59 g_list_free (cms);
60 }
61
62 int
main(int argc,char ** argv)63 main (int argc,
64 char **argv)
65 {
66 gchar *dir;
67 GError *error = NULL;
68 int result;
69
70 /* This test relies on D-Bus not finding any service file so tweak
71 * TP_TESTS_SERVICES_DIR to point to an empty directory. */
72 dir = g_dir_make_tmp ("tp-glib-tests.XXXXXX", &error);
73 g_assert_no_error (error);
74 g_setenv ("TP_TESTS_SERVICES_DIR", dir, TRUE);
75
76 tp_tests_init (&argc, &argv);
77 g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
78
79 g_test_add ("/cm/list-cm-no-cm", Test, NULL, setup, test_list_cm_no_cm,
80 teardown);
81
82 result = tp_tests_run_with_bus ();
83
84 g_rmdir (dir);
85 g_free (dir);
86
87 return result;
88 }
89