]> SALOME platform Git repositories - tools/eficas.git/blob - Pmw/Pmw_1_2/tests/ScrolledCanvas_test.py
Salome HOME
Modif V6_4_°
[tools/eficas.git] / Pmw / Pmw_1_2 / tests / ScrolledCanvas_test.py
1 import Test
2 import Pmw
3
4 Test.initialise()
5
6 c = Pmw.ScrolledCanvas
7
8 def _createOvals():
9     w = Test.currentWidget()
10     w.create_oval(50, 50, 150, 100, fill = 'red')
11     w.create_oval(100, 50, 150, 150, fill = 'blue')
12     w.create_oval(50, 100, 200, 350, fill = 'yellow')
13
14 def _createWindow():
15     w = Test.currentWidget()
16     lb = Pmw.ScrolledListBox(w.interior(),
17             items = range(20), listbox_height = 6)
18     w.create_window(300, 100, window = lb)
19
20 def _testYView(doBottom):
21     w = Test.currentWidget()
22     top, bottom = w.yview()
23     if type(top) != type(0.0) or type(bottom) != type(0.0):
24         return 'bad type ' + str(top) + ' ' + str(bottom)
25     if doBottom:
26         if bottom != 1.0:
27             return 'bottom is ' + str(bottom)
28     else:
29         if top != 0.0:
30             return 'top is ' + str(top)
31
32 kw_1 = {'labelpos': 'n', 'label_text': 'ScrolledCanvas', 'borderframe' : 1}
33 tests_1 = (
34   (c.pack, (), {'padx' : 10, 'pady' : 10, 'fill' : 'both', 'expand' : 1}),
35   (Test.num_options, (), 8),
36   (_createOvals, ()),
37   (c.resizescrollregion, ()),
38   (_createWindow, ()),
39   (c.resizescrollregion, ()),
40   ('hull_background', 'aliceblue'),
41   ('Scrollbar_borderwidth', 3),
42   ('hull_cursor', 'gumby'),
43   ('label_text', 'Label'),
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   ('vscrollmode', 'bogus', 'ValueError: bad vscrollmode ' +
54     'option "bogus": should be static, dynamic, or none'),
55   ('hscrollmode', 'bogus', 'ValueError: bad hscrollmode ' +
56     'option "bogus": should be static, dynamic, or none'),
57   (c.yview, ('moveto', 0.0)),
58   (_testYView, 0),
59   (c.yview, ('moveto', 0.02)),
60   (c.yview, ('moveto', 0.04)),
61   (c.yview, ('moveto', 0.06)),
62   (c.yview, ('moveto', 0.08)),
63   (c.yview, ('moveto', 0.10)),
64   (c.yview, ('moveto', 0.12)),
65   (c.yview, ('moveto', 0.14)),
66   (c.yview, ('moveto', 0.16)),
67   (c.yview, ('moveto', 0.18)),
68   (c.yview, ('moveto', 0.20)),
69   (c.yview, ('moveto', 0.22)),
70   (c.yview, ('moveto', 0.24)),
71   (c.yview, ('moveto', 0.26)),
72   (c.yview, ('moveto', 0.28)),
73   (c.yview, ('moveto', 0.98)),
74   (_testYView, 1),
75   (c.yview, ('scroll', -1, 'page')),
76   (c.yview, ('scroll', -1, 'page')),
77   (_testYView, 0),
78   (c.yview, ('scroll', 1, 'page')),
79   (c.yview, ('scroll', 1, 'page')),
80   (_testYView, 1),
81 )
82
83 kw_2 = {
84   'hscrollmode' : 'dynamic',
85   'label_text' : 'Label',
86   'labelpos' : 'n',
87   'scrollmargin': 20,
88   'canvasmargin': 20,
89   'usehullsize': 1,
90   'hull_width' : 500,
91   'hull_height' : 200,
92 }
93 tests_2 = (
94   (c.pack, (), {'padx' : 10, 'pady' : 10, 'fill' : 'both', 'expand' : 1}),
95 )
96
97 alltests = (
98   (tests_1, kw_1),
99   (tests_2, kw_2),
100 )
101
102 testData = ((Pmw.ScrolledCanvas, alltests),)
103
104 if __name__ == '__main__':
105     Test.runTests(testData)