OSDN Git Service

Initial revision
[pf3gnuchains/sourceware.git] / itcl / iwidgets3.0.0 / tests / tabset.test
1 # This file is a Tcl script to test out [incr Widgets] Tabset class.
2 # It is organized in the standard fashion for Tcl tests with the following
3 # notation for test case labels:
4 #
5 #   1.x - Construction/Destruction tests
6 #   2.x - Configuration option tests
7 #   3.x - Method tests
8 #
9 # Copyright (c) 1995 DSC Technologies Corporation
10 #
11 # See the file "license.terms" for information on usage and redistribution
12 # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13 #
14 # @(#) $Id$
15
16 package require Iwidgets 3.0
17
18 if {[string compare test [info procs test]] == 1} {
19     source defs
20 }
21
22 wm geometry . {}
23 raise .
24
25 set c 1
26 set o 1
27 set m 1
28
29 #
30 # Initial construction test
31 #
32 test Tabset-1.$c {Tabset construction} {
33     iwidgets::Tabset .ts
34     pack .ts 
35     update 
36     .ts add -label one
37     update 
38     .ts add -label two
39     update 
40     .ts add -label three
41     update 
42 } {}
43
44 incr c
45
46 #
47 # Option tests which are successful.
48 #
49 test Tabset-2.$o {configuration option} {
50     llength [.ts configure]
51 } {24}
52
53 incr o
54
55 foreach test {
56         {-disabledforeground #a3a3a3 #a3a3a3 }
57         {-backdrop white white }
58         {-start 4 4 }
59         {-command   }
60         {-font fixed fixed }
61         {-selectbackground #ececec #ececec }
62         {-gap overlap overlap }
63         {-background #CDCDB7B7B5B5 #CDCDB7B7B5B5 }
64         {-state normal normal }
65         {-equaltabs true true }
66         {-bevelamount 0 0 }
67         {-selectforeground black black }
68         {-foreground #000000000000 #000000000000 }
69         {-raiseselect false false }
70         {-padx 4 4 }
71         {-pady 4 4 }
72         {-cursor   }
73         {-margin 5 5 }
74         {-angle 20 20 }
75         {-width 0 0 }
76         {-tabborders true true }
77         {-height 0 0 }
78         {-tabpos s s }
79         } {
80         set option [lindex $test 0]
81         test Tabset-2.$o "configuration options, $option" {
82             .ts configure $option [lindex $test 1] 
83                 lindex [.ts configure $option] 4
84         } [lindex $test 2]
85         update 
86         incr o
87 }
88
89 #
90 # Tabconfigure Option tests which are successful.
91 #
92 test Tabset-2.$o {tab configuration option} {
93     llength [.ts tabconfigure 0]
94 } {22}
95
96 # do tabconfigure tests also...
97 foreach test {
98         {0 -bevelamount 0 0}
99         {0 -state normal normal}
100         {0 -anchor c c}
101         {0 -image {} {}}
102         {0 -bitmap {} {}}
103         {0 -label Hello Hello}
104         {0 -label "Hello World" "Hello World"}
105         {0 -padx 4 4}
106         {0 -pady 4 4}
107         {0 -selectbackground gray70 gray70}
108         {0 -selectforeground black black}
109         {0 -disabledforeground gray gray}
110         {0 -background white white}
111         {0 -foreground black black}
112         {0 -orient vertical vertical}
113         {0 -invert false false}
114         {0 -angle 20 20}
115         {0 -font "-adobe-helvetica-bold-r-normal--34-240-100-100-p-182-iso8859-1" "-adobe-helvetica-bold-r-normal--34-240-100-100-p-182-iso8859-1"}
116         {0 -tabborders true true}
117         } {
118                 set index  [lindex $test 0]
119                 set option [lindex $test 1]
120                 test Tabset-2.$o "tab configuration options, $option" {
121                         .ts tabconfigure $index $option [lindex $test 2] 
122                         .ts tabcget $index $option
123                 } [lindex $test 3]
124         update 
125         incr o
126 }
127
128 #
129 # Option tests which fail and produce errors.
130 #
131 #foreach test {
132 #       { -OPTION BADVALUE {ERROR_MESSAGE} }
133 #       } {
134 #       set option [lindex $test 0]
135 #        test Tabset-2.$o "configuration options, $option" {
136 #           list [catch {.bb configure $option [lindex $test 1]} msg] $msg
137 #       } [list 1 [lindex $test 2]]
138 #       incr o
139 #}
140
141 #
142 # Method tests which are successful.
143 #
144 foreach test {
145     {{.ts add} 
146                 {::.ts-tab[0-9]+}}
147     {{.ts add} 
148                 {::.ts-tab[0-9]+}}
149     {{.ts add} 
150                 {::.ts-tab[0-9]+}}
151     {{.ts add -label Never} 
152                 {::.ts-tab[0-9]+}}
153     {{.ts add} 
154                 {::.ts-tab[0-9]+}}
155         {{.ts add -label "Hello World" -disabledforeground gray} 
156                 {::.ts-tab[0-9]+}}
157     {{.ts index end} 
158                 {[0-9]+}}
159     {{.ts index Never} 
160                 {[0-9]+}}
161     {{.ts index 0} 
162                 {0}}
163     {{.ts select 0} 
164                 {0}}
165     {{.ts select select} 
166                 {0}}
167     {{.ts select end} 
168                 {[0-9]+}}
169     {{.ts select "Hello World"} 
170                 {[0-9]+}}
171     {{.ts insert 0} 
172                 {::.ts-tab[0-9]+}}
173     {{.ts insert select -label "An Insert"} 
174                 {::.ts-tab[0-9]+}}
175     {{.ts insert end -label "Next To Last"} 
176                 {::.ts-tab[0-9]+}}
177     {{.ts select 0} 
178                 {0}}
179     {{.ts next} 
180                 {1}}
181     {{.ts next} 
182                 {2}}
183     {{.ts prev} 
184                 {1}}
185     {{.ts prev} 
186                 {0}}
187     {{.ts delete Never} 
188                 {}}
189     {{.ts delete 1 2} 
190                 {}}
191     {{.ts delete 0 "Hello World"} 
192                 {}}
193     {{.ts add} 
194                 {::.ts-tab[0-9]+}}
195     {{.ts add} 
196                 {::.ts-tab[0-9]+}}
197     {{.ts add} 
198                 {::.ts-tab[0-9]+}}
199     {{.ts add} 
200                 {::.ts-tab[0-9]+}}
201     {{.ts delete 0 end} 
202                 {}}
203     {{.ts add} 
204                 {::.ts-tab[0-9]+}}
205     {{.ts add} 
206                 {::.ts-tab[0-9]+}}
207     {{.ts add} 
208                 {::.ts-tab[0-9]+}}
209     {{.ts add} 
210                 {::.ts-tab[0-9]+}}
211     {{.ts select 2} 
212                 {[-]*[0-9]+}}
213     {{.ts delete select end} 
214                 {}}
215     {{.ts delete 0 end} 
216                 {}}
217     {{.ts add -label "First Page"} 
218                 {::.ts-tab[0-9]+}}
219     {{.ts add -label "Second Page"} 
220                 {::.ts-tab[0-9]+}}
221     {{.ts add -label "Third Page"} 
222                 {::.ts-tab[0-9]+}}
223     {{.ts add -label "Fourth Page"} 
224                 {::.ts-tab[0-9]+}}
225     {{.ts add -label "Fifth Page"} 
226                 {::.ts-tab[0-9]+}}
227     {{.ts add -label "Sixth Page"} 
228                 {::.ts-tab[0-9]+}}
229     {{.ts select "First Page"} 
230                 {[-]*[0-9]+}}
231     {{.ts delete select "Second Page"} 
232                 {}}
233     {{.ts delete "Third Page" 1} 
234                 {}}
235     {{.ts delete "Fifth Page" "Sixth Page"} 
236                 {}}
237         } {
238         set method [lindex [lindex $test 0] 1]
239         set method_invoke [lindex $test 0]
240         test_pattern Tabset-3.$m "\[$method_invoke\]" {
241             list [catch {eval [lindex $test 0]} msg] $msg
242         } [list 0 [lindex $test 1]]
243         update 
244         incr m
245 }
246
247 #
248 # Method tests which fail and produce errors
249 #
250 foreach test {
251                 {{.ts delete 0 end} {}}
252                 {{.ts add} {}}
253                 {{.ts delete 0} {}}
254                 {{.ts delete 0} {can't delete tabs, no tabs}}
255                 {{.ts add} {}}
256                 {{.ts delete 1} {bad value for index1}}
257                 {{.ts delete select} {bad value for index1}}
258                 {{.ts delete 0} {}}
259                 {{.ts add} {}}
260                 {{.ts delete 0 1} {bad value for index2}}
261                 {{.ts delete 1 4} {bad value for index1}}
262                 {{.ts add} {}}
263                 {{.ts delete 0 1} {}}
264                 {{.ts add} {}}
265                 {{.ts delete 0 1 4 5 6} {wrong # args}}
266                 {{.ts delete} {wrong # args}}
267                 {{.ts delete 0} {}}
268                 {{.ts delete 0} {can't delete tabs}}
269                 {{.ts delete select} {can't delete tabs}}
270                 {{.ts insert 0} {no tab to insert before, tabset}}
271                 {{.ts add} {}}
272                 {{.ts add} {}}
273                 {{.ts insert 2} {bad value}}
274                 {{.ts insert -1} {bad option}}
275                 {{.ts delete 0 end} {}}
276                 {{.ts next} {can't goto next tab, no tabs in the tabset}}
277                 {{.ts prev} {can't goto previous tab, no tabs in the tabset}}
278                 {{.ts select 0} {can't activate a tab, no tabs in the tabset}}
279                 {{.ts add} {}}
280                 {{.ts select 1} {bad value}}
281                 {{.ts delete 0} {}}
282         } {
283                 set method [lindex [lindex $test 0] 1]
284                 set method_invoke [lindex $test 0]
285                 test_pattern Tabset-3.$m "\[$method_invoke\]" {
286                         list [catch {eval [lindex $test 0]} msg] $msg
287                 } [list 1 [lindex $test 1]]
288         incr m
289         }
290
291 # Conclusion of constrcution/destruction tests
292 #
293 test Tabset-1.$c {Tabset destruction} {
294     destroy .ts
295     update 
296 } {}
297
298 incr c
299
300 test Tabset-1.$c {Tabset construction} {
301     iwidgets::Tabset .ts -width 100 -height 100
302     pack .ts 
303     update 
304     .ts add -label one
305     update 
306     .ts add -label two
307     update 
308     .ts add -label three
309     update 
310 } {}
311
312 incr c
313
314 test Tabset-1.$c {Tabset destruction} {
315         destroy .ts
316     update 
317 } {}