style tests: Show the window
authorMatthias Clasen <mclasen@redhat.com>
Wed, 15 Jan 2020 07:00:09 +0000 (02:00 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 18 Jan 2020 04:47:34 +0000 (23:47 -0500)
Not doing so somewhat defeats the point that we want
to verify the regular styles, not some weird initial
conditions.

testsuite/css/style/test-css-style.c

index c7c0bca3aa680b19d4be38d5dfc932230284dba1..833cc3dc0dfd7ac14a17ea7a5bbcb02a6be631f5 100644 (file)
@@ -98,12 +98,23 @@ done:
   return diff;
 }
 
+static void
+style_context_changed (GtkWidget *window, const char **output)
+{
+  GtkStyleContext *context;
+
+  context = gtk_widget_get_style_context (window);
+
+  *output = gtk_style_context_to_string (context, GTK_STYLE_CONTEXT_PRINT_RECURSE |
+                                                  GTK_STYLE_CONTEXT_PRINT_SHOW_STYLE);
+  g_main_context_wakeup (NULL);
+}
+
 static void
 load_ui_file (GFile *file, gboolean generate)
 {
   GtkBuilder *builder;
   GtkWidget *window;
-  GtkStyleContext *context;
   char *output, *diff;
   char *ui_file, *css_file, *reference_file;
   GtkCssProvider *provider;
@@ -125,10 +136,13 @@ load_ui_file (GFile *file, gboolean generate)
 
   g_assert (window != NULL);
 
-  context = gtk_widget_get_style_context (window);
+  output = NULL;
+  g_signal_connect (window, "map", G_CALLBACK (style_context_changed), &output);
+
+  gtk_widget_show (window);
 
-  output = gtk_style_context_to_string (context, GTK_STYLE_CONTEXT_PRINT_RECURSE |
-                                                 GTK_STYLE_CONTEXT_PRINT_SHOW_STYLE);
+  while (!output)
+    g_main_context_iteration (NULL, FALSE);
 
   if (generate)
     {