summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPaulo Alcantara <pcacjr@gmail.com>2012-01-19 16:10:34 -0300
committerPaulo Alcantara <pcacjr@gmail.com>2012-01-23 11:34:28 -0300
commit6f3792457c3c965d49f9cdc614ccbfff7b94317c (patch)
tree67788e8d45d8f67723b0b5594e8fc3dc6f7d29eb /tests
parent3aba7ebbf7ae05804d96dc1db9edad3926c89ee5 (diff)
downloadpyside-6f3792457c3c965d49f9cdc614ccbfff7b94317c.tar.gz
pyside-6f3792457c3c965d49f9cdc614ccbfff7b94317c.tar.xz
pyside-6f3792457c3c965d49f9cdc614ccbfff7b94317c.zip
Fix BUG #1124 - "QPainter.drawPixmapFragments should take a list as
first argument" See http://bugs.pyside.org/show_bug.cgi?id=1124. Signed-off-by: Paulo Alcantara <pcacjr@gmail.com> Reviewed-by: Hugo Parente Lima <hugo.pl@gmail.com> Reviewed-by: Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/QtGui/CMakeLists.txt1
-rw-r--r--tests/QtGui/bug_1124.py66
2 files changed, 67 insertions, 0 deletions
diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt
index 5998ca5..35c0aa6 100644
--- a/tests/QtGui/CMakeLists.txt
+++ b/tests/QtGui/CMakeLists.txt
@@ -82,6 +82,7 @@ PYSIDE_TEST(bug_1006.py)
PYSIDE_TEST(bug_1041.py)
PYSIDE_TEST(bug_1048.py)
PYSIDE_TEST(bug_1077.py)
+PYSIDE_TEST(bug_1124.py)
PYSIDE_TEST(customproxywidget_test.py)
PYSIDE_TEST(deepcopy_test.py)
PYSIDE_TEST(event_filter_test.py)
diff --git a/tests/QtGui/bug_1124.py b/tests/QtGui/bug_1124.py
new file mode 100644
index 0000000..63fccf3
--- /dev/null
+++ b/tests/QtGui/bug_1124.py
@@ -0,0 +1,66 @@
+''' unit test for BUG #1124 '''
+
+import unittest
+from helper import UsesQApplication
+from PySide import QtCore, QtGui
+import sys
+
+class MyWidget(QtGui.QWidget):
+ def __init__(self, parent=None, app=None):
+ super(MyWidget, self).__init__(parent)
+ if not app:
+ app = QApplication([])
+
+ self.app = app
+
+ def paintEvent(self, event):
+ pa = QtGui.QPainter(self)
+ fragments = []
+
+ makeFragment = lambda *a, **kw: \
+ fragments.append(QtGui.QPainter.PixmapFragment.create(*a, **kw))
+
+ makeFragment(QtCore.QPointF(0, 0), QtCore.QRectF(0, 0, 2, 2))
+ makeFragment(QtCore.QPointF(2, 0), QtCore.QRectF(0, 0, 2, 2),
+ rotation=90)
+ makeFragment(QtCore.QPointF(4, 0), QtCore.QRectF(0, 0, 2, 2),
+ rotation=180)
+ makeFragment(QtCore.QPointF(6, 0), QtCore.QRectF(0, 0, 1, 1),
+ scaleX=2, scaleY=2)
+ makeFragment(QtCore.QPointF(8, 0), QtCore.QRectF(1, 0, 1, 1),
+ scaleX=2, scaleY=2)
+ makeFragment(QtCore.QPointF(0, 2), QtCore.QRectF(0, 0, 2, 2),
+ opacity=0.5)
+ makeFragment(QtCore.QPointF(2, 2), QtCore.QRectF(0, 0, 2, 2),
+ scaleX=2, scaleY=2)
+ makeFragment(QtCore.QPointF(6, 2), QtCore.QRectF(0, 0, 2, 2),
+ scaleX=2, scaleY=2, rotation=90, opacity=0.5)
+
+ try:
+ pa.drawPixmapFragments(fragments, QtGui.QPixmap(2, 2), 0)
+ except TypeError:
+ sys.exit(-1)
+
+ # test pa.drawPixmapFragments() by passing a tuple of integers rather
+ # than QtGui.QPainter.PixmapFragment's that _must_ throw a TypeError
+ # exception.
+ try:
+ pa.drawPixmapFragments((1, 2, 3), QtGui.QPixmap(2, 2), 0)
+ sys.exit(-1) # it should not reach here
+ except TypeError:
+ pass
+
+class QPainterTestCase(UsesQApplication):
+ qapplication = True
+
+ def setUp(self):
+ super(QPainterTestCase, self).setUp()
+ self.wid = MyWidget(app=self.app)
+
+ def testIt(self):
+ QtCore.QTimer.singleShot(200, self.app.quit)
+ self.wid.show()
+ self.app.exec_()
+
+if __name__ == "__main__":
+ unittest.main()