+2004-08-06 Johan Dahlin <johan@gnome.org>
+
+ * testsuite/struct.py (StructureTest.testStructureChange): Enable
+ some tests.
+
+ * gst/gst.override (_wrap_gst_structure_ass_subscript): Impl
+
2004-08-05 Thomas Vander Stichele <thomas at apestaart dot org>
* testsuite/struct.py:
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);
}
%%
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 */
};
%%
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
pygtk.require('2.0')
import gobject
+gobject.threads_init()
# Don't insert before .
sys.path.insert(1, os.path.join('..'))
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)
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
#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__":
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)
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
#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__":