From 4a1679f6985d497b65e3bff41a2f22ee45ac2446 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 1 Mar 2019 19:30:41 -0300 Subject: [PATCH] tests: Add utilities to print the timeline Making debugging tests simpler --- tests/check/ges/test-utils.c | 41 ++++++++++++++++++++++++++++++++++++ tests/check/ges/test-utils.h | 2 ++ tests/check/python/common.py | 19 +++++++++++++++++ 3 files changed, 62 insertions(+) diff --git a/tests/check/ges/test-utils.c b/tests/check/ges/test-utils.c index fd0ff4d6ff..bfb299bada 100644 --- a/tests/check/ges/test-utils.c +++ b/tests/check/ges/test-utils.c @@ -271,3 +271,44 @@ ges_test_get_tmp_uri (const gchar * filename) return uri; } + +void +print_timeline (GESTimeline * timeline) +{ + GList *layer, *clip, *clips, *group; + + g_printerr + ("\n\n=========================== GESTimeline: %p ==================\n", + timeline); + for (layer = timeline->layers; layer; layer = layer->next) { + clips = ges_layer_get_clips (layer->data); + + g_printerr ("layer %04d: ", ges_layer_get_priority (layer->data)); + for (clip = clips; clip; clip = clip->next) { + g_printerr ("{ %s [ %" G_GUINT64_FORMAT "(%" G_GUINT64_FORMAT ") %" + G_GUINT64_FORMAT "] } ", GES_TIMELINE_ELEMENT_NAME (clip->data), + GES_TIMELINE_ELEMENT_START (clip->data), + GES_TIMELINE_ELEMENT_INPOINT (clip->data), + GES_TIMELINE_ELEMENT_END (clip->data)); + } + if (layer->next) + g_printerr ("\n--------------------------------------------------\n"); + + g_list_free_full (clips, gst_object_unref); + } + + if (ges_timeline_get_groups (timeline)) { + g_printerr ("\n--------------------------------------------------\n"); + g_printerr ("\nGROUPS:"); + g_printerr ("\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"); + } + + for (group = ges_timeline_get_groups (timeline); group; group = group->next) { + g_printerr ("%" GES_FORMAT ": ", GES_ARGS (group->data)); + for (clip = GES_CONTAINER_CHILDREN (group->data); clip; clip = clip->next) + g_printerr ("[ %s ]", GES_TIMELINE_ELEMENT_NAME (clip->data)); + } + + g_printerr + ("\n=====================================================================\n"); +} diff --git a/tests/check/ges/test-utils.h b/tests/check/ges/test-utils.h index e05c27e489..7b8199fe5d 100644 --- a/tests/check/ges/test-utils.h +++ b/tests/check/ges/test-utils.h @@ -108,4 +108,6 @@ G_STMT_START { \ GST_TIME_ARGS(GES_TIMELINE_ELEMENT_INPOINT(element)), \ GST_TIME_ARGS(GES_TIMELINE_ELEMENT_DURATION(element)) +void print_timeline(GESTimeline *timeline); + #endif /* _GES_TEST_UTILS */ diff --git a/tests/check/python/common.py b/tests/check/python/common.py index e30be96ea2..0da9927b60 100644 --- a/tests/check/python/common.py +++ b/tests/check/python/common.py @@ -152,6 +152,25 @@ class GESSimpleTimelineTest(GESTest): self.track_types = [GES.TrackType.AUDIO, GES.TrackType.VIDEO] super(GESSimpleTimelineTest, self).__init__(*args) + def timeline_as_str(self): + res = "====== %s =======\n" % self.timeline + for layer in self.timeline.get_layers(): + res += "Layer %04d: " % layer.get_priority() + for clip in layer.get_clips(): + res += "{ %s }" % clip + res += '\n------------------------\n' + + for group in self.timeline.get_groups(): + res += "GROUP %s :" % group + for clip in group.get_children(False): + res += " { %s }" % clip.props.name + res += '\n' + res += "================================\n" + return res + + def print_timeline(self): + print(self.timeline_as_str()) + def setUp(self): self.timeline = GES.Timeline.new() for track_type in self.track_types: