From 007d27fa40ce043a10e49e4dc5dad80da1ab826e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 29 May 2020 19:31:22 +0200 Subject: [PATCH] tests/conform: Use the clutter stage from mutter The tests created their own stage, which caused various issues. Lets use the one from mutter instead. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1289 --- src/tests/clutter-test-utils.c | 26 +++++-------------- .../clutter/conform/actor-shader-effect.c | 2 +- .../clutter/conform/timeline-interpolate.c | 5 ++++ src/tests/clutter/conform/timeline-rewind.c | 5 ++++ src/tests/clutter/conform/timeline.c | 5 ++++ 5 files changed, 23 insertions(+), 20 deletions(-) diff --git a/src/tests/clutter-test-utils.c b/src/tests/clutter-test-utils.c index 59db1021a..4f387e2bf 100644 --- a/src/tests/clutter-test-utils.c +++ b/src/tests/clutter-test-utils.c @@ -5,8 +5,6 @@ #include typedef struct { - ClutterActor *stage; - guint no_display : 1; } ClutterTestEnvironment; @@ -98,18 +96,9 @@ out: ClutterActor * clutter_test_get_stage (void) { - g_assert (test_environ != NULL); + MetaBackend *backend = meta_get_backend (); - if (test_environ->stage == NULL) - { - /* create a stage, and ensure that it goes away at the end */ - test_environ->stage = clutter_stage_new (); - clutter_actor_set_name (test_environ->stage, "Test Stage"); - g_object_add_weak_pointer (G_OBJECT (test_environ->stage), - (gpointer *) &test_environ->stage); - } - - return test_environ->stage; + return meta_backend_get_stage (backend); } typedef struct { @@ -122,11 +111,13 @@ static void clutter_test_func_wrapper (gconstpointer data_) { const ClutterTestData *data = data_; + ClutterActor *stage; g_test_log_set_fatal_handler (log_func, NULL); /* ensure that the previous test state has been cleaned up */ - g_assert_null (test_environ->stage); + stage = clutter_test_get_stage (); + g_assert_false (clutter_actor_is_mapped (stage)); if (test_environ->no_display) { @@ -151,11 +142,8 @@ out: if (data->test_notify != NULL) data->test_notify (data->test_data); - if (test_environ->stage != NULL) - { - clutter_actor_destroy (test_environ->stage); - g_assert_null (test_environ->stage); - } + clutter_actor_remove_all_children (stage); + clutter_actor_hide (stage); } /** diff --git a/src/tests/clutter/conform/actor-shader-effect.c b/src/tests/clutter/conform/actor-shader-effect.c index a2cea6d46..f3b063c2e 100644 --- a/src/tests/clutter/conform/actor-shader-effect.c +++ b/src/tests/clutter/conform/actor-shader-effect.c @@ -260,7 +260,7 @@ actor_shader_effect (void) if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL)) return; - stage = clutter_stage_new (); + stage = clutter_test_get_stage (); rect = make_actor (foo_old_shader_effect_get_type ()); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rect); diff --git a/src/tests/clutter/conform/timeline-interpolate.c b/src/tests/clutter/conform/timeline-interpolate.c index 8d3ceeef8..aa3556b59 100644 --- a/src/tests/clutter/conform/timeline-interpolate.c +++ b/src/tests/clutter/conform/timeline-interpolate.c @@ -132,8 +132,11 @@ completed_cb (ClutterTimeline *timeline, static void timeline_interpolation (void) { + ClutterActor *stage; TestState state; + stage = clutter_test_get_stage (); + state.timeline = clutter_timeline_new (TEST_TIMELINE_DURATION); clutter_timeline_set_repeat_count (state.timeline, -1); @@ -151,6 +154,8 @@ timeline_interpolation (void) state.passed = TRUE; state.expected_frame = 0; + clutter_actor_show (stage); + state.start_time = g_get_real_time (); clutter_timeline_start (state.timeline); diff --git a/src/tests/clutter/conform/timeline-rewind.c b/src/tests/clutter/conform/timeline-rewind.c index ca3d1096e..9adc198b4 100644 --- a/src/tests/clutter/conform/timeline-rewind.c +++ b/src/tests/clutter/conform/timeline-rewind.c @@ -70,8 +70,11 @@ new_frame_cb (ClutterTimeline *timeline, static void timeline_rewind (void) { + ClutterActor *stage; TestState state; + stage = clutter_test_get_stage (); + state.timeline = clutter_timeline_new (TEST_TIMELINE_DURATION); g_signal_connect (G_OBJECT(state.timeline), @@ -85,6 +88,8 @@ timeline_rewind (void) &state); state.rewind_count = 0; + clutter_actor_show (stage); + clutter_timeline_start (state.timeline); clutter_main(); diff --git a/src/tests/clutter/conform/timeline.c b/src/tests/clutter/conform/timeline.c index eb9e1cd4f..da04a9889 100644 --- a/src/tests/clutter/conform/timeline.c +++ b/src/tests/clutter/conform/timeline.c @@ -184,6 +184,7 @@ delay_cb (gpointer data) static void timeline_base (void) { + ClutterActor *stage; ClutterTimeline *timeline_1; TimelineData data_1; ClutterTimeline *timeline_2; @@ -194,6 +195,8 @@ timeline_base (void) gsize n_markers; guint delay_tag; + stage = clutter_test_get_stage (); + timeline_data_init (&data_1, 1); timeline_1 = clutter_timeline_new (FRAME_COUNT * 1000 / FPS); clutter_timeline_add_marker_at_time (timeline_1, "start-marker", @@ -263,6 +266,8 @@ timeline_base (void) "completed", G_CALLBACK (timeline_complete_cb), &data_3); + clutter_actor_show (stage); + if (!g_test_quiet ()) g_print ("Without delay...\n");