[pitivi: 3/7] tests: Add still image tests



commit 0dad293907bde05409b7b23b3a46b5c132575324
Author: Robert Swain <robert swain collabora co uk>
Date:   Sun Aug 15 16:26:37 2010 +0200

    tests: Add still image tests

 tests/Makefile.am                      |    1 +
 tests/samples/flat_colour1_640x480.png |  Bin 0 -> 1673 bytes
 tests/samples/flat_colour2_640x480.png |  Bin 0 -> 1674 bytes
 tests/samples/flat_colour3_320x180.png |  Bin 0 -> 548 bytes
 tests/test_still_image.py              |  141 ++++++++++++++++++++++++++++++++
 5 files changed, 142 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 54d45c2..f612314 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -12,6 +12,7 @@ tests = \
 	test_integration.py			\
 	test_transitions.py			\
 	test_alpha_passthrough.py		\
+	test_still_image.py			\
 	test_gap.py
 
 EXTRA_DIST = $(tests) runtests.py common.py
diff --git a/tests/samples/flat_colour1_640x480.png b/tests/samples/flat_colour1_640x480.png
new file mode 100644
index 0000000..c18d315
Binary files /dev/null and b/tests/samples/flat_colour1_640x480.png differ
diff --git a/tests/samples/flat_colour2_640x480.png b/tests/samples/flat_colour2_640x480.png
new file mode 100644
index 0000000..59cd46d
Binary files /dev/null and b/tests/samples/flat_colour2_640x480.png differ
diff --git a/tests/samples/flat_colour3_320x180.png b/tests/samples/flat_colour3_320x180.png
new file mode 100644
index 0000000..9179321
Binary files /dev/null and b/tests/samples/flat_colour3_320x180.png differ
diff --git a/tests/test_still_image.py b/tests/test_still_image.py
new file mode 100644
index 0000000..69cfe86
--- /dev/null
+++ b/tests/test_still_image.py
@@ -0,0 +1,141 @@
+# PiTiVi , Non-linear video editor
+#
+#       tests/test_still_image.py
+#
+# Copyright (c) 2010, Robert Swain <robert swain collabora co uk>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this program; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+# Boston, MA 02111-1307, USA.
+
+import os.path
+from unittest import TestCase
+
+import gobject
+gobject.threads_init()
+import gst
+
+import common
+
+from pitivi.factories.file import FileSourceFactory, PictureFileSourceFactory
+from pitivi.factories.timeline import TimelineSourceFactory
+from pitivi.timeline.track import Track, SourceTrackObject
+from pitivi.timeline.timeline import Timeline, TimelineObject
+from pitivi.encode import RenderSinkFactory, RenderFactory
+from pitivi.action import RenderAction
+from pitivi.settings import StreamEncodeSettings, RenderSettings
+from pitivi.stream import VideoStream
+from pitivi.factories.test import VideoTestSourceFactory
+from pitivi.pipeline import Pipeline, PipelineError
+
+class TestStillImage(TestCase):
+    clip_duration = 3 * gst.SECOND
+    def setUp(self):
+        self.mainloop = gobject.MainLoop()
+
+        samples = os.path.join(os.path.dirname(__file__), "samples")
+        self.facs = []
+        self.facs.append([PictureFileSourceFactory('file://' + os.path.join(samples, "flat_colour1_640x480.png")), VideoStream(gst.Caps("video/x-raw-rgb,bpp=(int)24,depth=(int)24,endianness=(int)4321,red_mask=(int)16711680,green_mask=(int)65280,blue_mask=(int)255"))])
+        self.facs.append([PictureFileSourceFactory('file://' + os.path.join(samples, "flat_colour2_640x480.png")), VideoStream(gst.Caps("video/x-raw-rgb,bpp=(int)24,depth=(int)24,endianness=(int)4321,red_mask=(int)16711680,green_mask=(int)65280,blue_mask=(int)255"))])
+        self.facs.append([PictureFileSourceFactory('file://' + os.path.join(samples, "flat_colour3_320x180.png")), VideoStream(gst.Caps("video/x-raw-rgb,bpp=(int)24,depth=(int)24,endianness=(int)4321,red_mask=(int)16711680,green_mask=(int)65280,blue_mask=(int)255"))])
+        # one video with a different resolution
+        self.facs.append([VideoTestSourceFactory(), VideoStream(gst.Caps('video/x-raw-yuv,width=(int)640,height=(int)480,format=(fourcc)I420'))])
+
+        # configure durations and add output streams to factories
+        for fac in self.facs:
+            factory = fac[0]
+            stream = fac[1]
+            factory.duration = self.clip_duration
+            factory.addOutputStream(stream)
+        self.track_objects = []
+        self.track = Track(self.facs[0][1])
+        self.timeline = Timeline()
+        self.timeline.addTrack(self.track)
+
+        vsettings = StreamEncodeSettings(encoder="theoraenc")
+        rsettings = RenderSettings(settings=[vsettings],
+                                   muxer="oggmux")
+        rendersink = RenderSinkFactory(RenderFactory(settings=rsettings),
+                                       common.FakeSinkFactory())
+        self.render = RenderAction()
+        self.pipeline = Pipeline()
+        self.pipeline.connect("eos", self._renderEOSCb)
+        self.pipeline.connect("error", self._renderErrorCb)
+        self.pipeline.addAction(self.render)
+        self.render.addConsumers(rendersink)
+        timeline_factory = TimelineSourceFactory(self.timeline)
+        self.render.addProducers(timeline_factory)
+
+    def tearDown(self):
+        self.mainloop.quit()
+
+    def configureStreams(self, inputs, offsets):
+        count = 0
+        for i in inputs:
+            factory = self.facs[i][0]
+            stream = self.facs[i][1]
+            track_object = SourceTrackObject(factory, stream)
+            self.track_objects.append(track_object)
+            track_object.start = offsets[count]
+            self.track.addTrackObject(track_object)
+            count += 1
+
+    def startRender(self):
+        self.render.activate()
+        self.pipeline.play()
+        self.mainloop.run()
+
+    def _renderEOSCb(self, obj):
+        self.mainloop.quit()
+        # check the render was successful
+
+    def _renderErrorCb(self, obj, error, details):
+        print "Error: %s\nDetails: %s" % (str(error), str(details))
+        self.fail("Pipeline rendering error")
+
+    def cleanUp(self):
+        self.render.deactivate()
+        self.track.removeAllTrackObjects()
+        self.track_objects = []
+
+    def testRendering(self):
+        # use one of the still image streams
+        self.configureStreams(range(1), [0])
+        self.startRender()
+        self.cleanUp()
+
+
+        # use two images with the same resolution and concatenate them
+        self.configureStreams(range(2), [0, self.clip_duration])
+        self.startRender()
+        self.cleanUp()
+
+
+        # concatenate images with different resolutions
+        self.configureStreams(range(3), [0, self.clip_duration, 2 * self.clip_duration])
+        self.startRender()
+        self.cleanUp()
+
+
+        # mix images and videos with the same resolution
+        self.configureStreams([0, 1, 3], [0, self.clip_duration, 2 * self.clip_duration])
+        self.startRender()
+        self.cleanUp()
+
+
+        # mix images and videos with different resolutions
+        self.configureStreams(range(4), [0, self.clip_duration, 2 * self.clip_duration, 3 * self.clip_duration])
+        self.startRender()
+        self.cleanUp()
+



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]