summaryrefslogtreecommitdiffstats
path: root/tk8.6/tests/geometry.test
blob: 13cc51559ae169b8c78842db2cd2de7994736653 (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
# This file is a Tcl script to test the procedures in the file
# tkGeometry.c (generic support for geometry managers).  It is
# organized in the standard fashion for Tcl tests.
#
# Copyright (c) 1994 The Regents of the University of California.
# Copyright (c) 1994 Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.

proc getsize w {
    regexp {(^[^+-]*)} [wm geometry $w] foo x
    return $x
}

package require tcltest 2.2
eval tcltest::configure $argv
tcltest::loadTestedCommands
namespace import -force tcltest::test


wm geometry . 300x300
raise .
update

frame .f -bd 2 -relief raised
frame .f.f -bd 2 -relief sunken
frame .f.f.f -bd 2 -relief raised
button .b1 -text .b1
button .b2 -text .b2
button .b3 -text .b3
button .f.f.b4 -text .b4

test geometry-1.1 {Tk_ManageGeometry procedure} -setup {
	foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
        place forget $w
    }
} -body {
    place .b1 -x 120 -y 80
    update
    list [winfo x .b1] [winfo y .b1]
} -result {120 80}
test geometry-1.2 {Tk_ManageGeometry procedure} -setup {
	foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
        place forget $w
    }
} -body {
    place .f -x 20 -y 30 -width 200 -height 200
    place .b1 -in .f -x 40 -y 30
    update
    pack .b1 -side top -anchor w
    place .f -x 30 -y 40
    update
    list [winfo x .b1] [winfo y .b1]
} -result {0 0}


test geometry-2.1 {Tk_GeometryRequest procedure} -setup {
	foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
        place forget $w
    }
    destroy .f2
} -body {
    frame .f2
    set result [list [winfo reqwidth .f2] [winfo reqheight .f2]]
    .f2 configure -width 150 -height 300
    update
    lappend result [winfo reqwidth .f2] [winfo reqheight .f2] \
        [winfo geom .f2]
    place .f2 -x 10 -y 20
    update
    lappend result [winfo geom .f2]
    .f2 configure -width 100 -height 80
    update
    lappend result [winfo geom .f2]
} -cleanup {
    destroy .f2
} -result {1 1 150 300 1x1+0+0 150x300+10+20 100x80+10+20}


test geometry-3.1 {Tk_SetInternalBorder procedure} -setup {
	foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
        place forget $w
    }
} -body {
    place .f -x 20 -y 30 -width 200 -height 200
    place .b1 -in .f -x 50 -y 5
    update
    set x [list [winfo x .b1] [winfo y .b1]]
    .f configure -bd 5
    update
    lappend x [winfo x .b1] [winfo y .b1]
} -cleanup {
    .f configure -bd 2
} -result {72 37 75 40}


