[gtk/ci-default-settings-4] reftests: Enforce default settings




commit 4e4f57e091020750d66134c212d7778c17d96c20
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Jul 19 13:10:31 2021 -0400

    reftests: Enforce default settings
    
    Set all settings to their default values, so we
    are less dependent on the environment to be set
    up just right. In particular, this fixes animations
    being disabled when we happen to run in a vm.

 testsuite/reftests/gtk-reftest.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
---
diff --git a/testsuite/reftests/gtk-reftest.c b/testsuite/reftests/gtk-reftest.c
index efe48e6480..cd153969a8 100644
--- a/testsuite/reftests/gtk-reftest.c
+++ b/testsuite/reftests/gtk-reftest.c
@@ -453,6 +453,37 @@ log_writer (GLogLevelFlags   log_level,
   return g_log_writer_standard_streams (log_level, fields, n_fields, user_data);
 }
 
+static void
+enforce_default_settings (void)
+{
+  GtkSettings *settings;
+  GObjectClass *klass;
+  GParamSpec **pspecs;
+  guint n_pspecs;
+  int i;
+
+  settings = gtk_settings_get_default ();
+
+  klass = g_type_class_ref (G_OBJECT_TYPE (settings));
+
+  pspecs = g_object_class_list_properties (klass, &n_pspecs);
+  for (i = 0; i < n_pspecs; i++)
+    {
+      GParamSpec *pspec = pspecs[i];
+      const GValue *value;
+
+      if ((pspec->flags & G_PARAM_WRITABLE) == 0)
+        continue;
+
+      value = g_param_spec_get_default_value (pspec);
+      g_object_set_property (G_OBJECT (settings), pspec->name, value);
+    }
+
+  g_free (pspecs);
+
+  g_type_class_unref (klass);
+}
+
 int
 main (int argc, char **argv)
 {
@@ -503,6 +534,8 @@ main (int argc, char **argv)
    */
   chdir (basedir);
 
+  enforce_default_settings ();
+
   g_log_set_writer_func (log_writer, NULL, NULL);
 
   result = g_test_run ();


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