[next] telepathy-glib: Test tp_account_channel_request_set_file_transfer_description etc.

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


Module: telepathy-glib
Branch: next
Commit: 0f17e3bf57c0c1f0fd2a618f36269215b0a948e5
URL:    http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=0f17e3bf57c0c1f0fd2a618f36269215b0a948e5

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Wed Apr 25 15:59:10 2012 +0100

Test tp_account_channel_request_set_file_transfer_description etc.

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 |   63 ++++++++++++++++++++++++++++++++++
 1 files changed, 63 insertions(+), 0 deletions(-)

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 ();
 }



More information about the telepathy-commits mailing list