File: test_pen.py

package info (click to toggle)
wxpython4.0 4.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 221,752 kB
  • sloc: cpp: 962,555; python: 230,573; ansic: 170,731; makefile: 51,756; sh: 9,342; perl: 1,564; javascript: 584; php: 326; xml: 200
file content (125 lines) | stat: -rw-r--r-- 3,008 bytes parent folder | download | duplicates (4)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import unittest
from unittests import wtc
import wx
import os


#---------------------------------------------------------------------------

class pen_Tests(wtc.WidgetTestCase):

    def test_penCtor1(self):
        p = wx.Pen()
        self.assertTrue(not p.IsOk())
        p.SetColour(wx.BLUE)
        p.SetWidth(1)
        p.SetStyle(wx.PENSTYLE_SOLID)
        self.assertTrue(p.IsOk())


    def test_penCtor2(self):
        p = wx.Pen(wx.BLUE)
        self.assertTrue(p.IsOk())
        self.assertTrue(p.GetColour() == wx.BLUE)

        p = wx.Pen('blue')
        self.assertTrue(p.IsOk())
        self.assertTrue(p.GetColour() == wx.BLUE)

        p = wx.Pen('#0000FF')
        self.assertTrue(p.IsOk())
        self.assertTrue(p.GetColour() == wx.BLUE)


    def test_penCtor3(self):
        p1 = wx.Pen(wx.BLUE, 2, wx.PENSTYLE_SOLID)
        p2 = wx.Pen(p1)
        self.assertTrue( p1 is not p2)
        self.assertTrue( p1 == p2)


    def test_penNull(self):
        wx.NullPen
        self.assertTrue(not wx.NullPen.IsOk())


    def test_penNonzero(self):
        p = wx.Pen(wx.BLUE)
        test = False
        if p:
            test = True
        self.assertTrue(test)


    def test_penStock(self):
        for p in [wx.RED_PEN, wx.BLUE_PEN, wx.CYAN_PEN, wx.GREEN_PEN,
                  wx.YELLOW_PEN, wx.BLACK_PEN, wx.WHITE_PEN,
                  wx.TRANSPARENT_PEN, wx.BLACK_DASHED_PEN, wx.GREY_PEN,
                  wx.MEDIUM_GREY_PEN, wx.LIGHT_GREY_PEN]:
            self.assertTrue(isinstance(p, wx.Pen))
            self.assertTrue(p.IsOk())


    def test_penDashes(self):
        p = wx.Pen()
        p.Style = wx.PENSTYLE_USER_DASH
        p.Width = 1
        dashes = [1,2,2,1]
        p.SetDashes(dashes)
        d = p.GetDashes()
        self.assertTrue(d == dashes)


    def test_penProperties(self):
        p = wx.Pen(wx.BLUE)
        p.Cap
        p.Colour
        p.Dashes
        p.Join
        p.Stipple
        p.Style
        p.Width


    def test_penConstants(self):
        wx.PENSTYLE_INVALID
        wx.PENSTYLE_SOLID
        wx.PENSTYLE_DOT
        wx.PENSTYLE_LONG_DASH
        wx.PENSTYLE_SHORT_DASH
        wx.PENSTYLE_DOT_DASH
        wx.PENSTYLE_USER_DASH
        wx.PENSTYLE_TRANSPARENT
        wx.PENSTYLE_STIPPLE_MASK_OPAQUE
        wx.PENSTYLE_STIPPLE_MASK
        wx.PENSTYLE_STIPPLE
        wx.PENSTYLE_BDIAGONAL_HATCH
        wx.PENSTYLE_CROSSDIAG_HATCH
        wx.PENSTYLE_FDIAGONAL_HATCH
        wx.PENSTYLE_CROSS_HATCH
        wx.PENSTYLE_HORIZONTAL_HATCH
        wx.PENSTYLE_VERTICAL_HATCH
        wx.PENSTYLE_FIRST_HATCH
        wx.PENSTYLE_LAST_HATCH

        wx.JOIN_INVALID
        wx.JOIN_BEVEL
        wx.JOIN_MITER
        wx.JOIN_ROUND

        wx.CAP_INVALID
        wx.CAP_ROUND
        wx.CAP_PROJECTING
        wx.CAP_BUTT


    def test_penOldStyleNames(self):
        p = wx.Pen('red', 1, wx.STIPPLE)



#---------------------------------------------------------------------------


if __name__ == '__main__':
    unittest.main()