File: test_richtextbuffer.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 (313 lines) | stat: -rw-r--r-- 10,110 bytes parent folder | download | duplicates (2)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
import unittest
from unittests import wtc
import wx
import wx.richtext

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

class richtextbuffer_Tests(wtc.WidgetTestCase):

    def test_richtextbuffer01(self):
        wx.richtext.RICHTEXT_TYPE_ANY
        wx.richtext.RICHTEXT_TYPE_TEXT
        wx.richtext.RICHTEXT_TYPE_XML
        wx.richtext.RICHTEXT_TYPE_HTML
        wx.richtext.RICHTEXT_TYPE_RTF
        wx.richtext.RICHTEXT_TYPE_PDF
        wx.richtext.RICHTEXT_FIXED_WIDTH
        wx.richtext.RICHTEXT_FIXED_HEIGHT
        wx.richtext.RICHTEXT_VARIABLE_WIDTH
        wx.richtext.RICHTEXT_VARIABLE_HEIGHT
        wx.richtext.RICHTEXT_LAYOUT_SPECIFIED_RECT
        wx.richtext.RICHTEXT_DRAW_IGNORE_CACHE
        wx.richtext.RICHTEXT_DRAW_SELECTED
        wx.richtext.RICHTEXT_DRAW_PRINT
        wx.richtext.RICHTEXT_DRAW_GUIDELINES

        wx.richtext.RICHTEXT_FORMATTED
        wx.richtext.RICHTEXT_UNFORMATTED
        wx.richtext.RICHTEXT_CACHE_SIZE
        wx.richtext.RICHTEXT_HEIGHT_ONLY
        wx.richtext.RICHTEXT_SETSTYLE_NONE
        wx.richtext.RICHTEXT_SETSTYLE_WITH_UNDO
        wx.richtext.RICHTEXT_SETSTYLE_OPTIMIZE
        wx.richtext.RICHTEXT_SETSTYLE_PARAGRAPHS_ONLY
        wx.richtext.RICHTEXT_SETSTYLE_CHARACTERS_ONLY
        wx.richtext.RICHTEXT_SETSTYLE_RENUMBER
        wx.richtext.RICHTEXT_SETSTYLE_SPECIFY_LEVEL
        wx.richtext.RICHTEXT_SETSTYLE_RESET
        wx.richtext.RICHTEXT_SETSTYLE_REMOVE

        wx.richtext.RICHTEXT_SETPROPERTIES_NONE
        wx.richtext.RICHTEXT_SETPROPERTIES_WITH_UNDO
        wx.richtext.RICHTEXT_SETPROPERTIES_PARAGRAPHS_ONLY
        wx.richtext.RICHTEXT_SETPROPERTIES_CHARACTERS_ONLY
        wx.richtext.RICHTEXT_SETPROPERTIES_RESET
        wx.richtext.RICHTEXT_SETPROPERTIES_REMOVE

        wx.richtext.RICHTEXT_INSERT_NONE
        wx.richtext.RICHTEXT_INSERT_WITH_PREVIOUS_PARAGRAPH_STYLE
        wx.richtext.RICHTEXT_INSERT_INTERACTIVE
        wx.richtext.TEXT_ATTR_KEEP_FIRST_PARA_STYLE

        wx.richtext.RICHTEXT_HITTEST_NONE
        wx.richtext.RICHTEXT_HITTEST_BEFORE
        wx.richtext.RICHTEXT_HITTEST_AFTER
        wx.richtext.RICHTEXT_HITTEST_ON
        wx.richtext.RICHTEXT_HITTEST_OUTSIDE
        wx.richtext.RICHTEXT_HITTEST_NO_NESTED_OBJECTS
        wx.richtext.RICHTEXT_HITTEST_NO_FLOATING_OBJECTS
        wx.richtext.RICHTEXT_HITTEST_HONOUR_ATOMIC
        wx.richtext.TEXT_BOX_ATTR_FLOAT
        wx.richtext.TEXT_BOX_ATTR_CLEAR
        wx.richtext.TEXT_BOX_ATTR_COLLAPSE_BORDERS
        wx.richtext.TEXT_BOX_ATTR_VERTICAL_ALIGNMENT
        wx.richtext.TEXT_ATTR_UNITS_TENTHS_MM
        wx.richtext.TEXT_ATTR_UNITS_PIXELS
        wx.richtext.TEXT_ATTR_UNITS_PERCENTAGE
        wx.richtext.TEXT_ATTR_UNITS_POINTS
        wx.richtext.TEXT_ATTR_UNITS_MASK
        wx.richtext.TEXT_BOX_ATTR_POSITION_STATIC
        wx.richtext.TEXT_BOX_ATTR_POSITION_RELATIVE
        wx.richtext.TEXT_BOX_ATTR_POSITION_ABSOLUTE
        wx.richtext.TEXT_BOX_ATTR_POSITION_MASK


    def test_richtextbuffer02(self):
        tad = wx.richtext.TextAttrDimension()


    def test_richtextbuffer03(self):
        tad = wx.richtext.TextAttrDimension(123, wx.richtext.TEXT_ATTR_UNITS_TENTHS_MM)
        self.assertTrue(tad.IsValid())
        tad.Value
        tad.ValueMM
        tad.Units


    def test_richtextbuffer04(self):
        tads = wx.richtext.TextAttrDimensions()
        tads.Left.Value = 123
        tads.Left.IsValid()


    def test_richtextbuffer05(self):
        tas = wx.richtext.TextAttrSize()
        tas.SetWidth(wx.richtext.TextAttrDimension(123))
        assert tas.Width.IsValid()
        assert tas.Width.Value == 123


    def test_richtextbuffer06(self):
        c = wx.richtext.TextAttrDimensionConverter(123)


    def test_richtextbuffer07(self):
        wx.richtext.TEXT_BOX_ATTR_BORDER_NONE
        wx.richtext.TEXT_BOX_ATTR_BORDER_SOLID
        wx.richtext.TEXT_BOX_ATTR_BORDER_DOTTED
        wx.richtext.TEXT_BOX_ATTR_BORDER_DASHED
        wx.richtext.TEXT_BOX_ATTR_BORDER_DOUBLE
        wx.richtext.TEXT_BOX_ATTR_BORDER_GROOVE
        wx.richtext.TEXT_BOX_ATTR_BORDER_RIDGE
        wx.richtext.TEXT_BOX_ATTR_BORDER_INSET
        wx.richtext.TEXT_BOX_ATTR_BORDER_OUTSET
        wx.richtext.TEXT_BOX_ATTR_BORDER_STYLE
        wx.richtext.TEXT_BOX_ATTR_BORDER_COLOUR
        wx.richtext.TEXT_BOX_ATTR_BORDER_THIN
        wx.richtext.TEXT_BOX_ATTR_BORDER_MEDIUM
        wx.richtext.TEXT_BOX_ATTR_BORDER_THICK
        wx.richtext.TEXT_BOX_ATTR_FLOAT_NONE
        wx.richtext.TEXT_BOX_ATTR_FLOAT_LEFT
        wx.richtext.TEXT_BOX_ATTR_FLOAT_RIGHT
        wx.richtext.TEXT_BOX_ATTR_CLEAR_NONE
        wx.richtext.TEXT_BOX_ATTR_CLEAR_LEFT
        wx.richtext.TEXT_BOX_ATTR_CLEAR_RIGHT
        wx.richtext.TEXT_BOX_ATTR_CLEAR_BOTH
        wx.richtext.TEXT_BOX_ATTR_COLLAPSE_NONE
        wx.richtext.TEXT_BOX_ATTR_COLLAPSE_FULL
        wx.richtext.TEXT_BOX_ATTR_VERTICAL_ALIGNMENT_NONE
        wx.richtext.TEXT_BOX_ATTR_VERTICAL_ALIGNMENT_TOP
        wx.richtext.TEXT_BOX_ATTR_VERTICAL_ALIGNMENT_CENTRE
        wx.richtext.TEXT_BOX_ATTR_VERTICAL_ALIGNMENT_BOTTOM


    def test_richtextbuffer08(self):
        b = wx.richtext.TextAttrBorder()


    def test_richtextbuffer09(self):
        b = wx.richtext.TextAttrBorders()
        b.Left
        b.Right
        b.Top
        b.Bottom


    def test_richtextbuffer10(self):
        ba = wx.richtext.TextBoxAttr()


    def test_richtextbuffer11(self):
        t1 = wx.richtext.RichTextAttr()
        t2 = wx.richtext.RichTextAttr(t1)
        t3 = wx.richtext.RichTextAttr(wx.TextAttr())


    def test_richtextbuffer12(self):
        p = wx.richtext.RichTextProperties()
        p.SetProperty('foo', 'bar')
        p.SetProperty('num', 123)
        self.assertEqual(p.GetProperty('foo'), 'bar')


    def test_richtextbuffer13(self):
        t = wx.richtext.RichTextFontTable()


    def test_richtextbuffer14a(self):
        r1 = wx.richtext.RichTextRange()
        r2 = wx.richtext.RichTextRange(111, 222)
        r3 = wx.richtext.RichTextRange(r2)
        r3.Start
        r3.End

    def test_richtextbuffer14b(self):
        wx.richtext.RICHTEXT_ALL
        wx.richtext.RICHTEXT_NONE
        wx.richtext.RICHTEXT_NO_SELECTION

    def test_richtextbuffer14c(self):
        r = wx.richtext.RichTextRange(111, 222)
        start = r[0]
        end = r[1]
        self.assertEqual(start, 111)
        self.assertEqual(end, 222)

    def test_richtextbuffer14d(self):
        r = wx.richtext.RichTextRange(111, 222)
        start, end = r.Get()
        self.assertEqual(start, 111)
        self.assertEqual(end, 222)

    def test_richtextbuffer14e(self):
        r = wx.richtext.RichTextRange()
        self.assertEqual(r.Get(), (0,0))
        r[0] = 111
        r[1] = 222
        self.assertEqual(r.Get(), (111,222))


    def test_richtextbuffer15(self):
        s1 = wx.richtext.RichTextSelection()
        s2 = wx.richtext.RichTextSelection(s1)


    def test_richtextbuffer16(self):
        c = wx.richtext.RichTextDrawingContext(None)


    def test_richtextbuffer17(self):
        with self.assertRaises(TypeError):
            o1 = wx.richtext.RichTextObject()  # It's an ABC

    def test_richtextbuffer18(self):
        with self.assertRaises(TypeError):
            o1 = wx.richtext.RichTextCompositeObject()  # It's an ABC

    def test_richtextbuffer19(self):
        o1 = wx.richtext.RichTextParagraphLayoutBox()

    def test_richtextbuffer20(self):
        o1 = wx.richtext.RichTextBox()

    def test_richtextbuffer21(self):
        o1 = wx.richtext.RichTextField()

    def test_richtextbuffer22(self):
        with self.assertRaises(TypeError):
            o1 = wx.richtext.RichTextFieldType('foo')  # It's an ABC

    def test_richtextbuffer23(self):
        o1 = wx.richtext.RichTextFieldTypeStandard()

    def test_richtextbuffer24(self):
        o1 = wx.richtext.RichTextFieldTypeStandard('foo', 'bar')

    def test_richtextbuffer25(self):
        o1 = wx.richtext.RichTextLine(None)

    def test_richtextbuffer26(self):
        para = wx.richtext.RichTextParagraph()
        para.AllocateLine(0)
        para.AllocateLine(1)
        lines = para.GetLines()
        self.assertEqual(len(lines), 2)
        for l in lines:
            self.assertTrue(isinstance(l, wx.richtext.RichTextLine))

    def test_richtextbuffer27(self):
        o1 = wx.richtext.RichTextParagraph()

    def test_richtextbuffer28(self):
        o1 = wx.richtext.RichTextPlainText()

    def test_richtextbuffer29(self):
        o1 = wx.richtext.RichTextPlainText('some text')

    def test_richtextbuffer30(self):
        o1 = wx.richtext.RichTextImageBlock()

    def test_richtextbuffer31(self):
        o1 = wx.richtext.RichTextImage()

    def test_richtextbuffer32(self):
        o1 = wx.richtext.RichTextImage(wx.Image(100,75))

    def test_richtextbuffer33(self):
        o1 = wx.richtext.RichTextImage()
        o2 = wx.richtext.RichTextImage(o1)

    def test_richtextbuffer34(self):
        o1 = wx.richtext.RichTextBuffer()

    def test_richtextbuffer35(self):
        o1 = wx.richtext.RichTextObjectAddress()

    def test_richtextbuffer36(self):
        o1 = wx.richtext.RichTextCommand('name')

    def test_richtextbuffer37(self):
        c = wx.richtext.RichTextCommand('name')
        b = wx.richtext.RichTextBuffer()
        # TODO: finish this   a = wx.richtext.RichTextAction(c, 'name', 1234, b, )

    def test_richtextbuffer38(self):
        o1 = wx.richtext.RichTextBufferDataObject()

    def test_richtextbuffer39(self):
        o1 = wx.richtext.RichTextRenderer()

    def test_richtextbuffer39(self):
        o1 = wx.richtext.RichTextStdRenderer()



    def test_GetIM(self):
        # Test the immutable version returned by GetIM
        obj = wx.richtext.RichTextRange(1,2)
        im = obj.GetIM()
        assert isinstance(im, tuple)
        assert im.Start == obj.Start
        assert im.End == obj.End
        obj2 = wx.richtext.RichTextRange(im)
        assert obj == obj2





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

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