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

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [insight/] [itcl/] [iwidgets3.0.0/] [tests/] [toolbar.test] - Blame information for rev 1765

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] Toolbar 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: toolbar.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 Toolbar-1.$c {Toolbar construction} {
33
    iwidgets::Toolbar .tb
34
    pack .tb
35
    update
36
    .tb add button item1 -text item1
37
    update
38
    .tb add button item2 -text item2
39
    update
40
    .tb add button item3 -text item3
41
    update
42
} {}
43
 
44
incr c
45
 
46
#
47
# Option tests which are successful.
48
#
49
test Toolbar-2.$o {configuration option} {
50
    llength [.tb configure]
51
} {27}
52
 
53
incr o
54
 
55
foreach test {
56
        {-disabledforeground #a3a3a3 #a3a3a3 }
57
        {-highlightthickness 0 0 }
58
        {-selectborderwidth 4 4  }
59
        {-balloonfont 6x10 6x10 }
60
        {-balloondelay1 1000 1000 }
61
        {-balloondelay2 200 200 }
62
        {-borderwidth 2 2 }
63
        {-selectcolor #CDCDB7B7B5B5 #CDCDB7B7B5B5 }
64
        {-highlightcolor Black Black }
65
        {-font -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* }
66
        {-balloonbackground yellow yellow }
67
        {-helpvariable testing testing}
68
        {-troughcolor #c3c3c3 #c3c3c3 }
69
        {-selectbackground #c3c3c3 #c3c3c3 }
70
        {-highlightbackground #d9d9d9 #d9d9d9 }
71
        {-background #CDCDB7B7B5B5 #CDCDB7B7B5B5 }
72
        {-state normal normal }
73
        {-balloonforeground black black }
74
        {-selectforeground Black Black }
75
        {-foreground #000000000000 #000000000000 }
76
        {-activebackground #ececec #ececec }
77
        {-insertbackground Black Black }
78
        {-cursor crosshair crosshair  }
79
        {-activeforeground Black Black }
80
        {-insertforeground Black Black }
81
        {-orient horizontal horizontal }
82
        } {
83
        set option [lindex $test 0]
84
        test Toolbar-2.$o "configuration options, $option" {
85
            .tb configure $option [lindex $test 1]
86
                .tb cget $option
87
        } [lindex $test 2]
88
        update
89
        incr o
90
}
91
 
92
#
93
# Itemconfigure Option tests which are successful.
94
#
95
# This happens to be for a button...
96
set o 0
97
test Toolbar-3.$o {tab configuration option} {
98
    llength [.tb itemconfigure 0]
99
} {33}
100
 
101
# do itemconfigure tests also...
102
foreach test {
103
        {0 -activebackground #ececec #ececec }
104
        {0 -activeforeground Black Black }
105
        {0 -anchor center center }
106
        {0 -background #d9d9d9 #d9d9d9 }
107
        {0 -bd 0 0 }
108
        {0 -bg #d9d9d9 #d9d9d9  }
109
        {0 -bitmap {} {} }
110
        {0 -borderwidth 2 2 }
111
        {0 -command {} {} }
112
        {0 -cursor {} {} }
113
        {0 -disabledforeground #a3a3a3 #a3a3a3 }
114
        {0 -fg Black Black }
115
        {0 -font -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* }
116
        {0 -foreground Black Black }
117
        {0 -height 0 0 }
118
        {0 -highlightbackground #d9d9d9 #d9d9d9 }
119
        {0 -highlightcolor Black Black }
120
        {0 -highlightthickness 2 2 }
121
        {0 -image  {} {} }
122
        {0 -justify center center }
123
        {0 -padx 4 4 }
124
        {0 -pady 4 4 }
125
        {0 -relief raised raised }
126
        {0 -state normal normal }
127
        {0 -takefocus false false  }
128
        {0 -text {} {} }
129
        {0 -textvariable {} {}  }
130
        {0 -underline -1 -1 }
131
        {0 -width 0 0 }
132
        {0 -wraplength 0 0 }
133
        {0 -helpstr {} {} }
134
        {0 -balloonstr {} {} }
135
        } {
136
                set index  [lindex $test 0]
137
                set option [lindex $test 1]
138
                test Toolbar-2.$o "tab configuration options, $option" {
139
                        .tb itemconfigure $index $option [lindex $test 2]
140
                        .tb itemcget $index $option
141
                } [lindex $test 3]
142
        update
143
        incr o
144
}
145
 
146
#
147
# Option tests which fail and produce errors.
148
#
149
#foreach test {
150
#       { -OPTION BADVALUE {ERROR_MESSAGE} }
151
#       } {
152
#       set option [lindex $test 0]
153
#        test Toolbar-2.$o "configuration options, $option" {
154
#           list [catch {.bb configure $option [lindex $test 1]} msg] $msg
155
#       } [list 1 [lindex $test 2]]
156
#       incr o
157
#}
158
 
159
#
160
# Method tests which are successful.
161
#
162
foreach test {
163
    {{.tb delete 0 end}
164
                {}}
165
    {{.tb add radiobutton one}
166
                {.tb.one}}
167
    {{.tb index end}
168
                {0}}
169
    {{.tb add checkbutton two}
170
                {.tb.two}}
171
    {{.tb index end}
172
                {1}}
173
    {{.tb index one}
174
                {0}}
175
    {{.tb insert end button oneandhalf -text "One & half"}
176
                {.tb.oneandhalf}}
177
    {{.tb index oneandhalf}
178
                {1}}
179
    {{.tb delete oneandhalf}
180
                {}}
181
    {{.tb index two}
182
                {1}}
183
    {{.tb delete 0 end}
184
                {}}
185
    {{.tb index 0}
186
                {-1}}
187
        } {
188
        set method [lindex [lindex $test 0] 1]
189
        set method_invoke [lindex $test 0]
190
        test_pattern Toolbar-4.$m "\[$method_invoke\]" {
191
            list [catch {eval [lindex $test 0]} msg] $msg
192
        } [list 0 [lindex $test 1]]
193
        update
194
        incr m
195
}
196
 
197
#
198
# Method tests which fail and produce errors
199
#
200
foreach test {
201
                {{.tb delete 0 end} {}}
202
                {{.tb add button item1} {}}
203
                {{.tb delete 0} {}}
204
                {{.tb delete 0} {can't delete widget, no widgets in the Toolbar}}
205
                {{.tb add button item1} {}}
206
                {{.tb delete 1} {bad Toolbar widget index in delete method}}
207
                {{.tb delete 0} {}}
208
                {{.tb add button item1} {}}
209
                {{.tb delete 0 1} {bad Toolbar widget index2 in delete method}}
210
                {{.tb delete 1 4} {bad Toolbar widget index1 in delete method}}
211
                {{.tb add button item2} {}}
212
                {{.tb delete 1 0} {bad Toolbar widget index1 in delete method}}
213
                {{.tb delete 0 1} {}}
214
                {{.tb add button item1} {}}
215
                {{.tb delete 0 1 4 5 6} {wrong # args}}
216
                {{.tb delete} {wrong # args}}
217
                {{.tb delete 0} {}}
218
                {{.tb delete 0} {can't delete widget, no widgets in the Toolbar}}
219
                {{.tb insert 0 button itemA} {}}
220
                {{.tb add button item1} {}}
221
                {{.tb add button item2} {}}
222
                {{.tb insert 0 button itemAA} {}}
223
                {{.tb insert -1 button bogus} {bad toolbar entry index -1}}
224
                {{.tb delete 0 end} {}}
225
        } {
226
                set method [lindex [lindex $test 0] 1]
227
                set method_invoke [lindex $test 0]
228
                test_pattern Toolbar-5.$m "\[$method_invoke\]" {
229
                        list [catch {eval [lindex $test 0]} msg] $msg
230
                } [list 1 [lindex $test 1]]
231
        incr m
232
        }
233
 
234
#
235
# Conclusion of constrcution/destruction tests
236
#
237
test Toolbar-1.$c {Toolbar destruction} {
238
    destroy .tb
239
    update
240
} {}
241
 
242
incr c
243
 
244
test Toolbar-1.$c {Toolbar construction} {
245
    iwidgets::Toolbar .tb
246
    pack .tb
247
    update
248
    .tb add iwidgets::optionmenu opt
249
    update
250
    .tb add button b
251
    update
252
    .tb add frame filler
253
    update
254
} {}
255
 
256
incr c
257
 
258
test Toolbar-1.$c {Toolbar destruction} {
259
        destroy .tb
260
    update
261
} {}

powered by: WebSVN 2.1.0

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