1 /* A very basic feature test for TpClient
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/client.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     TpClient *client;
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->client = NULL;
36 }
37 
38 static void
teardown(Test * test,gconstpointer data)39 teardown (Test *test,
40           gconstpointer data)
41 {
42   if (test->client != NULL)
43     {
44       g_object_unref (test->client);
45       test->client = NULL;
46     }
47 
48   g_object_unref (test->dbus);
49   test->dbus = NULL;
50   g_main_loop_unref (test->mainloop);
51   test->mainloop = NULL;
52 }
53 
54 static void
test_new(Test * test,gconstpointer data G_GNUC_UNUSED)55 test_new (Test *test,
56           gconstpointer data G_GNUC_UNUSED)
57 {
58   test->client = tp_tests_object_new_static_class (TP_TYPE_CLIENT,
59       "dbus-daemon", test->dbus,
60       "object-path", "/org/freedesktop/Telepathy/Client/whatever",
61       "bus-name", "org.freedesktop.Telepathy.Client.whatever",
62       NULL);
63   g_assert (test->client != NULL);
64 }
65 
66 int
main(int argc,char ** argv)67 main (int argc,
68       char **argv)
69 {
70   tp_tests_init (&argc, &argv);
71   g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
72 
73   g_test_add ("/client/new", Test, NULL, setup, test_new, teardown);
74 
75   return tp_tests_run_with_bus ();
76 }
77