OSDN Git Service

16d1faecb781311391d9f151ce4b65d23c133764
[pf3gnuchains/pf3gnuchains3x.git] / itcl / iwidgets / tests / labeledframe.test
1 # This file is a Tcl script to test out [incr Widgets] Labeledframe 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$
15
16 package require tcltest
17 namespace import -force ::tcltest::*
18
19 if [catch {package require Iwidgets 4.0}] {
20   # Let's try modifying the auto_path.  Note that the IWIDGETS_LIBRARY
21   # env var is initialized in the Makefile when doing a 'make test'.
22   # If sourcing this file independently, this variable must be set manually.
23   if ![info exists env(IWIDGETS_LIBRARY)] {
24     error "Unable to locate Iwidgets package.  Set your IWIDGETS_LIBRARY\
25       environment\nvariable to the directory that contains iwidgets.tcl"
26   }
27   lappend auto_path $env(IWIDGETS_LIBRARY)
28   package require Iwidgets 4.0
29 }
30
31 if {[string compare test [info procs test]] == 1} {
32     source defs
33 }
34
35 wm geometry . {}
36 raise .
37
38 set c 1
39 set o 1
40 set m 1
41
42 #
43 # Initial construction test
44 #
45 test Labeledframe-1.$c {Labeledframe construction} {
46     iwidgets::Labeledframe .lf
47     set cs [.lf childsite]
48     .lf configure -background yellow
49     pack [radiobutton $cs.w1 -anchor w -text "Button1"] -anchor w -fill x
50     pack [radiobutton $cs.w2 -anchor w -text "Button2"] -anchor w -fill x
51     pack [radiobutton $cs.w3 -anchor w -text "Button3"] -anchor w -fill x
52     pack [radiobutton $cs.w4 -anchor w -text "Button4"] -anchor w -fill x
53     pack [radiobutton $cs.w5 -anchor w -text "Button5"] -anchor w -fill x
54     pack [radiobutton $cs.w6 -anchor w -text "Button6"] -anchor w -fill x
55     pack [radiobutton $cs.w7 -anchor w -text "Button7"] -anchor w -fill x
56     pack [radiobutton $cs.w8 -anchor w -text "Button8"] -anchor w -fill x
57
58     pack .lf -fill both -expand yes
59     update 
60 } {}
61
62 incr c
63
64 #
65 # Option tests which are successful.
66 #
67 test Labeledframe-2.$o {configuration option} {
68     llength [.lf configure]
69 } {15}
70
71 incr o
72
73 foreach test {
74     {-labeltext "Label" "Label"}
75     {-labelpos nw nw}
76     {-labelpos n n}
77     {-labelpos ne ne}
78     {-labelpos en en}
79     {-labelpos e e}
80     {-labelpos es es}
81     {-labelpos sw sw}
82     {-labelpos s s}
83     {-labelpos se se}
84     {-labelpos wn wn}
85     {-labelpos w w}
86     {-labelpos ws ws}
87     {-labelfont 6x13 6x13}
88     {-labelpos nw nw}
89     {-labelpos n n}
90     {-labelpos ne ne}
91     {-labelpos en en}
92     {-labelpos e e}
93     {-labelpos es es}
94     {-labelpos sw sw}
95     {-labelpos s s}
96     {-labelpos se se}
97     {-labelpos wn wn}
98     {-labelpos w w}
99     {-labelpos ws ws}
100     {-relief groove groove}
101     {-relief sunken sunken}
102     {-relief raised raised}
103     {-relief ridge  ridge}
104     {-relief flat   flat}
105     {-borderwidth 2 2}
106     {-borderwidth 4 4}
107     {-borderwidth 6 6}
108     {-borderwidth 8 8}
109     {-borderwidth 10 10}
110     {-ipadx 20 20}
111     {-ipady 20 20}
112     {-ipadx 10 10}
113     {-ipady 10 10}
114     {-ipadx 0 0}
115     {-ipady 0 0}
116     } {
117         set option [lindex $test 0]
118         test Labeledframe-1.$o "configuration options, $option" {
119             .lf configure $option [lindex $test 1]
120             lindex [.lf configure $option] 4
121         } [lindex $test 2]
122         update 
123         incr o
124     }
125
126 #
127 # Method tests which are successful.
128 #
129 test Labeledframe-3.$m {object method, childsite} {
130     list [catch {.lf childsite} msg] $msg
131 } [list 0 .lf.childsite]
132
133 incr m
134
135 test Labeledframe-3.$m {object static method, initTable} {
136
137 } {}
138
139 incr m
140
141 #
142 # Method tests which fail and produce errors
143 #
144 test Labeledframe-3.$m {initTable static method} {
145     button .b
146
147 } {.b}
148
149 incr m
150
151 test Labeledframe-1.$c {Labeledframe destruction} {
152     destroy .b
153     destroy .lf
154     update 
155 } {}
156
157 incr c
158
159 test Labeledframe-1.$c {Labeledframe construction} {
160     iwidgets::labeledframe .lf -labeltext "ListBox" -labelpos s
161     set cs [.lf childsite]
162     .lf configure -background yellow
163     pack [radiobutton $cs.w1 -anchor w -text "Button1"] -anchor w -fill x
164     pack [radiobutton $cs.w2 -anchor w -text "Button2"] -anchor w -fill x
165     pack [radiobutton $cs.w3 -anchor w -text "Button3"] -anchor w -fill x
166     pack [radiobutton $cs.w4 -anchor w -text "Button4"] -anchor w -fill x
167     pack [radiobutton $cs.w5 -anchor w -text "Button5"] -anchor w -fill x
168     pack [radiobutton $cs.w6 -anchor w -text "Button6"] -anchor w -fill x
169     pack [radiobutton $cs.w7 -anchor w -text "Button7"] -anchor w -fill x
170     pack [radiobutton $cs.w8 -anchor w -text "Button8"] -anchor w -fill x
171     pack .lf -fill both -expand yes
172     update 
173 } {}
174
175 incr c
176
177 test Labeledframe-1.$c {Labeledframe destruction} {
178     destroy .lf
179     update 
180 } {}
181
182 incr c
183
184 test Labeledframe-1.$c {Labeledframe construction} {
185     iwidgets::labeledframe .lf 
186     pack .lf 
187     destroy .lf
188     update 
189 } {}
190
191
192
193 ::tcltest::cleanupTests
194 exit