[Xfce4-commits] <midori:master> Refactor test timeout as grab_max_timeout, try wakeup first

Christian Dywan noreply at xfce.org
Sat Dec 8 15:32:01 CET 2012


Updating branch refs/heads/master
         to 22f6ef50d24d2a8edfef411161a13bdba8f68d8b (commit)
       from cb9900d237be9ee9310c0b69e61606cce88d740c (commit)

commit 22f6ef50d24d2a8edfef411161a13bdba8f68d8b
Author: Christian Dywan <christian at twotoasts.de>
Date:   Sat Dec 8 15:30:40 2012 +0100

    Refactor test timeout as grab_max_timeout, try wakeup first

 midori/midori-dialog.vala |   20 ++++++++++++++++++++
 tests/app.vala            |   13 ++++++-------
 tests/tab.vala            |    6 ++----
 wscript                   |    1 +
 4 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/midori/midori-dialog.vala b/midori/midori-dialog.vala
index d8c7146..a03d80d 100644
--- a/midori/midori-dialog.vala
+++ b/midori/midori-dialog.vala
@@ -24,6 +24,26 @@ namespace Midori {
     }
 
     namespace Test {
+        internal static uint test_max_timeout = 0;
+        internal static string? test_first_try = null;
+        public void grab_max_timeout () {
+            test_first_try = "once";
+            test_max_timeout = GLib.Timeout.add_seconds (3, ()=>{
+                stdout.printf ("Timed out %s%s\n", test_first_try,
+                    MainContext.default ().pending () ? " (loop)" : "");
+                if (test_first_try == "twice")
+                    Process.exit (0);
+                test_first_try = "twice";
+                MainContext.default ().wakeup ();
+                return true;
+                });
+        }
+        public void release_max_timeout () {
+            assert (test_max_timeout > 0);
+            GLib.Source.remove (test_max_timeout);
+            test_max_timeout = 0;
+        }
+
         internal static bool test_idle_timeouts = false;
         public void idle_timeouts () {
             test_idle_timeouts = true;
diff --git a/tests/app.vala b/tests/app.vala
index d6b9234..0ded6b0 100644
--- a/tests/app.vala
+++ b/tests/app.vala
@@ -10,8 +10,7 @@
 */
 
 void app_normal () {
-    uint test_timeout = GLib.Timeout.add_seconds (10, ()=>{
-        stdout.printf ("Timed out\n"); Process.exit (0); });
+    Midori.Test.grab_max_timeout ();
 
     Midori.Test.idle_timeouts ();
     Midori.Test.log_set_fatal_handler_for_icons ();
@@ -30,18 +29,16 @@ void app_normal () {
         do { loop.iteration (true); } while (loop.pending ());
     }
 
-    GLib.Source.remove (test_timeout);
+    Midori.Test.release_max_timeout ();
 }
 
 void app_custom_config () {
     Midori.Test.log_set_fatal_handler_for_icons ();
-    /*
     Midori.Paths.Test.reset_runtime_mode ();
     var app = Midori.normal_app_new ("/tmp/mylittlepony", false, false, null, null, null, -1, null);
     var loop = MainContext.default ();
     do { loop.iteration (true); } while (loop.pending ());
     Midori.normal_app_on_quit (app);
-    */
 }
 void app_private () {
     Midori.Test.log_set_fatal_handler_for_icons ();
@@ -59,7 +56,8 @@ void app_web () {
 }
 
 void app_extensions () {
-    /*
+    Midori.Test.grab_max_timeout ();
+
     Midori.Test.idle_timeouts ();
     Midori.Test.log_set_fatal_handler_for_icons ();
     Midori.Paths.Test.reset_runtime_mode ();
@@ -72,7 +70,8 @@ void app_extensions () {
         app.browser.close_tab (tab);
         do { loop.iteration (true); } while (loop.pending ());
     }
-    */
+
+    Midori.Test.release_max_timeout ();
 }
 
 void main (string[] args) {
diff --git a/tests/tab.vala b/tests/tab.vala
index da3c210..b117641 100644
--- a/tests/tab.vala
+++ b/tests/tab.vala
@@ -76,9 +76,7 @@ static void tab_display_ellipsize () {
 }
 
 void tab_special () {
-    uint test_timeout = GLib.Timeout.add_seconds (10, ()=>{
-        stdout.printf ("Timed out\n"); Process.exit (0); });
-
+    Midori.Test.grab_max_timeout ();
     Midori.Test.log_set_fatal_handler_for_icons ();
     var test_address = new Soup.Address ("127.0.0.1", Soup.ADDRESS_ANY_PORT);
     test_address.resolve_sync (null);
@@ -169,7 +167,7 @@ void tab_special () {
     browser.activate_action ("TabDuplicate");
     browser.activate_action ("TabCloseOther");
 
-    GLib.Source.remove (test_timeout);
+    Midori.Test.release_max_timeout ();
 }
 
 void tab_download_dialog () {
diff --git a/wscript b/wscript
index 7ea9ca1..ee10a0b 100644
--- a/wscript
+++ b/wscript
@@ -577,6 +577,7 @@ def shutdown ():
             Utils.check_dir (os.environ[x])
         # Avoid i18n-related false failures
         os.environ['LC_ALL'] = 'C'
+        os.environ['UNIQUE_BACKEND'] = 'bacon'
         test = UnitTest.unit_test ()
 
         if True:


More information about the Xfce4-commits mailing list