From 287d4f76ecf0ccd2171eaf4a61c79ccea06e5f1d Mon Sep 17 00:00:00 2001 From: "Owen W. Taylor" Date: Mon, 8 Jun 2009 13:13:18 -0400 Subject: [PATCH] Remove useless manual timeline ticking The master clock now works fine whether or not there are any stages, so in the timeline conformance tests don't need to set up their own times. Set CLUTTER_VBLANK=none for the conformance tests, which in addition to removing an test-environment dependency, will result in the ticking for timeline tests being throttled to the default frame rate. http://bugzilla.openedhand.com/show_bug.cgi?id=1637 Signed-off-by: Emmanuele Bassi --- tests/conform/test-conform-main.c | 7 ++++ tests/conform/test-timeline-interpolate.c | 19 ---------- tests/conform/test-timeline-rewind.c | 19 ---------- tests/conform/test-timeline.c | 44 ----------------------- 4 files changed, 7 insertions(+), 82 deletions(-) diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c index b2aa07077..05e5e7b4c 100644 --- a/tests/conform/test-conform-main.c +++ b/tests/conform/test-conform-main.c @@ -72,6 +72,13 @@ main (int argc, char **argv) } #endif + /* Turning of sync-to-vblank removes a dependency on the specifics of the + * test environment. It also means that the timeline-only tests are + * throttled to a reasonable frame rate rather than running in tight + * infinite loop. + */ + g_setenv ("CLUTTER_VBLANK", "none", FALSE); + g_test_init (&argc, &argv, NULL); g_test_bug_base ("http://bugzilla.openedhand.com/show_bug.cgi?id=%s"); diff --git a/tests/conform/test-timeline-interpolate.c b/tests/conform/test-timeline-interpolate.c index 29fe9263f..2c6cc59ba 100644 --- a/tests/conform/test-timeline-interpolate.c +++ b/tests/conform/test-timeline-interpolate.c @@ -23,7 +23,6 @@ typedef struct _TestState gint expected_frame; gint completion_count; gboolean passed; - guint source_id; } TestState; @@ -132,20 +131,6 @@ completed_cb (ClutterTimeline *timeline, } } -static gboolean -frame_tick (gpointer data) -{ - TestState *state = data; - GTimeVal cur_tick = { 0, }; - - g_get_current_time (&cur_tick); - - if (clutter_timeline_is_playing (state->timeline)) - clutter_timeline_do_tick (state->timeline, &cur_tick); - - return TRUE; -} - void test_timeline_interpolate (TestConformSimpleFixture *fixture, gconstpointer data) @@ -169,14 +154,10 @@ test_timeline_interpolate (TestConformSimpleFixture *fixture, state.passed = TRUE; state.expected_frame = 0; - state.source_id = - clutter_threads_add_frame_source (60, frame_tick, &state); - g_get_current_time (&state.start_time); clutter_timeline_start (state.timeline); clutter_main(); - g_source_remove (state.source_id); g_object_unref (state.timeline); } diff --git a/tests/conform/test-timeline-rewind.c b/tests/conform/test-timeline-rewind.c index 67668c55f..b1e0838c5 100644 --- a/tests/conform/test-timeline-rewind.c +++ b/tests/conform/test-timeline-rewind.c @@ -11,7 +11,6 @@ typedef struct _TestState { ClutterTimeline *timeline; gint rewind_count; - guint source_id; } TestState; static gboolean @@ -67,20 +66,6 @@ new_frame_cb (ClutterTimeline *timeline, } } -static gboolean -frame_tick (gpointer data) -{ - TestState *state = data; - GTimeVal cur_tick = { 0, }; - - g_get_current_time (&cur_tick); - - if (clutter_timeline_is_playing (state->timeline)) - clutter_timeline_do_tick (state->timeline, &cur_tick); - - return TRUE; -} - void test_timeline_rewind (TestConformSimpleFixture *fixture, gconstpointer data) @@ -100,13 +85,9 @@ test_timeline_rewind (TestConformSimpleFixture *fixture, &state); state.rewind_count = 0; - state.source_id = - clutter_threads_add_frame_source (60, frame_tick, &state); - clutter_timeline_start (state.timeline); clutter_main(); - g_source_remove (state.source_id); g_object_unref (state.timeline); } diff --git a/tests/conform/test-timeline.c b/tests/conform/test-timeline.c index 0a1038e54..bc53b6b13 100644 --- a/tests/conform/test-timeline.c +++ b/tests/conform/test-timeline.c @@ -181,38 +181,10 @@ delay_cb (gpointer data) return TRUE; } -typedef struct _FrameCounter FrameCounter; - -struct _FrameCounter -{ - GSList *timelines; -}; - -static gboolean -frame_tick (gpointer data) -{ - FrameCounter *counter = data; - GTimeVal cur_tick = { 0, }; - GSList *l; - - g_get_current_time (&cur_tick); - - for (l = counter->timelines; l != NULL; l = l->next) - { - ClutterTimeline *timeline = l->data; - - if (clutter_timeline_is_playing (timeline)) - clutter_timeline_do_tick (timeline, &cur_tick); - } - - return TRUE; -} - void test_timeline (TestConformSimpleFixture *fixture, gconstpointer data) { - FrameCounter *counter; ClutterTimeline *timeline_1; TimelineData data_1; ClutterTimeline *timeline_2; @@ -222,11 +194,6 @@ test_timeline (TestConformSimpleFixture *fixture, gchar **markers; gsize n_markers; guint delay_tag; - guint source_id; - - counter = g_new0 (FrameCounter, 1); - - source_id = clutter_threads_add_frame_source (FPS, frame_tick, counter); timeline_data_init (&data_1, 1); timeline_1 = clutter_timeline_new (FRAME_COUNT * 1000 / FPS); @@ -243,8 +210,6 @@ test_timeline (TestConformSimpleFixture *fixture, g_assert (n_markers == 3); g_strfreev (markers); - counter->timelines = g_slist_prepend (counter->timelines, timeline_1); - timeline_data_init (&data_2, 2); timeline_2 = clutter_timeline_clone (timeline_1); clutter_timeline_add_marker_at_time (timeline_2, "bar", 2 * 1000 / FPS); @@ -254,8 +219,6 @@ test_timeline (TestConformSimpleFixture *fixture, g_assert (strcmp (markers[0], "bar") == 0); g_strfreev (markers); - counter->timelines = g_slist_prepend (counter->timelines, timeline_2); - timeline_data_init (&data_3, 3); timeline_3 = clutter_timeline_clone (timeline_1); clutter_timeline_set_direction (timeline_3, CLUTTER_TIMELINE_BACKWARD); @@ -266,8 +229,6 @@ test_timeline (TestConformSimpleFixture *fixture, clutter_timeline_add_marker_at_time (timeline_3, "end-marker", 0 * 1000 / FPS); - counter->timelines = g_slist_prepend (counter->timelines, timeline_3); - g_signal_connect (timeline_1, "marker-reached", G_CALLBACK (timeline_marker_reached_cb), &data_1); @@ -346,9 +307,4 @@ test_timeline (TestConformSimpleFixture *fixture, timeline_data_destroy (&data_3); g_source_remove (delay_tag); - - g_source_remove (source_id); - - g_slist_free (counter->timelines); - g_free (counter); }