From 1f6e31aae20ac9c512524bfa0fd201b7002da093 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 16 Apr 2012 18:14:44 +0100 Subject: [PATCH 06/14] TpAccountChannelRequest: test that properties get through to the request --- 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(+) 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; -- 1.7.10