[gimp] app: Add gimp_test_run_temp_mainloop()



commit 1923280e5719af3c50cfda3a076e4174fbbe715f
Author: Martin Nordholts <martinn src gnome org>
Date:   Thu Sep 17 00:12:23 2009 +0200

    app: Add gimp_test_run_temp_mainloop()
    
    Add gimp_test_run_temp_mainloop() which is a helper function for tests
    that wants to run a main loop for a while. Useful when you want GIMP's
    state to settle before doing tests.

 app/tests.c |   33 +++++++++++++++++++++++++++++++++
 app/tests.h |    7 ++++---
 2 files changed, 37 insertions(+), 3 deletions(-)
---
diff --git a/app/tests.c b/app/tests.c
index f16e255..6e0cd85 100644
--- a/app/tests.c
+++ b/app/tests.c
@@ -104,3 +104,36 @@ gimp_init_for_gui_testing (gboolean use_cpu_accel, gboolean show_gui)
 }
 
 #endif /* GIMP_CONSOLE_COMPILATION */
+
+static gboolean
+gimp_tests_quit_mainloop (GMainLoop *loop)
+{
+  g_main_loop_quit (loop);
+
+  return FALSE;
+}
+
+/**
+ * gimp_test_run_temp_mainloop:
+ * @running_time: The time to run the main loop.
+ *
+ * Helper function for tests that wants to run a main loop for a
+ * while. Useful when you want GIMP's state to settle before doing
+ * tests.
+ **/
+void
+gimp_test_run_temp_mainloop (guint32 running_time)
+{
+  GMainLoop *loop;
+  loop = g_main_loop_new (NULL, FALSE);
+
+  g_timeout_add (running_time,
+                 (GSourceFunc) gimp_tests_quit_mainloop,
+                 loop);
+
+  g_main_loop_run (loop);
+
+  g_main_loop_unref (loop);
+}
+
+
diff --git a/app/tests.h b/app/tests.h
index 1282753..d4e2fcd 100644
--- a/app/tests.h
+++ b/app/tests.h
@@ -19,9 +19,10 @@
 #define __TESTS_H__
 
 
-Gimp * gimp_init_for_testing     (gboolean use_cpu_accel);
-Gimp * gimp_init_for_gui_testing (gboolean use_cpu_accel,
-                                  gboolean show_gui);
+Gimp * gimp_init_for_testing       (gboolean use_cpu_accel);
+Gimp * gimp_init_for_gui_testing   (gboolean use_cpu_accel,
+                                    gboolean show_gui);
+void   gimp_test_run_temp_mainloop (guint32  running_time);
 
 
 #endif /* __TESTS_H__ */



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