Implemented QGLBuffer unittest.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>,
Marcelo Lira <marcelo.lira@openbossa.org>
This commit is contained in:
parent
0c6e44c7d4
commit
14e5013ef6
1 changed files with 49 additions and 0 deletions
49
tests/qtopengl/qglbuffer_test.py
Normal file
49
tests/qtopengl/qglbuffer_test.py
Normal file
|
|
@ -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()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue