More testing
authorJohan Dahlin <johan@gnome.org>
Fri, 6 Aug 2004 19:03:08 +0000 (19:03 +0000)
committerJohan Dahlin <johan@gnome.org>
Fri, 6 Aug 2004 19:03:08 +0000 (19:03 +0000)
Original commit message from CVS:
More testing

gst/gst.override
testsuite/caps.py
testsuite/struct.py
testsuite/test_caps.py
testsuite/test_struct.py

index ec4981f..439f2d0 100644 (file)
@@ -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);
index 367eed1..b5569a1 100644 (file)
@@ -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()
index 252056c..e51e2b3 100644 (file)
@@ -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')
index 367eed1..b5569a1 100644 (file)
@@ -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()
index 252056c..e51e2b3 100644 (file)
@@ -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')