summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcelo Lira <marcelo.lira@openbossa.org>2011-01-11 18:53:06 -0300
committerMarcelo Lira <marcelo.lira@openbossa.org>2011-01-12 10:44:21 -0300
commited0d9cf82066496a0cc8e9a0bf6de58c81f535c0 (patch)
treee20581af2e67ea77ca0efd0e7c76fc17dc7490df
parent814bc522ce510dd37818b87e23ffedd4b7b5c0b8 (diff)
downloadpyside-ed0d9cf82066496a0cc8e9a0bf6de58c81f535c0.tar.gz
pyside-ed0d9cf82066496a0cc8e9a0bf6de58c81f535c0.tar.xz
pyside-ed0d9cf82066496a0cc8e9a0bf6de58c81f535c0.zip
Added test for QPainter.setPen() method.
Calls it with enum, to call the setPen(Qt.PenStyle) signature, and with an integer, to call the setPen(QColor) signature (QColor is implicitly built from an unsigned int in C++). For more details see Bug #511: http://bugs.openbossa.org/show_bug.cgi?id=511 Reviewed by Luciano Wolf <luciano.wolf@openbossa.org> Reviewed by Renato Ara├║jo <renato.filho@openbossa.org>
-rw-r--r--tests/QtGui/qpen_test.py30
1 files changed, 27 insertions, 3 deletions
diff --git a/tests/QtGui/qpen_test.py b/tests/QtGui/qpen_test.py
index f9e9b18..b1e0b7a 100644
--- a/tests/QtGui/qpen_test.py
+++ b/tests/QtGui/qpen_test.py
@@ -1,10 +1,25 @@
import unittest
+from helper import UsesQApplication
-from PySide.QtCore import Qt
-from PySide.QtGui import QPen
+from PySide.QtCore import Qt, QTimer
+from PySide.QtGui import QPen, QPainter, QWidget
-class QPenTest(unittest.TestCase):
+class Painting(QWidget):
+ def __init__(self):
+ QWidget.__init__(self)
+ self.penFromEnum = None
+ self.penFromInteger = None
+
+ def paintEvent(self, event):
+ painter = QPainter(self)
+ painter.setPen(Qt.NoPen)
+ self.penFromEnum = painter.pen()
+ painter.setPen(int(Qt.NoPen))
+ self.penFromInteger = painter.pen()
+
+
+class QPenTest(UsesQApplication):
def testCtorWithCreatedEnums(self):
'''A simple case of QPen creation using created enums.'''
@@ -14,6 +29,15 @@ class QPenTest(unittest.TestCase):
join = Qt.PenJoinStyle(0)
pen = QPen(Qt.blue, width, style, cap, join)
+ def testSetPenWithPenStyleEnum(self):
+ '''Calls QPainter.setPen with both enum and integer. Bug #511.'''
+ w = Painting()
+ w.show()
+ QTimer.singleShot(1000, self.app.quit)
+ self.app.exec_()
+ self.assertEqual(w.penFromEnum.style(), Qt.NoPen)
+ self.assertEqual(w.penFromInteger.style(), Qt.SolidLine)
+
if __name__ == '__main__':
unittest.main()