[pitivi: 7/9] tests: Extend alpha test coverage



commit 9f053b81bffaa9928d45557a63eb1c40012bffdc
Author: Robert Swain <robert swain collabora co uk>
Date:   Thu Aug 12 11:18:24 2010 +0200

    tests: Extend alpha test coverage
    
    New tests:
    - SVmBin.do_request_new_pad() with alpha_count > 0
    - Remove the only track object with any alpha keyframes to test the track
      object removed callback's re-evaluation of the alpha state

 tests/test_alpha_passthrough.py |   62 +++++++++++++++++++++++++++++---------
 1 files changed, 47 insertions(+), 15 deletions(-)
---
diff --git a/tests/test_alpha_passthrough.py b/tests/test_alpha_passthrough.py
index 8582d17..9dfa7bd 100644
--- a/tests/test_alpha_passthrough.py
+++ b/tests/test_alpha_passthrough.py
@@ -41,23 +41,28 @@ class TestAlpha(TestCase):
         # define some streams
         streams = []
         streams.append([VideoStream(gst.Caps('video/x-raw-yuv,format=(fourcc)I420')), VideoTestSourceFactory()])
+        streams.append([VideoStream(gst.Caps('video/x-raw-yuv,format=(fourcc)Y42B')), VideoTestSourceFactory()])
         streams.append([VideoStream(gst.Caps('video/x-raw-yuv,format=(fourcc)Y444')), VideoTestSourceFactory()])
