OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [tags/] [start/] [insight/] [itcl/] [iwidgets3.0.0/] [tests/] [menubar.test] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
# This file is a Tcl script to test out [incr Widgets] Menubar 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: menubar.test,v 1.1.1.1 2002-01-16 10:24:51 markom Exp $
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 Menubar-1.$c {Menubar construction} {
33
    iwidgets::Menubar .mb -menubuttons {
34
                menubutton file -text File -menu {
35
                        options -tearoff no
36
                        command ok -label "Ok"
37
                        command quit -label "Quit"
38
                }
39
        }
40
    pack .mb
41
    update
42
    .mb add menubutton .other -text Other -menu {
43
                radiobutton r1 -label "Radio One"
44
                radiobutton r2 -label "Radio Two"
45
        }
46
    update
47
        .mb add menubutton view -text View -menu {
48
                command uno -label Uno
49
                command dos -label Dos
50
        }
51
        update
52
        .mb add cascade .view.more -label More -menu {
53
                command one -label One
54
                command two -label Two
55
                cascade extra -label Extra -menu {
56
                        radiobutton rad1 -label "Choice One"
57
                        radiobutton rad2 -label "Choice Two"
58
                        cascade somemore \
59
                                        -label "Some More" \
60
                                        -helpstr "Yet some more" \
61
                                        -menu {
62
                                command triangle -label "Triangle" -command {puts TRIANGLE}
63
                                command square -label "Square" -command {puts SQUARE}
64
                                command octagon -label "Octagon" -command {puts OCTAGON}
65
                        }
66
                }
67
        }
68
    update
69
} {}
70
 
71
incr c
72
 
73
#
74
# Option tests which are successful.
75
#
76
test Menubar-2.$o {configuration option} {
77
    llength [.mb configure]
78
} {22}
79
 
80
incr o
81
 
