summaryrefslogtreecommitdiffstats
path: root/tests/winWm.test
blob: a9c014f0fe8ba6150bfc45082cfe8e1ff2b2d55c (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
# This file tests  is a Tcl script to test the procedures in the file
# tkWinWm.c.  It is organized in the standard fashion for Tcl tests.
#
# This file contains a collection of tests for one or more of the Tcl
# built-in commands.  Sourcing this file into Tcl runs the tests and
# generates output for errors.  No output means no errors were found.
#
# Copyright (c) 1996 by Sun Microsystems, Inc.
# Copyright (c) 1998-1999 by Scriptics Corporation.
# All rights reserved.
#
# RCS: @(#) $Id: winWm.test,v 1.9.2.1 2004/09/17 22:45:07 hobbs Exp $

package require tcltest 2.1
namespace import -force tcltest::configure
namespace import -force tcltest::testsDirectory
configure -testdir [file join [pwd] [file dirname [info script]]]
configure -loadfile [file join [testsDirectory] constraints.tcl]
tcltest::loadTestedCommands

# Measure the height of a single menu line

toplevel .t
frame .t.f -width 100 -height 50
pack .t.f
menu .t.m
.t.m add command -label "thisisreallylong"
.t conf -menu .t.m
wm geom .t -0-0
update
set menuheight [winfo y .t]
.t.m add command -label "thisisreallylong"
wm geom .t -0-0
update
set menuheight [expr $menuheight - [winfo y .t]]
destroy .t

test winWm-1.1 {TkWmMapWindow} {pcOnly} {
    toplevel .t
    wm override .t 1
    wm geometry .t +0+0
    update
    set result [list [winfo rootx .t] [winfo rooty .t]]
    destroy .t
    set result
} {0 0}
test winWm-1.2 {TkWmMapWindow} {pcOnly} {
    toplevel .t
    wm transient .t .
    update
    wm iconify .
    update
    wm deiconify .
    update
    catch {wm iconify .t} msg
    destroy .t
    set msg
} {can't iconify ".t": it is a transient}
test winWm-1.3 {TkWmMapWindow} {pcOnly} {
    toplevel .t
    update
    toplevel .t2
    update
    set result [expr [winfo x .t] != [winfo x .t2]]
    destroy .t .t2
    set result
} 1
test winWm-1.4 {TkWmMapWindow} {pcOnly} {
    toplevel .t
    wm geometry .t +10+10
    update
    toplevel .t2
    wm geometry .t2 +40+10
    update
    set result [list [winfo x .t] [winfo x .t2]]
    destroy .t .t2
    set result
} {10 40}
test winWm-1.5 {TkWmMapWindow} {pcOnly} {
    toplevel .t
    wm iconify .t
    update
    set result [wm state .t]
    destroy .t
    set result
} iconic

test winWm-2.1 {TkpWmSetState} {pcOnly} {
    toplevel .t
    wm geometry .t 150x50+10+10
    update
    set result [wm state .t]
    wm iconify .t
    update
    lappend result [wm state .t]
    wm deiconify .t
    update
    lappend result [wm state .t]
    destroy .t
    set result
} {normal iconic normal}
test winWm-2.2 {TkpWmSetState} {pcOnly} {
    toplevel .t
    wm geometry .t 150x50+10+10
    update
    set result [wm state .t]
    wm withdraw .t
    update
    lappend result [wm state .t]
    wm iconify .t
    update
    lappend result [wm state .t]
    wm deiconify .t
    update 
    lappend result [wm state .t]
    destroy .t
    set result
} {normal withdrawn iconic normal}
test winWm-2.2 {TkpWmSetState} {pcOnly} {
    toplevel .t
    wm geometry .t 150x50+10+10
    update
    set result [wm state .t]
    wm state .t withdrawn
    update
    lappend result [wm state .t]
    wm state .t iconic
    update
    lappend result [wm state .t]
    wm state .t normal
    update 
    lappend result [wm state .t]
    destroy .t
    set result
} {normal withdrawn iconic normal}
test winWm-2.4 {TkpWmSetState} {pcOnly} {
    set result {}
    toplevel .t
    wm geometry .t 150x50+10+10
    update
    lappend result [list [wm state .t] [wm geometry .t]]
    wm iconify .t
    update
    lappend result [list [wm state .t] [wm geometry .t]]
    wm geometry .t 200x50+10+10
    update
    lappend result [list [wm state .t] [wm geometry .t]]
    wm deiconify .t
    update
    lappend result [list [wm state .t] [wm geometry .t]]
    destroy .t
    set result
} {{normal 150x50+10+10} {iconic 150x50+10+10} {iconic 150x50+10+10} {normal 200x50+10+10}}

test winWm-3.1 {ConfigureTopLevel: window geometry propagation} {pcOnly} {
    toplevel .t
    wm geometry .t +0+0
    button .t.b
    pack .t.b
    update
    set x [winfo x .t.b]
    destroy .t
    toplevel .t
    wm geometry .t +0+0
    button .t.b
    update
    pack .t.b
    update
    set x [expr $x == [winfo x .t.b]]
    destroy .t
    set x
} 1

test winWm-4.1 {ConfigureTopLevel: menu resizing} {pcOnly} {
    set result {}
    toplevel .t
    frame .t.f -width 150 -height 50 -bg red
    pack .t.f
    wm geometry .t -0-0
    update
    set y [winfo y .t]
    menu .t.m
    .t.m add command -label foo
    .t conf -menu .t.m
    update
    set result [expr $y - [winfo y .t]]
    destroy .t
    set result
} [expr $menuheight + 1]

test winWm-5.1 {UpdateGeometryInfo: menu resizing} {pcOnly} {
    set result {}
    toplevel .t
    frame .t.f -width 150 -height 50 -bg red
    pack .t.f
    update
    set result [winfo height .t]
    menu .t.m
    .t.m add command -label foo
    .t conf -menu .t.m
    update
    lappend result [winfo height .t]
    .t.m add command -label "thisisreallylong"
    .t.m add command -label "thisisreallylong"
    update
    lappend result [winfo height .t]
    destroy .t
    set result
} {50 50 50}
test winWm-5.2 {UpdateGeometryInfo: menu resizing} {pcOnly} {
    set result {}
    toplevel .t
    frame .t.f -width 150 -height 50 -bg red
    pack .t.f
    wm geom .t -0-0
    update
    set y [winfo rooty .t]
    lappend result [winfo height .t]
    menu .t.m
    .t conf -menu .t.m
    .t.m add command -label foo
    .t.m add command -label "thisisreallylong"
    .t.m add command -label "thisisreallylong"
    update
    lappend result [winfo height .t]
    lappend result [expr $y - [winfo rooty .t]]
    destroy .t
    set result
} {50 50 0}

test winWm-6.1 {wm attributes} {pcOnly} {
    destroy .t
    toplevel .t
    wm attributes .t
} {-disabled 0 -toolwindow 0 -topmost 0}
test winWm-6.2 {wm attributes} {pcOnly} {
    destroy .t
    toplevel .t
    wm attributes .t -disabled
} {0}
test winWm-6.3 {wm attributes} {pcOnly} {
    # This isn't quite the correct error message yet, but it works.
    destroy .t
    toplevel .t
    list [catch {wm attributes .t -foo} msg] $msg
} {1 {wrong # args: should be "wm attributes window ?-disabled ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"}}

test winWm-7.1 {deiconify on an unmapped toplevel
        will raise the window and set the focus} {pcOnly} {
    destroy .t
    toplevel .t
    lower .t
    focus -force .
    wm deiconify .t
    update
    list [wm stackorder .t isabove .] [focus]
} {1 .t}

test winWm-7.2 {deiconify on an already mapped toplevel
        will raise the window and set the focus} {pcOnly} {
    destroy .t
    toplevel .t
    lower .t
    update
    focus -force .
    wm deiconify .t
    update
    list [wm stackorder .t isabove .] [focus]
} {1 .t}

test winWm-7.3 {UpdateWrapper must maintain Z order} win {
    destroy .t
    toplevel .t
    lower .t
    update
    set res [wm stackorder .t isbelow .]
    wm resizable .t 0 0
    update
    list $res [wm stackorder .t isbelow .]
} {1 1}

test winWm-7.4 {UpdateWrapper must maintain focus} win {
    destroy .t
    toplevel .t
    focus -force .t
    update
    set res [focus]
    wm resizable .t 0 0
    update
    list $res [focus]
} {.t .t}

destroy .t

# cleanup
::tcltest::cleanupTests
return