[gtk+] reftests: Make animation-direction test more reliable



commit 5a2feab8c0e856ae3536817b8f120d0ff13bb623
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Jan 31 13:51:54 2016 -0500

    reftests: Make animation-direction test more reliable
    
    This test was failing in continuous, where the tests are running
    in a VM with disabled animations. Make the test adapt to that
    situation by changing the reference ui on the fly if we find
    that animations are disabled.

 testsuite/reftests/Makefile.am                |    1 +
 testsuite/reftests/animation-direction.ref.ui |   32 +++++++++++++++++
 testsuite/reftests/label-attributes.c         |   46 +++++++++++++++++++++++++
 3 files changed, 79 insertions(+), 0 deletions(-)
---
diff --git a/testsuite/reftests/Makefile.am b/testsuite/reftests/Makefile.am
index 89d89e0..369bf6f 100644
--- a/testsuite/reftests/Makefile.am
+++ b/testsuite/reftests/Makefile.am
@@ -506,6 +506,7 @@ libreftest_la_SOURCES =                     \
        statusbar-remove-all.c          \
        textview-border-windows.c       \
        textview-tags.c                 \
+       label-attributes.c              \
        $(NULL)
 
 -include $(top_srcdir)/git.mk
diff --git a/testsuite/reftests/animation-direction.ref.ui b/testsuite/reftests/animation-direction.ref.ui
index 6d8dc7b..c43ed1c 100644
--- a/testsuite/reftests/animation-direction.ref.ui
+++ b/testsuite/reftests/animation-direction.ref.ui
@@ -15,6 +15,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffff00000000"/>
             </attributes>
@@ -29,6 +30,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffffffff0000"/>
             </attributes>
@@ -43,6 +45,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffff00000000"/>
             </attributes>
@@ -57,6 +60,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffff00000000"/>
             </attributes>
@@ -71,6 +75,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffff00000000"/>
             </attributes>
@@ -85,6 +90,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffff00000000"/>
             </attributes>
@@ -99,6 +105,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffff00000000"/>
             </attributes>
@@ -113,6 +120,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffff00000000"/>
             </attributes>
@@ -127,6 +135,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffff00000000"/>
             </attributes>
@@ -141,6 +150,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffff00000000"/>
             </attributes>
@@ -155,6 +165,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffff00000000"/>
             </attributes>
@@ -169,6 +180,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffff00000000"/>
             </attributes>
@@ -183,6 +195,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffff00000000"/>
             </attributes>
@@ -197,6 +210,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffff00000000"/>
             </attributes>
@@ -211,6 +225,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffff00000000"/>
             </attributes>
@@ -225,6 +240,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffff00000000"/>
             </attributes>
@@ -239,6 +255,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffff00000000"/>
             </attributes>
@@ -253,6 +270,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffffffff0000"/>
             </attributes>
@@ -267,6 +285,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffffffff0000"/>
             </attributes>
@@ -281,6 +300,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffffffff0000"/>
             </attributes>
@@ -295,6 +315,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffffffff0000"/>
             </attributes>
@@ -309,6 +330,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffffffff0000"/>
             </attributes>
@@ -323,6 +345,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffffffff0000"/>
             </attributes>
@@ -337,6 +360,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffffffff0000"/>
             </attributes>
@@ -351,6 +375,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffffffff0000"/>
             </attributes>
@@ -365,6 +390,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffffffff0000"/>
             </attributes>
@@ -379,6 +405,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffffffff0000"/>
             </attributes>
@@ -393,6 +420,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffffffff0000"/>
             </attributes>
@@ -407,6 +435,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffffffff0000"/>
             </attributes>
@@ -421,6 +450,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffffffff0000"/>
             </attributes>
@@ -435,6 +465,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffffffff0000"/>
             </attributes>
@@ -449,6 +480,7 @@
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="label" translatable="yes">XXX</property>
+            <signal name="map" handler="reftest:strip_attributes_if_no_animation"/>
             <attributes>
               <attribute name="foreground" value="#ffffffff0000"/>
             </attributes>
diff --git a/testsuite/reftests/label-attributes.c b/testsuite/reftests/label-attributes.c
new file mode 100644
index 0000000..7ee9902
--- /dev/null
+++ b/testsuite/reftests/label-attributes.c
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2016 Red Hat Inc.
+ *
+ * Author:
+ *      Matthias Clasen <mclasen redhat com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <gtk/gtk.h>
+
+#include "gtk-reftest.h"
+
+static gboolean
+unblock (gpointer data)
+{
+  reftest_uninhibit_snapshot ();
+  return G_SOURCE_REMOVE;
+}
+
+G_MODULE_EXPORT void
+strip_attributes_if_no_animation (GtkWidget *widget)
+{
+  gboolean enabled;
+
+  g_object_get (gtk_widget_get_settings (widget), "gtk-enable-animations", &enabled, NULL);
+  if (enabled)
+    return;
+
+  reftest_inhibit_snapshot ();
+  gtk_label_set_attributes (GTK_LABEL (widget), NULL);
+  g_timeout_add (500, unblock, NULL);
+}


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