82
foreach test {
83
        {-anchor center center }
84
        {-disabledforeground #a3a3a3 #a3a3a3 }
85
        {-menubuttons {} {} }
86
        {-highlightthickness 0 0 }
87
        {-borderwidth 2 2 }
88
        {-helpvariable {} {} }
89
        {-highlightcolor Black Black }
90
        {-font -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* }
91
        {-background #CDCDB7B7B5B5 #CDCDB7B7B5B5 }
92
        {-highlightbackground #d9d9d9 #d9d9d9 }
93
        {-activeborderwidth 2 2 }
94
        {-wraplength 0 0 }
95
        {-activebackground #ececec #ececec }
96
        {-padx 4 4 }
97
        {-pady 4 4 }
98
        {-justify center center }
99
        {-cursor {} {} }
100
        {-activeforeground black black }
101
        {-width 0 0 }
102
        {-height 0 0 }
103
        } {
104
        set option [lindex $test 0]
105
        test Menubar-2.$o "configuration options, $option" {
106
            .mb configure $option [lindex $test 1]
107
                .mb cget $option
108
        } [lindex $test 2]
109
        update
110
        incr o
111
}
112
 
113
#
114
# Menuconfigure Option tests which are successful.
115
#
116
# This happens to be for a command...
117
test Menubar-3.$o {menubar menuconfiguration option} {
118
    llength [.mb menuconfigure .file.quit]
119
} {15}
120
 
121
# do menuconfigure tests also...
122
foreach test {
123
        { .file.quit -activebackground red red }
124
        { .file.quit -activeforeground red red }
125
        { .file.quit -accelerator {} {}  }
126
        { .file.quit -background red red }
127
        { .file.quit -bitmap {} {} }
128
        { .file.quit -command {} {}   }
129
        { .file.quit -font fixed fixed  }
130
        { .file.quit -foreground  red red }
131
        { .file.quit -image {} {} }
132
        { .file.quit -label hello hello }
133
        { .file.quit -state normal normal }
134
        { .file.quit -underline -1 -1 }
135
        { .file.quit -helpstr {} {} }
136
        } {
137
                set index  [lindex $test 0]
138
                set option [lindex $test 1]
139
                test Menubar-2.$o "tab configuration options, $option" {
140
                        .mb menuconfigure $index $option [lindex $test 2]
141
                        .mb menucget $index $option
142
                } [lindex $test 3]
143
        update
144
        incr o
145
}
146
 
147
# test on cascade item
148
# This happens to be for a cascade...
149
test Menubar-3.$o {menubar menuconfiguration option} {
150
    llength [.mb menuconfigure .view.more]
151
} {17}
152
 
153
# do menuconfigure tests also...
154
foreach test {
155
        { .view.more -activebackground red red }
156
        { .view.more -activeforeground red red }
157
        { .view.more -accelerator {} {}  }
158
        { .view.more -background  red red}
159
        { .view.more -bitmap {} {}  }
160
        { .view.more -command {} {}  }
161
        { .view.more -font   }
162
        { .view.more -foreground   }
163
        { .view.more -image {} {}  }
164
        { .view.more -label {} {}  }
165
        { .view.more -state normal normal }
166
        { .view.more -underline -1 -1 }
167
        { .view.more -helpstr {} {} }
168
        } {
169
                set index  [lindex $test 0]
170
                set option [lindex $test 1]
171
                test Menubar-2.$o "tab configuration options, $option" {
172
                        .mb menuconfigure $index $option [lindex $test 2]
173
                        .mb menucget $index $option
174
                } [lindex $test 3]
175
        update
176
        incr o
177
}
178
 
179
#
180
# Option tests which fail and produce errors.
181
#
182
#foreach test {
183
#       { -OPTION BADVALUE {ERROR_MESSAGE} }
184
#       } {
185
#       set option [lindex $test 0]
186
#        test Menubar-2.$o "configuration options, $option" {
187
#           list [catch {.bb configure $option [lindex $test 1]} msg] $msg
188
#       } [list 1 [lindex $test 2]]
189
#       incr o
190
#}
191
 
192
#
193
# Method tests which are successful.
194
#
195
foreach test {
196
    {{.mb delete 0 end}
197
                {}}
198
        {{.mb add menubutton .help -text Help}
199
                {}}
200
        {{.mb add command .help.context -label "On Context..."}
201
                {}}
202
        {{.mb insert .help.context command index -label "By Index..."}
203
                {}}
204
        {{.mb delete .help}
205
                {}}
206
        {{.mb add menubutton .help -text HELP -menu {
207
                        command index -label "By Index..."
208
                        command context -label "By Context..."
209
                        separator sep1
210
                        command keyword -label "By Keyword..."
211
                }}
212
                {}}
213
        {{.mb delete .help.sep1 .help.keyword}
214
                {}}
215
        {{.mb menuconfigure .help -text HeLp -menu {
216
                        command index -label "By Index..."
217
                        command context -label "By Context..."
218
                        separator sep1
219
                        command keyword -label "By Keyword..."
220
                }}
221
                {}}
222
        {{.mb configure -menubuttons {
223
                menubutton file -text File -menu {
224
                        options -tearoff $tearoff
225
                        command ok -label $okLabel
226
                        command quit -label $quitLabel
227
                        }
228
                }}
229
                {}}
230
        {{.mb add menubutton .other -text Other -menu {
231
                radiobutton r1 -label "Radio One"
232
                radiobutton r2 -label "Radio Two"
233
        }}
234
                {}}
235
        {{.mb insert .other menubutton view -text View -menu {
236
                command uno -label Uno
237
                command dos -label Dos
238
        }}
239
                {}}
240
        {{.mb add cascade .view.more -label More -menu {
241
                command one -label One
242
                command two -label Two
243
                cascade extra -label Extra -menu {
244
                        radiobutton rad1 -label "Choice One"
245
                        radiobutton rad2 -label "Choice Two"
246
                        cascade somemore \
247
                                        -label "Some More" \
248
                                        -helpstr "Yet some more" \
249
                                        -menu {
250
                                command triangle -label "Triangle" -command {puts TRIANGLE}
251
                                command square -label "Square" -command {puts SQUARE}
252
                                command octagon -label "Octagon" -command {puts OCTAGON}
253
                        }
254
                }
255
        }}
256
                {}}
257
        {{.mb insert .view.uno cascade before -label Before -menu {
258
                command red -label Red
259
                command green -label Green
260
                command blue -label Blue
261
        }}
262
                {}}
263
        {{.mb add menubutton .help -text Help}
264
                {}}
265
        {{.mb add command .help.context -label "On Context..."}
266
                {}}
267
        {{.mb insert .help.context command index -label "By Index..."}
268
                {}}
269
        {{.mb insert .view.before.green cascade colors -label Colors -menu {
270
                command orange -label Orange -command "puts ORANGE" -helpstr "orange"
271
                separator sep1
272
                command purple -label Purple
273
        }}
274
 
275
                {}}
276
        {{.mb insert .view.before.colors.purple cascade morecolors -label "More Colors" -menu {}}
277
                {}}
278
        {{.mb add command .view.before.colors.morecolors.pink -label Pink}
279
                {}}
280
        {{.mb add command .view.before.colors.morecolors.peach -label Peach}
281
                {}}
282
        {{.mb add command .view.before.colors.morecolors.yellow -label Yellow}
283
                {}}
284
        {{.mb menuconfigure .view -text VIEW -menu {
285
                command o -label OH -command {puts OH}
286
                cascade negative -label Negative -menu {
287
                        command print -label Print
288
                        command save -label Save
289
                }
290
                # Comments are supported.
291
#               command dummy -label PlaceHolder
292
                cascade plus -label Plus -menu {
293
                        command yep -label Yep
294
                        command nope -label Nope
295
                }
296
        }}
297
                {}}
298
        {{.mb menuconfigure .view.negative -label NEGATIVE -menu {
299
                command print -label PRINT
300
                command save -label SAVE
301
        }}
302
                {}}
303
        {{.mb delete .0 .end}
304
                {}}
305
        } {
306
        set method [lindex [lindex $test 0] 1]
307
        set method_invoke [lindex $test 0]
308
        test_pattern Menubar-4.$m "\[$method_invoke\]" {
309
            list [catch {eval [lindex $test 0]} msg] $msg
310
        } [list 0 [lindex $test 1]]
311
        update
312
        incr m
313
}
314
 
315
#
316
# Method tests which fail and produce errors or results
317
# Specifically, deals with method invocation on empty menubar.
318
#
319
foreach test {
320
                {{.mb delete .0 .last}
321
                        {bad path:}}
322
                {{.mb index .0}
323
                        {-1}}
324
                {{.mb index .end}
325
                        {-1}}
326
                {{.mb index .last}
327
                        {-1}}
328
                {{.mb index .help}
329
                        {-1}}
330
                {{.mb delete .0}
331
                        {bad path:}}
332
                {{.mb delete .end}
333
                        {bad path:}}
334
                {{.mb delete .last}
335
                        {bad path:}}
336
                {{.mb delete .help}
337
                        {bad path:}}
338
                {{.mb insert .0 menubutton file -text File}
339
                        {bad path:}}
340
                {{.mb insert .end menubutton file -text File}
341
                        {bad path:}}
342
                {{.mb insert .last menubutton file -text File}
343
                        {bad path:}}
344
                {{.mb insert .help menubutton file -text File}
345
                        {bad path:}}
346
                {{.mb invoke .0.0}
347
                        {bad path:}}
348
                {{.mb invoke .end.0}
349
                        {bad path:}}
350
                {{.mb invoke .last.0}
351
                        {bad path:}}
352
                {{.mb invoke .help.0}
353
                        {bad path:}}
354
                {{.mb menucget .0 -text}
355
                        {bad path:}}
356
                {{.mb menucget .end -text}
357
                        {bad path:}}
358
                {{.mb menucget .last -text}
359
                        {bad path:}}
360
                {{.mb menucget .help -text}
361
                        {bad path:}}
362
                {{.mb menuconfigure .0 -text}
363
                        {bad path:}}
364
                {{.mb menuconfigure .end -text}
365
                        {bad path:}}
366
                {{.mb menuconfigure .last -text}
367
                        {bad path:}}
368
                {{.mb menuconfigure .help -text}
369
                        {bad path:}}
370
                {{.mb path *quit}
371
                        {}}
372
                {{.mb type .0.0}
373
                        {bad path:}}
374
                {{.mb type .0.end}
375
                        {bad path:}}
376
                {{.mb type .0.last}
377
                        {bad path:}}
378
                {{.mb type .0.new}
379
                        {bad path:}}
380
                {{.mb yposition .0.new}
381
                        {bad path:}}
382
        } {
383
                set method [lindex [lindex $test 0] 1]
384
                set method_invoke [lindex $test 0]
385
                test_pattern Menubar-5.$m "\[$method_invoke\]" {
386
                        list [catch {eval [lindex $test 0]} msg] $msg
387
                } [list 1 [lindex $test 1]]
388
        incr m
389
        }
390
 
391
#
392
# Method tests which fail and produce errors or results
393
# On a non-empty menubar...
394
foreach test {
395
                {{.mb configure -menubuttons {
396
                        menubutton file -text File -menu {
397
                                options -tearoff no
398
                                command ok -label "Ok"
399
                                command quit -label "Quit"
400
                        }
401
                }}
402
                        {}}
403
                {{.mb delete .file.hello}
404
                        {bad path}}
405
                {{.mb index .0.hello}
406
                        {-1}}
407
                {{.mb index .0.quit}
408
                        {1}}
409
                {{.mb index 0.end}
410
                        {1}}
411
                {{.mb index .file.last}
412
                        {1}}
413
                {{.mb index .file.ok}
414
                        {0}}
415
                {{.mb delete .view .file}
416
                        {bad path:}}
417
                {{.mb delete .file .help}
418
                        {bad path:}}
419
                {{.mb add command .file.menu}
420
                        {bad name}}
421
                {{.mb add command .file.last}
422
                        {bad name}}
423
                {{.mb add command .file.end}
424
                        {bad name}}
425
                {{.mb add command .file.2}
426
                        {bad name}}
427
                {{.mb insert .0 menu view -text View}
428
                        {bad type}}
429
                {{.mb insert .file command view -text View}
430
                        {bad entry path}}
431
                {{.mb insert .file menubutton view -text View}
432
                        {[.]mb[.]menubar[.]view}}
433
                {{.mb invoke .0.quit}
434
                        {bad path}}
435
                {{.mb menucget .0 -text}
436
                        {View}}
437
                {{.mb menucget .end -text}
438
                        {File}}
439
                {{.mb menucget .last -text}
440
                        {File}}
441
                {{.mb menucget .help -text}
442
                        {bad path}}
443
                {{.mb menuconfigure .0 -text}
444
                        {-text text Text {} View}}
445
                {{.mb menuconfigure .end.last -label}
446
                        {-label {} {} {} Quit}}
447
                {{.mb menuconfigure .last -text}
448
                        {-text text Text {} File}}
449
                {{.mb menuconfigure .help -text}
450
                        {bad path}}
451
                {{.mb path *quit}
452
                        {[.]file[.]quit}}
453
                {{.mb type .end.0}
454
                        {command}}
455
                {{.mb type .end.end}
456
                        {command}}
457
                {{.mb type .end.last}
458
                        {command}}
459
                {{.mb type .0.new}
460
                        {bad path}}
461
        } {
462
                set method [lindex [lindex $test 0] 1]
463
                set method_invoke [lindex $test 0]
464
                test_pattern Menubar-5.$m "\[$method_invoke\]" {
465
                        list [catch {eval [lindex $test 0]} msg] $msg
466
                } [list 1 [lindex $test 1]]
467
        incr m
468
        }
469
 
470
#
471
# Conclusion of constrcution/destruction tests
472
#
473
test Menubar-1.$c {Menubar destruction} {
474
    destroy .mb
475
    update
476
} {}
477
 
478
incr c
479
 
480
test Menubar-1.$c {Menubar construction} {
481
    iwidgets::Menubar .mb -menubuttons {
482
                menubutton file -text File -menu {
483
                        options -tearoff no
484
                        command ok -label "Ok"
485
                        command quit -label "Quit"
486
                }
487
        }
488
    pack .mb
489
    update
490
    .mb add menubutton .other -text Other -menu {
491
                radiobutton r1 -label "Radio One"
492
                radiobutton r2 -label "Radio Two"
493
        }
494
    update
495
        .mb add menubutton view -text View -menu {
496
                command uno -label Uno
497
                command dos -label Dos
498
        }
499
        update
500
        .mb add cascade .view.more -label More -menu {
501
                command one -label One
502
                command two -label Two
503
                cascade extra -label Extra -menu {
504
                        radiobutton rad1 -label "Choice One"
505
                        radiobutton rad2 -label "Choice Two"
506
                        cascade somemore \
507
                                        -label "Some More" \
508
                                        -helpstr "Yet some more" \
509
                                        -menu {
510
                                command triangle -label "Triangle" -command {puts TRIANGLE}
511
                                command square -label "Square" -command {puts SQUARE}
512
                                command octagon -label "Octagon" -command {puts OCTAGON}
513
                        }
514
                }
515
        }
516
    update
517
} {}
518
 
519
incr c
520
 
521
test Menubar-1.$c {Menubar destruction} {
522
        destroy .mb
523
    update
524
} {}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.