~ubuntu-branches/ubuntu/wily/telepathy-glib/wily

« back to all changes in this revision

Viewing changes to tests/dbus/finalized-in-invalidated-handler.c

  • Committer: Bazaar Package Importer
  • Author(s): Simon McVittie
  • Date: 2009-03-24 22:06:52 UTC
  • mfrom: (1.3.1 upstream) (17.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20090324220652-c8dvom0nsqomp23d
Tags: 0.7.28-1
* New upstream version (ABI, API added)
* Put the -dbg package in section debug, as per recent archive changes
* Remove obsolete Conflicts/Replaces with libtelepathy-glib-static-dev, which
  was never in a stable release (and probably never in Debian at all)

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
#include "tests/lib/myassert.h"
18
18
#include "tests/lib/simple-conn.h"
19
19
#include "tests/lib/textchan-null.h"
 
20
#include "tests/lib/util.h"
20
21
 
21
 
static int fail = 0;
22
22
static GMainLoop *mainloop;
23
23
 
24
24
static void
25
 
myassert_failed (void)
26
 
{
27
 
  fail = 1;
28
 
}
29
 
 
30
 
static void
31
25
on_invalidated (TpChannel *chan,
32
26
                guint domain,
33
27
                gint code,
36
30
{
37
31
  TpChannel **client = user_data;
38
32
 
39
 
  MYASSERT (domain == TP_ERRORS_DISCONNECTED, ": domain \"%s\"",
 
33
  MYASSERT (domain == TP_ERRORS, ": domain \"%s\"",
40
34
      g_quark_to_string (domain));
41
 
  MYASSERT (code == TP_CONNECTION_STATUS_REASON_REQUESTED, ": code %u", code);
 
35
  MYASSERT (code == TP_ERROR_CANCELLED, ": code %u", code);
42
36
 
43
37
  MYASSERT (*client == chan, "%p vs %p", *client, chan);
44
38
  g_object_unref (*client);
45
39
  *client = NULL;
46
 
 
47
 
  g_main_loop_quit (mainloop);
48
40
}
49
41
 
50
42
static gboolean
55
47
  return FALSE;
56
48
}
57
49
 
 
50
static void
 
51
on_shutdown_finished (TpBaseConnection *base_conn,
 
52
                      gpointer user_data)
 
53
{
 
54
  g_main_loop_quit (mainloop);
 
55
}
 
56
 
58
57
int
59
58
main (int argc,
60
59
      char **argv)
75
74
  g_type_init ();
76
75
  tp_debug_set_flags ("all");
77
76
  mainloop = g_main_loop_new (NULL, FALSE);
 
77
  dbus = tp_dbus_daemon_new (tp_get_bus ());
78
78
 
79
79
  service_conn = SIMPLE_CONNECTION (g_object_new (SIMPLE_TYPE_CONNECTION,
80
80
        "account", "me@example.com",
84
84
  MYASSERT (service_conn != NULL, "");
85
85
  MYASSERT (service_conn_as_base != NULL, "");
86
86
 
 
87
  g_signal_connect (service_conn, "shutdown-finished",
 
88
      G_CALLBACK (on_shutdown_finished), NULL);
 
89
 
87
90
  MYASSERT (tp_base_connection_register (service_conn_as_base, "simple",
88
91
        &name, &conn_path, &error), "");
89
 
  MYASSERT_NO_ERROR (error);
 
92
  test_assert_no_error (error);
90
93
 
91
 
  dbus = tp_dbus_daemon_new (tp_get_bus ());
92
94
  conn = tp_connection_new (dbus, name, conn_path, &error);
93
95
  MYASSERT (conn != NULL, "");
94
 
  MYASSERT_NO_ERROR (error);
 
96
  test_assert_no_error (error);
95
97
 
96
98
  MYASSERT (tp_connection_run_until_ready (conn, TRUE, &error, NULL), "");
97
 
  MYASSERT_NO_ERROR (error);
 
99
  test_assert_no_error (error);
98
100
 
99
101
  /* Paste on a channel */
100
102
 
103
105
  MYASSERT (contact_repo != NULL, "");
104
106
 
105
107
  handle = tp_handle_ensure (contact_repo, "them@example.org", NULL, &error);
106
 
  MYASSERT_NO_ERROR (error);
 
108
  test_assert_no_error (error);
107
109
  chan_path = g_strdup_printf ("%s/Channel", conn_path);
108
110
 
109
111
  service_chan = TEST_TEXT_CHANNEL_NULL (g_object_new (
115
117
 
116
118
  chan = tp_channel_new (conn, chan_path, TP_IFACE_CHANNEL_TYPE_TEXT,
117
119
      TP_HANDLE_TYPE_CONTACT, handle, &error);
118
 
  MYASSERT_NO_ERROR (error);
 
120
  test_assert_no_error (error);
119
121
 
120
122
  tp_channel_run_until_ready (chan, &error, NULL);
121
 
  MYASSERT_NO_ERROR (error);
 
123
  test_assert_no_error (error);
122
124
 
123
125
  g_signal_connect (chan, "invalidated", G_CALLBACK (on_invalidated),
124
126
      &chan);
142
144
  g_free (conn_path);
143
145
  g_free (chan_path);
144
146
 
145
 
  return fail;
 
147
  return 0;
146
148
}