+        streams.append([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')), VideoTestSourceFactory()])
         streams.append([VideoStream(gst.Caps('video/x-raw-yuv,format=(fourcc)AYUV')), VideoTestSourceFactory()])
 
         # make a track, make track objects from the streams and add the track objects to the track
         offset = 0
+        count = 0
         self.track1 = Track(streams[0][0])
         self.track_objects = []
         for item in streams:
+            count += 1
             stream = item[0]
             factory = item[1]
             factory.duration = 15 * gst.SECOND
             factory.addOutputStream(stream)
             track_object = SourceTrackObject(factory, stream)
             self.track_objects.append(track_object)
-            track_object.start = offset
+            if 2 * (count//2) == count:
+                track_object.start = offset
+                offset += 15 * gst.SECOND
             self.track1.addTrackObject(track_object)
-            offset += 15 * gst.SECOND
 
         # make a fakesink for the pipeline and connect it as necessary with a callback
         composition = self.track1.composition
@@ -84,7 +89,7 @@ class TestAlpha(TestCase):
         TestCase.tearDown(self)
 
     def testAlphaAggregation(self):
-        svmbin_inputs = list(self.track1.mixer.elements())[0].inputs.values()
+        svmbin = list(self.track1.mixer.elements())[0]
 
         # adjust all up to 1.0
         for track_obj in self.track1.track_objects:
@@ -93,7 +98,7 @@ class TestAlpha(TestCase):
                 for kf in interpolator.getKeyframes():
                     interpolator.setKeyframeValue(kf, 1.0)
         # check that each SmartVideomixerBin input has alpha _not_ set on its capsfilter
-        for input in svmbin_inputs:
+        for input in svmbin.inputs.values():
             svmbin_input_capsfilter = input[2]
             self.failIf(svmbin_input_capsfilter.props.caps[0].has_key("format"))
 
@@ -104,7 +109,7 @@ class TestAlpha(TestCase):
             interpolator.setKeyframeValue(kf, 0.8)
             break
         # check that each SmartVideomixerBin input has alpha set on its capsfilter
-        for input in svmbin_inputs:
+        for input in svmbin.inputs.values():
             svmbin_input_capsfilter = input[2]
             self.failUnlessEqual(svmbin_input_capsfilter.props.caps[0]["format"], gst.Fourcc('AYUV'))
 
@@ -116,7 +121,7 @@ class TestAlpha(TestCase):
                     # random() should return a value in the range [0.0, 1.0)
                     interpolator.setKeyframeValue(kf, 0.9 * random.random())
         # check that each SmartVideomixerBin input has alpha set on its capsfilter
-        for input in svmbin_inputs:
+        for input in svmbin.inputs.values():
             svmbin_input_capsfilter = input[2]
             self.failUnlessEqual(svmbin_input_capsfilter.props.caps[0]["format"], gst.Fourcc('AYUV'))
 
@@ -127,20 +132,19 @@ class TestAlpha(TestCase):
             interpolator.setKeyframeValue(kf, 1.0)
             break
         # check that each SmartVideomixerBin input has alpha set on its capsfilter
-        for input in svmbin_inputs:
+        for input in svmbin.inputs.values():
             svmbin_input_capsfilter = input[2]
             self.failUnlessEqual(svmbin_input_capsfilter.props.caps[0]["format"], gst.Fourcc('AYUV'))
 
         # remove a track object
         self.track1.removeTrackObject(self.track1.track_objects[2])
-        # check that there are now just 2 track objects
-        self.failUnlessEqual(len(self.track1.track_objects), 2)
+        # check that there are now just 4 track objects
+        self.failUnlessEqual(len(self.track1.track_objects), 4)
         # check that each SmartVideomixerBin input has alpha set on its capsfilter
-        for input in svmbin_inputs:
+        for input in svmbin.inputs.values():
             svmbin_input_capsfilter = input[2]
             self.failUnlessEqual(svmbin_input_capsfilter.props.caps[0]["format"], gst.Fourcc('AYUV'))
 
-
         # adjust all up to 1.0 again
         for track_obj in self.track1.track_objects:
             interpolator = track_obj.getInterpolator("alpha")
@@ -148,16 +152,44 @@ class TestAlpha(TestCase):
                 for kf in interpolator.getKeyframes():
                     interpolator.setKeyframeValue(kf, 1.0)
         # check that each SmartVideomixerBin input has alpha _not_ set on its capsfilter
-        for input in svmbin_inputs:
+        for input in svmbin.inputs.values():
             svmbin_input_capsfilter = input[2]
             self.failIf(svmbin_input_capsfilter.props.caps[0].has_key("format"))
 
         # remove a track object
         self.track1.removeTrackObject(self.track1.track_objects[0])
-        # check that there is now just 1 track object
-        self.failUnlessEqual(len(self.track1.track_objects), 1)
+        # check that there is now just 3 track objects
+        self.failUnlessEqual(len(self.track1.track_objects), 3)
         # check that each SmartVideomixerBin input has alpha _not_ set on its capsfilter
-        for input in svmbin_inputs:
+        for input in svmbin.inputs.values():
             svmbin_input_capsfilter = input[2]
             self.failIf(svmbin_input_capsfilter.props.caps[0].has_key("format"))
 
+        # adjust one below 1.0 and test do_request_new_pad()
+        obj = self.track1.track_objects[1]
+        interpolator = obj.getInterpolator("alpha")
+        for kf in interpolator.getKeyframes():
+            interpolator.setKeyframeValue(kf, 0.8)
+            break
+        # check that each SmartVideomixerBin input has alpha set on its capsfilter
+        for input in svmbin.inputs.values():
+            svmbin_input_capsfilter = input[2]
+            self.failUnlessEqual(svmbin_input_capsfilter.props.caps[0]["format"], gst.Fourcc('AYUV'))
+        # call do_request_new_pad()
+        template = gst.PadTemplate("sink_%u", gst.PAD_SINK, gst.PAD_REQUEST,
+                                   gst.Caps("video/x-raw-yuv;video/x-raw-rgb"))
+        test_pad = svmbin.do_request_new_pad(template)
+        for input in svmbin.inputs.values():
+            svmbin_input_capsfilter = input[2]
+            self.failUnlessEqual(svmbin_input_capsfilter.props.caps[0]["format"], gst.Fourcc('AYUV'))
+
+        # remove the only track_object with an alpha keyframe
+        self.track1.removeTrackObject(obj)
+        # check that there is now just 2 track objects
+        self.failUnlessEqual(len(self.track1.track_objects), 2)
+        # check that each SmartVideomixerBin input has alpha _not_ set on its capsfilter
+        for input in svmbin.inputs.values():
+            svmbin_input_capsfilter = input[2]
+            self.failIf(svmbin_input_capsfilter.props.caps[0].has_key("format"))
+
+



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