mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
More testing
Original commit message from CVS: More testing
This commit is contained in:
parent
04d47f4be2
commit
4b55e4eafe
5 changed files with 55 additions and 19 deletions
|
@ -396,6 +396,7 @@ _wrap_gst_caps_new_empty(PyGBoxed *self, PyObject *args, PyObject *kwargs)
|
|||
len = PyTuple_Size(args);
|
||||
self->gtype = GST_TYPE_CAPS;
|
||||
self->free_on_dealloc = FALSE;
|
||||
|
||||
if (len == 0) {
|
||||
self->boxed = gst_caps_new_empty();
|
||||
} else if (len == 1) {
|
||||
|
@ -761,7 +762,6 @@ _wrap_gst_structure_ass_subscript(PyGObject *self,
|
|||
const char *key;
|
||||
GstStructure* structure;
|
||||
GValue value = { 0, };
|
||||
GType gtype;
|
||||
|
||||
structure = (GstStructure*)self->obj;
|
||||
key = PyString_AsString(py_key);
|
||||
|
|
|
@ -34,18 +34,22 @@ class CapsTest(unittest.TestCase):
|
|||
|
||||
def testCapsConstructFromStructures(self):
|
||||
struct1 = gst.structure_from_string('video/x-raw-yuv,width=10')
|
||||
struct2 = gst.structure_from_string('video/x-raw-rgb,width=20')
|
||||
struct2 = gst.structure_from_string('video/x-raw-rgb,height=20.0')
|
||||
caps = gst.Caps(struct1, struct2)
|
||||
assert isinstance(caps, gst.Caps)
|
||||
assert len(caps) == 2
|
||||
assert isinstance(caps[0], gst.Structure)
|
||||
assert isinstance(caps[1], gst.Structure)
|
||||
assert caps[0].get_name() == 'video/x-raw-yuv'
|
||||
assert caps[1].get_name() == 'video/x-raw-rgb'
|
||||
assert isinstance(caps[0]['width'], int)
|
||||
assert isinstance(caps[1]['width'], int)
|
||||
assert caps[0]['width'] == 10
|
||||
assert caps[1]['width'] == 20
|
||||
struct = caps[0]
|
||||
assert isinstance(struct, gst.Structure), struct
|
||||
assert struct.get_name() == 'video/x-raw-yuv', struct.get_name()
|
||||
assert struct.has_key('width')
|
||||
assert isinstance(struct['width'], int)
|
||||
assert struct['width'] == 10
|
||||
struct = caps[1]
|
||||
assert isinstance(struct, gst.Structure), struct
|
||||
assert struct.get_name() == 'video/x-raw-rgb', struct.get_name()
|
||||
assert struct.has_key('height')
|
||||
assert isinstance(struct['height'], float)
|
||||
assert struct['height'] == 20.0
|
||||
|
||||
def testCapsStructureChange(self):
|
||||
'test if changing the structure of the caps works by reference'
|
||||
|
@ -56,5 +60,16 @@ class CapsTest(unittest.TestCase):
|
|||
structure = self.caps[0]
|
||||
assert structure['width'] == 5.0
|
||||
|
||||
def testCapsBadConstructor(self):
|
||||
struct = gst.structure_from_string('video/x-raw-yuv,width=10')
|
||||
self.assertRaises(TypeError, gst.Caps, None)
|
||||
self.assertRaises(TypeError, gst.Caps, 1)
|
||||
self.assertRaises(TypeError, gst.Caps, 2.0)
|
||||
self.assertRaises(TypeError, gst.Caps, object)
|
||||
self.assertRaises(TypeError, gst.Caps, 1, 2, 3)
|
||||
|
||||
# This causes segfault!
|
||||
#self.assertRaises(TypeError, gst.Caps, struct, 10, None)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -5,6 +5,9 @@ class StructureTest(unittest.TestCase):
|
|||
def setUp(self):
|
||||
self.struct = gst.structure_from_string('video/x-raw-yuv,width=10,foo="bar",pixel-aspect-ratio=1/2,framerate=5.0')
|
||||
|
||||
#def foo(self):
|
||||
# gst.structure_from_string("foo")
|
||||
|
||||
def testName(self):
|
||||
assert self.struct.get_name() == 'video/x-raw-yuv'
|
||||
self.struct.set_name('foobar')
|
||||
|
|
|
@ -34,18 +34,22 @@ class CapsTest(unittest.TestCase):
|
|||
|
||||
def testCapsConstructFromStructures(self):
|
||||
struct1 = gst.structure_from_string('video/x-raw-yuv,width=10')
|
||||
struct2 = gst.structure_from_string('video/x-raw-rgb,width=20')
|
||||
struct2 = gst.structure_from_string('video/x-raw-rgb,height=20.0')
|
||||
caps = gst.Caps(struct1, struct2)
|
||||
assert isinstance(caps, gst.Caps)
|
||||
assert len(caps) == 2
|
||||
assert isinstance(caps[0], gst.Structure)
|
||||
assert isinstance(caps[1], gst.Structure)
|
||||
assert caps[0].get_name() == 'video/x-raw-yuv'
|
||||
assert caps[1].get_name() == 'video/x-raw-rgb'
|
||||
assert isinstance(caps[0]['width'], int)
|
||||
assert isinstance(caps[1]['width'], int)
|
||||
assert caps[0]['width'] == 10
|
||||
assert caps[1]['width'] == 20
|
||||
struct = caps[0]
|
||||
assert isinstance(struct, gst.Structure), struct
|
||||
assert struct.get_name() == 'video/x-raw-yuv', struct.get_name()
|
||||
assert struct.has_key('width')
|
||||
assert isinstance(struct['width'], int)
|
||||
assert struct['width'] == 10
|
||||
struct = caps[1]
|
||||
assert isinstance(struct, gst.Structure), struct
|
||||
assert struct.get_name() == 'video/x-raw-rgb', struct.get_name()
|
||||
assert struct.has_key('height')
|
||||
assert isinstance(struct['height'], float)
|
||||
assert struct['height'] == 20.0
|
||||
|
||||
def testCapsStructureChange(self):
|
||||
'test if changing the structure of the caps works by reference'
|
||||
|
@ -56,5 +60,16 @@ class CapsTest(unittest.TestCase):
|
|||
structure = self.caps[0]
|
||||
assert structure['width'] == 5.0
|
||||
|
||||
def testCapsBadConstructor(self):
|
||||
struct = gst.structure_from_string('video/x-raw-yuv,width=10')
|
||||
self.assertRaises(TypeError, gst.Caps, None)
|
||||
self.assertRaises(TypeError, gst.Caps, 1)
|
||||
self.assertRaises(TypeError, gst.Caps, 2.0)
|
||||
self.assertRaises(TypeError, gst.Caps, object)
|
||||
self.assertRaises(TypeError, gst.Caps, 1, 2, 3)
|
||||
|
||||
# This causes segfault!
|
||||
#self.assertRaises(TypeError, gst.Caps, struct, 10, None)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -5,6 +5,9 @@ class StructureTest(unittest.TestCase):
|
|||
def setUp(self):
|
||||
self.struct = gst.structure_from_string('video/x-raw-yuv,width=10,foo="bar",pixel-aspect-ratio=1/2,framerate=5.0')
|
||||
|
||||
#def foo(self):
|
||||
# gst.structure_from_string("foo")
|
||||
|
||||
def testName(self):
|
||||
assert self.struct.get_name() == 'video/x-raw-yuv'
|
||||
self.struct.set_name('foobar')
|
||||
|
|
Loading…
Reference in a new issue