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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [itcl/] [iwidgets3.0.0/] [tests/] [buttonbox.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] Buttonbox 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: buttonbox.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 Buttonbox-1.$c {Buttonbox construction} {
33
    iwidgets::Buttonbox .bb
34
    pack .bb
35
    update
36
} {}
37
 
38
incr c
39
 
40
#
41
# Button additions
42
#
43
test Buttonbox-1.$c {Buttonbox construction} {
44
    .bb add Yes -text Yes
45
    update
46
    .bb add No -text No
47
    update
48
    .bb default Yes
49
    update
50
} {}
51
 
52
incr c
53
 
54
#
55
# Option tests which are successful.
56
#
57
test Buttonbox-2.$o {configuration option} {
58
    llength [.bb configure]
59
} {14}
60
 
61
incr o
62
 
63
foreach test {
64
    {-activebackground #ececec #ececec}
65
    {-activeforeground Black Black}
66
    {-orient vertical vertical}
67
    {-background #d9d9d9 #d9d9d9}
68
    {-cursor gumby gumby}
69
    {-disabledforeground #a3a3a3 #a3a3a3}
70
    {-foreground Black Black}
71
    {-highlightcolor Black Black}
72
    {-highlightthickness 2 2}
73
    {-orient horizontal horizontal}
74
    {-padx 10 10}
75
    {-pady 10 10}} {
76
        set option [lindex $test 0]
77
        test Buttonbox-2.$o "configuration options, $option" {
78
            .bb configure $option [lindex $test 1]
79
            lindex [.bb configure $option] 4
80
        } [lindex $test 2]
81
        update
82
        incr o
83
}
84
 
85
#
86
# Option tests which fail and produce errors.
87
#
88
foreach test {
89
  {-orient bogus {bad orientation option "bogus", should be either horizontal or vertical}}} {
90
        set option [lindex $test 0]
91
        test Buttonbox-2.$o "configuration options, $option" {
92
            list [catch {.bb configure $option [lindex $test 1]} msg] $msg
93
        } [list 1 [lindex $test 2]]
94
        incr o
95
}
96
 
97
#
98
# Method tests which are successful.
99
#
100
foreach test {
101
    {{.bb index 0} {0}}
102
    {{.bb index end} {1}}
103
    {{.bb index default} {0}}
104
    {{.bb index No} {1}}
105
    {{.bb index Y*} {0}}
106
    {{.bb add Maybe -text Maybe} {}}
107
    {{.bb insert 0 Never -text Never} {}}
108
    {{.bb default Never} {}}
109
    {{.bb hide Yes} {}}
110
    {{.bb show Yes } {}}
111
    {{.bb hide end} {}}
112
    {{.bb show end} {}}
113
    {{.bb hide 1} {}}
114
    {{.bb show 1} {}}
115
    {{.bb hide N*} {}}
116
    {{.bb show N*} {}}
117
    {{.bb invoke Yes} {}}
118
    {{.bb invoke} {}}
119
    {{.bb invoke default} {}}
120
    {{.bb delete Maybe} {}}
121
    {{.bb buttonconfigure Yes -text YES} {}}
122
    {{.bb buttonconfigure N* -defaultring no} {}}
123
    {{.bb buttonconfigure end -defaultring true} {}}} {
124
        set method [lindex [lindex $test 0] 1]
125
        test Buttonbox-3.$m "object methods, $method" {
126
            list [catch {eval [lindex $test 0]} msg] $msg
127
        } [list 0 [lindex $test 1]]
128
        update
129
        incr m
130
}
131
 
132
#
133
# Method tests which fail and produce errors
134
#
135
foreach test {
136
    {{.bb index 12} {Buttonbox index "12" is out of range}}
137
    {{.bb index bogus} {bad Buttonbox index "bogus": must be number, end, default, or pattern}}} {
138
        set method [lindex [lindex $test 0] 1]
139
        test Buttonbox-3.$m "object methods, $method" {
140
            list [catch {eval [lindex $test 0]} msg] $msg
141
        } [list 1 [lindex $test 1]]
142
        incr m
143
}
144
 
145
#
146
# Conclusion of constrcution/destruction tests
147
#
148
test Buttonbox-1.$c {Buttonbox destruction} {
149
    destroy .bb
150
    update
151
} {}
152
 
153
incr c
154
 
155
test Buttonbox-1.$c {Buttonbox construction} {
156
    iwidgets::buttonbox .bb
157
    pack .bb
158
    update
159
    .bb add Hello -text Hello
160
    update
161
    .bb insert end GoodBye -text GoodBye
162
    update
163
    .bb default Hello
164
    update
165
    .bb default GoodBye
166
    update
167
} {}
168
 
169
incr c
170
 
171
test Buttonbox-1.$c {Buttonbox destruction} {
172
    destroy .bb
173
    update
174
} {}
175
 
176
incr c
177
 
178
test Buttonbox-1.$c {Buttonbox destruction} {
179
    iwidgets::buttonbox .bb
180
    pack .bb
181
    destroy .bb
182
    update
183
} {}

powered by: WebSVN 2.1.0

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