From ab918abc1e103e0ca86939f7d057e8a44ac8a4ef Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 7 Jun 2010 14:43:45 -0300 Subject: Created new unittest model. Separete unittest for module. Only run unittest for compiled modules. Reviewer: Marcelo Lira , Luciano Wolf --- tests/QtGui/qpainter_test.py | 49 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/QtGui/qpainter_test.py (limited to 'tests/QtGui/qpainter_test.py') diff --git a/tests/QtGui/qpainter_test.py b/tests/QtGui/qpainter_test.py new file mode 100644 index 000000000..ad1d1e471 --- /dev/null +++ b/tests/QtGui/qpainter_test.py @@ -0,0 +1,49 @@ +import unittest + +from PySide.QtGui import QPainter, QBrush, QLinearGradient +from PySide.QtCore import QRect, QRectF, Qt + +class QPainterDrawText(unittest.TestCase): + + def setUp(self): + self.painter = QPainter() + self.text = 'teste!' + + def tearDown(self): + del self.text + del self.painter + + def testDrawText(self): + # bug #254 + rect = self.painter.drawText(100, 100, 100, 100, + Qt.AlignCenter | Qt.TextWordWrap, + self.text) + self.assert_(isinstance(rect, QRect)) + + def testDrawTextWithRect(self): + # bug #225 + rect = QRect(100, 100, 100, 100) + newRect = self.painter.drawText(rect, Qt.AlignCenter | Qt.TextWordWrap, + self.text) + + self.assert_(isinstance(newRect, QRect)) + + def testDrawTextWithRectF(self): + '''QPainter.drawText(QRectF, ... ,QRectF*) inject code''' + rect = QRectF(100, 52.3, 100, 100) + newRect = self.painter.drawText(rect, Qt.AlignCenter | Qt.TextWordWrap, + self.text) + + self.assert_(isinstance(newRect, QRectF)) + +class SetBrushWithOtherArgs(unittest.TestCase): + '''Using qpainter.setBrush with args other than QBrush''' + + def testSetBrushGradient(self): + painter = QPainter() + gradient = QLinearGradient(0, 0, 0, 0) + painter.setBrush(gradient) + +if __name__ == '__main__': + unittest.main() + -- cgit v1.2.3