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/] [tabnotebook.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] Tabnotebook 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: tabnotebook.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 Tabnotebook-1.$c {Tabnotebook construction} {
33
    iwidgets::Tabnotebook .tn
34
    pack .tn
35
    update
36
    .tn add -label one
37
    update
38
    .tn add -label two
39
    update
40
    .tn add -label three
41
    update
42
} {}
43
 
44
incr c
45
 
46
#
47
# Option tests which are successful.
48
#
49
test Tabnotebook-2.$o {configuration option} {
50
    llength [.tn configure]
51
} {26}
52
 
53
incr o
54
 
55
foreach test {
56
        {-disabledforeground #a3a3a3 #a3a3a3 }
57
        {-start 4 4 }
58
        {-backdrop #d9d9d9 #d9d9d9 }
59
        {-borderwidth 2 2 }
60
        {-scrollcommand   }
61
        {-font -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* -Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-* }
62
        {-gap overlap overlap }
63
        {-background #CDCDB7B7B5B5 #CDCDB7B7B5B5 }
64
        {-state normal normal }
65
        {-bevelamount 0 0 }
66
        {-equaltabs true true }
67
        {-foreground #000000000000 #000000000000 }
68
        {-raiseselect false false }
69
        {-padx 4 4 }
70
        {-pady 4 4 }
71
        {-margin 4 4 }
72
        {-cursor   }
73
        {-angle 15 15 }
74
        {-tabbackground #d9d9d9 #d9d9d9 }
75
        {-tabborders true true }
76
        {-width 300 300 }
77
        {-tabpos s s }
78
        {-auto true true }
79
        {-height 150 150 }
80
        {-tabforeground Black Black }
81
        } {
82
        set option [lindex $test 0]
83
        test Tabnotebook-2.$o "configuration options, $option" {
84
            .tn configure $option [lindex $test 1]
85
                lindex [.tn configure $option] 4
86
        } [lindex $test 2]
87
        update
88
        incr o
89
}
90
 
91
#
92
# PageConfigure Option tests which are successful.
93
#
94
test Tabnotebook-2.$o {page configuration option} {
95
    llength [.tn pageconfigure 0]
96
} {30}
97
 
98
# do pageconfigure tests also...
99
foreach test {
100
                {0 -label Hello Hello}
101
                {end -label "Hello World" "Hello World"}
102
        } {
103
                set index  [lindex $test 0]
104
                set option [lindex $test 1]
105
                test Tabnotebook-2.$o "configuration options, $option" {
106
                        .tn pageconfigure $index $option [lindex $test 2]
107
                        lindex [.tn pageconfigure $index $option] 4
108
                } [lindex $test 3]
109
        update
110
        incr o
111
}
112
 
113
#
114
# Option tests which fail and produce errors.
115
#
116
#foreach test {
117
#       { -OPTION BADVALUE {ERROR_MESSAGE} }
118
#       } {
119
#       set option [lindex $test 0]
120
#        test Tabnotebook-2.$o "configuration options, $option" {
121
#           list [catch {.bb configure $option [lindex $test 1]} msg] $msg
122
#       } [list 1 [lindex $test 2]]
123
#       incr o
124
#}
125
 
126
#
127
# Method tests which are successful.
128
#
129
foreach test {
130
    {{.tn add}
131
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
132
    {{.tn add}
133
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
134
    {{.tn add}
135
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
136
    {{.tn add -label Never}
137
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
138
    {{.tn add}
139
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
140
        {{.tn add -label "Hello World" -disabledforeground gray}
141
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
142
    {{.tn childsite Never}
143
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
144
    {{.tn childsite 0}
145
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
146
    {{.tn childsite end}
147
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
148
    {{.tn index end}
149
                {[0-9]+}}
150
    {{.tn index Never}
151
                {[0-9]+}}
152
    {{.tn index 0}
153
                {0}}
154
    {{.tn select 0}
155
                {0}}
156
    {{.tn select select}
157
                {}}
158
    {{.tn select end}
159
                {[0-9]+}}
160
    {{.tn select "Hello World"}
161
                {[0-9]+}}
162
    {{.tn insert 0}
163
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
164
    {{.tn insert select -label "An Insert"}
165
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
166
    {{.tn insert end -label "Next To Last"}
167
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
168
    {{.tn select 0}
169
                {0}}
170
    {{.tn next}
171
                {1}}
172
    {{.tn next}
173
                {2}}
174
    {{.tn prev}
175
                {1}}
176
    {{.tn prev}
177
                {0}}
178
    {{.tn delete Never}
179
                {}}
180
    {{.tn delete 1 2}
181
                {}}
182
    {{.tn delete 0 "Hello World"}
183
                {}}
184
    {{.tn add}
185
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
186
    {{.tn add}
187
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
188
    {{.tn add}
189
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
190
    {{.tn add}
191
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
192
    {{.tn delete 0 end}
193
                {}}
194
    {{.tn add}
195
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
196
    {{.tn add}
197
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
198
    {{.tn add}
199
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
200
    {{.tn add}
201
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
202
    {{.tn select 2}
203
                {[-]*[0-9]+}}
204
    {{.tn delete select end}
205
                {}}
206
    {{.tn delete 0 end}
207
                {}}
208
    {{.tn add -label "First Page"}
209
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
210
    {{.tn add -label "Second Page"}
211
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
212
    {{.tn add -label "Third Page"}
213
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
214
    {{.tn add -label "Fourth Page"}
215
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
216
    {{.tn add -label "Fifth Page"}
217
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
218
    {{.tn add -label "Sixth Page"}
219
                {[.]tn[.]canvas[.]notebook[.]cs[.]page[0-9]+[.]cs}}
220
    {{.tn select "First Page"}
221
                {[-]*[0-9]+}}
222
    {{.tn delete select "Second Page"}
223
                {}}
224
    {{.tn delete "Third Page" 1}
225
                {}}
226
    {{.tn delete "Fifth Page" "Sixth Page"}
227
                {}}
228
        } {
229
        set method [lindex [lindex $test 0] 1]
230
        set method_invoke [lindex $test 0]
231
        test_pattern Tabnotebook-3.$m "\[$method_invoke\]" {
232
            list [catch {eval [lindex $test 0]} msg] $msg
233
        } [list 0 [lindex $test 1]]
234
        update
235
        incr m
236
}
237
 
238
#
239
# Method tests which fail and produce errors
240
#
241
foreach test {
242
                {{.tn delete 0 end} {}}
243
                {{.tn childsite 0} {can't get childsite, no pages}}
244
                {{.tn add} {}}
245
                {{.tn childsite 1} {bad Notebook page index in childsite method}}
246
                {{.tn childsite -1} {bad Notebook page index in childsite method}}
247
                {{.tn delete 0} {}}
248
                {{.tn delete 0} {can't delete page, no pages}}
249
                {{.tn add} {}}
250
                {{.tn delete 1} {bad Notebook page index in delete method:}}
251
                {{.tn delete select} {bad Notebook page index in delete method:}}
252
                {{.tn delete 0} {}}
253
                {{.tn add} {}}
254
                {{.tn delete 0 1} {bad Notebook page index2 in delete method:}}
255
                {{.tn delete 1 4} {bad Notebook page index1 in delete method:}}
256
                {{.tn add} {}}
257
                {{.tn delete 1 0} {bad Notebook page index1 in delete method: index1 is greater than index2}}
258
                {{.tn delete 0 1} {}}
259
                {{.tn add} {}}
260
                {{.tn delete 0 1 4 5 6} {wrong # args}}
261
                {{.tn delete} {wrong # args}}
262
                {{.tn delete 0} {}}
263
                {{.tn delete 0} {can't delete page}}
264
                {{.tn delete select} {can't delete page}}
265
                {{.tn insert 0} {can't insert page}}
266
                {{.tn add} {}}
267
                {{.tn add} {}}
268
                {{.tn insert 2} {bad Notebook page index in insert method:}}
269
                {{.tn insert -1} {bad Notebook page index}}
270
                {{.tn delete 0 end} {}}
271
                {{.tn next} {can't move to next page, no pages in the notebook}}
272
                {{.tn prev} {can't move to previous page, no pages in the notebook}}
273
                {{.tn select 0} {can't select page}}
274
                {{.tn add} {}}
275
                {{.tn select 1} {bad Notebook page index in select method:}}
276
                {{.tn delete 0} {}}
277
        } {
278
                set method [lindex [lindex $test 0] 1]
279
                set method_invoke [lindex $test 0]
280
                test_pattern Tabnotebook-3.$m "\[$method_invoke\]" {
281
                        list [catch {eval [lindex $test 0]} msg] $msg
282
                } [list 1 [lindex $test 1]]
283
        incr m
284
        }
285
 
286
 
287
# Conclusion of constrcution/destruction tests
288
#
289
test Tabnotebook-1.$c {Tabnotebook destruction} {
290
    destroy .tn
291
    update
292
} {}
293
 
294
incr c
295
 
296
test Tabnotebook-1.$c {Tabnotebook construction} {
297
    iwidgets::Tabnotebook .tn -width 100 -height 100
298
    pack .tn
299
    update
300
    .tn add -label one
301
    update
302
    .tn add -label two
303
    update
304
    .tn add -label three
305
    update
306
} {}
307
 
308
incr c
309
 
310
test Tabnotebook-1.$c {Tabnotebook destruction} {
311
        destroy .tn
312
    update
313
} {}

powered by: WebSVN 2.1.0

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