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

powered by: WebSVN 2.1.0

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