node tests: Show the window
authorMatthias Clasen <mclasen@redhat.com>
Sat, 18 Jan 2020 01:35:00 +0000 (20:35 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 18 Jan 2020 04:47:34 +0000 (23:47 -0500)
This avoids using default styles.

testsuite/css/nodes/test-css-nodes.c

index 54664c7d45f7e15fe31a082448f65a36973a03a2..28bdfcb9b1f512a80adb44415163785adbb5dbcc 100644 (file)
@@ -96,12 +96,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);
+
+  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, *reference_file;
   GError *error = NULL;
@@ -118,9 +129,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);
+  while (!output)
+    g_main_context_iteration (NULL, FALSE);
 
   if (generate)
     {