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
This commit is contained in:
Johan Dahlin 2004-08-06 14:18:28 +00:00
parent 8b9edb951b
commit 3f630774bb
8 changed files with 56 additions and 23 deletions

View file

@ -1,3 +1,10 @@
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:

View file

@ -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 */
};
%%

View file

@ -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

View file

@ -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('..'))

View file

@ -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)

View file

@ -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__":

View file

@ -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)

View file

@ -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__":