Add a little wait to focus tests
authorMatthias Clasen <mclasen@redhat.com>
Fri, 12 May 2023 02:23:01 +0000 (22:23 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 12 May 2023 02:24:10 +0000 (22:24 -0400)
I don't know exactly why, but this seems
to help the tests not fail on X11.

testsuite/gtk/test-focus-chain.c

index 63484ee1a572742c4351b982fad3c2ae70866ae2..c89e276126beece3745cc133d15869918d325698 100644 (file)
@@ -67,6 +67,26 @@ check_focus_states (GtkWidget *focus_widget)
     }
 }
 
+static gboolean
+quit_iteration_loop (gpointer user_data)
+{
+  gboolean *keep_running = user_data;
+
+  *keep_running = FALSE;
+
+  return G_SOURCE_REMOVE;
+}
+
+static void
+wait (guint millis)
+{
+  gboolean keep_running = TRUE;
+
+  g_timeout_add (millis, quit_iteration_loop, &keep_running);
+  while (keep_running)
+    g_main_context_iteration (NULL, TRUE);
+}
+
 static char *
 generate_focus_chain (GtkWidget        *window,
                       GtkDirectionType  dir)
@@ -125,6 +145,7 @@ generate_focus_chain (GtkWidget        *window,
         }
 
       g_string_append_printf (output, "%s\n", name);
+      wait (100);
       count++;
 
       if (!first)
@@ -170,16 +191,6 @@ get_dir_for_file (const char *path)
   return 0;
 }
 
-static gboolean
-quit_iteration_loop (gpointer user_data)
-{
-  gboolean *keep_running = user_data;
-
-  *keep_running = FALSE;
-
-  return G_SOURCE_REMOVE;
-}
-
 static gboolean
 load_ui_file (GFile *ui_file,
               GFile *ref_file,