]> SALOME platform Git repositories - tools/eficas.git/blob - Pmw/Pmw_1_2/tests/ComboBox_test.py
Salome HOME
Modif V6_4_°
[tools/eficas.git] / Pmw / Pmw_1_2 / tests / ComboBox_test.py
1 # Based on iwidgets2.2.0/tests/combobox.test code. 
2
3
4 import Tkinter
5 import Test
6 import Pmw
7
8 Test.initialise()
9
10 if Tkinter.TkVersion >= 8.4:
11   expected1 = 'TclError: bad relief "bogus": must be '
12   expected2 = 'TclError: bad state "bogus": must be ' + \
13     'disabled, normal, or readonly'
14 elif Tkinter.TkVersion >= 8.3:
15   expected1 = 'TclError: bad relief "bogus": must be '
16   expected2 = 'TclError: bad state "bogus": must be disabled or normal'
17 else:
18   expected1 = 'TclError: bad relief type "bogus": must be '
19   expected2 = 'TclError: bad state value "bogus": must be normal or disabled'
20
21 c = Pmw.ComboBox
22
23 kw_1a = {
24   'labelpos' : 'w',
25   'label_text' : 'Label:',
26   'autoclear': 1,
27   'listheight': 250,
28   'scrolledlist_items': ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'),
29 }
30
31 kw_1b = {
32   'dropdown': 0,
33   'entry_state': 'disabled',
34   'selectioncommand' : Test.callback1,
35   'scrolledlist_items': ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'),
36   'listheight' : 200,
37   'label_text' : 'DropDown:',
38   'labelpos' : 'w',
39   'listbox_cursor' : 'hand1',
40   'unique' : 1
41 }
42
43 tests_1 = (
44   (c.pack, (), {'padx' : 10, 'pady' : 10, 'fill' : 'both', 'expand' : 1}),
45   (Test.num_options, (), 11),
46   ('entry_width', 20),
47   ('entry_textvariable', Test.stringvar),
48   ('label_text', 'ComboBox:'),
49   ('label_image', Test.flagup),
50   ('label_image', ''),
51   ('entry_borderwidth', 10),
52   ('entry_borderwidth', 2),
53   ('hull_background', 'steelblue'),
54   ('entry_foreground', 'white'),
55   ('hull_background', 'grey85'),
56   ('entry_foreground', 'Black'),
57   ('entry_textvariable', ''),
58   ('entry_state', 'disabled'),
59   ('entry_state', 'normal'),
60   ('label_font', Test.font['variable']),
61   ('entry_font', Test.font['large']),
62   ('entry_font', Test.font['variable']),
63   (c.invoke, ()),
64   ('hull_cursor', ''),
65   ('entry_relief', 'raised'),
66   ('entry_relief', 'groove'),
67   ('entry_relief', 'flat'),
68   ('entry_relief', 'sunken'),
69   ('entry_exportselection', 1),
70   ('entry_exportselection', 0),
71   ('entryfield_invalidcommand', Test.bell),
72   ('listbox_cursor', 'hand1'),
73   ('listbox_cursor', 'hand2'),
74   ('entry_selectbackground', '#b2dfee'),
75   ('listbox_selectbackground', 'steelblue'),
76   ('entry_selectborderwidth', 1),
77   ('entry_selectforeground', 'Black'),
78   ('entry_background', 'white'),
79   ('entryfield_validate', 'alphabetic'),
80   (c.setentry, '1234', 0),
81   (c.get, (), 'this is some text'),
82   ('entryfield_validate', None),
83   ('scrolledlist_hscrollmode', 'dynamic'),
84   ('scrolledlist_hscrollmode', 'dynamic'),
85   ('scrolledlist_vscrollmode', 'dynamic'),
86   ('scrolledlist_vscrollmode', 'dynamic'),
87   ('entry_borderwidth', 'bogus', 'TclError: bad screen distance "bogus"'),
88   ('entry_cursor', 'bogus', 'TclError: bad cursor spec "bogus"'),
89   ('entry_exportselection', 'bogus',
90     'TclError: expected boolean value but got "bogus"'),
91   ('scrolledlist_hscrollmode', 'bogus',
92     'ValueError: bad hscrollmode option "bogus": should be static, dynamic, ' +
93         'or none'),
94   ('listbox_cursor', 'bogus', 'TclError: bad cursor spec "bogus"'),
95   ('entry_relief', 'bogus', expected1 + Test.reliefs),
96   ('entry_selectborderwidth', 'bogus', 'TclError: bad screen distance "bogus"'),
97   ('entry_state', 'bogus', expected2),
98   ('entryfield_validate', 'bogus',
99     "ValueError: bad validate value \"bogus\":  must be a function or one of " +
100         "the standard validators ('alphabetic', 'alphanumeric', 'date', " +
101         "'hexadecimal', 'integer', 'numeric', 'real', 'time') or extra " +
102         "validators ()"),
103   ('scrolledlist_vscrollmode', 'bogus',
104     'ValueError: bad vscrollmode option "bogus": should be static, dynamic, ' +
105         'or none'),
106   ('entry_width', 'bogus', 'TclError: expected integer but got "bogus"'),
107   (c.interior, (), Tkinter.Frame),
108   (c.setentry, 'This is some text', 1),
109   (c.get, (), 'This is some text'),
110   (c.get, 2, 'C'),
111   (c.get, (2, 4), ('C', 'D', 'E')),
112   ('listbox_exportselection', 0),
113   (c.selectitem, 3),
114   (c.getcurselection, (), ('D',)),
115   (c.get, (), 'D'),
116   (c.selectitem, 'H'),
117   (c.getcurselection, (), ('H',)),
118   (c.get, (), 'H'),
119   (c.setentry, '', 1),
120   (c.size, (), 10),
121   (c.get, (), ''),
122   (c.delete, (0, 'end')),
123   (c.insert, (0, 'Test1', 'Test2', 'Test3', 'Test4')),
124   (c.insert, ('end', 'More Test')),
125   (c.size, (), 5),
126   (c.delete, (1),),
127   (c.delete, (0, 2)),
128   (c.size, (), 1),
129   (c.get, 0, 'More Test'),
130   (c.setentry, '', 1),
131   (c.get, (), ''),
132   (c.selectitem, 'More Test'),
133   (c.curselection, (), ('0',)),
134   (c.delete, (0, 'end')),
135   (c.size, (), 0),
136   (c.getcurselection, (), ()),
137   (c.insert, ('end', 'Test1', 'Test2', 'Really Long String Test')),
138   (c.size, (), 3),
139   (c.get, 0, 'Test1'),
140   (c.get, 2, 'Really Long String Test'),
141   (c.insert, (0, 'Test3', 'Test4', 'Really Long String Test')),
142   (c.size, (), 6),
143   (c.insert, (1, 'Test5', 'Test6', 'Really Long String Test')),
144   (c.size, (), 9),
145   (c.insert, (5, 'Test7', 'Test8', 'Really Long String Test')),
146   (c.size, (), 12),
147   (c.see, 0),
148   (c.see, 11),
149   (c.get, 'end', 'Really Long String Test'),
150   (c.selectitem, 5),
151   (c.curselection, (), ('5',)),
152   (c.clear, ()),
153   (c.get, (), ''),
154   (c.size, (), 0),
155 )
156
157 kw_2 = {
158   'fliparrow': 1,
159   'history': 1,
160   'buttonaspect': 0.5,
161   'arrowbutton_relief': 'groove',
162   'selectioncommand' : Test.callback,
163   'hull_background' : 'red',
164   'scrolledlist_items' : (123, 456, 789, 101112),
165   'listheight' : 50,
166   'label_text' : 'Numeric Simple:',
167   'labelpos' : 'w',
168   'entryfield_validate' : 'numeric',
169   'unique' : 0,
170 }
171 tests_2 = (
172   (c.pack, (), {'padx' : 10, 'pady' : 10, 'fill' : 'both', 'expand' : 1}),
173 )
174
175 alltests = (
176   (tests_1, kw_1a),
177   (tests_1, kw_1b),
178   (tests_2, kw_2),
179 )
180
181 testData = ((c, alltests),)
182
183 if __name__ == '__main__':
184     Test.runTests(testData)