~ubuntu-branches/ubuntu/maverick/telepathy-glib/maverick

« back to all changes in this revision

Viewing changes to tests/dbus/client.c

  • Committer: Bazaar Package Importer
  • Author(s): Simon McVittie
  • Date: 2009-06-26 18:39:28 UTC
  • mfrom: (1.4.1 upstream) (17.2.5 karmic)
  • Revision ID: james.westby@ubuntu.com-20090626183928-8mvdxsfsak23eqcp
Tags: 0.7.33-1
* New upstream version (API, ABI unchanged)
  + Should fix builds on powerpc, sparc etc.
* Standards-Version: 3.8.2 (no changes required)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 <telepathy-glib/client.h>
 
12
#include <telepathy-glib/debug.h>
 
13
 
 
14
typedef struct {
 
15
    GMainLoop *mainloop;
 
16
    TpDBusDaemon *dbus;
 
17
 
 
18
    TpClient *client;
 
19
    GError *error /* initialized where needed */;
 
20
} Test;
 
21
 
 
22
static void
 
23
setup (Test *test,
 
24
       gconstpointer data)
 
25
{
 
26
  g_type_init ();
 
27
  tp_debug_set_flags ("all");
 
28
 
 
29
  test->mainloop = g_main_loop_new (NULL, FALSE);
 
30
  test->dbus = tp_dbus_daemon_dup (NULL);
 
31
  g_assert (test->dbus != NULL);
 
32
 
 
33
  test->client = NULL;
 
34
}
 
35
 
 
36
static void
 
37
teardown (Test *test,
 
38
          gconstpointer data)
 
39
{
 
40
  if (test->client != NULL)
 
41
    {
 
42
      g_object_unref (test->client);
 
43
      test->client = NULL;
 
44
    }
 
45
 
 
46
  g_object_unref (test->dbus);
 
47
  test->dbus = NULL;
 
48
  g_main_loop_unref (test->mainloop);
 
49
  test->mainloop = NULL;
 
50
}
 
51
 
 
52
static void
 
53
test_new (Test *test,
 
54
          gconstpointer data G_GNUC_UNUSED)
 
55
{
 
56
  test->client = g_object_new (TP_TYPE_CLIENT,
 
57
      "dbus-daemon", test->dbus,
 
58
      "object-path", "/org/freedesktop/Telepathy/Client/whatever",
 
59
      "bus-name", "org.freedesktop.Telepathy.Client.whatever",
 
60
      NULL);
 
61
  g_assert (test->client != NULL);
 
62
}
 
63
 
 
64
int
 
65
main (int argc,
 
66
      char **argv)
 
67
{
 
68
  g_test_init (&argc, &argv, NULL);
 
69
  g_test_bug_base ("http://bugs.freedesktop.org/show_bug.cgi?id=");
 
70
 
 
71
  g_test_add ("/client/new", Test, NULL, setup, test_new, teardown);
 
72
 
 
73
  return g_test_run ();
 
74
}