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/] [combobox.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] Combobox 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 John S. Sigler
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
package require Iwidgets 3.0
15
 
16
if {[string compare test [info procs test]] == 1} {
17
    source defs
18
}
19
 
20
wm geometry . {}
21
raise .
22
 
23
set c 1
24
set o 1
25
set m 1
26
 
27
#
28
# Initial construction test
29
#
30
test Combobox-1.$c {Combobox construction} {
31
    iwidgets::Combobox .cb
32
    pack .cb -padx 10 -pady 10 -fill x -expand yes
33
    image create bitmap flagup -file $tk_library/demos/images/flagup.bmp
34
    update
35
} {}
36
 
37
incr c
38
 
39
#
40
# Option tests which are successful.
41
#
42
test Combobox-2.$o {configuration option} {
43
    llength [.cb configure]
44
} {50}
45
 
46
incr o
47
 
48
foreach test {
49
    {-listheight 150 150}
50
    {-width 20 20}
51
    {-textvariable option option}
52
    {-labeltext Combobox: Combobox:}
53
    {-labelpos nw nw}
54
    {-labelpos n n}
55
    {-labelpos ne ne}
56
    {-labelpos w w}
57
    {-labelimage flagup flagup}
58
    {-labelpos nw nw}
59
    {-labelpos n n}
60
    {-labelpos ne ne}
61
    {-labelpos w w}
62
    {-labelimage {} {}}
63
    {-borderwidth 10 10}
64
    {-borderwidth 2 2}
65
    {-background steelblue steelblue}
66
    {-foreground white white}
67
    {-background grey85 grey85}
68
    {-foreground Black Black}
69
    {-textvariable {} {}}
70
    {-state disabled disabled}
71
    {-state normal normal}
72
    {-textvariable option option}
73
    {-arrowrelief groove groove}
74
    {-arrowrelief flat flat}
75
    {-arrowrelief raised raised}
76
    {-selectioncommand {doit} {@scope :: doit}}
77
    {-selectioncommand {} {}}
78
    {-cursor {} {}}
79
        {-grab global global}
80
        {-grab local local}
81
    {-textvariable {} {} }
82
    {-dropdown false false}
83
    {-dropdown true true}
84
    {-textvariable option option}
85
    {-editable true true}
86
    {-editable false false}
87
    {-relief raised raised}
88
    {-relief groove groove}
89
    {-relief flat flat}
90
    {-relief sunken sunken}
91
    {-exportselection 1 1}
92
    {-exportselection 0 0}
93
    {-invalid {catch {blt_bell}} {catch {blt_bell}} }
94
    {-labelmargin 2 2}
95
    {-labelfont -Adobe-Helvetica-Bold-R-Normal--*-120-*  \
96
        -Adobe-Helvetica-Bold-R-Normal--*-120-*}
97
    {-margin 5 5}
98
    {-popupcursor hand1 hand1}
99
    {-popupcursor hand2 hand2}
100
    {-selectbackground \#b2dfee \#b2dfee}
101
    {-selectbackground steelblue steelblue}
102
    {-selectborderwidth 1 1}
103
    {-selectforeground Black Black}
104
    {-textbackground white white}
105
    {-textfont 10x20 10x20}
106
    {-textfont -Adobe-Helvetica-Medium-R-Normal--*-120-* \
107
        -Adobe-Helvetica-Medium-R-Normal--*-120-*}
108
    {-textvariable {} {} }
109
    {-unique true true}
110
    {-validate alpha alpha}
111
    {-validate {} {}}
112
    {-dropdown false false}
113
    {-hscrollmode dynamic static}
114
    {-hscrollmode dynamic dynamic}
115
    {-vscrollmode dynamic static}
116
        {-grab global global}
117
    {-vscrollmode dynamic dynamic}
118
    {-dropdown true true}} {
119
        set option [lindex $test 0]
120
        test Combobox-2.$o "configuration options, $option" {
121
            .cb configure $option [lindex $test 2]
122
            lindex [.cb configure $option] 4
123
        } [lindex $test 2]
124
        update
125
        incr o
126
    }
127
 
128
#
129
# Option tests which fail and produce errors.
130
#
131
foreach test {
132
    {-borderwidth bogus {bad screen distance "bogus"}}
133
        {-completion bogus {bad completion option "bogus": should be boolean}}
134
    {-cursor bogus {bad cursor spec "bogus"}}
135
    {-dropdown bogus {bad dropdown option "bogus": should be boolean}}
136
        {-editable bogus {bad editable option "bogus": should be boolean}}
137
    {-exportselection bogus {expected boolean value but got "bogus"}}
138
    {-grab bogus {bad grab value "bogus": must be global or local}}
139
    {-listheight bogus {bad screen distance "bogus"}}
140
    {-hscrollmode bogus {bad hscrollmode option "bogus": should be static, dynamic, or none}}
141
    {-margin bogus {bad screen distance "bogus"}}
142
    {-popupcursor bogus {bad cursor spec "bogus"}}
143
    {-selectborderwidth bogus {bad screen distance "bogus"}}
144
    {-state bogus {bad state value "bogus": must be normal or disabled}}
145
    {-unique bogus {bad unique value "bogus": should be boolean}}
146
    {-vscrollmode bogus {bad vscrollmode option "bogus": should be static, dynamic, or none}}
147
    {-width bogus {expected integer but got "bogus"}} } {
148
        set option [lindex $test 0]
149
        test Combobox-2.$o "configuration options, $option" {
150
            list [catch {.cb configure $option [lindex $test 1]} msg] $msg
151
        } [list 1 [lindex $test 2]]
152
        incr o
153
}
154
#
155
# Method tests which are successful.
156
#
157
foreach test {
158
    {{.cb configure -editable 1} {}}
159
    {{.cb clear all} {}}
160
    {{.cb insert list 0 Test1 Test2 Test3 Test4} {}}
161
    {{.cb insert list end {More Test}} {}}
162
    {{.cb size} {5}}
163
    {{.cb delete list 1} {}}
164
    {{.cb delete list 0 2} {}}
165
    {{.cb size} {1}}
166
    {{.cb get 0} {More Test}}
167
    {{.cb selection set end end} {}}
168
    {{.cb getcurselection} {More Test}}
169
    {{.cb get} {More Test}}
170
    {{.cb clear entry} {}}
171
    {{.cb get} {}}
172
    {{.cb insert entry end "this is a test"} {} }
173
    {{.cb get} {this is a test}}
174
    {{.cb curselection} {}}
175
    {{.cb clear} {}}
176
    {{.cb size} {0}}
177
    {{.cb getcurselection} {}}
178
    {{.cb insert list end {Test1} {Test2} {Really Long String Test}} {}}
179
    {{.cb size} {3}}
180
    {{.cb get 0} {Test1}}
181
        {{.cb insert entry end R} {}}
182
        {{.cb getcurselection} {Really Long String Test}}
183
        {{.cb get} {Really Long String Test}}
184
        {{.cb config -completion off} {}}
185
        {{.cb selection clear 0 end} {}}
186
        {{.cb insert entry end R} {}}
187
        {{.cb get} {R}}
188
        {{.cb getcurselection} {}}
189
        {{.cb config -completion on} {}}
190
    {{.cb get [expr [.cb size]-1]} {Really Long String Test}}
191
    {{.cb insert list 0 {Test3} {Test4} {Really Long String Test}} {}}
192
    {{.cb size} {6}}
193
    {{.cb insert list 1 {Test5} {Test6} {Really Long String Test}} {}}
194
    {{.cb size} {9}}
195
    {{.cb insert list 5 {Test7} {Test8} {Really Long String Test}} {}}
196
    {{.cb size} {12}}
197
        {{.cb config -state disabled} {}}
198
        {{.cb insert list end {not gonna make it in}} {}}
199
        {{.cb size} {12}}
200
        {{.cb insert entry end {eally!}} {}}
201
        {{.cb get} {R}}
202
        {{.cb config -state normal} {}}
203
        {{.cb config -dropdown 0} {}}
204
        {{.cb size} {12}}
205
        {{.cb config -dropdown 1} {}}
206
        {{.cb size} {12}}
207
    {{.cb see 0} {}}
208
    {{.cb see 11} {}}
209
    {{.cb get end} {Really Long String Test}}
210
    {{.cb selection clear 0 end} {}}
211
    {{.cb selection set 5 5} {}}
212
    {{.cb curselection} {5}}
213
    {{.cb justify left} {}}
214
    {{.cb justify right} {}}
215
    {{.cb justify top} {}}
216
    {{.cb justify bottom} {}}
217
    {{.cb sort ascending} {}}
218
    {{.cb sort descending} {}}
219
    {{.cb sort increasing} {}}
220
    {{.cb sort decreasing} {}}} {
221
        set method [lindex [lindex $test 0] 1]
222
        test Combobox-3.$m "object methods, $method" {
223
            list [catch {eval [lindex $test 0]} msg] $msg
224
        } [list 0 [lindex $test 1]]
225
        update
226
        incr m
227
}
228
 
229
#
230
# Method tests which fail and produce errors
231
#
232
foreach test {
233
    {{.cb clear bogus} {bad Combobox component "bogus": must be entry, list, or all.}}
234
    {{.cb delete} {wrong # args: should be ".cb delete component first ?last?"}}
235
    {{.cb delete bogus 0} {bad Combobox component "bogus": must be entry or list.}}
236
    {{.cb delete list} {wrong # args: should be ".cb delete component first ?last?"}}
237
    {{.cb delete entry} {wrong # args: should be ".cb delete component first ?last?"}}
238
    {{.cb get bogus1 bogus2} {wrong # args: should be ".cb get ?index?"}}
239
    {{.cb insert} {wrong # args: should be ".cb insert component index ?arg arg ...?"}}
240
    {{.cb insert bogus 0 bogus0} {bad Combobox component "bogus": must be entry or list.}}
241
    {{.cb insert list} {wrong # args: should be ".cb insert component index ?arg arg ...?"}}
242
    {{.cb insert list 1} {no value given for parameter "string" in function "Combobox::insert"}}
243
    {{.cb insert entry a b c} {called function "Combobox::insert entry" with too many arguments}}
244
    {{.cb selection} {wrong # args: should be ".cb selection option first ?last?"}}
245
    {{.cb selection bogus1 bogus2 bogus3 bogus4} {wrong # args: should be ".cb selection option first ?last?"}}
246
    {{.cb selection bogus bogus} {bad Scrolledlistbox index "bogus": must be active, anchor, end, @x,y, number, or a pattern}}
247
    {{.cb sort bogus} {bad sort argument "bogus": should be ascending, descending, increasing, or decreasing}}} {
248
    set method [lindex [lindex $test 0] 1]
249
    test Combobox-3.$m "object methods, $method" {
250
        list [catch {eval [lindex $test 0]} msg] $msg
251
    } [list 1 [lindex $test 1]]
252
    incr m
253
}
254
 
255
#
256
# Conclusion of constrcution/destruction tests
257
#
258
test Combobox-4.1 {Combobox destruction} {
259
    destroy .cb
260
    update
261
} {}
262
 
263
incr c
264
 
265
test Combobox-4.2 {Combobox construction} {
266
    iwidgets::Combobox .cb3 -selectioncommand {puts "choice: [.cb get]" } \
267
        -dropdown false -listheight 50 \
268
        -labeltext "Numeric Simple:" -labelpos w \
269
        -validate numeric -unique false
270
        .cb3 insert list end 123 456 789 101112
271
    pack .cb3 -padx 10 -pady 10 -fill both -expand yes
272
    update
273
} {}
274
 
275
incr c
276
 
277
test Combobox-4.3 {Combobox destruction} {
278
    destroy .cb3
279
    update
280
} {}
281
 
282
test Combobox-4.4 {Combobox construction} {
283
    iwidgets::Combobox .cb4 -arrowrelief flat -selectioncommand {puts "choice: [.cb get]" } \
284
        -editable false \
285
        -listheight 200 -labeltext "DropDown:" -labelpos w \
286
        -popupcursor hand1 -unique true
287
        .cb4 insert list end Hello {Out There} World
288
    pack .cb4 -padx 10 -pady 10 -fill both -expand yes
289
    update
290
} {}
291
 
292
incr c
293
 
294
test Combobox-4.5 {Combobox destruction} {
295
    destroy .cb4
296
    update
297
} {}

powered by: WebSVN 2.1.0

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