[gupnp] tests: Add a way to test cancelling introspection gets



commit c90f519475e3c710128454188f5c3e5c3ad62ee0
Author: Jussi Kukkonen <jussi kukkonen intel com>
Date:   Tue Dec 3 22:55:44 2013 +0200

    tests: Add a way to test cancelling introspection gets
    
    First ctrl-C in test-introspection will cancel all current and future
    gupnp_service_info_get_introspection_async_full() calls.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=704867

 tests/test-introspection.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
---
diff --git a/tests/test-introspection.c b/tests/test-introspection.c
index 0a6ca16..4ba97a8 100644
--- a/tests/test-introspection.c
+++ b/tests/test-introspection.c
@@ -30,6 +30,8 @@
 
 GMainLoop *main_loop;
 
+static GCancellable *cancellable;
+
 static gboolean async = FALSE;
 static GOptionEntry entries[] =
 {
@@ -41,7 +43,13 @@ static GOptionEntry entries[] =
 static void
 interrupt_signal_handler (G_GNUC_UNUSED int signum)
 {
-        g_main_loop_quit (main_loop);
+        if (g_cancellable_is_cancelled (cancellable)) {
+                g_main_loop_quit (main_loop);
+        } else {
+                g_print ("Canceling all introspection calls. "
+                         "Press ^C again to quit.\n");
+                g_cancellable_cancel (cancellable);
+        }
 }
 
 static void
@@ -202,9 +210,10 @@ service_proxy_available_cb (G_GNUC_UNUSED GUPnPControlPoint *cp,
         info = GUPNP_SERVICE_INFO (proxy);
 
         if (async) {
-                gupnp_service_info_get_introspection_async (info,
-                                                            got_introspection,
-                                                            NULL);
+                gupnp_service_info_get_introspection_async_full (info,
+                                                                 got_introspection,
+                                                                 cancellable,
+                                                                 NULL);
         } else {
                 introspection =
                         gupnp_service_info_get_introspection (info, &error);
@@ -270,6 +279,8 @@ main (int argc, char **argv)
                 return EXIT_FAILURE;
         }
 
+        cancellable = g_cancellable_new ();
+
         /* We're interested in everything */
         cp = gupnp_control_point_new (context, "ssdp:all");
 


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