[Telepathy-commits] [telepathy-glib/master] tests/dbus/channel-introspect.c: exercise new_with_properties (fd.o #17427) and borrow_immutable_properties
Simon McVittie
simon.mcvittie at collabora.co.uk
Fri Nov 28 07:05:11 PST 2008
---
tests/dbus/channel-introspect.c | 124 ++++++++++++++++++++++++++++++++++-----
1 files changed, 108 insertions(+), 16 deletions(-)
diff --git a/tests/dbus/channel-introspect.c b/tests/dbus/channel-introspect.c
index 4bd6d78..cdd1101 100644
--- a/tests/dbus/channel-introspect.c
+++ b/tests/dbus/channel-introspect.c
@@ -59,6 +59,7 @@ static void
assert_chan_sane (TpChannel *chan,
TpHandle handle)
{
+ GHashTable *asv;
TpHandleType type;
MYASSERT (tp_channel_is_ready (chan), "");
@@ -70,6 +71,18 @@ assert_chan_sane (TpChannel *chan,
MYASSERT (tp_channel_get_channel_type_id (chan) ==
TP_IFACE_QUARK_CHANNEL_TYPE_TEXT, "");
MYASSERT (TP_IS_CONNECTION (tp_channel_borrow_connection (chan)), "");
+
+ asv = tp_channel_borrow_immutable_properties (chan);
+ MYASSERT (asv != NULL, "");
+ MYASSERT_SAME_STRING (
+ tp_asv_get_string (asv, TP_IFACE_CHANNEL ".ChannelType"),
+ TP_IFACE_CHANNEL_TYPE_TEXT);
+ MYASSERT_SAME_UINT (
+ tp_asv_get_uint32 (asv, TP_IFACE_CHANNEL ".TargetHandleType", NULL),
+ TP_HANDLE_TYPE_CONTACT);
+ MYASSERT_SAME_UINT (
+ tp_asv_get_uint32 (asv, TP_IFACE_CHANNEL ".TargetHandle", NULL),
+ handle);
}
int
@@ -80,7 +93,7 @@ main (int argc,
TpBaseConnection *service_conn_as_base;
TpHandleRepoIface *contact_repo;
TestTextChannelNull *service_chan;
- TestPropsTextChannel *service_props_chan;
+ TestTextChannelNull *service_props_chan;
TpDBusDaemon *dbus;
TpConnection *conn;
TpChannel *chan;
@@ -94,6 +107,8 @@ main (int argc,
gboolean was_ready;
GError invalidated_for_test = { TP_ERRORS, TP_ERROR_PERMISSION_DENIED,
"No channel for you!" };
+ GHashTable *asv;
+ GValue *value;
g_type_init ();
tp_debug_set_flags ("all");
@@ -137,7 +152,7 @@ main (int argc,
props_chan_path = g_strdup_printf ("%s/PropertiesChannel", conn_path);
- service_props_chan = TEST_PROPS_TEXT_CHANNEL (g_object_new (
+ service_props_chan = TEST_TEXT_CHANNEL_NULL (g_object_new (
TEST_TYPE_PROPS_TEXT_CHANNEL,
"connection", service_conn,
"object-path", props_chan_path,
@@ -146,7 +161,7 @@ main (int argc,
mainloop = g_main_loop_new (NULL, FALSE);
- /* Channel becomes invalid while we wait */
+ g_message ("Channel becomes invalid while we wait");
chan = tp_channel_new (conn, chan_path, TP_IFACE_CHANNEL_TYPE_TEXT,
TP_HANDLE_TYPE_CONTACT, handle, &error);
@@ -162,7 +177,7 @@ main (int argc,
g_object_unref (chan);
chan = NULL;
- /* Channel becomes invalid and we are called back synchronously */
+ g_message ("Channel becomes invalid and we are called back synchronously");
chan = tp_channel_new (conn, chan_path, TP_IFACE_CHANNEL_TYPE_TEXT,
TP_HANDLE_TYPE_CONTACT, handle, &error);
@@ -180,7 +195,7 @@ main (int argc,
g_object_unref (chan);
chan = NULL;
- /* Channel becomes ready while we wait */
+ g_message ("Channel becomes ready while we wait");
test_connection_run_until_dbus_queue_processed (conn);
@@ -203,8 +218,85 @@ main (int argc,
g_object_unref (chan);
chan = NULL;
- /* Channel becomes ready while we wait (in the case where we have to discover
- * the channel type) */
+ g_message ("Channel becomes ready while we wait (the version with "
+ "Properties)");
+
+ test_connection_run_until_dbus_queue_processed (conn);
+
+ service_props_chan->get_handle_called = 0;
+ service_props_chan->get_interfaces_called = 0;
+ service_props_chan->get_channel_type_called = 0;
+
+ chan = tp_channel_new (conn, props_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);
+ /* FIXME: enable this when the Properties fast-path works
+ MYASSERT_SAME_UINT (service_props_chan->get_handle_called, 0);
+ MYASSERT_SAME_UINT (service_props_chan->get_interfaces_called, 0);
+ MYASSERT_SAME_UINT (service_props_chan->get_channel_type_called, 0);
+ */
+
+ assert_chan_sane (chan, handle);
+
+ g_object_unref (chan);
+ chan = NULL;
+
+ g_message ("Channel becomes ready while we wait (preloading immutable "
+ "properties)");
+
+ test_connection_run_until_dbus_queue_processed (conn);
+
+ service_chan->get_handle_called = 0;
+ service_chan->get_interfaces_called = 0;
+ service_chan->get_channel_type_called = 0;
+
+ asv = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
+ (GDestroyNotify) tp_g_value_slice_free);
+
+ value = tp_g_value_slice_new (G_TYPE_STRING);
+ g_value_set_static_string (value, TP_IFACE_CHANNEL_TYPE_TEXT);
+ g_hash_table_insert (asv, g_strdup (TP_IFACE_CHANNEL ".ChannelType"),
+ tp_g_value_slice_dup (value));
+
+ value = tp_g_value_slice_new (G_TYPE_UINT);
+ g_value_set_uint (value, TP_HANDLE_TYPE_CONTACT);
+ g_hash_table_insert (asv, g_strdup (TP_IFACE_CHANNEL ".TargetHandleType"),
+ tp_g_value_slice_dup (value));
+
+ value = tp_g_value_slice_new (G_TYPE_UINT);
+ g_value_set_uint (value, handle);
+ g_hash_table_insert (asv, g_strdup (TP_IFACE_CHANNEL ".TargetHandle"),
+ tp_g_value_slice_dup (value));
+
+ value = tp_g_value_slice_new (G_TYPE_STRV);
+ g_value_set_static_boxed (value, NULL);
+ g_hash_table_insert (asv, g_strdup (TP_IFACE_CHANNEL ".Interfaces"),
+ tp_g_value_slice_dup (value));
+
+ chan = tp_channel_new_from_properties (conn, chan_path, asv, &error);
+ MYASSERT_NO_ERROR (error);
+
+ g_hash_table_destroy (asv);
+ asv = NULL;
+
+ MYASSERT (tp_channel_run_until_ready (chan, &error, NULL), "");
+ MYASSERT_NO_ERROR (error);
+ /* FIXME: enable this when the Properties based fast-path works
+ MYASSERT_SAME_UINT (service_chan->get_handle_called, 0);
+ MYASSERT_SAME_UINT (service_chan->get_interfaces_called, 0);
+ MYASSERT_SAME_UINT (service_chan->get_channel_type_called, 0);
+ */
+
+ assert_chan_sane (chan, handle);
+
+ g_object_unref (chan);
+ chan = NULL;
+
+ g_message ("Channel becomes ready while we wait (in the case where we "
+ "have to discover the channel type)");
test_connection_run_until_dbus_queue_processed (conn);
@@ -227,8 +319,8 @@ main (int argc,
g_object_unref (chan);
chan = NULL;
- /* Channel becomes ready while we wait (in the case where we have to discover
- * the handle type) */
+ g_message ("Channel becomes ready while we wait (in the case where we "
+ "have to discover the handle type)");
test_connection_run_until_dbus_queue_processed (conn);
@@ -251,8 +343,8 @@ main (int argc,
g_object_unref (chan);
chan = NULL;
- /* Channel becomes ready while we wait (in the case where we have to discover
- * the handle) */
+ g_message ("Channel becomes ready while we wait (in the case where we "
+ "have to discover the handle)");
test_connection_run_until_dbus_queue_processed (conn);
@@ -275,7 +367,7 @@ main (int argc,
g_object_unref (chan);
chan = NULL;
- /* channel does not, in fact, exist (callback) */
+ g_message ("channel does not, in fact, exist (callback)");
bad_chan_path = g_strdup_printf ("%s/Does/Not/Actually/Exist", conn_path);
chan = tp_channel_new (conn, bad_chan_path, NULL,
@@ -299,7 +391,7 @@ main (int argc,
g_free (bad_chan_path);
bad_chan_path = NULL;
- /* channel does not, in fact, exist (run_until_ready) */
+ g_message ("channel does not, in fact, exist (run_until_ready)");
bad_chan_path = g_strdup_printf ("%s/Does/Not/Actually/Exist", conn_path);
chan = tp_channel_new (conn, bad_chan_path, NULL,
@@ -320,7 +412,7 @@ main (int argc,
g_free (bad_chan_path);
bad_chan_path = NULL;
- /* Channel becomes ready and we are called back */
+ g_message ("Channel becomes ready and we are called back");
test_connection_run_until_dbus_queue_processed (conn);
@@ -347,7 +439,7 @@ main (int argc,
/* ... keep the same channel for the next test */
- /* Channel already ready, so we are called back synchronously */
+ g_message ("Channel already ready, so we are called back synchronously");
was_ready = FALSE;
tp_channel_call_when_ready (chan, channel_ready, &was_ready);
@@ -358,7 +450,7 @@ main (int argc,
/* ... keep the same channel for the next test */
- /* Channel already dead, so we are called back synchronously */
+ g_message ("Channel already dead, so we are called back synchronously");
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