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/] [hierarchy.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] Hierarchy 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: hierarchy.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
set cdir [pwd]
30
 
31
#
32
# Initial construction test
33
#
34
test Hierarchy-1.$c {Hierarchy construction} {
35
    iwidgets::Hierarchy .h
36
    pack .h -padx 10 -pady 10 -fill both -expand yes
37
    update
38
 
39
    image create bitmap testicon -data {
40
        #define node.xbm_width 16
41
        #define node.xbm_height 16
42
        static unsigned char node.xbm_bits[] = {
43
           0x00, 0x00, 0x00, 0x00, 0xfe, 0x7f, 0x02, 0x40,
44
           0xfa, 0x5f, 0xfa, 0x5f, 0x82, 0x41, 0x82, 0x41,
45
           0x82, 0x41, 0x82, 0x41, 0x82, 0x41, 0x02, 0x40,
46
           0xfe, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
47
    }
48
 
49
    set homelist [lsort [glob -nocomplain $env(HOME)/*]]
50
 
51
    proc get_files {file} {
52
        global env
53
 
54
        if {$file == ""} {
55
            set dir $env(HOME)
56
        } else {
57
            set dir $file
58
        }
59
 
60
        if {[catch {cd $dir}] != 0} {
61
            return ""
62
        }
63
 
64
        set rlist ""
65
 
66
        foreach file [lsort [glob -nocomplain *]] {
67
            lappend rlist [list [file join $dir $file] $file]
68
        }
69
 
70
        return $rlist
71
    }
72
} {}
73
 
74
incr c
75
 
76
#
77
# Option tests which are successful.
78
#
79
test Hierarchy-2.$o {configuration option} {
80
    llength [.h configure]
81
} {51}
82
 
83
incr o
84
 
85
foreach test {
86
    {-activebackground #ececec #ececec}
87
    {-activeforeground Black Black}
88
    {-activerelief raised raised}
89
    {-alwaysquery 0 0}
90
    {-background #d9d9d9 #d9d9d9}
91
    {-borderwidth 2 2}
92
    {-cursor gumby gumby}
93
    {-disabledforeground #a3a3a3 #a3a3a3}
94
    {-elementborderwidth -1 -1}
95
    {-foreground Black Black}
96
    {-height 300 300}
97
    {-width 400 400}
98
    {-highlightcolor Black Black}
99
    {-highlightthickness 2 2}
100
    {-hscrollmode none none}
101
    {-hscrollmode static static}
102
    {-hscrollmode dynamic dynamic}
103
    {-jump 0 0}
104
    {-textbackground GhostWhite GhostWhite}
105
    {-labelmargin 5 5}
106
    {-labeltext Label Label}
107
    {-labelpos nw nw}
108
    {-labelpos ne ne}
109
    {-labelpos en en}
110
    {-labelpos e e}
111
    {-labelpos es es}
112
    {-labelpos se se}
113
    {-labelpos s s}
114
    {-labelpos sw sw}
115
    {-labelpos wn wn}
116
    {-labelpos w w}
117
    {-labelpos ws ws}
118
    {-labelpos n n}
119
    {-markbackground #a0a0a0 #a0a0a0}
120
    {-markforeground Black Black}
121
    {-menucursor gumby gumby}
122
    {-relief raised raised}
123
    {-relief sunken sunken}
124
    {-vscrollmode none none}
125
    {-vscrollmode static static}
126
    {-vscrollmode dynamic dynamic}
127
    {-sbwidth 20 20}
128
    {-scrollmargin 5 5}
129
    {-textbackground #d9d9d9 #d9d9d9}
130
    {-visibleitems 40x20 40x20}
131
    {-height 0 0}
132
    {-width 0 0}
133
    {-selectbackground #c3c3c3 #c3c3c3}
134
    {-selectcolor #b03060 #b03060}
135
    {-selectforeground Black Black}
136
    {-spacing1 0 0}
137
    {-spacing2 0 0}
138
    {-spacing3 0 0}
139
    {-closedicon testicon testicon}
140
    {-nodeicon testicon testicon}
141
    {-openicon testicon testicon}
142
    {-querycommand {get_files %n} {get_files %n}}
143
    {-closedicon closedFolder closedFolder}
144
    {-nodeicon nodeFolder nodeFolder}
145
    {-openicon openFolder openFolder}
146
    {-querycommand {get_files %n} {get_files %n}}
147
    {-expanded 0 0}
148
    {-filter 0 0}
149
    {-iconcommand {} {}}
150
    {-selectcommand {} {}}} {
151
        set option [lindex $test 0]
152
        test Hierarchy-2.$o "configuration options, $option" {
153
            .h configure $option [lindex $test 1]
154
            lindex [.h configure $option] 4
155
        } [lindex $test 2]
156
        update
157
        incr o
158
}
159
 
160
#
161
# Option tests which fail and produce errors.
162
#
163
foreach test {
164
  {-filter bogus {bad filter option "bogus": should be boolean}}
165
  {-expanded bogus {bad expanded option "bogus": should be boolean}}
166
  {-openicon bogus {bad openicon option "bogus": should be an existing image}}
167
  {-closedicon bogus {bad closedicon option "bogus": should be an existing image}}
168
  {-nodeicon bogus {bad nodeicon option "bogus": should be an existing image}}
169
  {-visibleitems bogus {bad visibleitems option "bogus": should be widthxheight}}
170
  {-hscrollmode bogus {bad hscrollmode option "bogus": should be static, dynamic, or none}}
171
  {-vscrollmode bogus {bad vscrollmode option "bogus": should be static, dynamic, or none}}} {
172
        set option [lindex $test 0]
173
        test Hierarchy-2.$o "configuration options, $option" {
174
            list [catch {.h configure $option [lindex $test 1]} msg] $msg
175
        } [list 1 [lindex $test 2]]
176
        incr o
177
}
178
 
179
#
180
# Addtional test for selection/mark get
181
#
182
test Hierarchy-1.$m {Hierarchy selection/mark get} {
183
    .h draw -now
184
    .h selection clear
185
    eval .h selection add $homelist
186
    update
187
    if {[lsort [.h selection get]] != [lsort $homelist]} {
188
        error "selection isn't right"
189
    }
190
    .h selection clear
191
    update
192
 
193
    .h mark clear
194
    eval .h mark add $homelist
195
    update
196
    if {[lsort [.h mark get]] != [lsort $homelist]} {
197
        error "mark isn't right"
198
    }
199
    update
200
    .h mark clear
201
} {}
202
incr m
203
 
204
#
205
# Method tests which are successful.
206
#
207
foreach test {
208
    {{eval .h selection add $homelist} {}}
209
    {{eval .h selection remove $homelist} {}}
210
    {{.h selection clear} {}}
211
    {{eval .h mark add $homelist} {}}
212
    {{eval .h mark remove $homelist} {}}
213
    {{.h mark clear} {}}
214
    {{.h current} {}}
215
    {{.h expand [lindex $homelist 0]} {}}
216
    {{.h collapse [lindex $homelist 0]} {}}
217
    {{.h toggle [lindex $homelist 0]} {}}
218
    {{.h refresh [lindex $homelist 0]} {}}
219
    {{.h prune [lindex $homelist 0]} {}}
220
    {{.h draw -now} {}}
221
    {{.h draw -eventually} {}}
222
    {{.h clear} {}}} {
223
        set method [lindex [lindex $test 0] 1]
224
        test Hierarchy-3.$m "object methods, $method" {
225
            list [catch {eval [lindex $test 0]} msg] $msg
226
        } [list 0 [lindex $test 1]]
227
        update
228
        incr m
229
}
230
 
231
#
232
# Method tests which fail and produce errors
233
#
234
foreach test {
235
    {{.h expand bogus} {bad expand node argument: "bogus", the node doesn't exist}}
236
    {{.h collapse bogus} {bad collapse node argument: "bogus", the node doesn't exist}}
237
    {{.h toggle bogus} {bad toggle node argument: "bogus", the node doesn't exist}}
238
    {{.h draw bogus} {bad when option "bogus": should be -eventually or -now}}
239
    {{.h mark bogus} {bad mark operation "bogus": should be add, remove, clear or get}}
240
    {{.h selection bogus} {bad selection operation "bogus": should be add, remove, clear or get}}} {
241
        set method [lindex [lindex $test 0] 1]
242
        test Hierarchy-3.$m "object methods, $method" {
243
            list [catch {eval [lindex $test 0]} msg] $msg
244
        } [list 1 [lindex $test 1]]
245
        incr m
246
}
247
 
248
#
249
# Conclusion of constrcution/destruction tests
250
#
251
test Hierarchy-1.$c {Hierarchy destruction} {
252
    destroy .h
253
    update
254
} {}
255
 
256
incr c
257
 
258
test Hierarchy-1.$c {Hierarchy construction} {
259
    iwidgets::hierarchy .h -hscrollmode dynamic -labeltext "Label" \
260
            -labelpos n -labelmargin 5
261
    pack .h -padx 10 -pady 10 -fill both -expand yes
262
    update
263
} {}
264
 
265
incr c
266
 
267
test Hierarchy-1.$c {Hierarchy destruction} {
268
    destroy .h
269
    update
270
} {}
271
 
272
incr c
273
 
274
test Hierarchy-1.$c {Hierarchy destruction} {
275
    iwidgets::hierarchy .h
276
    pack .h
277
    destroy .h
278
    update
279
} {}
280
 
281
cd $cdir

powered by: WebSVN 2.1.0

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