test geometry-4.1 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
	foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
        place forget $w
    }
} -body {
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .b1 -in .f.f.f -x 50 -y 5
    update
    list [winfo x .b1] [winfo y .b1]
} -result {91 46}
test geometry-4.2 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
	foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
        place forget $w
    }
} -body {
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .b1 -in .f.f.f -x 50 -y 5
    place .b2 -in .f.f.f -x 10 -y 25
    place .b3 -in .f.f.f -x 50 -y 25
    update
    place .f -x 30 -y 25
    update
    list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \
        [winfo x .b3] [winfo y .b3]
} -result {101 41 61 61 101 61}
test geometry-4.3 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
	foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
        place forget $w
    }
} -body {
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .b1 -in .f.f.f -x 50 -y 5
    place .b2 -in .f.f.f -x 10 -y 25
    place .b3 -in .f.f.f -x 50 -y 25
    update
    destroy .b1
    button .b1 -text .b1
    place .f.f -x 10 -y 25
    update
    list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \
        [winfo x .b3] [winfo y .b3]
} -result {0 0 46 86 86 86}
test geometry-4.4 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
	foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
        place forget $w
    }
} -body {
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .b1 -in .f.f.f -x 50 -y 5
    place .b2 -in .f.f.f -x 10 -y 25
    place .b3 -in .f.f.f -x 50 -y 25
    update
    destroy .b2
    button .b2 -text .b2
    place .f.f.f -x 2 -y 3
    update
    list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \
        [winfo x .b3] [winfo y .b3]
} -result {93 49 0 0 93 69}
test geometry-4.5 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
	foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
        place forget $w
    }
} -body {
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .b1 -in .f.f.f -x 50 -y 5
    place .b2 -in .f.f.f -x 10 -y 25
    place .b3 -in .f.f.f -x 50 -y 25
    update
    destroy .b3
    button .b3 -text .b3
    place .f.f.f -x 2 -y 3
    update
    list [winfo x .b1] [winfo y .b1] [winfo x .b2] [winfo y .b2] \
        [winfo x .b3] [winfo y .b3]
} -result {93 49 53 69 0 0}
test geometry-4.6 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
	foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
        place forget $w
    }
} -body {
    foreach w {.f .f.f .f.f.f .b1 .b2 .b3 .f.f.b4} {
    place forget $w
    }
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .f.f.b4 -in .f.f.f -x 50 -y 5
    place .b2 -in .f.f.f -x 10 -y 25
    update
    place .f -x 25 -y 35
    update
    list [winfo x .f.f.b4] [winfo y .f.f.b4] [winfo x .b2] [winfo y .b2]
} -result {54 9 56 71}
test geometry-4.7 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
	foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
        place forget $w
    }
} -body {
    bind .b1 <Configure> {lappend x configure}
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .f.f.b4 -in .f.f.f -x 50 -y 5
    place .b1 -in .f.f.f -x 10 -y 25
    update
    set x init
    place .f -x 25 -y 35
    update
    lappend x |
    place .f -x 30 -y 40
    place .f.f -x 10 -y 0
    update
    return $x
} -cleanup {
    bind .b1 <Configure> {}
} -result {init configure |}
test geometry-4.8 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
	foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
        place forget $w
    }
} -body {
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .b1 -in .f.f.f -x 50 -y 5
    place .b2 -in .f.f.f -x 10 -y 25
    place .b3 -in .f.f.f -x 50 -y 25
    update
    destroy .f.f
    frame .f.f -bd 2 -relief raised
    frame .f.f.f -bd 2 -relief raised
    place .f -x 30 -y 25
    update
    list [winfo x .b1] [winfo y .b1] [winfo ismapped .b1] \
        [winfo x .b2] [winfo y .b2] [winfo ismapped .b2] \
        [winfo x .b3] [winfo y .b3] [winfo ismapped .b3]
} -result {91 46 0 51 66 0 91 66 0}
test geometry-4.9 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
	foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
        place forget $w
    }
} -body {
    place .f -x 20 -y 30 -width 200 -height 200
    place .f.f -x 15 -y 5 -width 150 -height 120
    place .f.f.f -width 100 -height 80
    place .b1 -in .f.f.f -x 50 -y 5
    update
    set result [winfo ismapped .b1]
    place forget .f.f
    update
    lappend result [winfo ismapped .b1]
    place .f.f -x 15 -y 5 -width 150 -height 120
    update
    lappend result [winfo ismapped .b1]
} -result {1 0 1}
test geometry-4.10 {Tk_MaintainGeometry and Tk_UnmaintainGeometry} -setup {
	foreach w {.f .f.f .f.f.f .b1 .b2 .b3} {
        place forget $w
    }
    destroy .t
} -body {
    toplevel .t
    wm geometry .t +0+0
    tkwait visibility .t
    update
    pack [frame .t.f] 
    button .t.quit -text Quit -command exit
    pack .t.quit -in .t.f
    wm iconify .t
    set x 0
    after 500 {set x 1}
    tkwait variable x
    wm deiconify .t
    update
    winfo ismapped .t.quit
} -cleanup {
    destroy .t
} -result {1}


# cleanup
cleanupTests
return