telepathy-glib: TpAccountChannelRequest: test that properties get through to the request

Simon McVittie smcv at kemper.freedesktop.org
Mon Apr 30 11:57:29 PDT 2012


Module: telepathy-glib
Branch: master
Commit: 2e07d043286d90064679b066118877d26bae1f58
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=2e07d043286d90064679b066118877d26bae1f58

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Mon Apr 16 18:14:44 2012 +0100

TpAccountChannelRequest: test that properties get through to the request

Signed-off-by: Simon McVittie <simon.mcvittie at collabora.co.uk>
Reviewed-by: Jonny Lamb <jonny.lamb at collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=48780

---

 tests/dbus/account-channel-request.c  |   18 ++++++++++++++++++
 tests/lib/simple-channel-dispatcher.c |   25 +++++++++++++++++++++++++
 tests/lib/simple-channel-dispatcher.h |    7 +++++++
 3 files changed, 50 insertions(+), 0 deletions(-)

diff --git a/tests/dbus/account-channel-request.c b/tests/dbus/account-channel-request.c
index f899083..a3a5c38 100644
--- a/tests/dbus/account-channel-request.c
+++ b/tests/dbus/account-channel-request.c
@@ -218,6 +218,15 @@ test_handle_create_success (Test *test,
   g_assert (TP_IS_CHANNEL_REQUEST (chan_req));
   g_assert (tp_account_channel_request_get_channel_request (req) == chan_req);
   g_object_unref (chan_req);
+
+  /* The request had the properties we wanted */
+  g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request,
+        TP_PROP_CHANNEL_CHANNEL_TYPE), ==, TP_IFACE_CHANNEL_TYPE_TEXT);
+  g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request,
+        TP_PROP_CHANNEL_TARGET_ID), ==, "alice");
+  g_assert_cmpuint (tp_asv_get_uint32 (test->cd_service->last_request,
+        TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, NULL), ==, TP_HANDLE_TYPE_CONTACT);
+  g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 3);
 }
 
 /* ChannelDispatcher.CreateChannel() call fails */
@@ -356,6 +365,15 @@ test_handle_ensure_success (Test *test,
   g_assert_error (test->error, TP_ERRORS, TP_ERROR_NOT_YOURS);
 
   g_object_unref (alice);
+
+  /* The request had the properties we wanted */
+  g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request,
+        TP_PROP_CHANNEL_CHANNEL_TYPE), ==, TP_IFACE_CHANNEL_TYPE_TEXT);
+  g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request,
+        TP_PROP_CHANNEL_TARGET_ID), ==, "alice");
+  g_assert_cmpuint (tp_asv_get_uint32 (test->cd_service->last_request,
+        TP_PROP_CHANNEL_TARGET_HANDLE_TYPE, NULL), ==, TP_HANDLE_TYPE_CONTACT);
+  g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 3);
 }
 
 /* Cancel the operation before starting it */
diff --git a/tests/lib/simple-channel-dispatcher.c b/tests/lib/simple-channel-dispatcher.c
index d3cb44b..ca4ac83 100644
--- a/tests/lib/simple-channel-dispatcher.c
+++ b/tests/lib/simple-channel-dispatcher.c
@@ -124,6 +124,16 @@ create_channel (TpTestsSimpleChannelDispatcher *self,
     GHashTable *hints,
     DBusGMethodInvocation *context)
 {
+  tp_clear_pointer (&self->last_request, g_hash_table_unref);
+  self->last_request = g_boxed_copy (TP_HASH_TYPE_STRING_VARIANT_MAP, request);
+  tp_clear_pointer (&self->last_hints, g_hash_table_unref);
+  self->last_hints = g_boxed_copy (TP_HASH_TYPE_STRING_VARIANT_MAP, request);
+  self->last_user_action_time = user_action_time;
+  g_free (self->last_account);
+  self->last_account = g_strdup (account);
+  g_free (self->last_preferred_handler);
+  self->last_preferred_handler = g_strdup (preferred_handler);
+
   if (tp_asv_get_boolean (request, "CreateChannelFail", NULL))
     {
       /* Fail to create the channel */
@@ -193,6 +203,16 @@ ensure_channel (TpTestsSimpleChannelDispatcher *self,
     GHashTable *hints,
     DBusGMethodInvocation *context)
 {
+  tp_clear_pointer (&self->last_request, g_hash_table_unref);
+  self->last_request = g_boxed_copy (TP_HASH_TYPE_STRING_VARIANT_MAP, request);
+  tp_clear_pointer (&self->last_hints, g_hash_table_unref);
+  self->last_hints = g_boxed_copy (TP_HASH_TYPE_STRING_VARIANT_MAP, request);
+  self->last_user_action_time = user_action_time;
+  g_free (self->last_account);
+  self->last_account = g_strdup (account);
+  g_free (self->last_preferred_handler);
+  self->last_preferred_handler = g_strdup (preferred_handler);
+
   if (self->priv->old_handler != NULL)
     {
       /* Pretend that the channel already exists */
@@ -381,6 +401,11 @@ tp_tests_simple_channel_dispatcher_dispose (GObject *object)
 
   g_free (self->priv->old_handler);
 
+  tp_clear_pointer (&self->last_request, g_hash_table_unref);
+  tp_clear_pointer (&self->last_hints, g_hash_table_unref);
+  tp_clear_pointer (&self->last_account, g_free);
+  tp_clear_pointer (&self->last_preferred_handler, g_free);
+
   if (G_OBJECT_CLASS (tp_tests_simple_channel_dispatcher_parent_class)->dispose != NULL)
     G_OBJECT_CLASS (tp_tests_simple_channel_dispatcher_parent_class)->dispose (object);
 }
diff --git a/tests/lib/simple-channel-dispatcher.h b/tests/lib/simple-channel-dispatcher.h
index 42ba45f..4512e99 100644
--- a/tests/lib/simple-channel-dispatcher.h
+++ b/tests/lib/simple-channel-dispatcher.h
@@ -29,6 +29,13 @@ struct _TpTestsSimpleChannelDispatcherClass {
 struct _TpTestsSimpleChannelDispatcher {
     GObject parent;
 
+    /* so regression tests can verify what was asked for */
+    GHashTable *last_request;
+    gchar *last_account;
+    gint64 last_user_action_time;
+    gchar *last_preferred_handler;
+    GHashTable *last_hints;
+
     TpTestsSimpleChannelDispatcherPrivate *priv;
 
     gboolean refuse_delegate;



More information about the telepathy-commits mailing list