[gtk/matthiasc/css-change: 10/11] testsuite: Don't check default styles



commit 6602fdc2142cccebc00e115fa1152e8f21d89dda
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Jan 15 02:00:09 2020 -0500

    testsuite: Don't check default styles
    
    This somewhat defeats the point that we want
    to verify the regular styles, not some weird
    initial conditions. So show the window, and
    wait until it gets mapped to get the style.

 testsuite/css/style/test-css-style.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
---
diff --git a/testsuite/css/style/test-css-style.c b/testsuite/css/style/test-css-style.c
index 9c9cbb18e5..0dc5a7977f 100644
--- a/testsuite/css/style/test-css-style.c
+++ b/testsuite/css/style/test-css-style.c
@@ -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)
     {


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