filechooserbutton: Duh, remove all the timeouts after tests

Otherwise tests may start failing if they start after an old timeout triggers.

Signed-off-by: Federico Mena Quintero <federico@gnome.org>
This commit is contained in:
Federico Mena Quintero 2013-03-12 13:34:13 -06:00
parent d84f5ae17e
commit 563eb60666

View File

@ -128,6 +128,7 @@ test_set_filename (GtkFileChooserAction action,
{ {
GtkWidget *chooser; GtkWidget *chooser;
struct test_set_filename_closure closure; struct test_set_filename_closure closure;
guint timeout_id;
chooser = gtk_file_chooser_dialog_new ("hello", NULL, action, chooser = gtk_file_chooser_dialog_new ("hello", NULL, action,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
@ -141,8 +142,9 @@ test_set_filename (GtkFileChooserAction action,
(* set_filename_fn) (GTK_FILE_CHOOSER (chooser), data); (* set_filename_fn) (GTK_FILE_CHOOSER (chooser), data);
gdk_threads_add_timeout_full (G_MAXINT, SLEEP_DURATION, set_filename_timeout_cb, &closure, NULL); timeout_id = gdk_threads_add_timeout_full (G_MAXINT, SLEEP_DURATION, set_filename_timeout_cb, &closure, NULL);
gtk_dialog_run (GTK_DIALOG (chooser)); gtk_dialog_run (GTK_DIALOG (chooser));
g_source_remove (timeout_id);
(* compare_filename_fn) (GTK_FILE_CHOOSER (chooser), data); (* compare_filename_fn) (GTK_FILE_CHOOSER (chooser), data);
@ -373,8 +375,11 @@ sleep_timeout_cb (gpointer data)
static void static void
sleep_in_main_loop (void) sleep_in_main_loop (void)
{ {
gdk_threads_add_timeout_full (G_MAXINT, 250, sleep_timeout_cb, NULL, NULL); guint timeout_id;
timeout_id = gdk_threads_add_timeout_full (G_MAXINT, 250, sleep_timeout_cb, NULL, NULL);
gtk_main (); gtk_main ();
g_source_remove (timeout_id);
} }
static void static void
@ -607,10 +612,15 @@ signal_watcher_expect (SignalWatcher *watcher, const char *signal_name, char *un
if (!conn->emitted) if (!conn->emitted)
{ {
gdk_threads_add_timeout_full (G_MAXINT, 1000, sleep_timeout_cb, NULL, NULL); guint timeout_id;
timeout_id = gdk_threads_add_timeout_full (G_MAXINT, 1000, sleep_timeout_cb, NULL, NULL);
watcher->in_main_loop = TRUE; watcher->in_main_loop = TRUE;
gtk_main (); gtk_main ();
watcher->in_main_loop = FALSE; watcher->in_main_loop = FALSE;
g_source_remove (timeout_id);
} }
emitted = conn->emitted; emitted = conn->emitted;
@ -1780,6 +1790,7 @@ test_confirm_overwrite_for_path (const char *path, gboolean append_extension)
gboolean passed; gboolean passed;
struct confirm_overwrite_closure closure; struct confirm_overwrite_closure closure;
char *filename; char *filename;
guint timeout_id;
passed = TRUE; passed = TRUE;
@ -1825,8 +1836,9 @@ test_confirm_overwrite_for_path (const char *path, gboolean append_extension)
gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (closure.chooser), path); gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (closure.chooser), path);
} }
gdk_threads_add_timeout_full (G_MAXINT, SLEEP_DURATION, confirm_overwrite_timeout_cb, &closure, NULL); timeout_id = gdk_threads_add_timeout_full (G_MAXINT, SLEEP_DURATION, confirm_overwrite_timeout_cb, &closure, NULL);
gtk_dialog_run (GTK_DIALOG (closure.chooser)); gtk_dialog_run (GTK_DIALOG (closure.chooser));
g_source_remove (timeout_id);
filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (closure.chooser)); filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (closure.chooser));
passed = passed && filename && (strcmp (filename, path) == 0); passed = passed && filename && (strcmp (filename, path) == 0);