blob: 7aad6b8e6dbfc1fb64d1e6cd122ce8cb4af8f48b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
# This file is a Tcl script to test the Unix specific behavior of
# labels, buttons, checkbuttons, and radiobuttons in Tk (i.e., all the
# widgets defined in tkUnixButton.c).
#
# Copyright © 1994 The Regents of the University of California.
# Copyright © 1994-1997 Sun Microsystems, Inc.
# Copyright © 1998-1999 Scriptics Corporation.
# All rights reserved.
# NOTES
#
# * This test file is specific for the unix platform. This includes macOS.
# Tests regarding buttons that are specific to the MS Windows platform
# go into the test file winButton.test. Tests that are platform-indifferent go
# into the test file button.test. Or they may exist as each other's counterparts
# in both unixButton.test and winButton.test, but only if they are an integral part
# of a contiguous sequence of tests.
# * This test file is skipped entirely on non-unix platforms.
#
#
# TESTFILE INITIALIZATION
#
package require tcltest 2.2; # needed in mode -singleproc 0
# Load the main script main.tcl, which takes care of:
# - setup for the application and the root window
# - importing commands from the tcltest namespace
# - loading of the testutils mechanism along with its utility procs
# - loading of Tk specific test constraints (additionally to constraints
# provided by the package tcltest)
source [file join [tcltest::configure -testdir] main.tcl]
# Ensure a pristine initial window state
resetWindows
# Import utility procs for specific functional areas
testutils import button image
imageInit
#
# COMMON TEST SETUP
#
# Create entries in the option database to be sure that geometry options
# like border width have predictable values.
option add *Label.borderWidth 2
option add *Label.highlightThickness 0
option add *Label.font {Helvetica -12 bold}
option add *Button.borderWidth 2
option add *Button.highlightThickness 2
option add *Button.font {Helvetica -12 bold}
option add *Checkbutton.borderWidth 2
option add *Checkbutton.highlightThickness 2
option add *Checkbutton.font {Helvetica -12 bold}
option add *Radiobutton.borderWidth 2
option add *Radiobutton.highlightThickness 2
option add *Radiobutton.font {Helvetica -12 bold}
if {[tk windowingsystem] eq "aqua"} {
set smallIndicator 20
set bigIndicator 20
set defaultBorder 10
} else {
set smallIndicator 27
set bigIndicator 40
set defaultBorder 20
}
#
# TESTS
#
test unixbutton-1.1 {TkpComputeButtonGeometry procedure} -constraints {
unix testImageType
} -setup {
deleteWindows
imageCleanup
} -body {
image create test image1
image1 changed 0 0 0 0 60 40
label .b1 -image image1 -bd 4 -padx 0 -pady 2
button .b2 -image image1 -bd 4 -padx 0 -pady 2
checkbutton .b3 -image image1 -bd 4 -padx 1 -pady 1
radiobutton .b4 -image image1 -bd 4 -padx 2 -pady 0
pack .b1 .b2 .b3 .b4
update
list [winfo reqwidth .b1] [winfo reqheight .b1] \
[winfo reqwidth .b2] [winfo reqheight .b2] \
[winfo reqwidth .b3] [winfo reqheight .b3] \
[winfo reqwidth .b4] [winfo reqheight .b4]
} -cleanup {
deleteWindows
image delete image1
} -result [list 68 48 \
74 54 \
[expr {72 + $bigIndicator}] 52 \
[expr {72 + $bigIndicator}] 52]
test unixbutton-1.2 {TkpComputeButtonGeometry procedure} -constraints {
unix
} -setup {
deleteWindows
} -body {
label .b1 -bitmap question -bd 3 -padx 0 -pady 2
button .b2 -bitmap question -bd 3 -padx 0 -pady 2
checkbutton .b3 -bitmap question -bd 3 -padx 1 -pady 1
radiobutton .b4 -bitmap question -bd 3 -padx 2 -pady 0
pack .b1 .b2 .b3 .b4
update
list [winfo reqwidth .b1] [winfo reqheight .b1] \
[winfo reqwidth .b2] [winfo reqheight .b2] \
[winfo reqwidth .b3] [winfo reqheight .b3] \
[winfo reqwidth .b4] [winfo reqheight .b4]
} -cleanup {
deleteWindows
} -result [list 23 33 \
29 39 \
[expr {27 + $smallIndicator}] 37 \
[expr {27 + $smallIndicator}] 37]
test unixbutton-1.3 {TkpComputeButtonGeometry procedure} -constraints {
unix
} -setup {
deleteWindows
} -body {
label .b1 -bitmap question -bd 3 -highlightthickness 4
button .b2 -bitmap question -bd 3 -highlightthickness 0
checkbutton .b3 -bitmap question -bd 3 -highlightthickness 1 \
-indicatoron 0
radiobutton .b4 -bitmap question -bd 3 -highlightthickness 1 \
-indicatoron false
pack .b1 .b2 .b3 .b4
update
list [winfo reqwidth .b1] [winfo reqheight .b1] \
[winfo reqwidth .b2] [winfo reqheight .b2] \
[winfo reqwidth .b3] [winfo reqheight .b3] \
[winfo reqwidth .b4] [winfo reqheight .b4]
} -cleanup {
deleteWindows
} -result {31 41 25 35 25 35 25 35}
test unixbutton-1.4 {TkpComputeButtonGeometry procedure} -constraints {
unix nonPortable fonts
} -setup {
deleteWindows
} -body {
label .b1 -text Xagqpim -padx 0 -pady 2 -font {Helvetica -18 bold}
button .b2 -text Xagqpim -padx 0 -pady 2 -font {Helvetica -18 bold}
checkbutton .b3 -text Xagqpim -padx 1 -pady 1 -font {Helvetica -18 bold}
radiobutton .b4 -text Xagqpim -padx 2 -pady 0 -font {Helvetica -18 bold}
pack .b1 .b2 .b3 .b4
update
list [winfo reqwidth .b1] [winfo reqheight .b1] \
[winfo reqwidth .b2] [winfo reqheight .b2] \
[winfo reqwidth .b3] [winfo reqheight .b3] \
[winfo reqwidth .b4] [winfo reqheight .b4]
} -cleanup {
deleteWindows
} -result {82 29 88 35 114 31 121 29}
test unixbutton-1.5 {TkpComputeButtonGeometry procedure} -constraints {
unix nonPortable fonts
} -setup {
deleteWindows
} -body {
label .l1 -text "This is a long string that will wrap around on several lines.\n\nIt also has a blank line (above)." -wraplength 1.5i -padx 0 -pady 0
pack .l1
update
list [winfo reqwidth .l1] [winfo reqheight .l1]
} -cleanup {
deleteWindows
} -result {136 88}
test unixbutton-1.6 {TkpComputeButtonGeometry procedure} -constraints {
unix nonPortable fonts
} -setup {
deleteWindows
} -body {
label .l1 -text "This is a long string without wrapping.\n\nIt also has a blank line (above)." -padx 0 -pady 0
pack .l1
update
list [winfo reqwidth .l1] [winfo reqheight .l1]
} -cleanup {
deleteWindows
} -result {231 46}
test unixbutton-1.7 {TkpComputeButtonGeometry procedure} -constraints {
unix nonPortable fonts
} -setup {
deleteWindows
} -body {
label .b1 -text Xagqpim -bd 2 -padx 0 -pady 2 -width 10
button .b2 -text Xagqpim -bd 2 -padx 0 -pady 2 -height 5
checkbutton .b3 -text Xagqpim -bd 2 -padx 1 -pady 1 -width 20 -height 2
radiobutton .b4 -text Xagqpim -bd 2 -padx 2 -pady 0 -width 4
pack .b1 .b2 .b3 .b4
update
list [winfo reqwidth .b1] [winfo reqheight .b1] \
[winfo reqwidth .b2] [winfo reqheight .b2] \
[winfo reqwidth .b3] [winfo reqheight .b3] \
[winfo reqwidth .b4] [winfo reqheight .b4]
} -cleanup {
deleteWindows
} -result {74 22 60 84 168 38 61 22}
test unixbutton-1.8 {TkpComputeButtonGeometry procedure} -constraints {
unix nonPortable fonts
} -setup {
deleteWindows
} -body {
label .b1 -text Xagqpim -bd 2 -padx 0 -pady 2 \
-highlightthickness 4
button .b2 -text Xagqpim -bd 2 -padx 0 -pady 2 \
-highlightthickness 0
checkbutton .b3 -text Xagqpim -bd 2 -padx 1 -pady 1 \
-highlightthickness 1 -indicatoron no
radiobutton .b4 -text Xagqpim -bd 2 -padx 2 -pady 0 -indicatoron 0
pack .b1 .b2 .b3 .b4
update
list [winfo reqwidth .b1] [winfo reqheight .b1] \
[winfo reqwidth .b2] [winfo reqheight .b2] \
[winfo reqwidth .b3] [winfo reqheight .b3] \
[winfo reqwidth .b4] [winfo reqheight .b4]
} -cleanup {
deleteWindows
} -result {62 30 56 24 58 22 62 22}
test unixbutton-1.9 {TkpComputeButtonGeometry procedure} -constraints {
unix
} -setup {
deleteWindows
} -body {
button .b2 -bitmap question -default active
list [winfo reqwidth .b2] [winfo reqheight .b2]
} -cleanup {
deleteWindows
} -result [list [expr {17 + $defaultBorder}] [expr {27 + $defaultBorder}]]
test unixbutton-1.10 {TkpComputeButtonGeometry procedure} -constraints {
unix
} -setup {
deleteWindows
} -body {
button .b2 -bitmap question -default normal
list [winfo reqwidth .b2] [winfo reqheight .b2]
} -cleanup {
deleteWindows
} -result [list [expr {17 + $defaultBorder}] [expr {27 + $defaultBorder}]]
test unixbutton-1.11 {TkpComputeButtonGeometry procedure} -constraints {
unix
} -setup {
deleteWindows
} -body {
button .b2 -bitmap question -default disabled
list [winfo reqwidth .b2] [winfo reqheight .b2]
} -cleanup {
deleteWindows
} -result {27 37}
test unixbutton-2.1 {disabled coloring check, bug 669595} -constraints {
unix
} -setup {
deleteWindows
catch {unset value}
} -body {
# this was just a visual bug, but at least this shows the visual
set on 1
set off 0
label .l -text "The following widgets should\
\nshow significant visible diffs\
\nfor selected vs unselected."
checkbutton .cb0 -anchor w -state disabled \
-text Unselected -variable off
checkbutton .cb1 -anchor w -state disabled \
-text Selected -variable on
checkbutton .cb2 -anchor w -state disabled \
-text Unselected -variable off -disabledforeground ""
checkbutton .cb3 -anchor w -state disabled \
-text Selected -variable on -disabledforeground ""
radiobutton .rb0 -anchor w -state disabled \
-text Unselected -variable off
radiobutton .rb1 -anchor w -state disabled \
-text Selected -variable on -value 1
radiobutton .rb2 -anchor w -state disabled \
-text Unselected -variable off -disabledforeground ""
radiobutton .rb3 -anchor w -state disabled \
-text Selected -variable on -value 1 -disabledforeground ""
pack .l .cb0 .cb1 .cb2 .cb3 .rb0 .rb1 .rb2 .rb3 -side top -fill x
after 400
set on
} -cleanup {
deleteWindows
} -result 1
#
# TESTFILE CLEANUP
#
imageFinish
testutils forget button image
cleanupTests
# Local variables:
# mode: tcl
# End:
|