---
 tests/file-transfer.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/tests/file-transfer.c b/tests/file-transfer.c
index 1421f1e..d8dcf6c 100644
--- a/tests/file-transfer.c
+++ b/tests/file-transfer.c
@@ -170,6 +170,47 @@ test_cancel_on_start_task(Fixture *f, gconstpointer 
user_data)
     g_main_loop_run (f->loop);
 }
 
+/*******************************************************************************
+ * TEST CANCEL ON FILE-INFO
+ 
******************************************************************************/
+
+static void
+transfer_flush_callback_cancel_before_flush(SpiceFileTransferTask *xfer_task,
+                                            void *buffer,
+                                            gssize count,
+                                            gpointer user_data)
+{
+    gint i;
+    Fixture *f = user_data;
+    for (i = 0; i < f->num_files; i++) {
+        g_test_expect_message("GSpice", G_LOG_LEVEL_CRITICAL, "*assertion 
'channel != NULL'*");
+    }
+    g_cancellable_cancel(f->cancellable);
+    spice_file_transfer_task_flush_done(xfer_task, NULL);
+    agent_send_success_async(xfer_task);
+}
+
+static void
+test_cancel_on_file_info(Fixture *f, gconstpointer user_data)
+{
+    GList *it;
+
+    f->tasks = spice_file_transfer_task_create_tasks(NULL,
+                                                     f->files,
+                                                     G_FILE_COPY_NONE,
+                                                     f->cancellable,
+                                                     
transfer_flush_callback_cancel_before_flush,
+                                                     f,
+                                                     transfer_done,
+                                                     f);
+    for (it = f->tasks; it != NULL; it = it->next) {
+        SpiceFileTransferTask *xfer_task = SPICE_FILE_TRANSFER_TASK(it->data);
+        g_signal_connect(xfer_task, "file-info", 
G_CALLBACK(transfer_task_on_file_info), f);
+        spice_file_transfer_task_start_task(xfer_task);
+    }
+    g_main_loop_run (f->loop);
+}
+
 /* Tests summary:
  *
  * This tests are specific to SpiceFileTransferTask and how it handles the
@@ -212,6 +253,10 @@ int main(int argc, char* argv[])
                Fixture, GUINT_TO_POINTER(SINGLE_FILE),
                f_setup, test_cancel_on_start_task, f_teardown);
 
+    g_test_add("/spice-file-transfer-task/single/cancel/on-file-info",
+               Fixture, GUINT_TO_POINTER(SINGLE_FILE),
+               f_setup, test_cancel_on_file_info, f_teardown);
+
     g_test_add("/spice-file-transfer-task/multiple/simple-transfer",
                Fixture, GUINT_TO_POINTER(MULTIPLE_FILES),
                f_setup, test_simple_transfer, f_teardown);
@@ -220,5 +265,9 @@ int main(int argc, char* argv[])
                Fixture, GUINT_TO_POINTER(MULTIPLE_FILES),
                f_setup, test_cancel_on_start_task, f_teardown);
 
+    g_test_add("/spice-file-transfer-task/multiple/cancel/on-file-info",
+               Fixture, GUINT_TO_POINTER(MULTIPLE_FILES),
+               f_setup, test_cancel_on_file_info, f_teardown);
+
     return g_test_run();
 }
-- 
2.5.5

_______________________________________________
Spice-devel mailing list
Spice-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/spice-devel

Reply via email to