1 /* A very basic feature test for TpChannelDispatcher
2 *
3 * Copyright (C) 2009 Collabora Ltd. <http://www.collabora.co.uk/>
4 * Copyright (C) 2009 Nokia Corporation
5 *
6 * Copying and distribution of this file, with or without modification,
7 * are permitted in any medium without royalty provided the copyright
8 * notice and this notice are preserved.
9 */
10
11 #include "config.h"
12
13 #include <telepathy-glib/channel-dispatcher.h>
14 #include <telepathy-glib/debug.h>
15
16 #include "tests/lib/util.h"
17
18 typedef struct {
19 GMainLoop *mainloop;
20 TpDBusDaemon *dbus;
21
22 TpChannelDispatcher *cd;
23 GError *error /* initialized where needed */;
24 } Test;
25
26 static void
setup(Test * test,gconstpointer data)27 setup (Test *test,
28 gconstpointer data)
29 {
30 tp_debug_set_flags ("all");
31
32 test->mainloop = g_main_loop_new (NULL, FALSE);
33 test->dbus = tp_tests_dbus_daemon_dup_or_die ();
34
35 test->cd = NULL;
36 }
37
38 static void
teardown(Test * test,gconstpointer data)39 teardown (Test *test,
40 gconstpointer data)
41 {
42 if (test->cd != NULL)
43 {
44 g_object_unref (test->cd);
45 test->cd = NULL;
46 }
47
48 /* make sure any pending things have happened */
49 tp_tests_proxy_run_until_dbus_queue_processed (test->dbus);
50
51 g_object_unref (test->dbus);
52 test->dbus = NULL;
53 g_main_loop_unref (test->mainloop);
54 test->mainloop = NULL;
55 }
56
57 static void
test_new(Test * test,gconstpointer data G_GNUC_UNUSED)58 test_new (Test *test,
59 gconstpointer data G_GNUC_UNUSED)
60 {
61 test->cd = tp_channel_dispatcher_new (test->dbus);
62 g_assert (test->cd != NULL);
63 }
64
65 int
main(int argc,char ** argv)66 main (int argc,
67 char **argv)
68 {
69 tp_tests_init (&argc, &argv);
70 g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
71
72 g_test_add ("/cd/new", Test, NULL, setup, test_new, teardown);
73 /* tp_channel_dispatcher_present_channel_async() is tested in
74 * test-base-client */
75
76 return tp_tests_run_with_bus ();
77 }
78