From fc21eb395a1de1da49be8eb81ac0c52e88744804 Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Fri, 10 Jun 2011 16:58:55 +0200 Subject: [PATCH] pyges : Improve the test suite --- .../python/testsuite/test_global_functions.py | 11 +++ bindings/python/testsuite/test_layer.py | 21 +++++ .../python/testsuite/test_simple_layer.py | 22 ++++++ bindings/python/testsuite/test_textoverlay.py | 77 +++++++++++-------- bindings/python/testsuite/test_timeline.py | 36 ++------- .../testsuite/test_timeline_file_source.py | 18 +++++ .../test_timeline_parse_launch_effect.py | 24 ++++++ .../testsuite/test_timeline_pipeline.py | 14 ++++ .../testsuite/test_timeline_test_source.py | 19 +++++ .../testsuite/test_timeline_title_source.py | 23 ++++++ bindings/python/testsuite/test_track.py | 24 ++++++ 11 files changed, 229 insertions(+), 60 deletions(-) create mode 100644 bindings/python/testsuite/test_global_functions.py create mode 100644 bindings/python/testsuite/test_layer.py create mode 100644 bindings/python/testsuite/test_simple_layer.py create mode 100644 bindings/python/testsuite/test_timeline_file_source.py create mode 100644 bindings/python/testsuite/test_timeline_parse_launch_effect.py create mode 100644 bindings/python/testsuite/test_timeline_pipeline.py create mode 100644 bindings/python/testsuite/test_timeline_test_source.py create mode 100644 bindings/python/testsuite/test_timeline_title_source.py create mode 100644 bindings/python/testsuite/test_track.py diff --git a/bindings/python/testsuite/test_global_functions.py b/bindings/python/testsuite/test_global_functions.py new file mode 100644 index 0000000000..ba58945c7f --- /dev/null +++ b/bindings/python/testsuite/test_global_functions.py @@ -0,0 +1,11 @@ +import glib +import gst + +from common import TestCase +from gst import ges + +class GlobalFunctions(TestCase): + + def testGlobalFunctions(self): + tl = ges.timeline_new_audio_video() + tr = ges.timeline_standard_transition_new_for_nick("crossfade") diff --git a/bindings/python/testsuite/test_layer.py b/bindings/python/testsuite/test_layer.py new file mode 100644 index 0000000000..ea0276cc2a --- /dev/null +++ b/bindings/python/testsuite/test_layer.py @@ -0,0 +1,21 @@ +import glib +import gst + +from common import TestCase +from gst import ges + +class Layer(TestCase): + + def testLayer(self): + lyr = ges.TimelineLayer() + tl = ges.Timeline() + src = ges.TimelineTestSource() + + lyr.set_timeline(tl) + + assert (lyr.add_object(src) == True) + self.failIf(len (lyr.get_objects()) != 1) + assert (lyr.remove_object(src) == True) + + lyr.set_priority(1) + self.failIf(lyr.get_priority() != 1) diff --git a/bindings/python/testsuite/test_simple_layer.py b/bindings/python/testsuite/test_simple_layer.py new file mode 100644 index 0000000000..15a832faf8 --- /dev/null +++ b/bindings/python/testsuite/test_simple_layer.py @@ -0,0 +1,22 @@ +import glib +import gst + +from common import TestCase +from gst import ges + +class SimpleLayer(TestCase): + + def testSimpleLayer(self): + lyr = ges.SimpleTimelineLayer() + tl = ges.Timeline() + src = ges.TimelineTestSource() + src2 = ges.TimelineTestSource() + + lyr.set_timeline(tl) + + assert (lyr.add_object(src, 0) == True) + assert (lyr.add_object(src2, 1) == True) + assert (lyr.nth(0) == src) + assert (lyr.move_object (src, 1) == True) + self.failIf(lyr.index(src) != 1) + assert (lyr.is_valid() == True) diff --git a/bindings/python/testsuite/test_textoverlay.py b/bindings/python/testsuite/test_textoverlay.py index 25571e2ae4..d31f878026 100644 --- a/bindings/python/testsuite/test_textoverlay.py +++ b/bindings/python/testsuite/test_textoverlay.py @@ -2,44 +2,59 @@ import gst from common import TestCase from gst import ges +from time import sleep -class Timeline(TestCase): +class TextOverlay(TestCase): - def testTimeline(self): + def testTextOverlay(self): - tl = ges.timeline_new_audio_video() - lyr = ges.SimpleTimelineLayer() - src = ges.TimelineTestSource() - pip = ges.TimelinePipeline() ovrl = ges.TimelineTextOverlay() - bus = pip.get_bus() + lyr = ges.TimelineLayer() + tl = ges.timeline_new_audio_video() + tck = tl.get_tracks()[0] - # Let's add the layer to the timeline, and the sources to the layer. - - tl.add_layer(lyr) - src.set_duration(long(gst.SECOND * 10)) - ovrl.set_duration(long(gst.SECOND * 5)) - ovrl.set_start(long(gst.SECOND * 5)) ovrl.set_text("Foo") + self.failIf (ovrl.get_text() != "Foo") + ovrl.set_font_desc ("Arial") + self.failIf (ovrl.get_font_desc() != "Arial") + ovrl.set_valign("top") + self.failIf (ovrl.get_valignment().value_name != "top") + ovrl.set_halign("left") + self.failIf (ovrl.get_halignment().value_name != "left") - lyr.add_object(src, -1) - lyr.add_object(ovrl, -1) + #We will test Timeline Object class functions here - pip.add_timeline(tl) - bus.set_sync_handler(self.bus_handler) + ovrl.set_start(long(100)) + ovrl.set_inpoint(long(50)) + ovrl.set_duration(long(500)) + ovrl.set_priority(2) + ovrl.set_layer(lyr) + tck_obj = ovrl.create_track_object(tck) + self.failIf (ovrl.release_track_object(tck_obj) != True) + self.failIf (ovrl.add_track_object(tck_obj) != True) + self.failIf (len(ovrl.get_track_objects()) != 1) + self.failIf (ovrl.get_layer() != lyr) + ovrl.release_track_object(tck_obj) - self.pipeline = pip - self.layer = lyr + #We test TrackTextOverlay and TrackObject here + tck_obj.set_text("Bar") + self.failIf (tck_obj.get_text() != "Bar") + tck_obj.set_font_desc ("Arial") + self.failIf (tck_obj.get_font_desc() != "Arial") + tck_obj.set_valignment("top") + self.failIf (tck_obj.get_valignment().value_name != "top") + tck_obj.set_halignment("left") + self.failIf (tck_obj.get_halignment().value_name != "left") - #Mainloop is finished, tear down. - self.pipeline = None - - - def bus_handler(self, unused_bus, message): - if message.type == gst.MESSAGE_ERROR: - print "ERROR" - self.mainloop.quit() - elif message.type == gst.MESSAGE_EOS: - print "Done" - self.mainloop.quit() - return gst.BUS_PASS + tck_obj.set_locked(False) + self.failIf (tck_obj.is_locked() != False) + tck_obj.set_start(long(100)) + tck_obj.set_inpoint(long(50)) + tck_obj.set_duration(long(500)) + tck_obj.set_priority(2) + self.failIf (tck_obj.get_start() != 100) + self.failIf (tck_obj.get_inpoint() != 50) + self.failIf (tck_obj.get_duration() != 500) + self.failIf (tck_obj.get_priority() != 2) + tck_obj.set_timeline_object(ovrl) + self.failIf(tck_obj.get_timeline_object() != ovrl) diff --git a/bindings/python/testsuite/test_timeline.py b/bindings/python/testsuite/test_timeline.py index d18e65d587..0458de5085 100644 --- a/bindings/python/testsuite/test_timeline.py +++ b/bindings/python/testsuite/test_timeline.py @@ -10,35 +10,13 @@ class Timeline(TestCase): tl = ges.timeline_new_audio_video() lyr = ges.SimpleTimelineLayer() - src = ges.TimelineTestSource() - pip = ges.TimelinePipeline() - bus = pip.get_bus() - tck_src = ges.TrackAudioTestSource() - self.mainloop = glib.MainLoop() + tck = ges.track_audio_raw_new() - a = tck_src.list_children_properties() - - #Let's add the layer to the timeline, and the source to the layer. - src.set_duration(long(gst.SECOND * 10)) - src.set_vpattern("Random (television snow)") + assert (tl.add_track(tck) == True) + #We should have two tracks from the timeline_new_audio_video() function + 1 + self.failIf(len(tl.get_tracks()) != 3) + assert (tl.remove_track(tck) == True) assert (tl.add_layer(lyr) == True) - assert (lyr.add_object(src, -1) == True) - self.failIf(len(src.get_track_objects()) != 2) - assert (pip.add_timeline(tl) == True) - - bus.set_sync_handler(self.bus_handler) - - self.pipeline = pip - self.layer = lyr - - #Mainloop is finished, tear down. - self.pipeline = None - - - def bus_handler(self, unused_bus, message): - if message.type == gst.MESSAGE_ERROR: - print "ERROR" - elif message.type == gst.MESSAGE_EOS: - print "Done" - return gst.BUS_PASS + self.failIf(len(tl.get_layers()) != 1) + assert (tl.remove_layer(lyr) == True) diff --git a/bindings/python/testsuite/test_timeline_file_source.py b/bindings/python/testsuite/test_timeline_file_source.py new file mode 100644 index 0000000000..fd3f671cb1 --- /dev/null +++ b/bindings/python/testsuite/test_timeline_file_source.py @@ -0,0 +1,18 @@ +import gst + +from common import TestCase +from gst import ges + +class TimelineFileSource(TestCase): + + def testTimelineFileSource(self): + src = ges.TimelineFileSource("blahblahblah") + + src.set_mute(True) + src.set_max_duration(long(100)) + src.set_supported_formats("video") + assert (src.get_supported_formats().value_nicks[0] == "video") + src.set_is_image(True) + assert (src.get_max_duration() == 100) + assert (src.is_image() == True) + assert (src.get_uri() == "blahblahblah") diff --git a/bindings/python/testsuite/test_timeline_parse_launch_effect.py b/bindings/python/testsuite/test_timeline_parse_launch_effect.py new file mode 100644 index 0000000000..3f9ce9b820 --- /dev/null +++ b/bindings/python/testsuite/test_timeline_parse_launch_effect.py @@ -0,0 +1,24 @@ +import gst + +from common import TestCase +from gst import ges +from time import sleep + +class ParseLaunchEffect(TestCase): + + def testParseLaunchEffect(self): + tl = ges.Timeline() + tck = ges.track_video_raw_new() + lyr = ges.TimelineLayer() + efct = ges.TimelineParseLaunchEffect("agingtv", None) + tck_efct = ges.TrackParseLaunchEffect("agingtv") + + tl.add_layer(lyr) + efct.add_track_object(tck_efct) + lyr.add_object(efct) + tck.set_timeline(tl) + tck.add_object(tck_efct) + tck_efct.set_child_property("GstAgingTV::scratch-lines", 17) + self.failIf(tck_efct.get_child_property("GstAgingTV::scratch-lines") != 17) + self.failIf(len(tck_efct.list_children_properties()) != 6) + self.failIf (tck_efct.lookup_child ("scratch-lines") == None) diff --git a/bindings/python/testsuite/test_timeline_pipeline.py b/bindings/python/testsuite/test_timeline_pipeline.py new file mode 100644 index 0000000000..5aeaede28a --- /dev/null +++ b/bindings/python/testsuite/test_timeline_pipeline.py @@ -0,0 +1,14 @@ +import glib +import gst + +from common import TestCase +from gst import ges + +class TimelinePipeline(TestCase): + + def testTimelinePipeline(self): + stgs = gst.pbutils.EncodingAudioProfile(gst.Caps("video/x-dirac"), "test", gst.caps_new_any(), 0) + ppln = ges.TimelinePipeline() + tl = ges.Timeline() + assert (ppln.add_timeline (tl) == True) + assert (ppln.set_mode("TIMELINE_MODE_PREVIEW_AUDIO") == True) diff --git a/bindings/python/testsuite/test_timeline_test_source.py b/bindings/python/testsuite/test_timeline_test_source.py new file mode 100644 index 0000000000..265878d70a --- /dev/null +++ b/bindings/python/testsuite/test_timeline_test_source.py @@ -0,0 +1,19 @@ +import glib +import gst + +from common import TestCase +from gst import ges + +class TimelineTestSource(TestCase): + + def testTimelineTestSource(self): + src = ges.TimelineTestSource() + tck_src = ges.TrackAudioTestSource() + src.set_mute(True) + src.set_vpattern("snow") + src.set_frequency(880) + src.set_volume (1) + assert (src.get_vpattern() != None) + assert (src.is_muted() == True) + assert (src.get_frequency() == 880) + assert (src.get_volume() == 1) diff --git a/bindings/python/testsuite/test_timeline_title_source.py b/bindings/python/testsuite/test_timeline_title_source.py new file mode 100644 index 0000000000..d58199fc8a --- /dev/null +++ b/bindings/python/testsuite/test_timeline_title_source.py @@ -0,0 +1,23 @@ +import gst + +from common import TestCase +from gst import ges + +class TimelineTitleSource(TestCase): + + def testTimelineTitleSource(self): + src = ges.TimelineTitleSource() + lyr = ges.TimelineLayer() + tck = ges.track_video_raw_new() + + src.set_text("Foo") + self.failIf (src.get_text() != "Foo") + src.set_font_desc ("Arial") + self.failIf (src.get_font_desc() != "Arial") + src.set_valignment("top") + assert (src.get_valignment().value_name == "top") + src.set_halignment("left") + assert (src.get_halignment().value_name == "left") + src.set_mute(True) + assert (src.is_muted() == True) + diff --git a/bindings/python/testsuite/test_track.py b/bindings/python/testsuite/test_track.py new file mode 100644 index 0000000000..58610766dc --- /dev/null +++ b/bindings/python/testsuite/test_track.py @@ -0,0 +1,24 @@ +import gst + +from common import TestCase +from gst import ges + +class Track(TestCase): + + def testTrack(self): + tck = ges.track_video_raw_new() + tl = ges.Timeline() + lyr = ges.TimelineLayer() + src = ges.TimelineTestSource() + caps = gst.caps_from_string("image/jpeg") + obj = ges.TrackParseLaunchEffect ("agingtv") + + tl.add_layer(lyr) + src.add_track_object(obj) + lyr.add_object(src) + tck.set_timeline(tl) + + assert (tck.add_object(obj) == True) + assert (tck.get_timeline() == tl) + tck.set_caps(caps) + assert (tck.get_caps().to_string() == "image/jpeg")