summaryrefslogtreecommitdiffstats
path: root/tests/QtGui/qpen_test.py
blob: b1e0b7a0dbbefe21b0daaa2ca098db49c99b8010 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import unittest
from helper import UsesQApplication

from PySide.QtCore import Qt, QTimer
from PySide.QtGui import QPen, QPainter, QWidget

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.'''
        width = 0
        style = Qt.PenStyle(0)
        cap = Qt.PenCapStyle(0)
        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()