diff options
author | Renato Filho <renato.filho@openbossa.org> | 2010-05-26 14:30:05 -0300 |
---|---|---|
committer | Renato Filho <renato.filho@openbossa.org> | 2010-05-26 16:24:07 -0300 |
commit | 14e5013ef62c18ad60493a98e68db9224558840b (patch) | |
tree | c8750b07eb78497abd616fdbfd8561d7abb880ff /tests | |
parent | 0c6e44c7d421254eadd00282adbaf50247479ebe (diff) |
Implemented QGLBuffer unittest.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>,
Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/qtopengl/qglbuffer_test.py | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/tests/qtopengl/qglbuffer_test.py b/tests/qtopengl/qglbuffer_test.py new file mode 100644 index 000000000..b243d968e --- /dev/null +++ b/tests/qtopengl/qglbuffer_test.py @@ -0,0 +1,49 @@ +#!/usr/bin/python +'''Unit tests for QGLBuffer'' + +import unittest + +from PySide.QtCore import QByteArray +from PySide.QtOpenGL import QGLBuffer, QGLWidget + +from helper import UsesQApplication + +class QGLBufferTest(UsesQApplication): + def usageCheck(self, t): + w = QGLWidget() + w.makeCurrent() + + b = QGLBuffer(t) + self.assertEqual(b.usagePattern(), QGLBuffer.StaticDraw) + b.setUsagePattern(QGLBuffer.DynamicDraw) + + self.assert_(b.create()) + self.assert_(b.bufferId() != 0) + self.assert_(b.bind()) + + data = QByteArray("12345") + b.allocate(data) + self.assertEqual(b.size(), data.size()) + + m = b.map(QGLBuffer.ReadOnly) + self.assertEqual(m.data(), data.data()) + b.unmap() + + other_data = QByteArray("67") + b.write(0, other_data) + m = b.map(QGLBuffer.ReadOnly) + self.assertEqual(m.mid(0, other_data.size()).data(), other_data.data()) + b.unmap() + + result, rdata = b.read(0, other_data.size()) + print result, rdata + self.assert_(result) + self.assertEqual(other_data.data(), rdata.data()) + + b.release() + + def testUsage(self): + self.usageCheck(QGLBuffer.IndexBuffer) + +if __name__ == '__main__': + unittest.main() |