[spice-gtk v4 15/15] tests: file-transfer cancel on read file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

diff --git a/tests/file-transfer.c b/tests/file-transfer.c
index c268654..2efaba8 100644
--- a/tests/file-transfer.c
+++ b/tests/file-transfer.c
@@ -211,6 +211,47 @@ test_cancel_on_file_info(Fixture *f, gconstpointer user_data)
     g_main_loop_run (f->loop);
 }
 
+/*******************************************************************************
+ * TEST CANCEL ON READ FILE
+ ******************************************************************************/
+
+static void
+transfer_flush_callback_cancel_after_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 'SPICE_IS_CHANNEL(channel)*");
+    }
+    spice_file_transfer_task_flush_done(xfer_task, NULL);
+    g_cancellable_cancel(f->cancellable);
+    agent_send_success_async(xfer_task);
+}
+
+static void
+test_cancel_on_read_file(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_after_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
@@ -257,6 +298,10 @@ int main(int argc, char* argv[])
                Fixture, GUINT_TO_POINTER(SINGLE_FILE),
                f_setup, test_cancel_on_file_info, f_teardown);
 
+    g_test_add("/spice-file-transfer-task/single/cancel/on-read-file",
+               Fixture, GUINT_TO_POINTER(SINGLE_FILE),
+               f_setup, test_cancel_on_read_file, 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);
@@ -269,5 +314,9 @@ int main(int argc, char* argv[])
                Fixture, GUINT_TO_POINTER(MULTIPLE_FILES),
                f_setup, test_cancel_on_file_info, f_teardown);
 
+    g_test_add("/spice-file-transfer-task/multiple/cancel/on-read-file",
+               Fixture, GUINT_TO_POINTER(MULTIPLE_FILES),
+               f_setup, test_cancel_on_read_file, f_teardown);
+
     return g_test_run();
 }
-- 
2.5.5

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




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]