From 21e2f41a2684556c51b767abd3888e8c4ca43085 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 13 Aug 2020 14:39:13 +0200 Subject: [PATCH] tests/clutter/conform: Make sure to destroy created actors We're moving towards not supporting stand-alone application style clutter stages, meaning the stage tests use will be reused instead of recreated. To make this feasable, tests must clean up after themself. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1364 --- src/tests/clutter/conform/actor-invariants.c | 14 ++++++++++++++ src/tests/clutter/conform/actor-layout.c | 4 ++++ .../clutter/conform/actor-offscreen-redirect.c | 3 +++ src/tests/clutter/conform/actor-paint-opacity.c | 6 ++++++ src/tests/clutter/conform/actor-pick.c | 7 ++++++- src/tests/clutter/conform/actor-pivot-point.c | 3 +++ src/tests/clutter/conform/actor-shader-effect.c | 7 +++++++ 7 files changed, 43 insertions(+), 1 deletion(-) diff --git a/src/tests/clutter/conform/actor-invariants.c b/src/tests/clutter/conform/actor-invariants.c index a49b2bc63..652bdcfa7 100644 --- a/src/tests/clutter/conform/actor-invariants.c +++ b/src/tests/clutter/conform/actor-invariants.c @@ -74,6 +74,8 @@ actor_realized (void) g_assert (!(CLUTTER_ACTOR_IS_MAPPED (actor))); g_assert (!(CLUTTER_ACTOR_IS_VISIBLE (actor))); + + clutter_actor_destroy (actor); } static void @@ -115,6 +117,8 @@ actor_mapped (void) g_assert (CLUTTER_ACTOR_IS_REALIZED (actor)); g_assert (!CLUTTER_ACTOR_IS_MAPPED (actor)); g_assert (!CLUTTER_ACTOR_IS_VISIBLE (actor)); + + clutter_actor_destroy (actor); } static void @@ -155,6 +159,9 @@ actor_visibility_not_recursive (void) clutter_actor_show (stage); g_assert (!CLUTTER_ACTOR_IS_VISIBLE (actor)); + + clutter_actor_destroy (actor); + clutter_actor_destroy (group); } static void @@ -190,6 +197,9 @@ actor_realize_not_recursive (void) g_assert (!CLUTTER_ACTOR_IS_REALIZED (actor)); g_assert (!(CLUTTER_ACTOR_IS_MAPPED (actor))); g_assert (!(CLUTTER_ACTOR_IS_VISIBLE (actor))); + + clutter_actor_destroy (actor); + clutter_actor_destroy (group); } static void @@ -235,6 +245,9 @@ actor_map_recursive (void) g_assert (CLUTTER_ACTOR_IS_MAPPED (actor)); g_assert (CLUTTER_ACTOR_IS_VISIBLE (group)); g_assert (CLUTTER_ACTOR_IS_VISIBLE (actor)); + + clutter_actor_destroy (actor); + clutter_actor_destroy (group); } static void @@ -337,6 +350,7 @@ clone_no_map (void) g_assert (!(CLUTTER_ACTOR_IS_MAPPED (group))); g_assert (!(CLUTTER_ACTOR_IS_MAPPED (actor))); + clutter_actor_destroy (actor); clutter_actor_destroy (CLUTTER_ACTOR (clone)); clutter_actor_destroy (CLUTTER_ACTOR (group)); } diff --git a/src/tests/clutter/conform/actor-layout.c b/src/tests/clutter/conform/actor-layout.c index 9a9814b08..9af90f55a 100644 --- a/src/tests/clutter/conform/actor-layout.c +++ b/src/tests/clutter/conform/actor-layout.c @@ -41,6 +41,8 @@ actor_basic_layout (void) graphene_point_init (&p, 250, 50); clutter_test_assert_actor_at_point (stage, &p, flower[2]); + + clutter_actor_destroy (vase); } static void @@ -86,6 +88,8 @@ actor_margin_layout (void) graphene_point_init (&p, 212, 7); clutter_test_assert_actor_at_point (stage, &p, flower[2]); + + clutter_actor_destroy (vase); } CLUTTER_TEST_SUITE ( diff --git a/src/tests/clutter/conform/actor-offscreen-redirect.c b/src/tests/clutter/conform/actor-offscreen-redirect.c index 97e09806c..e4394ab99 100644 --- a/src/tests/clutter/conform/actor-offscreen-redirect.c +++ b/src/tests/clutter/conform/actor-offscreen-redirect.c @@ -442,6 +442,9 @@ actor_offscreen_redirect (void) while (!data.was_painted) g_main_context_iteration (NULL, FALSE); + + clutter_actor_destroy (data.parent_container); + clutter_actor_destroy (data.unrelated_actor); } CLUTTER_TEST_SUITE ( diff --git a/src/tests/clutter/conform/actor-paint-opacity.c b/src/tests/clutter/conform/actor-paint-opacity.c index 661d9efe5..f73a8f0f7 100644 --- a/src/tests/clutter/conform/actor-paint-opacity.c +++ b/src/tests/clutter/conform/actor-paint-opacity.c @@ -37,6 +37,8 @@ opacity_label (void) g_print ("label 50%%.get_paint_opacity()/2\n"); clutter_actor_set_opacity (label, 128); g_assert (clutter_actor_get_paint_opacity (label) == 128); + + clutter_actor_destroy (label); } G_GNUC_BEGIN_IGNORE_DEPRECATIONS @@ -70,6 +72,8 @@ opacity_rectangle (void) if (!g_test_quiet ()) g_print ("rect 100%%.get_paint_opacity()\n"); g_assert (clutter_actor_get_paint_opacity (rect) == 255); + + clutter_actor_destroy (rect); } G_GNUC_END_IGNORE_DEPRECATIONS @@ -135,6 +139,8 @@ opacity_paint (void) if (!g_test_quiet ()) g_print ("rect 100%%.get_paint_opacity()\n"); g_assert (clutter_actor_get_paint_opacity (rect) == 128); + + clutter_actor_destroy (group1); } G_GNUC_END_IGNORE_DEPRECATIONS diff --git a/src/tests/clutter/conform/actor-pick.c b/src/tests/clutter/conform/actor-pick.c index 0e04ac004..fff660d6d 100644 --- a/src/tests/clutter/conform/actor-pick.c +++ b/src/tests/clutter/conform/actor-pick.c @@ -19,6 +19,7 @@ struct _State guint failed_pass; guint failed_idx; gboolean pass; + GList *actor_list; }; static const char *test_passes[] = { @@ -61,6 +62,7 @@ on_timeout (gpointer data) clutter_actor_set_background_color (over_actor, &red); clutter_actor_set_size (over_actor, STAGE_WIDTH, STAGE_HEIGHT); clutter_actor_add_child (state->stage, over_actor); + state->actor_list = g_list_prepend (state->actor_list, over_actor); clutter_actor_hide (over_actor); if (!g_test_quiet ()) @@ -172,7 +174,7 @@ static void actor_pick (void) { int y, x; - State state; + State state = { 0 }; state.pass = TRUE; @@ -188,6 +190,7 @@ actor_pick (void) y * 255 / (ACTORS_Y - 1), 128, 255 }; ClutterActor *rect = clutter_actor_new (); + state.actor_list = g_list_prepend (state.actor_list, rect); clutter_actor_set_background_color (rect, &color); clutter_actor_set_position (rect, @@ -219,6 +222,8 @@ actor_pick (void) } g_assert (state.pass); + + g_list_free_full (state.actor_list, (GDestroyNotify) clutter_actor_destroy); } CLUTTER_TEST_SUITE ( diff --git a/src/tests/clutter/conform/actor-pivot-point.c b/src/tests/clutter/conform/actor-pivot-point.c index 828ac54e5..6bbd07873 100644 --- a/src/tests/clutter/conform/actor-pivot-point.c +++ b/src/tests/clutter/conform/actor-pivot-point.c @@ -41,6 +41,9 @@ actor_pivot (void) clutter_actor_get_transform (actor_explicit, &result_explicit); g_assert (cogl_matrix_equal (&result_implicit, &result_explicit)); + + clutter_actor_destroy (actor_implicit); + clutter_actor_destroy (actor_explicit); } CLUTTER_TEST_SUITE ( diff --git a/src/tests/clutter/conform/actor-shader-effect.c b/src/tests/clutter/conform/actor-shader-effect.c index 4a663403c..79b792dc7 100644 --- a/src/tests/clutter/conform/actor-shader-effect.c +++ b/src/tests/clutter/conform/actor-shader-effect.c @@ -256,6 +256,7 @@ actor_shader_effect (void) ClutterActor *stage; ClutterActor *rect; gboolean was_painted; + GList *actors = NULL; if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL)) return; @@ -264,18 +265,22 @@ actor_shader_effect (void) rect = make_actor (foo_old_shader_effect_get_type ()); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect); + actors = g_list_prepend (actors, rect); rect = make_actor (foo_new_shader_effect_get_type ()); clutter_actor_set_x (rect, 100); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect); + actors = g_list_prepend (actors, rect); rect = make_actor (foo_another_new_shader_effect_get_type ()); clutter_actor_set_x (rect, 200); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect); + actors = g_list_prepend (actors, rect); rect = make_actor (foo_new_shader_effect_get_type ()); clutter_actor_set_x (rect, 300); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect); + actors = g_list_prepend (actors, rect); clutter_actor_show (stage); @@ -286,6 +291,8 @@ actor_shader_effect (void) while (!was_painted) g_main_context_iteration (NULL, FALSE); + + g_list_free_full (actors, (GDestroyNotify) clutter_actor_destroy); } CLUTTER_TEST_SUITE (