aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtGui/qpixmap_test.py
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2010-06-07 14:43:45 -0300
committerRenato Filho <renato.filho@openbossa.org>2010-06-07 16:57:11 -0300
commitab918abc1e103e0ca86939f7d057e8a44ac8a4ef (patch)
tree53c6f57d089dcf5e145d766b1ceef704714046d8 /tests/QtGui/qpixmap_test.py
parent471486732b03cbb42b884158604a59d5a18e8a35 (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/QtGui/qpixmap_test.py')
-rw-r--r--tests/QtGui/qpixmap_test.py62
1 files changed, 62 insertions, 0 deletions
diff --git a/tests/QtGui/qpixmap_test.py b/tests/QtGui/qpixmap_test.py
new file mode 100644
index 000000000..481409462
--- /dev/null
+++ b/tests/QtGui/qpixmap_test.py
@@ -0,0 +1,62 @@
+import unittest
+
+import os
+from helper import UsesQApplication
+from PySide.QtGui import *
+from PySide.QtCore import *
+
+class QPixmapTest(UsesQApplication):
+ def testQVariantConstructor(self):
+ pixmap = QPixmap()
+ v = QVariant(pixmap)
+ pixmap_copy = QPixmap(v)
+
+ def testQSizeConstructor(self):
+ pixmap = QPixmap(QSize(10,20))
+ self.assert_(pixmap.size().height(), 20)
+
+ def testQStringConstructor(self):
+ pixmap = QPixmap(QString("Testing!"))
+
+ def testQVariantConstructor2(self):
+ v = QVariant(QPixmap())
+ pixmap2 = QPixmap(v)
+ v = QVariant(QImage())
+ pixmap2 = QPixmap(v)
+
+ def testQPixmapLoadFromDataWithQFile(self):
+ f = QFile(os.path.join(os.path.dirname(__file__), 'sample.png'))
+ self.assert_(f.open(QIODevice.ReadOnly))
+ data = f.read(f.size())
+ f.close()
+ pixmap = QPixmap()
+ self.assert_(pixmap.loadFromData(data))
+
+ def testQPixmapLoadFromDataWithPython(self):
+ data = open(os.path.join(os.path.dirname(__file__),'sample.png'),'rb').read()
+ pixmap = QPixmap()
+ self.assert_(pixmap.loadFromData(data))
+
+
+class QPixmapToImage(UsesQApplication):
+
+ def testFilledImage(self):
+ '''QPixmap.fill + toImage + image.pixel'''
+ pixmap = QPixmap(100, 200)
+ pixmap.fill(Qt.red) # Default Qt.white
+
+ self.assertEqual(pixmap.height(), 200)
+ self.assertEqual(pixmap.width(), 100)
+
+ image = pixmap.toImage()
+
+ self.assertEqual(image.height(), 200)
+ self.assertEqual(image.width(), 100)
+
+ pixel = image.pixel(10,10)
+ self.assertEqual(pixel, QColor(Qt.red).rgba())
+
+
+if __name__ == '__main__':
+ unittest.main()
+