[clutter/wip/smcv/issue8] tests/conform: Fix actor-offscreen-redirect



commit f829ddf31449f76292a0f0a2c3e7269802d41a32
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Thu May 26 22:44:49 2016 +0800

    tests/conform: Fix actor-offscreen-redirect
    
    The actor-offscreen-redirect didn't initialize its state properly, so
    it could potentially end up with the "was_painted" state being TRUE
    from the start, effectively skipping the whole test.
    
    Fixing so that the test even run resulted in the test getting stuck in
    a dead lock due to the verification that a frame was drawn was done
    from a paint callback. A paint callback had the mutex held, so when the
    test case tried to run the main loop, the next paint callback caller
    path taken would try to re-lock the same mutex, thus dead lock.
    
    [Changes originally from the fork of clutter in mutter 3.21.4,
    commit 9c0fa583.]
    
    Fixes: https://gitlab.gnome.org/GNOME/clutter/issues/8
    Bug-Debian: https://bugs.debian.org/931921
    Signed-off-by: Simon McVittie <smcv debian org>

 tests/conform/actor-offscreen-redirect.c | 49 +++++++++++++++++++-------------
 1 file changed, 30 insertions(+), 19 deletions(-)
---
diff --git a/tests/conform/actor-offscreen-redirect.c b/tests/conform/actor-offscreen-redirect.c
index f47af3617..63d5e6cfd 100644
--- a/tests/conform/actor-offscreen-redirect.c
+++ b/tests/conform/actor-offscreen-redirect.c
@@ -176,6 +176,33 @@ verify_redraw (Data *data, int expected_paint_count)
   g_assert_cmpint (data->foo_actor->paint_count, ==, expected_paint_count);
 }
 
+static gboolean
+verify_redraws (gpointer user_data)
+{
+  Data *data = user_data;
+
+  /* Queueing a redraw on the actor should cause a redraw */
+  clutter_actor_queue_redraw (data->container);
+  verify_redraw (data, 1);
+
+  /* Queueing a redraw on a child should cause a redraw */
+  clutter_actor_queue_redraw (data->child);
+  verify_redraw (data, 1);
+
+  /* Modifying the transformation on the parent should cause a
+     redraw */
+  clutter_actor_set_anchor_point (data->parent_container, 0, 1);
+  verify_redraw (data, 1);
+
+  /* Redrawing an unrelated actor shouldn't cause a redraw */
+  clutter_actor_set_position (data->unrelated_actor, 0, 1);
+  verify_redraw (data, 0);
+
+  data->was_painted = TRUE;
+
+  return G_SOURCE_REMOVE;
+}
+
 static gboolean
 run_verify (gpointer user_data)
 {
@@ -273,24 +300,8 @@ run_verify (gpointer user_data)
                   0,
                   255);
 
-  /* Queueing a redraw on the actor should cause a redraw */
-  clutter_actor_queue_redraw (data->container);
-  verify_redraw (data, 1);
-
-  /* Queueing a redraw on a child should cause a redraw */
-  clutter_actor_queue_redraw (data->child);
-  verify_redraw (data, 1);
-
-  /* Modifying the transformation on the parent should cause a
-     redraw */
-  clutter_actor_set_anchor_point (data->parent_container, 0, 1);
-  verify_redraw (data, 1);
-
-  /* Redrawing an unrelated actor shouldn't cause a redraw */
-  clutter_actor_set_position (data->unrelated_actor, 0, 1);
-  verify_redraw (data, 0);
-
-  data->was_painted = TRUE;
+  /* Check redraws */
+  g_idle_add (verify_redraws, data);
 
   return G_SOURCE_REMOVE;
 }
@@ -298,7 +309,7 @@ run_verify (gpointer user_data)
 static void
 actor_offscreen_redirect (void)
 {
-  Data data;
+  Data data = { 0 };
 
   if (!cogl_features_available (COGL_FEATURE_OFFSCREEN))
     return;


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