[Telepathy-commits] [telepathy-glib/master] Ensure details['error'] and message appear in invalidated
Will Thompson
will.thompson at collabora.co.uk
Tue Jan 6 11:35:35 PST 2009
Don't check exactly how, just that they're there in some form.
---
tests/dbus/cli-group.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 102 insertions(+), 0 deletions(-)
diff --git a/tests/dbus/cli-group.c b/tests/dbus/cli-group.c
index 00538de..6dd454f 100644
--- a/tests/dbus/cli-group.c
+++ b/tests/dbus/cli-group.c
@@ -8,6 +8,8 @@
* notice and this notice are preserved.
*/
+#include <string.h>
+
#include <telepathy-glib/channel.h>
#include <telepathy-glib/connection.h>
#include <telepathy-glib/dbus.h>
@@ -299,6 +301,105 @@ run_membership_tests (void)
run_membership_test (4, TRUE, TRUE);
}
+#define REMOVED_REASON TP_CHANNEL_GROUP_CHANGE_REASON_NO_ANSWER
+#define REMOVED_ERROR "if.bob.dylan.were.hiding.at.the.bottom.of.a.well"
+#define REMOVED_MESSAGE \
+ "I'm just sittin' here, hidin' inside of a well, and I ain't comin' out!"
+
+static void
+check_invalidated_cb (TpProxy *proxy,
+ guint domain,
+ gint code,
+ gchar *message,
+ gpointer user_data)
+{
+ gboolean *invalidated = user_data;
+
+ MYASSERT (!*invalidated, "");
+ *invalidated = TRUE;
+
+ MYASSERT (domain == TP_ERRORS_REMOVED_FROM_GROUP, ": %u (%s) != %u (%s)",
+ domain, g_quark_to_string (domain),
+ TP_ERRORS_REMOVED_FROM_GROUP, g_quark_to_string
+ (TP_ERRORS_REMOVED_FROM_GROUP));
+ MYASSERT (code == REMOVED_REASON, ": %i != %i", code, REMOVED_REASON);
+ MYASSERT (strstr (message, REMOVED_ERROR) != NULL, " (%s, %s)", message,
+ REMOVED_ERROR);
+ MYASSERT (strstr (message, REMOVED_MESSAGE) != NULL, " (%s, %s)", message,
+ REMOVED_MESSAGE);
+}
+
+
+static void
+check_removed_error_in_invalidated (void)
+{
+ gchar *chan_path;
+ TestTextChannelGroup *service_chan;
+ TpChannel *chan;
+ TpIntSet *self_handle_singleton = tp_intset_new ();
+ GHashTable *details = g_hash_table_new_full (g_str_hash, g_str_equal, NULL,
+ (GDestroyNotify) tp_g_value_slice_free);
+ GValue *v;
+ gboolean invalidated = FALSE;
+ GError *error = NULL;
+
+ chan_path = g_strdup_printf ("%s/Channel_1_6180339887", conn_path);
+ service_chan = TEST_TEXT_CHANNEL_GROUP (g_object_new (
+ TEST_TYPE_TEXT_CHANNEL_GROUP,
+ "connection", service_conn,
+ "object-path", chan_path,
+ "detailed", TRUE,
+ "properties", TRUE,
+ NULL));
+ chan = tp_channel_new (conn, chan_path, NULL, TP_UNKNOWN_HANDLE_TYPE, 0,
+ &error);
+
+ MYASSERT_NO_ERROR (error);
+
+ MYASSERT (tp_channel_run_until_ready (chan, &error, NULL), "");
+ MYASSERT_NO_ERROR (error);
+ DEBUG ("ready!");
+
+ g_signal_connect (chan, "invalidated", (GCallback) check_invalidated_cb,
+ &invalidated);
+
+ tp_intset_add (self_handle_singleton, self_handle);
+ tp_group_mixin_change_members ((GObject *) service_chan, "hello",
+ self_handle_singleton, NULL, NULL, NULL, 0,
+ TP_CHANNEL_GROUP_CHANGE_REASON_NONE);
+
+ test_connection_run_until_dbus_queue_processed (conn);
+
+ v = tp_g_value_slice_new (G_TYPE_UINT);
+ g_value_set_uint (v, REMOVED_REASON);
+ g_hash_table_insert (details, "change-reason", v);
+
+ v = tp_g_value_slice_new (G_TYPE_STRING);
+ g_value_set_static_string (v, REMOVED_MESSAGE);
+ g_hash_table_insert (details, "message", v);
+
+ v = tp_g_value_slice_new (G_TYPE_STRING);
+ g_value_set_static_string (v, REMOVED_ERROR);
+ g_hash_table_insert (details, "error", v);
+
+ tp_group_mixin_change_members_detailed ((GObject *) service_chan, NULL,
+ self_handle_singleton, NULL, NULL, details);
+
+ test_connection_run_until_dbus_queue_processed (conn);
+
+ tp_cli_channel_call_close (chan, -1, NULL, NULL, NULL, NULL);
+
+ g_hash_table_unref (details);
+
+ test_connection_run_until_dbus_queue_processed (conn);
+
+ MYASSERT (invalidated, "");
+
+ g_object_unref (chan);
+ g_object_unref (service_chan);
+ g_free (chan_path);
+}
+
int
main (int argc,
char **argv)
@@ -346,6 +447,7 @@ main (int argc,
MYASSERT_NO_ERROR (error);
run_membership_tests ();
+ check_removed_error_in_invalidated ();
MYASSERT (tp_cli_connection_run_disconnect (conn, -1, &error, NULL), "");
MYASSERT_NO_ERROR (error);
--
1.5.6.5
More information about the Telepathy-commits
mailing list