Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | # Based on iwidgets2.2.0/tests/scrolledtext.test code. |
2 | ||
3 | import Test | |
4 | import Pmw | |
5 | ||
6 | Test.initialise() | |
7 | ||
8 | c = Pmw.ScrolledText | |
9 | ||
10 | def _testYView(doBottom): | |
11 | w = Test.currentWidget() | |
12 | top, bottom = w.yview() | |
13 | if type(top) != type(0.0) or type(bottom) != type(0.0): | |
14 | return 'bad type ' + str(top) + ' ' + str(bottom) | |
15 | if doBottom: | |
16 | if bottom != 1.0: | |
17 | return 'bottom is ' + str(bottom) | |
18 | else: | |
19 | if top != 0.0: | |
20 | return 'top is ' + str(top) | |
21 | ||
22 | kw_1 = {'labelpos': 'n', 'label_text': 'ScrolledText'} | |
23 | tests_1 = ( | |
24 | (c.pack, (), {'padx' : 10, 'pady' : 10, 'fill' : 'both', 'expand' : 1}), | |
25 | (Test.num_options, (), 10), | |
26 | (c.importfile, 'ScrolledText_test.py'), | |
27 | ('hull_background', 'aliceblue'), | |
28 | ('text_borderwidth', 3), | |
29 | ('Scrollbar_borderwidth', 3), | |
30 | ('hull_cursor', 'gumby'), | |
31 | ('text_exportselection', 0), | |
32 | ('text_exportselection', 1), | |
33 | ('text_foreground', 'Black'), | |
34 | ('text_height', 10), | |
35 | ('text_width', 20), | |
36 | ('text_insertbackground', 'Black'), | |
37 | ('text_insertborderwidth', 1), | |
38 | ('text_insertofftime', 200), | |
39 | ('text_insertontime', 500), | |
40 | ('text_insertwidth', 3), | |
41 | ('label_text', 'Label'), | |
42 | ('text_relief', 'raised'), | |
43 | ('text_relief', 'sunken'), | |
44 | ('Scrollbar_repeatdelay', 200), | |
45 | ('Scrollbar_repeatinterval', 105), | |
46 | ('vscrollmode', 'none'), | |
47 | ('vscrollmode', 'static'), | |
48 | ('vscrollmode', 'dynamic'), | |
49 | ('hscrollmode', 'none'), | |
50 | ('hscrollmode', 'static'), | |
51 | ('hscrollmode', 'dynamic'), | |
52 | ('Scrollbar_width', 20), | |
53 | ('text_selectborderwidth', 2), | |
54 | ('text_state', 'disabled'), | |
55 | ('text_state', 'normal'), | |
56 | ('text_background', 'GhostWhite'), | |
57 | ('text_wrap', 'char'), | |
58 | ('text_wrap', 'none'), | |
59 | ('vscrollmode', 'bogus', 'ValueError: bad vscrollmode ' + | |
60 | 'option "bogus": should be static, dynamic, or none'), | |
61 | ('hscrollmode', 'bogus', 'ValueError: bad hscrollmode ' + | |
62 | 'option "bogus": should be static, dynamic, or none'), | |
63 | (c.cget, 'vscrollmode', 'bogus'), | |
64 | (c.cget, 'hscrollmode', 'bogus'), | |
65 | ('vscrollmode', 'dynamic'), | |
66 | ('hscrollmode', 'dynamic'), | |
67 | (c.insert, ('end', 'Hello there\n')), | |
68 | (_testYView, 0), | |
69 | (c.yview, ('moveto', 0.02)), | |
70 | (c.yview, ('moveto', 0.04)), | |
71 | (c.yview, ('moveto', 0.06)), | |
72 | (c.yview, ('moveto', 0.08)), | |
73 | (c.yview, ('moveto', 0.10)), | |
74 | (c.yview, ('moveto', 0.12)), | |
75 | (c.yview, ('moveto', 0.14)), | |
76 | (c.yview, ('moveto', 0.16)), | |
77 | (c.yview, ('moveto', 0.18)), | |
78 | (c.yview, ('moveto', 0.20)), | |
79 | (c.yview, ('moveto', 0.22)), | |
80 | (c.yview, ('moveto', 0.24)), | |
81 | (c.yview, ('moveto', 0.26)), | |
82 | (c.yview, ('moveto', 0.28)), | |
83 | (c.yview, ('moveto', 0.98)), | |
84 | (_testYView, 1), | |
85 | (c.yview, ('scroll', -1, 'page')), | |
86 | (c.yview, ('scroll', -50, 'page')), | |
87 | (_testYView, 0), | |
88 | (c.yview, ('scroll', 1, 'page')), | |
89 | (c.yview, ('scroll', 50, 'page')), | |
90 | (_testYView, 1), | |
91 | (c.clear, ()), | |
92 | (c.get, (), '\n'), | |
93 | ) | |
94 | ||
95 | kw_2 = { | |
96 | 'hscrollmode' : 'dynamic', | |
97 | 'label_text' : 'Label', | |
98 | 'labelpos' : 'n', | |
99 | 'scrollmargin': 20, | |
100 | } | |
101 | tests_2 = ( | |
102 | (c.pack, (), {'padx' : 10, 'pady' : 10, 'fill' : 'both', 'expand' : 1}), | |
103 | (c.importfile, 'ScrolledText_test.py'), | |
104 | ('text_relief', 'raised'), | |
105 | ('text_relief', 'sunken'), | |
106 | ) | |
107 | ||
108 | alltests = ( | |
109 | (tests_1, kw_1), | |
110 | (tests_2, kw_2), | |
111 | ) | |
112 | ||
113 | testData = ((Pmw.ScrolledText, alltests),) | |
114 | ||
115 | if __name__ == '__main__': | |
116 | Test.runTests(testData) |