diff options
author | Renato Filho <renato.filho@openbossa.org> | 2010-06-07 14:43:45 -0300 |
---|---|---|
committer | Renato Filho <renato.filho@openbossa.org> | 2010-06-07 16:57:11 -0300 |
commit | ab918abc1e103e0ca86939f7d057e8a44ac8a4ef (patch) | |
tree | 53c6f57d089dcf5e145d766b1ceef704714046d8 /tests/QtOpenGL/qglbuffer_test.py | |
parent | 471486732b03cbb42b884158604a59d5a18e8a35 (diff) |
Created new unittest model.
Separete unittest for module.
Only run unittest for compiled modules.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>,
Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests/QtOpenGL/qglbuffer_test.py')
-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..ae23fbdf3 --- /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() |