gst/gst.defs: Update for new API

Original commit message from CVS:
* gst/gst.defs:
Update for new API
* gst/gst.override:
Added unreffing for gst.Registry.get_plugin_list and .get_feature_list
* testsuite/common.py:
removed crude hack for gst.Registry and gst.Plugin
* testsuite/test_interface.py:
* testsuite/test_caps.py:
* testsuite/test_struct.py:
* testsuite/test_xml.py:
converted to using common's TestCase class
* testsuite/test_event.py:
Enabled/fixed previously non working test
* testsuite/test_registry.py:
Now uses common's TestCase class,
added special case setUp()
This commit is contained in:
Edward Hervey 2005-10-14 16:26:17 +00:00
parent 9f4d0c6bb3
commit 2aa12f0142
10 changed files with 163 additions and 104 deletions

View file

@ -1,3 +1,24 @@
2005-10-14 Edward Hervey <edward@fluendo.com>
* gst/gst.defs:
Update for new API
* gst/gst.override:
Added unreffing for gst.Registry.get_plugin_list and .get_feature_list
* testsuite/common.py:
removed crude hack for gst.Registry and gst.Plugin
* testsuite/test_interface.py:
* testsuite/test_caps.py:
* testsuite/test_struct.py:
* testsuite/test_xml.py:
converted to using common's TestCase class
* testsuite/test_event.py:
Enabled/fixed previously non working test
* testsuite/test_registry.py:
Now uses common's TestCase class,
added special case setUp()
2005-10-13 Edward Hervey <edward@fluendo.com> 2005-10-13 Edward Hervey <edward@fluendo.com>
* gst/Makefile.am: (noinst_HEADERS): * gst/Makefile.am: (noinst_HEADERS):

View file

@ -5282,6 +5282,27 @@
) )
) )
(define-method get_date
(of-object "GstTagList")
(c-name "gst_tag_list_get_date")
(return-type "gboolean")
(parameters
'("const-gchar*" "tag")
'("GDate**" "value")
)
)
(define-method get_date_index
(of-object "GstTagList")
(c-name "gst_tag_list_get_date_index")
(return-type "gboolean")
(parameters
'("const-gchar*" "tag")
'("guint" "index")
'("GDate**" "value")
)
)
;; From ../gstreamer/gst/gsttaginterface.h ;; From ../gstreamer/gst/gsttaginterface.h

View file

