From 67831acecf07e9665203b7149d49a02faa33e790 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Wed, 25 Apr 2012 15:59:10 +0100 Subject: [PATCH 14/16] Test tp_account_channel_request_set_file_transfer_description etc. Signed-off-by: Simon McVittie https://bugs.freedesktop.org/show_bug.cgi?id=48780 --- tests/dbus/account-channel-request.c | 63 ++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/tests/dbus/account-channel-request.c b/tests/dbus/account-channel-request.c index 069bd21..fb77dae 100644 --- a/tests/dbus/account-channel-request.c +++ b/tests/dbus/account-channel-request.c @@ -349,6 +349,65 @@ test_handle_cr_failed (Test *test, } static void +test_ft_props (Test *test, + gconstpointer data G_GNUC_UNUSED) +{ + TpAccountChannelRequest *req; + + req = tp_account_channel_request_new_file_transfer (test->account, + "warez.rar", "application/x-rar", G_GUINT64_CONSTANT (1234567890123), 0); + tp_account_channel_request_set_file_transfer_description (req, + "A collection of l33t warez"); + tp_account_channel_request_set_file_transfer_initial_offset (req, + 1024 * 1024); + tp_account_channel_request_set_file_transfer_timestamp (req, + 1111222233); + tp_account_channel_request_set_file_transfer_uri (req, + "file:///home/Downloads/warez.rar"); + + /* Ask to the CR to fire the signal */ + tp_account_channel_request_set_request_property (req, "FireFailed", + g_variant_new_boolean (TRUE)); + + tp_account_channel_request_create_and_handle_channel_async (req, + NULL, create_and_handle_cb, test); + + g_object_unref (req); + + g_main_loop_run (test->mainloop); + g_assert_error (test->error, TP_ERRORS, TP_ERROR_INVALID_ARGUMENT); + g_assert (test->channel == NULL); + + /* 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_FILE_TRANSFER); + g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request, + TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_FILENAME), ==, "warez.rar"); + g_assert_cmpuint (tp_asv_get_uint64 (test->cd_service->last_request, + TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_SIZE, NULL), ==, + G_GUINT64_CONSTANT (1234567890123)); + g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request, + TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_TYPE), ==, + "application/x-rar"); + g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request, + TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_DESCRIPTION), ==, + "A collection of l33t warez"); + g_assert_cmpstr (tp_asv_get_string (test->cd_service->last_request, + TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_URI), ==, + "file:///home/Downloads/warez.rar"); + g_assert_cmpuint (tp_asv_get_uint64 (test->cd_service->last_request, + TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_INITIAL_OFFSET, NULL), ==, + 1024 * 1024); + g_assert_cmpuint (tp_asv_get_uint64 (test->cd_service->last_request, + TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_DATE, NULL), ==, + 1111222233); + g_assert_cmpuint (tp_asv_get_boolean (test->cd_service->last_request, + "FireFailed", NULL), ==, TRUE); + g_assert_cmpuint (tp_asv_size (test->cd_service->last_request), ==, 9); + g_assert_cmpuint (test->cd_service->last_user_action_time, ==, 0); +} + +static void ensure_and_handle_cb (GObject *source, GAsyncResult *result, gpointer user_data) @@ -1231,5 +1290,9 @@ main (int argc, g_test_add ("/account-channels/request-observe/no-channel", Test, NULL, setup, test_observe_no_channel, teardown); + /* Particular properties of the request */ + g_test_add ("/account-channels/test-ft-props", Test, NULL, + setup, test_ft_props, teardown); + return g_test_run (); } -- 1.7.10