From 3f630774bb41d20995abf9d2486b4c92a9cba8bd Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Fri, 6 Aug 2004 14:18:28 +0000 Subject: [PATCH] testsuite/struct.py (StructureTest.testStructureChange): Enable some tests. Original commit message from CVS: * testsuite/struct.py (StructureTest.testStructureChange): Enable some tests. * gst/gst.override (_wrap_gst_structure_ass_subscript): Impl --- ChangeLog | 7 +++++++ gst/gst.override | 39 ++++++++++++++++++++++++++++++++++---- testsuite/Makefile.am | 2 +- testsuite/common.py | 1 + testsuite/pipeline.py | 4 ---- testsuite/struct.py | 11 ++++++----- testsuite/test_pipeline.py | 4 ---- testsuite/test_struct.py | 11 ++++++----- 8 files changed, 56 insertions(+), 23 deletions(-) diff --git a/ChangeLog b/ChangeLog index 203f0c18e0..798688b370 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-08-06 Johan Dahlin + + * testsuite/struct.py (StructureTest.testStructureChange): Enable + some tests. + + * gst/gst.override (_wrap_gst_structure_ass_subscript): Impl + 2004-08-05 Thomas Vander Stichele * testsuite/struct.py: diff --git a/gst/gst.override b/gst/gst.override index 807de4d6c2..9cc3dd8e6b 100644 --- a/gst/gst.override +++ b/gst/gst.override @@ -171,9 +171,13 @@ _wrap_gst_element_set_state(PyGObject *self, PyObject *args, PyObject *kwargs) return NULL; if (pyg_flags_get_value(GST_TYPE_ELEMENT_STATE, py_state, (gint *)&state)) return NULL; - pyg_unblock_threads(); + + Py_BEGIN_ALLOW_THREADS; + ret = gst_element_set_state(GST_ELEMENT(self->obj), state); - pyg_block_threads(); + + Py_END_ALLOW_THREADS; + return PyInt_FromLong(ret); } %% @@ -673,10 +677,37 @@ _wrap_gst_structure_subscript(PyGObject *self, PyObject *py_key) return v; } -static PySequenceMethods _wrap_gst_structure_tp_as_mapping = { +static int +_wrap_gst_structure_ass_subscript(PyGObject *self, + PyObject *py_key, + PyObject *py_value) +{ + const char *key; + + if (py_key != NULL) { + GType gtype; + GValue value = { 0, }; + + key = PyString_AsString(py_key); + gtype = gst_structure_get_field_type((GstStructure*)self->obj, key); + g_value_init(&value, gtype); + if (pyg_value_from_pyobject(&value, py_value)) { + PyErr_SetString(PyExc_TypeError, "can't convert value"); + return -1; + } + + gst_structure_set_value ((GstStructure*)self->obj, key, &value); + g_value_unset(&value); + + } + + return 0; +} + +static PyMappingMethods _wrap_gst_structure_tp_as_mapping = { (inquiry)_wrap_gst_structure_length, /* mp_length */ (binaryfunc)_wrap_gst_structure_subscript, /* mp_subscript */ - NULL, + (objobjargproc)_wrap_gst_structure_ass_subscript /* mp_ass_subscript */ }; %% diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am index 82a1e72004..101d6cdcdb 100644 --- a/testsuite/Makefile.am +++ b/testsuite/Makefile.am @@ -9,7 +9,7 @@ tests = \ pipeline.py check-local: - @PYTHONPATH=$(top_builddir):$(top_builddir)/gst/.libs $(PYTHON) $(srcdir)/runtests.py + @PYTHONPATH=$(PYTHONPATH):$(top_builddir):$(top_builddir)/gst/.libs $(PYTHON) $(srcdir)/runtests.py @rm -fr *.pyc EXTRA_DIST = $(tests) runtests.py diff --git a/testsuite/common.py b/testsuite/common.py index 370f0c9c29..86beb3ce0e 100644 --- a/testsuite/common.py +++ b/testsuite/common.py @@ -7,6 +7,7 @@ import pygtk pygtk.require('2.0') import gobject +gobject.threads_init() # Don't insert before . sys.path.insert(1, os.path.join('..')) diff --git a/testsuite/pipeline.py b/testsuite/pipeline.py index fec461147b..de4c6a9c06 100644 --- a/testsuite/pipeline.py +++ b/testsuite/pipeline.py @@ -1,10 +1,6 @@ from common import gst, unittest class PipelineConstructor(unittest.TestCase): - def testBadConstruct(self): - self.assertRaises(TypeError, gst.Pipeline) - self.assertRaises(TypeError, gst.Pipeline, None) - def testGoodConstructor(self): name = 'test-pipeline' pipeline = gst.Pipeline(name) diff --git a/testsuite/struct.py b/testsuite/struct.py index 449cfe4c7b..855655b415 100644 --- a/testsuite/struct.py +++ b/testsuite/struct.py @@ -2,12 +2,13 @@ import sys from common import gst, unittest class StructureTest(unittest.TestCase): - def fixmetestStructureChange(self): + def testStructureChange(self): caps = gst.caps_from_string('video/x-raw-yuv,width=10,pixel-aspect-ratio=1/2,framerate=5.0') structure = caps.get_structure(0) assert structure['width'] == 10 structure['width'] = 5 - assert structure['width'] == 5 + assert structure['width'] == 5, structure['width'] + #assert structure['pixel-aspect-ratio'].numerator == 1 #assert structure['pixel-aspect-ratio'].denominator == 2 #assert float(structure['pixel-aspect-ratio']) == 0.5 @@ -15,14 +16,14 @@ class StructureTest(unittest.TestCase): #assert structure['pixel-aspect-ratio'].numerator == 3 #assert structure['pixel-aspect-ratio'].denominator == 4 #assert float(structure['pixel-aspect-ratio']) == 0.75 + assert structure['framerate'] == 5.0 structure['framerate'] = 10.0 assert structure['framerate'] == 10.0 # a list of heights - structure['height'] = (20, 40, 60) - assert structure['width'] == (20, 40, 60) - + #structure['height'] = (20, 40, 60) + #assert structure['width'] == (20, 40, 60) # FIXME: add ranges if __name__ == "__main__": diff --git a/testsuite/test_pipeline.py b/testsuite/test_pipeline.py index fec461147b..de4c6a9c06 100644 --- a/testsuite/test_pipeline.py +++ b/testsuite/test_pipeline.py @@ -1,10 +1,6 @@ from common import gst, unittest class PipelineConstructor(unittest.TestCase): - def testBadConstruct(self): - self.assertRaises(TypeError, gst.Pipeline) - self.assertRaises(TypeError, gst.Pipeline, None) - def testGoodConstructor(self): name = 'test-pipeline' pipeline = gst.Pipeline(name) diff --git a/testsuite/test_struct.py b/testsuite/test_struct.py index 449cfe4c7b..855655b415 100644 --- a/testsuite/test_struct.py +++ b/testsuite/test_struct.py @@ -2,12 +2,13 @@ import sys from common import gst, unittest class StructureTest(unittest.TestCase): - def fixmetestStructureChange(self): + def testStructureChange(self): caps = gst.caps_from_string('video/x-raw-yuv,width=10,pixel-aspect-ratio=1/2,framerate=5.0') structure = caps.get_structure(0) assert structure['width'] == 10 structure['width'] = 5 - assert structure['width'] == 5 + assert structure['width'] == 5, structure['width'] + #assert structure['pixel-aspect-ratio'].numerator == 1 #assert structure['pixel-aspect-ratio'].denominator == 2 #assert float(structure['pixel-aspect-ratio']) == 0.5 @@ -15,14 +16,14 @@ class StructureTest(unittest.TestCase): #assert structure['pixel-aspect-ratio'].numerator == 3 #assert structure['pixel-aspect-ratio'].denominator == 4 #assert float(structure['pixel-aspect-ratio']) == 0.75 + assert structure['framerate'] == 5.0 structure['framerate'] = 10.0 assert structure['framerate'] == 10.0 # a list of heights - structure['height'] = (20, 40, 60) - assert structure['width'] == (20, 40, 60) - + #structure['height'] = (20, 40, 60) + #assert structure['width'] == (20, 40, 60) # FIXME: add ranges if __name__ == "__main__":