diff --git a/ChangeLog b/ChangeLog index 0e95a0304c..b1fed84c58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2004-07-13 Johan Dahlin + * testsuite/element.py (QueryTest.testQuery): Another small test + + * gst/gst.override (_wrap_gst_element_query): Ditto + (_wrap_gst_pad_convert): Ditto + * testsuite/event.py (EventFileSrcTest.setUp): Start the pipeline, so we don't get warnings when sending events (EventTest.setUp): Ditto. diff --git a/gst/gst.override b/gst/gst.override index 2b1bc87c30..8818decd40 100644 --- a/gst/gst.override +++ b/gst/gst.override @@ -204,7 +204,12 @@ _wrap_gst_element_query(PyGObject *self, PyObject *args, PyObject *kwargs) return NULL; value = 0; ret = gst_element_query(GST_ELEMENT(self->obj), type, &format, &value); - return Py_BuildValue("(bL)", ret, value); + if (!ret) { + PyErr_SetString(PyExc_RuntimeError, "query could not be performed"); + return NULL; + } + + return PyInt_FromLong(value); } %% override gst_pad_convert kwargs @@ -222,7 +227,12 @@ _wrap_gst_pad_convert(PyGObject *self, PyObject *args, PyObject *kwargs) src_value = PyLong_AsLongLong(src_value_obj); dest_value = 0; ret = gst_pad_convert(GST_PAD(self->obj), src_format, src_value, &dest_format, &dest_value); - return Py_BuildValue("(bL)", ret, dest_value); + if (!ret) { + PyErr_SetString(PyExc_RuntimeError, "conversion could not be performed"); + return NULL; + } + + return PyInt_FromLong(dest_value); } %% override gst_element_convert kwargs @@ -240,7 +250,12 @@ _wrap_gst_element_convert(PyGObject *self, PyObject *args, PyObject *kwargs) src_value = PyLong_AsLongLong(src_value_obj); dest_value = 0; ret = gst_element_convert(GST_ELEMENT(self->obj), src_format, src_value, &dest_format, &dest_value); - return Py_BuildValue("(bL)", ret, dest_value); + if (!ret) { + PyErr_SetString(PyExc_RuntimeError, "conversion could not be performed"); + return NULL; + } + + return PyInt_FromLong(dest_value); } %% override gst_element_link_many args diff --git a/testsuite/element.py b/testsuite/element.py index b1a613bd87..4fe29663c5 100644 --- a/testsuite/element.py +++ b/testsuite/element.py @@ -114,7 +114,7 @@ class FakeSinkTest(ElementTest): def testStateChangeReadyNull(self): self.checkStateChange(gst.STATE_READY, gst.STATE_NULL) - + class NonExistentTest(ElementTest): name = 'this-element-does-not-exist' alias = 'no-alias' @@ -146,5 +146,15 @@ class ElementName(unittest.TestCase): assert get_name(-1) == 'UNKNOWN!' self.assertRaises(TypeError, get_name, '') +class QueryTest(unittest.TestCase): + def setUp(self): + self.pipeline = gst.parse_launch('fakesrc name=source ! fakesink') + self.element = self.pipeline.get_by_name('source') + + def testQuery(self): + assert self.element.query(gst.QUERY_TOTAL, gst.FORMAT_BYTES) == -1 + assert self.element.query(gst.QUERY_POSITION, gst.FORMAT_BYTES) == 0 + assert self.element.query(gst.QUERY_POSITION, gst.FORMAT_TIME) == 0 + if __name__ == "__main__": unittest.main() diff --git a/testsuite/test_element.py b/testsuite/test_element.py index b1a613bd87..4fe29663c5 100644 --- a/testsuite/test_element.py +++ b/testsuite/test_element.py @@ -114,7 +114,7 @@ class FakeSinkTest(ElementTest): def testStateChangeReadyNull(self): self.checkStateChange(gst.STATE_READY, gst.STATE_NULL) - + class NonExistentTest(ElementTest): name = 'this-element-does-not-exist' alias = 'no-alias' @@ -146,5 +146,15 @@ class ElementName(unittest.TestCase): assert get_name(-1) == 'UNKNOWN!' self.assertRaises(TypeError, get_name, '') +class QueryTest(unittest.TestCase): + def setUp(self): + self.pipeline = gst.parse_launch('fakesrc name=source ! fakesink') + self.element = self.pipeline.get_by_name('source') + + def testQuery(self): + assert self.element.query(gst.QUERY_TOTAL, gst.FORMAT_BYTES) == -1 + assert self.element.query(gst.QUERY_POSITION, gst.FORMAT_BYTES) == 0 + assert self.element.query(gst.QUERY_POSITION, gst.FORMAT_TIME) == 0 + if __name__ == "__main__": unittest.main()