mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-21 07:46:38 +00:00
56f25a4653
Original commit message from CVS: * gst/common.h: cleanup * gst/gst-types.defs: * gst/gst.defs: Updated defs file to current gstreamer core * gst/gst.override: Added useless function (at least from python bindings) and little correction on _wrap_gst_xml_get_topelements() * gst/gstbin.override: * gst/gstbuffer.override: Fix memleak in gst.Buffer.set_caps() * gst/gstevent.override: Added wrapper for remaining gst_event_parse_*() * gst/gstlibs.override: Wrapped more gst.Controller methods * gst/gstmodule.c: (init_gst): new gst_init() Added atexit(gst_deinit) * gst/gstpad.override: Fix memleak in gst.Pad.set_caps() * gst/gstquery.override: add gst.Query.parse_segment() * gst/libs.defs: Updated to current gst-libs * gst/pygstminiobject.c: (pygstminiobject_register_wrapper), (pygstminiobject_new), (pygstminiobject_dealloc): Added debug * testsuite/Makefile.am: * testsuite/common.py: * testsuite/gstpython.supp: * testsuite/python.supp: * testsuite/test_bin.py: * testsuite/test_buffer.py: * testsuite/test_element.py: * testsuite/test_event.py: * testsuite/test_ghostpad.py: * testsuite/test_iterator.py: * testsuite/test_message.py: * testsuite/test_pipeline.py: Proper valgrind testing, Updated tests to new API
110 lines
3.9 KiB
Python
110 lines
3.9 KiB
Python
# -*- Mode: Python -*-
|
|
# vi:si:et:sw=4:sts=4:ts=4
|
|
#
|
|
# Copyright (C) 2005 Johan Dahlin
|
|
#
|
|
# This library 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 library 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 library; if not, write to the Free Software
|
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
import unittest
|
|
from common import gst, TestCase
|
|
|
|
class IteratorTest(TestCase):
|
|
# XXX: Elements
|
|
def testBinIterateElements(self):
|
|
pipeline = gst.parse_launch("fakesrc name=src ! fakesink name=sink")
|
|
elements = list(pipeline.elements())
|
|
fakesrc = pipeline.get_by_name("src")
|
|
fakesink = pipeline.get_by_name("sink")
|
|
|
|
self.assertEqual(len(elements), 2)
|
|
self.failUnless(fakesrc in elements)
|
|
self.failUnless(fakesink in elements)
|
|
|
|
pipeline.remove(fakesrc)
|
|
elements = list(pipeline.elements())
|
|
|
|
self.assertEqual(len(elements), 1)
|
|
self.failUnless(not fakesrc in pipeline)
|
|
|
|
# XXX : There seems to be a problem about the GType
|
|
# set in gst_bin_iterated_sorted
|
|
|
|
def testBinIterateSorted(self):
|
|
pipeline = gst.parse_launch("fakesrc name=src ! fakesink name=sink")
|
|
elements = list(pipeline.sorted())
|
|
fakesrc = pipeline.get_by_name("src")
|
|
fakesink = pipeline.get_by_name("sink")
|
|
|
|
self.assertEqual(elements[0], fakesink)
|
|
self.assertEqual(elements[1], fakesrc)
|
|
|
|
def testBinIterateRecurse(self):
|
|
pipeline = gst.parse_launch("fakesrc name=src ! fakesink name=sink")
|
|
elements = list(pipeline.recurse())
|
|
fakesrc = pipeline.get_by_name("src")
|
|
fakesink = pipeline.get_by_name("sink")
|
|
|
|
self.assertEqual(elements[0], fakesink)
|
|
self.assertEqual(elements[1], fakesrc)
|
|
|
|
def testBinIterateSinks(self):
|
|
pipeline = gst.parse_launch("fakesrc name=src ! fakesink name=sink")
|
|
elements = list(pipeline.sinks())
|
|
fakesrc = pipeline.get_by_name("src")
|
|
fakesink = pipeline.get_by_name("sink")
|
|
|
|
self.assertEqual(len(elements), 1)
|
|
self.failUnless(fakesink in elements)
|
|
self.failUnless(not fakesrc in elements)
|
|
|
|
|
|
def testIteratePadsFakeSrc(self):
|
|
fakesrc = gst.element_factory_make('fakesrc')
|
|
pads = list(fakesrc.pads())
|
|
srcpad = fakesrc.get_pad('src')
|
|
self.assertEqual(len(pads), 1)
|
|
self.assertEqual(pads[0], srcpad)
|
|
srcpads = list(fakesrc.src_pads())
|
|
self.assertEqual(len(srcpads), 1)
|
|
self.assertEqual(srcpads[0], srcpad)
|
|
sinkpads = list(fakesrc.sink_pads())
|
|
self.assertEqual(sinkpads, [])
|
|
|
|
self.assertEqual(len(list(fakesrc)), 1)
|
|
for pad in fakesrc:
|
|
self.assertEqual(pad, srcpad)
|
|
break
|
|
else:
|
|
raise AssertionError
|
|
|
|
def testIteratePadsFakeSink(self):
|
|
fakesink = gst.element_factory_make('fakesink')
|
|
pads = list(fakesink.pads())
|
|
sinkpad = fakesink.get_pad('sink')
|
|
self.assertEqual(len(pads), 1)
|
|
self.assertEqual(pads[0], sinkpad)
|
|
srcpads = list(fakesink.src_pads())
|
|
self.assertEqual(srcpads, [])
|
|
sinkpads = list(fakesink.sink_pads())
|
|
self.assertEqual(len(sinkpads), 1)
|
|
self.assertEqual(sinkpads[0], sinkpad)
|
|
|
|
self.assertEqual(len(list(fakesink)), 1)
|
|
for pad in fakesink:
|
|
self.assertEqual(pad, sinkpad)
|
|
break
|
|
else:
|
|
raise AssertionError
|
|
|