@ -385,23 +385,23 @@ override gst_registry_get_path_list
static PyObject * static PyObject *
_wrap_gst_registry_get_path_list (PyGObject *self) _wrap_gst_registry_get_path_list (PyGObject *self)
{ {
GstRegistry *registry; GstRegistry *registry;
GList *l, *paths; GList *l, *paths;
PyObject *list; PyObject *list;
gint i; gint i;
registry = GST_REGISTRY (self->obj); registry = GST_REGISTRY (self->obj);
paths = gst_registry_get_path_list (registry); paths = gst_registry_get_path_list (registry);
list = PyList_New (g_list_length(paths)); list = PyList_New (g_list_length(paths));
for (l = paths, i = 0; l; l = l->next, ++i) { for (l = paths, i = 0; l; l = l->next, ++i) {
gchar *path = (gchar *) l->data; gchar *path = (gchar *) l->data;
PyList_SetItem (list, i, PyString_FromString(path)); PyList_SetItem (list, i, PyString_FromString(path));
} }
g_list_free (paths); g_list_free (paths);
return list; return list;
} }
%% %%
@ -421,10 +421,13 @@ _wrap_gst_registry_get_plugin_list (PyGObject *self)
list = PyList_New (g_list_length(plugins)); list = PyList_New (g_list_length(plugins));
for (l = plugins, i = 0; l; l = l->next, ++i) { for (l = plugins, i = 0; l; l = l->next, ++i) {
GstPlugin *plugin = (GstPlugin *) l->data; GstPlugin *plugin = (GstPlugin *) l->data;
PyList_SetItem (list, i, pygobject_new (G_OBJECT (plugin))); PyObject *object = pygstobject_new (G_OBJECT (plugin));
gst_object_unref (plugin);
PyList_SetItem (list, i, object);
} }
g_list_free (plugins); g_list_free (plugins);
return list; return list;
} }
@ -457,6 +460,7 @@ _wrap_gst_registry_get_feature_list (PyGObject *self, PyObject *args, PyObject *
for (l = features, i = 0; l; l = l->next, ++i) { for (l = features, i = 0; l; l = l->next, ++i) {
GstPluginFeature *feature = (GstPluginFeature *) l->data; GstPluginFeature *feature = (GstPluginFeature *) l->data;
PyList_SetItem (list, i, pygobject_new (G_OBJECT (feature))); PyList_SetItem (list, i, pygobject_new (G_OBJECT (feature)));
gst_object_unref (feature);
} }
g_list_free (features); g_list_free (features);

View file

@ -111,7 +111,6 @@ def run_silent(function, *args, **kwargs):
class TestCase(unittest.TestCase): class TestCase(unittest.TestCase):
_types = [gst.Object, gst.MiniObject] _types = [gst.Object, gst.MiniObject]
_except_types = [gst.Registry, gst.Plugin, gst.PluginFeature]
def gccollect(self): def gccollect(self):
# run the garbage collector # run the garbage collector
@ -142,8 +141,6 @@ class TestCase(unittest.TestCase):
objs = [o for o in gc.get_objects() if isinstance(o, c)] objs = [o for o in gc.get_objects() if isinstance(o, c)]
new.extend([o for o in objs if o not in self._tracked[c]]) new.extend([o for o in objs if o not in self._tracked[c]])
for u in self._except_types:
new = [o for o in new if not isinstance(o, u)]
self.failIf(new, new) self.failIf(new, new)
#self.failIf(new, ["%r:%d" % (type(o), id(o)) for o in new]) #self.failIf(new, ["%r:%d" % (type(o), id(o)) for o in new])
del self._tracked del self._tracked

View file

@ -21,10 +21,11 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import sys import sys
from common import gst, unittest from common import gst, unittest, TestCase
class CapsTest(unittest.TestCase): class CapsTest(TestCase):
def setUp(self): def setUp(self):
TestCase.setUp(self)
self.caps = gst.caps_from_string('video/x-raw-yuv,width=10,framerate=5.0;video/x-raw-rgb,width=15,framerate=10.0') self.caps = gst.caps_from_string('video/x-raw-yuv,width=10,framerate=5.0;video/x-raw-rgb,width=15,framerate=10.0')
self.assertEquals(self.caps.__refcount__, 1) self.assertEquals(self.caps.__refcount__, 1)
self.structure = self.caps[0] self.structure = self.caps[0]

View file

@ -60,57 +60,62 @@ class EventTest(TestCase):
self.assertRaises(TypeError, self.sink.send_event, number) self.assertRaises(TypeError, self.sink.send_event, number)
# FIXME: fix these tests class EventFileSrcTest(TestCase):
#class EventFileSrcTest(unittest.TestCase): # FIXME: properly create temp files
# # FIXME: properly create temp files filename = '/tmp/gst-python-test-file'
# filename = '/tmp/gst-python-test-file' def setUp(self):
# def setUp(self): TestCase.setUp(self)
# if os.path.exists(self.filename): gst.info("start")
# os.remove(self.filename) if os.path.exists(self.filename):
# open(self.filename, 'w').write(''.join(map(str, range(10)))) os.remove(self.filename)
# open(self.filename, 'w').write(''.join(map(str, range(10))))
# self.pipeline = gst.parse_launch('filesrc name=source location=%s blocksize=1 ! fakesink signal-handoffs=1 name=sink' % self.filename)
# self.source = self.pipeline.get_by_name('source') self.pipeline = gst.parse_launch('filesrc name=source location=%s blocksize=1 ! fakesink signal-handoffs=1 name=sink' % self.filename)
# self.sink = self.pipeline.get_by_name('sink') self.source = self.pipeline.get_by_name('source')
# self.sink.connect('handoff', self.handoff_cb) self.sink = self.pipeline.get_by_name('sink')
# self.bus = self.pipeline.get_bus() self.sigid = self.sink.connect('handoff', self.handoff_cb)
# self.pipeline.set_state(gst.STATE_PLAYING) self.bus = self.pipeline.get_bus()
#
# def tearDown(self): def tearDown(self):
# assert self.pipeline.set_state(gst.STATE_PLAYING) self.pipeline.set_state(gst.STATE_NULL)
# if os.path.exists(self.filename): self.sink.disconnect(self.sigid)
# os.remove(self.filename) if os.path.exists(self.filename):
# os.remove(self.filename)
# def handoff_cb(self, element, buffer, pad): del self.bus
# self.handoffs.append(str(buffer)) del self.pipeline
# del self.source
# def playAndIter(self): del self.sink
# self.handoffs = [] del self.handoffs
# assert self.pipeline.set_state(gst.STATE_PLAYING) TestCase.tearDown(self)
# while 42:
# msg = self.bus.pop() def handoff_cb(self, element, buffer, pad):
# if msg and msg.type == gst.MESSAGE_EOS: self.handoffs.append(str(buffer))
# break
# assert self.pipeline.set_state(gst.STATE_PAUSED) def playAndIter(self):
# handoffs = self.handoffs self.handoffs = []
# self.handoffs = [] self.pipeline.set_state(gst.STATE_PLAYING)
# return handoffs assert self.pipeline.set_state(gst.STATE_PLAYING)
# while 42:
# def sink_seek(self, offset, method=gst.SEEK_METHOD_SET): msg = self.bus.pop()
# method |= (gst.SEEK_FLAG_FLUSH | gst.FORMAT_BYTES) if msg and msg.type == gst.MESSAGE_EOS:
# self.source.send_event(gst.event_new_seek(method, offset)) break
# self.source.send_event(gst.Event(gst.EVENT_FLUSH)) assert self.pipeline.set_state(gst.STATE_PAUSED)
# self.sink.send_event(gst.event_new_seek(method, offset)) handoffs = self.handoffs
# self.sink.send_event(gst.Event(gst.EVENT_FLUSH)) self.handoffs = []
# return handoffs
# def testSimple(self):
# handoffs = self.playAndIter() def sink_seek(self, offset, method=gst.SEEK_TYPE_SET):
# assert handoffs == map(str, range(10)) self.sink.seek(1.0, gst.FORMAT_BYTES, gst.SEEK_FLAG_FLUSH,
# method, offset,
# def testSeekCur(self): gst.SEEK_TYPE_NONE, 0)
# self.sink_seek(8)
# def testSimple(self):
# #print self.playAndIter() handoffs = self.playAndIter()
assert handoffs == map(str, range(10))
def testSeekCur(self):
self.sink_seek(8)
self.playAndIter()
class TestEmit(TestCase): class TestEmit(TestCase):
def testEmit(self): def testEmit(self):

View file

@ -20,11 +20,11 @@
# License along with this library; if not, write to the Free Software # License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from common import gst, unittest from common import gst, unittest, TestCase
import gobject import gobject
class Availability(unittest.TestCase): class Availability(TestCase):
def testXOverlay(self): def testXOverlay(self):
assert hasattr(gst.interfaces, 'XOverlay') assert hasattr(gst.interfaces, 'XOverlay')
assert issubclass(gst.interfaces.XOverlay, gobject.GInterface) assert issubclass(gst.interfaces.XOverlay, gobject.GInterface)
@ -33,7 +33,7 @@ class Availability(unittest.TestCase):
assert hasattr(gst.interfaces, 'Mixer') assert hasattr(gst.interfaces, 'Mixer')
assert issubclass(gst.interfaces.Mixer, gobject.GInterface) assert issubclass(gst.interfaces.Mixer, gobject.GInterface)
class FunctionCall(unittest.TestCase): class FunctionCall(TestCase):
def FIXME_testXOverlay(self): def FIXME_testXOverlay(self):
# obviously a testsuite is not allowed to instantiate this # obviously a testsuite is not allowed to instantiate this
# since it needs a running X or will fail. find some way to # since it needs a running X or will fail. find some way to

View file

@ -21,39 +21,48 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import sys import sys
from common import gst, unittest import gc
from common import gst, unittest, TestCase
class RegistryTest(TestCase):
def setUp(self):
self.registry = gst.registry_get_default()
self.plugins = self.registry.get_plugin_list()
TestCase.setUp(self)
class RegistryTest(unittest.TestCase):
def testGetDefault(self): def testGetDefault(self):
registry = gst.registry_get_default() assert(self.registry)
def testPluginList(self): def testPluginList(self):
registry = gst.registry_get_default() names = map(lambda p: p.get_name(), self.plugins)
plugins = registry.get_plugin_list()
names = map(lambda p: p.get_name(), plugins)
self.failUnless('gstcoreelements' in names) self.failUnless('gstcoreelements' in names)
def testFeatureList(self):
registry = gst.registry_get_default()
self.assertRaises(TypeError, registry.get_feature_list, "kaka")
features = registry.get_feature_list(gst.TYPE_ELEMENT_FACTORY)
elements = map(lambda f: f.get_name(), features)
self.failUnless('fakesink' in elements)
features = registry.get_feature_list(gst.TYPE_TYPE_FIND_FACTORY)
typefinds = map(lambda f: f.get_name(), features)
features = registry.get_feature_list(gst.TYPE_INDEX_FACTORY)
indexers = map(lambda f: f.get_name(), features)
self.failUnless('memindex' in indexers)
def testGetPathList(self): def testGetPathList(self):
# FIXME: this returns an empty list; probably due to core; # FIXME: this returns an empty list; probably due to core;
# examine problem # examine problem
registry = gst.registry_get_default()
paths = registry.get_path_list() paths = self.registry.get_path_list()
class RegistryFeatureTest(TestCase):
def setUp(self):
self.registry = gst.registry_get_default()
self.plugins = self.registry.get_plugin_list()
self.efeatures = self.registry.get_feature_list(gst.TYPE_ELEMENT_FACTORY)
self.tfeatures = self.registry.get_feature_list(gst.TYPE_TYPE_FIND_FACTORY)
self.ifeatures = self.registry.get_feature_list(gst.TYPE_INDEX_FACTORY)
TestCase.setUp(self)
def testFeatureList(self):
self.assertRaises(TypeError, self.registry.get_feature_list, "kaka")
elements = map(lambda f: f.get_name(), self.efeatures)
self.failUnless('fakesink' in elements)
typefinds = map(lambda f: f.get_name(), self.tfeatures)
indexers = map(lambda f: f.get_name(), self.ifeatures)
self.failUnless('memindex' in indexers)
if __name__ == "__main__": if __name__ == "__main__":
unittest.main() unittest.main()

View file

@ -21,10 +21,11 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
import sys import sys
from common import gst, unittest from common import gst, unittest, TestCase
class StructureTest(unittest.TestCase): class StructureTest(TestCase):
def setUp(self): def setUp(self):
TestCase.setUp(self)
self.struct = gst.structure_from_string('video/x-raw-yuv,width=10,foo="bar",pixel-aspect-ratio=1/2,framerate=5.0,boolean=(boolean)true') self.struct = gst.structure_from_string('video/x-raw-yuv,width=10,foo="bar",pixel-aspect-ratio=1/2,framerate=5.0,boolean=(boolean)true')
def testName(self): def testName(self):

View file

@ -20,9 +20,9 @@
# License along with this library; if not, write to the Free Software # License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from common import gst, unittest from common import gst, unittest, TestCase
class PadTest(unittest.TestCase): class PadTest(TestCase):
def testQuery(self): def testQuery(self):
xml = gst.XML() xml = gst.XML()