diff options
author | Marcelo Lira <marcelo.lira@openbossa.org> | 2011-01-11 18:53:06 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:51:45 -0300 |
commit | 99cbdef40cda9379651951d0f187fbba6e829ae1 (patch) | |
tree | 00548e6e09e6c117c170c1a618e8b453bbb114dd | |
parent | 64a35df0c16663bea2693701f576005e2f8ebb4c (diff) |
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.py | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/tests/QtGui/qpen_test.py b/tests/QtGui/qpen_test.py index f9e9b1861..b1e0b7a0d 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() |