1# This file is a Tcl script to test out Tk's interactions with
2# the window manager, including the "wm" command.  It is organized
3# in the standard fashion for Tcl tests.
4#
5# Copyright (c) 1992-1994 The Regents of the University of California.
6# Copyright (c) 1994-1997 Sun Microsystems, Inc.
7# Copyright (c) 1998-1999 by Scriptics Corporation.
8# All rights reserved.
9#
10# RCS: @(#) $Id: wm.test,v 1.21.2.8 2007/09/04 22:54:18 patthoyts Exp $
11
12# This file tests window manager interactions that work across
13# platforms. Window manager tests that only work on a specific
14# platform should be placed in unixWm.test or winWm.test.
15
16package require tcltest 2.1
17namespace import -force tcltest::configure
18namespace import -force tcltest::testsDirectory
19configure -testdir [file join [pwd] [file dirname [info script]]]
20configure -loadfile [file join [testsDirectory] constraints.tcl]
21tcltest::loadTestedCommands
22
23wm deiconify .
24if {![winfo ismapped .]} {
25    tkwait visibility .
26}
27
28proc stdWindow {} {
29    destroy .t
30    toplevel .t -width 100 -height 50
31    wm geom .t +0+0
32    update
33}
34
35# [raise] and [lower] may return before the window manager
36# has completed the operation.  The raiseDelay procedure
37# idles for a while to give the operation a chance to complete.
38#
39
40proc raiseDelay {} {
41    after 100; update
42}
43
44
45deleteWindows
46stdWindow
47
48test wm-1.1 {Tk_WmObjCmd procedure, miscellaneous errors} {
49    list [catch {wm} msg] $msg
50} {1 {wrong # args: should be "wm option window ?arg ...?"}}
51
52test wm-1.2 {Tk_WmObjCmd procedure, miscellaneous errors} {
53    list [catch {wm foo} msg] $msg
54} {1 {bad option "foo": must be aspect, attributes, client, colormapwindows, command, deiconify, focusmodel, frame, geometry, grid, group, iconbitmap, iconify, iconmask, iconname, iconphoto, iconposition, iconwindow, maxsize, minsize, overrideredirect, positionfrom, protocol, resizable, sizefrom, stackorder, state, title, transient, or withdraw}}
55
56test wm-1.3 {Tk_WmObjCmd procedure, miscellaneous errors} {
57    list [catch {wm command} msg] $msg
58} {1 {wrong # args: should be "wm option window ?arg ...?"}}
59
60test wm-1.4 {Tk_WmObjCmd procedure, miscellaneous errors} {
61    list [catch {wm aspect bogus} msg] $msg
62} {1 {bad window path name "bogus"}}
63
64test wm-1.5 {Tk_WmObjCmd procedure, miscellaneous errors} {
65    catch {destroy .b}
66    button .b -text hello
67    list [catch {wm geometry .b} msg] $msg
68} {1 {window ".b" isn't a top-level window}}
69
70
71test wm-aspect-1.1 {usage} {
72    list [catch {wm aspect} err] $err
73} {1 {wrong # args: should be "wm option window ?arg ...?"}}
74
75test wm-aspect-1.2 {usage} {
76    list [catch {wm aspect . _} err] $err
77} {1 {wrong # args: should be "wm aspect window ?minNumer minDenom maxNumer maxDenom?"}}
78
79test wm-aspect-1.3 {usage} {
80    list [catch {wm aspect . _ _ _} err] $err
81} {1 {wrong # args: should be "wm aspect window ?minNumer minDenom maxNumer maxDenom?"}}
82
83test wm-aspect-1.4 {usage} {
84    list [catch {wm aspect . _ _ _ _ _} err] $err
85} {1 {wrong # args: should be "wm aspect window ?minNumer minDenom maxNumer maxDenom?"}}
86
87test wm-aspect-1.5 {usage} {
88    list [catch {wm aspect . bad 14 15 16} msg] $msg
89} {1 {expected integer but got "bad"}}
90
91test wm-aspect-1.6 {usage} {
92    list [catch {wm aspect . 13 foo 15 16} msg] $msg
93} {1 {expected integer but got "foo"}}
94
95test wm-aspect-1.7 {usage} {
96    list [catch {wm aspect . 13 14 bar 16} msg] $msg
97} {1 {expected integer but got "bar"}}
98
99test wm-aspect-1.8 {usage} {
100    list [catch {wm aspect . 13 14 15 baz} msg] $msg
101} {1 {expected integer but got "baz"}}
102
103test wm-aspect-1.9 {usage} {
104    list [catch {wm aspect . 0 14 15 16} msg] $msg
105} {1 {aspect number can't be <= 0}}
106
107test wm-aspect-1.10 {usage} {
108    list [catch {wm aspect . 13 0 15 16} msg] $msg
109} {1 {aspect number can't be <= 0}}
110
111test wm-aspect-1.11 {usage} {
112    list [catch {wm aspect . 13 14 0 16} msg] $msg
113} {1 {aspect number can't be <= 0}}
114
115test wm-aspect-1.12 {usage} {
116    list [catch {wm aspect . 13 14 15 0} msg] $msg
117} {1 {aspect number can't be <= 0}}
118
119test wm-aspect-2.1 {setting and reading values} {
120    set result {}
121    lappend result [wm aspect .t]
122    wm aspect .t 3 4 10 2
123    lappend result [wm aspect .t]
124    wm aspect .t {} {} {} {}
125    lappend result [wm aspect .t]
126} [list {} {3 4 10 2} {}]
127
128
129test wm-attributes-1.1 {usage} {
130    list [catch {wm attributes} err] $err
131} {1 {wrong # args: should be "wm option window ?arg ...?"}}
132
133test wm-attributes-1.2.1 {usage} {pcOnly} {
134    list [catch {wm attributes . _} err] $err
135} {1 {wrong # args: should be "wm attributes window ?-alpha ?double?? ?-transparentcolor ?color?? ?-disabled ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"}}
136
137test wm-attributes-1.2.2 {usage} {pcOnly} {
138    list [catch {wm attributes . -alpha 1.0 -disabled} err] $err
139} {1 {wrong # args: should be "wm attributes window ?-alpha ?double?? ?-transparentcolor ?color?? ?-disabled ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"}}
140
141test wm-attributes-1.2.3 {usage} {pcOnly} {
142    list [catch {wm attributes . -to} err] $err
143} {1 {wrong # args: should be "wm attributes window ?-alpha ?double?? ?-transparentcolor ?color?? ?-disabled ?bool?? ?-toolwindow ?bool?? ?-topmost ?bool??"}}
144
145test wm-attributes-1.2.4 {usage} {macOrUnix notAqua} {
146    list [catch {wm attributes . _} err] $err
147} {1 {wrong # args: should be "wm attributes window ?-type list?"}}
148
149test wm-attributes-1.2.5 {usage} {aqua} {
150    list [catch {wm attributes . _} err] $err
151} {1 {bad attribute "_": must be -alpha, -modified, or -titlepath}}
152
153test wm-client-1.1 {usage} {
154    list [catch {wm client} err] $err
155} {1 {wrong # args: should be "wm option window ?arg ...?"}}
156
157test wm-client-1.2 {usage} {
158    list [catch {wm client . _ _} err] $err
159} {1 {wrong # args: should be "wm client window ?name?"}}
160
161test wm-client-2.1 {setting and reading values} {
162    set result {}
163    lappend result [wm client .t]
164    wm client .t Miffo
165    lappend result [wm client .t]
166    wm client .t {}
167    lappend result [wm client .t]
168} [list {} Miffo {}]
169
170
171test wm-colormapwindows-1.1 {usage} {
172    list [catch {wm colormapwindows} err] $err
173} {1 {wrong # args: should be "wm option window ?arg ...?"}}
174
175test wm-colormapwindows-1.2 {usage} {
176    list [catch {wm colormapwindows . _ _} err] $err
177} {1 {wrong # args: should be "wm colormapwindows window ?windowList?"}}
178
179test wm-colormapwindows-1.3 {usage} {
180    list [catch {wm colormapwindows . "a \{"} msg] $msg
181} {1 {unmatched open brace in list}}
182
183test wm-colormapwindows-1.4 {usage} {
184    list [catch {wm colormapwindows . foo} msg] $msg
185} {1 {bad window path name "foo"}}
186
187test wm-colormapwindows-2.1 {reading values} {
188    catch {destroy .t2}
189    toplevel .t2 -width 200 -height 200 -colormap new
190    wm geom .t2 +0+0
191    frame .t2.a -width 100 -height 30
192    frame .t2.b -width 100 -height 30 -colormap new
193    pack .t2.a .t2.b -side top
194    update
195    set x [wm colormapwindows .t2]
196    frame .t2.c -width 100 -height 30 -colormap new
197    pack .t2.c -side top
198    update
199    list $x [wm colormapwindows .t2]
200} {{.t2.b .t2} {.t2.b .t2.c .t2}}
201
202test wm-colormapwindows-2.2 {setting and reading values} {
203    catch {destroy .t2}
204    toplevel .t2 -width 200 -height 200
205    wm geom .t2 +0+0
206    frame .t2.a -width 100 -height 30
207    frame .t2.b -width 100 -height 30
208    frame .t2.c -width 100 -height 30
209    pack .t2.a .t2.b .t2.c -side top
210    wm colormapwindows .t2 {.t2.b .t2.a}
211    wm colormapwindows .t2
212} {.t2.b .t2.a}
213
214
215test wm-command-1.1 {usage} {
216    list [catch {wm command} err] $err
217} {1 {wrong # args: should be "wm option window ?arg ...?"}}
218
219test wm-command-1.2 {usage} {
220    list [catch {wm command . _ _} err] $err
221} {1 {wrong # args: should be "wm command window ?value?"}}
222
223test wm-command-1.3 {usage} {
224    list [catch {wm command . "a \{"} msg] $msg
225} {1 {unmatched open brace in list}}
226
227test wm-command-2.1 {setting and reading values} {
228    set result {}
229    lappend result [wm command .t]
230    wm command .t [list Miffo Foo]
231    lappend result [wm command .t]
232    wm command .t {}
233    lappend result [wm command .t]
234} [list {} [list Miffo Foo] {}]
235
236
237test wm-deiconify-1.1 {usage} {
238    list [catch {wm deiconify} err] $err
239} {1 {wrong # args: should be "wm option window ?arg ...?"}}
240
241test wm-deiconify-1.2 {usage} {
242    list [catch {wm deiconify . _} err] $err
243} {1 {wrong # args: should be "wm deiconify window"}}
244
245test wm-deiconify-1.3 {usage} {
246    list [catch {wm deiconify _} err] $err
247} {1 {bad window path name "_"}}
248
249test wm-deiconify-1.4 {usage} {
250    catch {destroy .icon}
251    toplevel .icon -width 50 -height 50 -bg red
252    wm iconwindow .t .icon
253    set result [list [catch {wm deiconify .icon} msg] $msg]
254    destroy .icon
255    set result
256} {1 {can't deiconify .icon: it is an icon for .t}}
257
258test wm-deiconify-1.5 {usage} {
259    catch {destroy .embed}
260    frame .t.f -container 1
261    toplevel .embed -use [winfo id .t.f]
262    set result [list [catch {wm deiconify .embed} msg] $msg]
263    destroy .t.f .embed
264    set result
265} {1 {can't deiconify .embed: it is an embedded window}}
266
267test wm-deiconify-2.1 {a window that has never been mapped
268        should not be mapped by a call to deiconify} {
269    deleteWindows
270    toplevel .t
271    wm deiconify .t
272    winfo ismapped .t
273} 0
274
275test wm-deiconify-2.2 {a window that has already been
276        mapped should be mapped by deiconify} {
277    deleteWindows
278    toplevel .t
279    update idletasks
280    wm withdraw .t
281    wm deiconify .t
282    winfo ismapped .t
283} 1
284
285test wm-deiconify-2.3 {geometry for an unmapped window
286        should not be calculated by a call to deiconify,
287        it should be done at idle time} {
288    deleteWindows
289    set results {}
290    toplevel .t -width 200 -height 200
291    lappend results [wm geometry .t]
292    wm deiconify .t
293    lappend results [wm geometry .t]
294    update idletasks
295    lappend results [lindex [split \
296        [wm geometry .t] +] 0]
297} {1x1+0+0 1x1+0+0 200x200}
298
299test wm-deiconify-2.4 {invoking destroy after a deiconify
300        should not result in a crash because of a callback
301        set on the toplevel} {
302    deleteWindows
303    toplevel .t
304    wm withdraw .t
305    wm deiconify .t
306    destroy .t
307    update
308} {}
309
310
311test wm-focusmodel-1.1 {usage} {
312    list [catch {wm focusmodel} err] $err
313} {1 {wrong # args: should be "wm option window ?arg ...?"}}
314
315test wm-focusmodel-1.2 {usage} {
316    list [catch {wm focusmodel . _ _} err] $err
317} {1 {wrong # args: should be "wm focusmodel window ?active|passive?"}}
318
319test wm-focusmodel-1.3 {usage} {
320    list [catch {wm focusmodel . bogus} msg] $msg
321} {1 {bad argument "bogus": must be active or passive}}
322
323stdWindow
324
325test wm-focusmodel-2.1 {setting and reading values} {
326    set result {} 
327    lappend result [wm focusmodel .t]
328    wm focusmodel .t active
329    lappend result [wm focusmodel .t]
330    wm focusmodel .t passive
331    lappend result [wm focusmodel .t]
332    set result
333} {passive active passive}
334
335
336test wm-frame-1.1 {usage} {
337    list [catch {wm frame} err] $err
338} {1 {wrong # args: should be "wm option window ?arg ...?"}}
339
340test wm-frame-1.2 {usage} {
341    list [catch {wm frame . _} err] $err
342} {1 {wrong # args: should be "wm frame window"}}
343
344
345test wm-geometry-1.1 {usage} {
346    list [catch {wm geometry} err] $err
347} {1 {wrong # args: should be "wm option window ?arg ...?"}}
348
349test wm-geometry-1.2 {usage} {
350    list [catch {wm geometry . _ _} err] $err
351} {1 {wrong # args: should be "wm geometry window ?newGeometry?"}}
352
353test wm-geometry-1.3 {usage} {
354    list [catch {wm geometry . bogus} msg] $msg
355} {1 {bad geometry specifier "bogus"}}
356
357test wm-geometry-2.1 {setting values} {
358    set result {}
359    wm geometry .t 150x150+50+50
360    update
361    lappend result [wm geometry .t]
362    wm geometry .t {}
363    update
364    lappend result [string equal [wm geometry .t] "150x150+50+50"]
365} [list 150x150+50+50 0]
366
367
368test wm-grid-1.1 {usage} {
369    list [catch {wm grid} err] $err
370} {1 {wrong # args: should be "wm option window ?arg ...?"}}
371
372test wm-grid-1.2 {usage} {
373    list [catch {wm grid . _} err] $err
374} {1 {wrong # args: should be "wm grid window ?baseWidth baseHeight widthInc heightInc?"}}
375
376test wm-grid-1.3 {usage} {
377    list [catch {wm grid . _ _ _} err] $err
378} {1 {wrong # args: should be "wm grid window ?baseWidth baseHeight widthInc heightInc?"}}
379
380test wm-grid-1.4 {usage} {
381    list [catch {wm grid . _ _ _ _ _} err] $err
382} {1 {wrong # args: should be "wm grid window ?baseWidth baseHeight widthInc heightInc?"}}
383
384test wm-grid-1.5 {usage} {
385    list [catch {wm grid . bad 14 15 16} msg] $msg
386} {1 {expected integer but got "bad"}}
387
388test wm-grid-1.6 {usage} {
389    list [catch {wm grid . 13 foo 15 16} msg] $msg
390} {1 {expected integer but got "foo"}}
391
392test wm-grid-1.7 {usage} {
393    list [catch {wm grid . 13 14 bar 16} msg] $msg
394} {1 {expected integer but got "bar"}}
395
396test wm-grid-1.8 {usage} {
397    list [catch {wm grid . 13 14 15 baz} msg] $msg
398} {1 {expected integer but got "baz"}}
399
400test wm-grid-1.9 {usage} {
401    list [catch {wm grid . -1 14 15 16} msg] $msg
402} {1 {baseWidth can't be < 0}}
403
404test wm-grid-1.10 {usage} {
405    list [catch {wm grid . 13 -1 15 16} msg] $msg
406} {1 {baseHeight can't be < 0}}
407
408test wm-grid-1.11 {usage} {
409    list [catch {wm grid . 13 14 -1 16} msg] $msg
410} {1 {widthInc can't be <= 0}}
411
412test wm-grid-1.12 {usage} {
413    list [catch {wm grid . 13 14 15 -1} msg] $msg
414} {1 {heightInc can't be <= 0}}
415
416test wm-grid-2.1 {setting and reading values} {
417    set result {}
418    lappend result [wm grid .t]
419    wm grid .t 3 4 10 2
420    lappend result [wm grid .t]
421    wm grid .t {} {} {} {}
422    lappend result [wm grid .t]
423} [list {} {3 4 10 2} {}]
424
425
426test wm-group-1.1 {usage} {
427    list [catch {wm group} err] $err
428} {1 {wrong # args: should be "wm option window ?arg ...?"}}
429
430test wm-group-1.2 {usage} {
431    list [catch {wm group .t 12 13} msg] $msg
432} {1 {wrong # args: should be "wm group window ?pathName?"}}
433
434test wm-group-1.3 {usage} {
435    list [catch {wm group .t bogus} msg] $msg
436} {1 {bad window path name "bogus"}}
437
438test wm-group-2.1 {setting and reading values} {
439    set result {}
440    lappend result [wm group .t]
441    wm group .t .
442    lappend result [wm group .t]
443    wm group .t {}
444    lappend result [wm group .t]
445} [list {} . {}]
446
447
448test wm-iconbitmap-1.1 {usage} {
449    list [catch {wm iconbitmap} err] $err
450} {1 {wrong # args: should be "wm option window ?arg ...?"}}
451
452test wm-iconbitmap-1.2.1 {usage} {macOrUnix} {
453    list [catch {wm iconbitmap .t 12 13} msg] $msg
454} {1 {wrong # args: should be "wm iconbitmap window ?bitmap?"}}
455
456test wm-iconbitmap-1.2.2 {usage} {pcOnly} {
457    list [catch {wm iconbitmap .t 12 13 14} msg] $msg
458} {1 {wrong # args: should be "wm iconbitmap window ?-default? ?image?"}}
459
460test wm-iconbitmap-1.3 {usage} {pcOnly} {
461    list [catch {wm iconbitmap .t 12 13} msg] $msg
462} {1 {illegal option "12" must be "-default"}}
463
464test wm-iconbitmap-1.4 {usage} {
465    list [catch {wm iconbitmap .t bad-bitmap} msg] $msg
466} {1 {bitmap "bad-bitmap" not defined}}
467
468test wm-iconbitmap-2.1 {setting and reading values} {
469    set result {}
470    lappend result [wm iconbitmap .t]
471    wm iconbitmap .t hourglass
472    lappend result [wm iconbitmap .t]
473    wm iconbitmap .t {}
474    lappend result [wm iconbitmap .t]
475} [list {} hourglass {}]
476
477
478test wm-iconify-1.1 {usage} {
479    list [catch {wm iconify} err] $err
480} {1 {wrong # args: should be "wm option window ?arg ...?"}}
481
482test wm-iconify-1.2 {usage} {
483    list [catch {wm iconify .t _} msg] $msg
484} {1 {wrong # args: should be "wm iconify window"}}
485
486test wm-iconify-2.1 {Misc errors} {
487    catch {destroy .t2}
488    toplevel .t2
489    wm overrideredirect .t2 1
490    set result [list [catch {wm iconify .t2} msg] $msg]
491    destroy .t2
492    set result
493} {1 {can't iconify ".t2": override-redirect flag is set}}
494
495test wm-iconify-2.2 {Misc errors} {
496    catch {destroy .t2}
497    toplevel .t2
498    wm geom .t2 +0+0
499    wm transient .t2 .t
500    set result [list [catch {wm iconify .t2} msg] $msg]
501    destroy .t2
502    set result
503} {1 {can't iconify ".t2": it is a transient}}
504
505test wm-iconify-2.3 {Misc errors} {
506    catch {destroy .t2}
507    toplevel .t2
508    wm geom .t2 +0+0
509    wm iconwindow .t .t2
510    set result [list [catch {wm iconify .t2} msg] $msg]
511    destroy .t2
512    set result
513} {1 {can't iconify .t2: it is an icon for .t}}
514
515test wm-iconify-2.4 {Misc errors} {
516    catch {destroy .t2}
517    frame .t.f -container 1
518    toplevel .t2 -use [winfo id .t.f]
519    set result [list [catch {wm iconify .t2} msg] $msg]
520    destroy .t2 .r.f
521    set result
522} {1 {can't iconify .t2: it is an embedded window}}
523
524test wm-iconify-3.1 {} {
525    catch {destroy .t2}
526    toplevel .t2
527    wm geom .t2 -0+0
528    update
529    set result [winfo ismapped .t2]
530    wm iconify .t2
531    update
532    lappend result [winfo ismapped .t2]
533    destroy .t2
534    set result
535} {1 0}
536
537
538test wm-iconmask-1.1 {usage} {
539    list [catch {wm iconmask} err] $err
540} {1 {wrong # args: should be "wm option window ?arg ...?"}}
541
542test wm-iconmask-1.2 {usage} {
543    list [catch {wm iconmask .t 12 13} msg] $msg
544} {1 {wrong # args: should be "wm iconmask window ?bitmap?"}}
545
546test wm-iconmask-1.3 {usage} {
547    list [catch {wm iconmask .t bad-bitmap} msg] $msg
548} {1 {bitmap "bad-bitmap" not defined}}
549
550test wm-iconmask-2.1 {setting and reading values} {
551    set result {}
552    lappend result [wm iconmask .t]
553    wm iconmask .t hourglass
554    lappend result [wm iconmask .t]
555    wm iconmask .t {}
556    lappend result [wm iconmask .t]
557} [list {} hourglass {}]
558
559
560test wm-iconname-1.1 {usage} {
561    list [catch {wm iconname} err] $err
562} {1 {wrong # args: should be "wm option window ?arg ...?"}}
563
564test wm-iconname-1.2 {usage} {
565    list [catch {wm iconname .t 12 13} msg] $msg
566} {1 {wrong # args: should be "wm iconname window ?newName?"}}
567
568test wm-iconname-2.1 {setting and reading values} {
569    set result {}
570    lappend result [wm iconname .t]
571    wm iconname .t ThisIconHasAName
572    lappend result [wm iconname .t]
573    wm iconname .t {}
574    lappend result [wm iconname .t]
575} [list {} ThisIconHasAName {}]
576
577
578test wm-iconphoto-1.1 {usage} {
579    list [catch {wm iconphoto} err] $err
580} {1 {wrong # args: should be "wm option window ?arg ...?"}}
581
582test wm-iconphoto-1.2 {usage} {
583    list [catch {wm iconphoto .} msg] $msg
584} {1 {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"}}
585test wm-iconphoto-1.3 {usage} {
586    list [catch {wm iconphoto . notanimage} msg] $msg
587} {1 {can't use "notanimage" as iconphoto: not a photo image}}
588test wm-iconphoto-1.4 {usage} {
589    # we currently have no return info
590    list [catch {wm iconphoto . -default} msg] $msg
591} {1 {wrong # args: should be "wm iconphoto window ?-default? image1 ?image2 ...?"}}
592
593# All other iconphoto tests are platform specific
594
595test wm-iconposition-1.1 {usage} {
596    list [catch {wm iconposition} err] $err
597} {1 {wrong # args: should be "wm option window ?arg ...?"}}
598
599test wm-iconposition-1.2 {usage} {
600    list [catch {wm iconposition .t 12} msg] $msg
601} {1 {wrong # args: should be "wm iconposition window ?x y?"}}
602
603test wm-iconposition-1.3 {usage} {
604    list [catch {wm iconposition .t 12 13 14} msg] $msg
605} {1 {wrong # args: should be "wm iconposition window ?x y?"}}
606
607test wm-iconposition-1.4 {usage} {
608    list [catch {wm iconposition .t bad 13} msg] $msg
609} {1 {expected integer but got "bad"}}
610
611test wm-iconposition-1.5 {usage} {
612    list [catch {wm iconposition .t 13 lousy} msg] $msg
613} {1 {expected integer but got "lousy"}}
614
615test wm-iconposition-2.1 {setting and reading values} {
616    set result {}
617    lappend result [wm iconposition .t]
618    wm iconposition .t 10 20
619    lappend result [wm iconposition .t]
620    wm iconposition .t {} {}
621    lappend result [wm iconposition .t]
622} [list {} {10 20} {}]
623
624
625test wm-iconwindow-1.1 {usage} {
626    list [catch {wm iconwindow} err] $err
627} {1 {wrong # args: should be "wm option window ?arg ...?"}}
628
629test wm-iconwindow-1.2 {usage} {
630    list [catch {wm iconwindow .t 12 13} msg] $msg
631} {1 {wrong # args: should be "wm iconwindow window ?pathName?"}}
632
633test wm-iconwindow-1.3 {usage} {
634    list [catch {wm iconwindow .t bogus} msg] $msg
635} {1 {bad window path name "bogus"}}
636
637test wm-iconwindow-1.4 {usage} {
638    catch {destroy .b}
639    button .b -text Help
640    set result [list [catch {wm iconwindow .t .b} msg] $msg]
641    destroy .b
642    set result
643} {1 {can't use .b as icon window: not at top level}}
644
645test wm-iconwindow-1.5 {usage} {
646    catch {destroy .icon}
647    toplevel .icon -width 50 -height 50 -bg green
648    catch {destroy .t2}
649    toplevel .t2
650    wm geom .t2 -0+0
651    wm iconwindow .t2 .icon
652    set result [list [catch {wm iconwindow .t .icon} msg] $msg]
653    destroy .t2
654    destroy .icon
655    set result
656} {1 {.icon is already an icon for .t2}}
657
658test wm-iconwindow-2.1 {setting and reading values} {
659    set result {}
660    lappend result [wm iconwindow .t]
661    catch {destroy .icon}
662    toplevel .icon -width 50 -height 50 -bg green
663    wm iconwindow .t .icon
664    lappend result [wm iconwindow .t]
665    wm iconwindow .t {}
666    destroy .icon
667    lappend result [wm iconwindow .t]
668} [list {} .icon {}]
669
670
671test wm-maxsize-1.1 {usage} {
672    list [catch {wm maxsize} msg]  $msg
673} {1 {wrong # args: should be "wm option window ?arg ...?"}}
674
675test wm-maxsize-1.2 {usage} {
676    list [catch {wm maxsize . a} msg]  $msg
677} {1 {wrong # args: should be "wm maxsize window ?width height?"}}
678
679test wm-maxsize-1.3 {usage} {
680    list [catch {wm maxsize . a b c} msg]  $msg
681} {1 {wrong # args: should be "wm maxsize window ?width height?"}}
682
683test wm-maxsize-1.4 {usage} {
684    list [catch {wm maxsize . x 100} msg]  $msg
685} {1 {expected integer but got "x"}}
686
687test wm-maxsize-1.5 {usage} {
688    list [catch {wm maxsize . 100 bogus} msg]  $msg
689} {1 {expected integer but got "bogus"}}
690
691test wm-maxsize-1.6 {usage} {
692    catch {destroy .t2}
693    toplevel .t2
694    wm maxsize .t2 200 150
695    set result [wm maxsize .t2]
696    destroy .t2
697    set result
698} {200 150}
699
700
701test wm-minsize-1.1 {usage} {
702    list [catch {wm minsize} msg]  $msg
703} {1 {wrong # args: should be "wm option window ?arg ...?"}}
704
705test wm-minsize-1.2 {usage} {
706    list [catch {wm minsize . a} msg]  $msg
707} {1 {wrong # args: should be "wm minsize window ?width height?"}}
708
709test wm-minsize-1.3 {usage} {
710    list [catch {wm minsize . a b c} msg]  $msg
711} {1 {wrong # args: should be "wm minsize window ?width height?"}}
712
713test wm-minsize-1.4 {usage} {
714    list [catch {wm minsize . x 100} msg]  $msg
715} {1 {expected integer but got "x"}}
716
717test wm-minsize-1.5 {usage} {
718    list [catch {wm minsize . 100 bogus} msg]  $msg
719} {1 {expected integer but got "bogus"}}
720
721test wm-minsize-1.6 {usage} {
722    catch {destroy .t2}
723    toplevel .t2
724    wm minsize .t2 200 150
725    set result [wm minsize .t2]
726    destroy .t2
727    set result
728} {200 150}
729
730
731test wm-overrideredirect-1.1 {usage} {
732    list [catch {wm overrideredirect} msg]  $msg
733} {1 {wrong # args: should be "wm option window ?arg ...?"}}
734
735test wm-overrideredirect-1.2 {usage} {
736    list [catch {wm overrideredirect .t 1 2} msg]  $msg
737} {1 {wrong # args: should be "wm overrideredirect window ?boolean?"}}
738
739test wm-overrideredirect-1.3 {usage} {
740    list [catch {wm overrideredirect .t boo} msg]  $msg
741} {1 {expected boolean value but got "boo"}}
742
743test wm-overrideredirect-2.1 {setting and reading values} {
744    set result {}
745    lappend result [wm overrideredirect .t]
746    wm overrideredirect .t true
747    lappend result [wm overrideredirect .t]
748    wm overrideredirect .t off
749    lappend result [wm overrideredirect .t]
750} {0 1 0}
751
752
753test wm-positionfrom-1.1 {usage} {
754    list [catch {wm positionfrom} msg]  $msg
755} {1 {wrong # args: should be "wm option window ?arg ...?"}}
756
757test wm-positionfrom-1.2 {usage} {
758    list [catch {wm positionfrom .t 1 2} msg]  $msg
759} {1 {wrong # args: should be "wm positionfrom window ?user/program?"}}
760
761test wm-positionfrom-1.3 {usage} {
762    list [catch {wm positionfrom .t none} msg]  $msg
763} {1 {bad argument "none": must be program or user}}
764
765test wm-positionfrom-2.1 {setting and reading values} {
766    catch {destroy .t2}
767    toplevel .t2
768    set result {}
769    wm positionfrom .t user
770    lappend result [wm positionfrom .t]
771    wm positionfrom .t program
772    lappend result [wm positionfrom .t]
773    wm positionfrom .t {}
774    lappend result [wm positionfrom .t]
775    destroy .t2
776    set result
777} {user program {}}
778
779
780test wm-protocol-1.1 {usage} {
781    list [catch {wm protocol} msg]  $msg
782} {1 {wrong # args: should be "wm option window ?arg ...?"}}
783
784test wm-protocol-1.2 {usage} {
785    list [catch {wm protocol .t 1 2 3} msg]  $msg
786} {1 {wrong # args: should be "wm protocol window ?name? ?command?"}}
787
788test wm-protocol-2.1 {setting and reading values} {
789    wm protocol .t {foo a} {a b c}
790    wm protocol .t bar {test script for bar}
791    set result [wm protocol .t]
792    wm protocol .t {foo a} {}
793    wm protocol .t bar {}
794    set result
795} {bar {foo a}}
796
797test wm-protocol-2.2 {setting and reading values} {
798    set result {}
799    wm protocol .t foo {a b c}
800    wm protocol .t bar {test script for bar}
801    lappend result [wm protocol .t foo] [wm protocol .t bar]
802    wm protocol .t foo {}
803    wm protocol .t bar {}
804    lappend result [wm protocol .t foo] [wm protocol .t bar]
805} {{a b c} {test script for bar} {} {}}
806
807test wm-protocol-2.3 {setting and reading values} {
808    wm protocol .t foo {a b c}
809    wm protocol .t foo {test script}
810    set result [wm protocol .t foo]
811    wm protocol .t foo {}
812    set result
813} {test script}
814
815
816test wm-resizable-1.1 {usage} {
817    list [catch {wm resizable} msg]  $msg
818} {1 {wrong # args: should be "wm option window ?arg ...?"}}
819
820test wm-resizable-1.2 {usage} {
821    list [catch {wm resizable .t 1} msg]  $msg
822} {1 {wrong # args: should be "wm resizable window ?width height?"}}
823
824test wm-resizable-1.3 {usage} {
825    list [catch {wm resizable .t 1 2 3} msg]  $msg
826} {1 {wrong # args: should be "wm resizable window ?width height?"}}
827
828test wm-resizable-1.4 {usage} {
829    list [catch {wm resizable .t bad 0} msg]  $msg
830} {1 {expected boolean value but got "bad"}}
831
832test wm-resizable-1.5 {usage} {
833    list [catch {wm resizable .t 1 bad} msg]  $msg
834} {1 {expected boolean value but got "bad"}}
835
836test wm-resizable-2.1 {setting and reading values} {
837    wm resizable .t 0 1
838    set result [wm resizable .t]
839    wm resizable .t 1 0
840    lappend result [wm resizable .t]
841    wm resizable .t 1 1
842    lappend result [wm resizable .t]
843} {0 1 {1 0} {1 1}}
844
845
846test wm-sizefrom-1.1 {usage} {
847    list [catch {wm sizefrom} msg]  $msg
848} {1 {wrong # args: should be "wm option window ?arg ...?"}}
849
850test wm-sizefrom-1.2 {usage} {
851    list [catch {wm sizefrom .t 1 2} msg]  $msg
852} {1 {wrong # args: should be "wm sizefrom window ?user|program?"}}
853
854test wm-sizefrom-1.4 {usage} {
855    list [catch {wm sizefrom .t bad} msg]  $msg
856} {1 {bad argument "bad": must be program or user}}
857
858test wm-sizefrom-2.1 {setting and reading values} {
859    set result [list [wm sizefrom .t]]
860    wm sizefrom .t user
861    lappend result [wm sizefrom .t]
862    wm sizefrom .t program
863    lappend result [wm sizefrom .t]
864    wm sizefrom .t {}
865    lappend result [wm sizefrom .t]
866} {{} user program {}}
867
868
869
870test wm-stackorder-1.1 {usage} {
871    list [catch {wm stackorder} err] $err
872} {1 {wrong # args: should be "wm option window ?arg ...?"}}
873
874test wm-stackorder-1.2 {usage} {
875    list [catch {wm stackorder . _} err] $err
876} {1 {wrong # args: should be "wm stackorder window ?isabove|isbelow window?"}}
877
878test wm-stackorder-1.3 {usage} {
879    list [catch {wm stackorder . _ _ _} err] $err
880} {1 {wrong # args: should be "wm stackorder window ?isabove|isbelow window?"}}
881
882test wm-stackorder-1.4 {usage} {
883    list [catch {wm stackorder . is .} err] $err
884} {1 {ambiguous argument "is": must be isabove or isbelow}}
885
886test wm-stackorder-1.5 {usage} {
887    list [catch {wm stackorder _} err] $err
888} {1 {bad window path name "_"}}
889
890test wm-stackorder-1.6 {usage} {
891    list [catch {wm stackorder . isabove _} err] $err
892} {1 {bad window path name "_"}}
893
894test wm-stackorder-1.7 {usage} {
895    catch {destroy .t}
896    toplevel .t
897    button .t.b
898    list [catch {wm stackorder .t.b} err] $err
899} {1 {window ".t.b" isn't a top-level window}}
900
901test wm-stackorder-1.8 {usage} {
902    catch {destroy .t}
903    toplevel .t
904    button .t.b
905    pack .t.b
906    update
907    list [catch {wm stackorder . isabove .t.b} err] $err
908} {1 {window ".t.b" isn't a top-level window}}
909
910test wm-stackorder-1.9 {usage} {
911    catch {destroy .t}
912    toplevel .t
913    button .t.b
914    pack .t.b
915    update
916    list [catch {wm stackorder . isbelow .t.b} err] $err
917} {1 {window ".t.b" isn't a top-level window}}
918
919test wm-stackorder-1.10 {usage, isabove|isbelow toplevels must be mapped} {
920    catch {destroy .t}
921    toplevel .t ; update
922    wm withdraw .t
923    list [catch {wm stackorder .t isabove .} err] $err
924} {1 {window ".t" isn't mapped}}
925
926test wm-stackorder-1.11 {usage, isabove|isbelow toplevels must be mapped} {
927    catch {destroy .t}
928    toplevel .t ; update
929    wm withdraw .t
930    list [catch {wm stackorder . isbelow .t} err] $err
931} {1 {window ".t" isn't mapped}}
932
933
934deleteWindows
935
936
937test wm-stackorder-2.1 {} {
938    catch {destroy .t}
939    toplevel .t ; update
940    wm stackorder .
941} {. .t}
942
943test wm-stackorder-2.2 {} {
944    catch {destroy .t}
945    toplevel .t ; update
946    raise .
947    raiseDelay
948    wm stackorder .
949} {.t .}
950
951test wm-stackorder-2.3 {} {
952    catch {destroy .t}
953    toplevel .t ; update
954    catch {destroy .t2}
955    toplevel .t2 ; update
956    raise .
957    raise .t2
958    raiseDelay
959    wm stackorder .
960} {.t . .t2}
961
962test wm-stackorder-2.4 {} {
963    catch {destroy .t}
964    toplevel .t ; update
965    catch {destroy .t2}
966    toplevel .t2 ; update
967    raise .
968    lower .t2
969    raiseDelay
970    wm stackorder .
971} {.t2 .t .}
972
973test wm-stackorder-2.5 {} {
974    catch {destroy .parent}
975    toplevel .parent ; update
976    catch {destroy .parent.child1}
977    toplevel .parent.child1 ; update
978    catch {destroy .parent.child2}
979    toplevel .parent.child2 ; update
980    catch {destroy .extra}
981    toplevel .extra ; update
982    raise .parent
983    lower .parent.child2
984    raiseDelay
985    wm stackorder .parent
986} {.parent.child2 .parent.child1 .parent}
987
988deleteWindows
989
990test wm-stackorder-2.6 {non-toplevel widgets ignored} {
991    catch {destroy .t1}
992    toplevel .t1
993    button .t1.b
994    pack .t1.b
995    update
996    wm stackorder .
997} {. .t1}
998
999deleteWindows
1000
1001test wm-stackorder-2.7 {no children returns self} {
1002    wm stackorder .
1003} {.}
1004
1005deleteWindows
1006
1007
1008test wm-stackorder-3.1 {unmapped toplevel} {
1009    catch {destroy .t1}
1010    toplevel .t1 ; update
1011    catch {destroy .t2}
1012    toplevel .t2 ; update
1013    wm iconify .t1
1014    wm stackorder .
1015} {. .t2}
1016
1017test wm-stackorder-3.2 {unmapped toplevel} {
1018    catch {destroy .t1}
1019    toplevel .t1 ; update
1020    catch {destroy .t2}
1021    toplevel .t2 ; update
1022    wm withdraw .t2
1023    wm stackorder .
1024} {. .t1}
1025
1026test wm-stackorder-3.3 {unmapped toplevel} {
1027    catch {destroy .t1}
1028    toplevel .t1 ; update
1029    catch {destroy .t2}
1030    toplevel .t2 ; update
1031    wm withdraw .t2
1032    wm stackorder .t2
1033} {}
1034
1035test wm-stackorder-3.4 {unmapped toplevel} {
1036    catch {destroy .t1}
1037    toplevel .t1 ; update
1038    toplevel .t1.t2 ; update
1039    wm withdraw .t1.t2
1040    wm stackorder .t1
1041} {.t1}
1042
1043test wm-stackorder-3.5 {unmapped toplevel} {
1044    catch {destroy .t1}
1045    toplevel .t1 ; update
1046    toplevel .t1.t2 ; update
1047    wm withdraw .t1
1048    wm stackorder .t1
1049} {.t1.t2}
1050
1051test wm-stackorder-3.6 {unmapped toplevel} {
1052    catch {destroy .t1}
1053    toplevel .t1 ; update
1054    toplevel .t1.t2 ; update
1055    toplevel .t1.t2.t3 ; update
1056    wm withdraw .t1.t2
1057    wm stackorder .t1
1058} {.t1 .t1.t2.t3}
1059
1060test wm-stackorder-3.7 {unmapped toplevel, mapped children returned} {
1061    catch {destroy .t1}
1062    toplevel .t1 ; update
1063    toplevel .t1.t2 ; update
1064    wm withdraw .t1
1065    wm stackorder .t1
1066} {.t1.t2}
1067
1068test wm-stackorder-3.8 {toplevel mapped in idle callback } {
1069    catch {destroy .t1}
1070    toplevel .t1
1071    wm stackorder .
1072} {.}
1073
1074
1075deleteWindows
1076
1077
1078test wm-stackorder-4.1 {wm stackorder isabove|isbelow} {
1079    catch {destroy .t}
1080    toplevel .t ; update
1081    raise .t
1082    wm stackorder . isabove .t
1083} {0}
1084
1085test wm-stackorder-4.2 {wm stackorder isabove|isbelow} {
1086    catch {destroy .t}
1087    toplevel .t ; update
1088    raise .t
1089    wm stackorder . isbelow .t
1090} {1}
1091
1092test wm-stackorder-4.3 {wm stackorder isabove|isbelow} {
1093    catch {destroy .t}
1094    toplevel .t ; update
1095    raise .
1096    raiseDelay
1097    wm stackorder .t isa .
1098} {0}
1099
1100test wm-stackorder-4.4 {wm stackorder isabove|isbelow} {
1101    catch {destroy .t}
1102    toplevel .t ; update
1103    raise .
1104    raiseDelay
1105    wm stackorder .t isb .
1106} {1}
1107
1108deleteWindows
1109
1110test wm-stackorder-5.1 {a menu is not a toplevel} {
1111    catch {destroy .t}
1112    toplevel .t
1113    menu .t.m -type menubar
1114    .t.m add cascade -label "File"
1115    .t configure -menu .t.m
1116    update
1117    raise .
1118    raiseDelay
1119    wm stackorder .
1120} {.t .}
1121
1122test wm-stackorder-5.2 {A normal toplevel can't be
1123        raised above an overrideredirect toplevel } {
1124    catch {destroy .t}
1125    toplevel .t
1126    wm overrideredirect .t 1
1127    raise .
1128    update
1129    raiseDelay
1130    wm stackorder . isabove .t
1131} 0
1132
1133test wm-stackorder-5.3 {An overrideredirect window
1134        can be explicitly lowered } {
1135    catch {destroy .t}
1136    toplevel .t
1137    wm overrideredirect .t 1
1138    lower .t
1139    update
1140    raiseDelay
1141    wm stackorder .t isbelow .
1142} 1
1143
1144test wm-stackorder-6.1 {An embedded toplevel does not
1145        appear in the stacking order} {
1146    deleteWindows
1147    toplevel .real -container 1
1148    toplevel .embd -bg blue -use [winfo id .real]
1149    update
1150    wm stackorder .
1151} {. .real}
1152
1153stdWindow
1154
1155test wm-title-1.1 {usage} {
1156    list [catch {wm title} msg]  $msg
1157} {1 {wrong # args: should be "wm option window ?arg ...?"}}
1158
1159test wm-title-1.2 {usage} {
1160    list [catch {wm title . 1 2} msg]  $msg
1161} {1 {wrong # args: should be "wm title window ?newTitle?"}}
1162
1163test wm-title-2.1 {setting and reading values} {
1164    destroy .t
1165    toplevel .t
1166    set result [wm title .t]
1167    wm title .t Apa
1168    lappend result [wm title .t]
1169    wm title .t {}
1170    lappend result [wm title .t]
1171} {t Apa {}}
1172
1173
1174test wm-transient-1.1 {usage} {
1175    catch {destroy .t} ; toplevel .t
1176    list [catch {wm transient .t 1 2} msg]  $msg
1177} {1 {wrong # args: should be "wm transient window ?master?"}}
1178
1179test wm-transient-1.2 {usage} {
1180    catch {destroy .t} ; toplevel .t
1181    list [catch {wm transient .t foo} msg]  $msg
1182} {1 {bad window path name "foo"}}
1183
1184test wm-transient-1.3 {usage} {
1185    catch {destroy .t} ; toplevel .t
1186    list [catch {wm transient foo .t} msg]  $msg
1187} {1 {bad window path name "foo"}}
1188
1189test wm-transient-1.4 {usage} {
1190    deleteWindows
1191    toplevel .master
1192    toplevel .subject
1193    wm transient .subject .master
1194    list [catch {wm iconify .subject} msg] $msg
1195} {1 {can't iconify ".subject": it is a transient}}
1196
1197test wm-transient-1.5 {usage} {
1198    deleteWindows
1199    toplevel .icon -bg blue
1200    toplevel .top
1201    wm iconwindow .top .icon
1202    toplevel .dummy
1203    list [catch {wm transient .icon .dummy} msg] $msg
1204} {1 {can't make ".icon" a transient: it is an icon for .top}}
1205
1206test wm-transient-1.6 {usage} {
1207    deleteWindows
1208    toplevel .icon -bg blue
1209    toplevel .top
1210    wm iconwindow .top .icon
1211    toplevel .dummy
1212    list [catch {wm transient .dummy .icon} msg] $msg
1213} {1 {can't make ".icon" a master: it is an icon for .top}}
1214
1215test wm-transient-1.7 {usage} {
1216    deleteWindows
1217    toplevel .master
1218    list [catch {wm transient .master .master} err] $err
1219} {1 {can't make ".master" its own master}}
1220
1221test wm-transient-1.8 {usage} {
1222    deleteWindows
1223    toplevel .master
1224    frame .master.f
1225    list [catch {wm transient .master .master.f} err] $err
1226} {1 {can't make ".master" its own master}}
1227
1228test wm-transient-2.1 { basic get/set of master } {
1229    deleteWindows
1230    set results [list]    
1231    toplevel .master
1232    toplevel .subject
1233    lappend results [wm transient .subject]
1234    wm transient .subject .master
1235    lappend results [wm transient .subject]
1236    wm transient .subject {}
1237    lappend results [wm transient .subject]
1238    set results
1239} {{} .master {}}
1240
1241test wm-transient-2.2 { first toplevel parent of
1242        non-toplevel master is used } {
1243    deleteWindows
1244    toplevel .master
1245    frame .master.f
1246    toplevel .subject
1247    wm transient .subject .master.f
1248    wm transient .subject
1249} {.master}
1250
1251test wm-transient-3.1 { transient toplevel is withdrawn
1252        when mapped if master is withdrawn } {
1253    deleteWindows
1254    toplevel .master
1255    wm withdraw .master
1256    update
1257    toplevel .subject
1258    wm transient .subject .master
1259    update
1260    list [wm state .subject] [winfo ismapped .subject]
1261} {withdrawn 0}
1262
1263test wm-transient-3.2 { already mapped transient toplevel
1264        takes on withdrawn state of master } {
1265    deleteWindows
1266    toplevel .master
1267    wm withdraw .master
1268    update
1269    toplevel .subject
1270    update
1271    wm transient .subject .master
1272    update
1273    list [wm state .subject] [winfo ismapped .subject]
1274} {withdrawn 0}
1275
1276test wm-transient-3.3 { withdraw/deiconify on the master
1277        also does a withdraw/deiconify on the transient } {
1278    deleteWindows
1279    set results [list]
1280    toplevel .master
1281    toplevel .subject
1282    update
1283    wm transient .subject .master
1284    wm withdraw .master
1285    update
1286    lappend results [wm state .subject] \
1287        [winfo ismapped .subject]
1288    wm deiconify .master
1289    update
1290    lappend results [wm state .subject] \
1291        [winfo ismapped .subject]
1292    set results
1293} {withdrawn 0 normal 1}
1294
1295test wm-transient-4.1 { transient toplevel is withdrawn
1296        when mapped if master is iconic } {
1297    deleteWindows
1298    toplevel .master
1299    wm iconify .master
1300    update
1301    toplevel .subject
1302    wm transient .subject .master
1303    update
1304    list [wm state .subject] [winfo ismapped .subject]
1305} {withdrawn 0}
1306
1307test wm-transient-4.2 { already mapped transient toplevel
1308        is withdrawn if master is iconic } {
1309    deleteWindows
1310    toplevel .master
1311    wm iconify .master
1312    update
1313    toplevel .subject
1314    update
1315    wm transient .subject .master
1316    update
1317    list [wm state .subject] [winfo ismapped .subject]
1318} {withdrawn 0}
1319
1320test wm-transient-4.3 { iconify/deiconify on the master
1321        does a withdraw/deiconify on the transient } {
1322    deleteWindows
1323    set results [list]
1324    toplevel .master
1325    toplevel .subject
1326    update
1327    wm transient .subject .master
1328    wm iconify .master
1329    update
1330    lappend results [wm state .subject] \
1331        [winfo ismapped .subject]
1332    wm deiconify .master
1333    update
1334    lappend results [wm state .subject] \
1335        [winfo ismapped .subject]
1336    set results
1337} {withdrawn 0 normal 1}
1338
1339test wm-transient-5.1 { an error during transient command should not
1340        cause the map/unmap binding to be deleted } {
1341    deleteWindows
1342    set results [list]
1343    toplevel .master
1344    toplevel .subject
1345    update
1346    wm transient .subject .master
1347    # Expect a bad window path error here
1348    lappend results [catch {wm transient .subject .bad}]
1349    wm withdraw .master
1350    update
1351    lappend results [wm state .subject]
1352    wm deiconify .master
1353    update
1354    lappend results [wm state .subject]
1355    set results
1356} {1 withdrawn normal}
1357
1358test wm-transient-5.2 { remove transient property when master
1359        is destroyed } {
1360    deleteWindows
1361    toplevel .master
1362    toplevel .subject
1363    wm transient .subject .master
1364    update
1365    destroy .master
1366    update
1367    wm transient .subject
1368} {}
1369
1370test wm-transient-5.3 { remove transient property from window
1371        that had never been mapped when master is destroyed } {
1372    deleteWindows
1373    toplevel .master
1374    toplevel .subject
1375    wm transient .subject .master
1376    destroy .master
1377    wm transient .subject
1378} {}
1379
1380test wm-transient-6.1 { a withdrawn transient does not track
1381        state changes in the master } {
1382    deleteWindows
1383    toplevel .master
1384    toplevel .subject
1385    update
1386    wm transient .subject .master
1387    wm withdraw .subject
1388    wm withdraw .master
1389    wm deiconify .master
1390    # idle handler should not map the transient
1391    update
1392    wm state .subject
1393} {withdrawn}
1394
1395test wm-transient-6.2 { a withdrawn transient does not track
1396        state changes in the master } {
1397    set results [list]
1398    deleteWindows
1399    toplevel .master
1400    toplevel .subject
1401    update
1402    wm transient .subject .master
1403    wm withdraw .subject
1404    wm withdraw .master
1405    wm deiconify .master
1406    # idle handler should not map the transient
1407    update
1408    lappend results [wm state .subject]
1409    wm deiconify .subject
1410    lappend results [wm state .subject]
1411    wm withdraw .master
1412    lappend results [wm state .subject]
1413    wm deiconify .master
1414    # idle handler should map transient
1415    update
1416    lappend results [wm state .subject]
1417} {withdrawn normal withdrawn normal}
1418
1419test wm-transient-6.3 { a withdrawn transient does not track
1420        state changes in the master } {
1421    deleteWindows
1422    toplevel .master
1423    toplevel .subject
1424    update
1425    # withdraw before making window a transient
1426    wm withdraw .subject
1427    wm transient .subject .master
1428    wm withdraw .master
1429    wm deiconify .master
1430    # idle handler should not map the transient
1431    update
1432    wm state .subject
1433} {withdrawn}
1434
1435# wm-transient-7.*: See SF Tk Bug #592201 "wm transient fails with two masters"
1436# wm-transient-7.3 through 7.5 all caused panics on Unix in Tk 8.4b1.
1437# 7.1 and 7.2 added to catch (potential) future errors.
1438#
1439test wm-transient-7.1 {Destroying transient} {
1440    deleteWindows
1441    toplevel .t 
1442    toplevel .transient 
1443    wm transient .transient .t
1444    destroy .transient
1445    destroy .t
1446    # OK: the above did not cause a panic.
1447} {}
1448
1449test wm-transient-7.2 {Destroying master} {
1450    deleteWindows
1451    toplevel .t
1452    toplevel .transient 
1453    wm transient .transient .t
1454    destroy .t
1455    set result [wm transient .transient]
1456    destroy .transient
1457    set result
1458} {}
1459
1460test wm-transient-7.3 {Reassign transient, destroy old master} {
1461    deleteWindows
1462    toplevel .t1 
1463    toplevel .t2 
1464    toplevel .transient
1465    wm transient .transient .t1
1466    wm transient .transient .t2
1467    destroy .t1	;# Caused panic in 8.4b1
1468    destroy .t2 
1469    destroy .transient
1470} {}
1471
1472test wm-transient-7.4 {Reassign transient, destroy new master} {
1473    deleteWindows
1474    toplevel .t1 
1475    toplevel .t2 
1476    toplevel .transient
1477    wm transient .transient .t1
1478    wm transient .transient .t2
1479    destroy .t2 	;# caused panic in 8.4b1
1480    destroy .t1
1481    destroy .transient
1482} {}
1483
1484test wm-transient-7.5 {Reassign transient, destroy transient} {
1485    deleteWindows
1486    toplevel .t1 
1487    toplevel .t2 
1488    toplevel .transient
1489    wm transient .transient .t1
1490    wm transient .transient .t2
1491    destroy .transient
1492    destroy .t2 	;# caused panic in 8.4b1
1493    destroy .t1		;# so did this
1494} {}
1495
1496test wm-state-1.1 {usage} {
1497    list [catch {wm state} err] $err
1498} {1 {wrong # args: should be "wm option window ?arg ...?"}}
1499
1500test wm-state-1.2 {usage} {
1501    list [catch {wm state . _ _} err] $err
1502} {1 {wrong # args: should be "wm state window ?state?"}}
1503
1504test wm-state-2.1 {initial state} {
1505    deleteWindows
1506    toplevel .t
1507    wm state .t
1508} {normal}
1509
1510test wm-state-2.2 {state change before map} {
1511    deleteWindows
1512    toplevel .t
1513    wm state .t withdrawn
1514    wm state .t
1515} {withdrawn}
1516
1517test wm-state-2.3 {state change before map} {
1518    deleteWindows
1519    toplevel .t
1520    wm withdraw .t
1521    wm state .t
1522} {withdrawn}
1523
1524test wm-state-2.4 {state change after map} {
1525    deleteWindows
1526    toplevel .t
1527    update
1528    wm state .t withdrawn
1529    wm state .t
1530} {withdrawn}
1531
1532test wm-state-2.5 {state change after map} {
1533    deleteWindows
1534    toplevel .t
1535    update
1536    wm withdraw .t
1537    wm state .t
1538} {withdrawn}
1539
1540test wm-state-2.6 {state change before map} {
1541    deleteWindows
1542    toplevel .t
1543    wm state .t iconic
1544    wm state .t
1545} {iconic}
1546
1547test wm-state-2.7 {state change before map} {
1548    deleteWindows
1549    toplevel .t
1550    wm iconify .t
1551    wm state .t
1552} {iconic}
1553
1554test wm-state-2.8 {state change after map} {
1555    deleteWindows
1556    toplevel .t
1557    update
1558    wm state .t iconic
1559    wm state .t
1560} {iconic}
1561
1562test wm-state-2.9 {state change after map} {
1563    deleteWindows
1564    toplevel .t
1565    update
1566    wm iconify .t
1567    wm state .t
1568} {iconic}
1569
1570test wm-state-2.10 {state change before map} {
1571    deleteWindows
1572    toplevel .t
1573    wm withdraw .t
1574    wm state .t normal
1575    wm state .t
1576} {normal}
1577
1578test wm-state-2.11 {state change before map} {
1579    deleteWindows
1580    toplevel .t
1581    wm withdraw .t
1582    wm deiconify .t
1583    wm state .t
1584} {normal}
1585
1586test wm-state-2.12 {state change after map} {
1587    deleteWindows
1588    toplevel .t
1589    update
1590    wm withdraw .t
1591    wm state .t normal
1592    wm state .t
1593} {normal}
1594
1595test wm-state-2.13 {state change after map} {
1596    deleteWindows
1597    toplevel .t
1598    update
1599    wm withdraw .t
1600    wm deiconify .t
1601    wm state .t
1602} {normal}
1603
1604test wm-state-2.14 {state change before map} {
1605    deleteWindows
1606    toplevel .t
1607    wm iconify .t
1608    wm state .t normal
1609    wm state .t
1610} {normal}
1611
1612test wm-state-2.15 {state change before map} {
1613    deleteWindows
1614    toplevel .t
1615    wm iconify .t
1616    wm deiconify .t
1617    wm state .t
1618} {normal}
1619
1620test wm-state-2.16 {state change after map} {
1621    deleteWindows
1622    toplevel .t
1623    update
1624    wm iconify .t
1625    wm state .t normal
1626    wm state .t
1627} {normal}
1628
1629test wm-state-2.17 {state change after map} {
1630    deleteWindows
1631    toplevel .t
1632    update
1633    wm iconify .t
1634    wm deiconify .t
1635    wm state .t
1636} {normal}
1637
1638test wm-state-2.18 {state change after map} {pcOnly} {
1639    deleteWindows
1640    toplevel .t
1641    update
1642    wm state .t zoomed
1643    wm state .t
1644} {zoomed}
1645
1646test wm-withdraw-1.1 {usage} {
1647    list [catch {wm withdraw} err] $err
1648} {1 {wrong # args: should be "wm option window ?arg ...?"}}
1649
1650test wm-withdraw-1.2 {usage} {
1651    list [catch {wm withdraw . _} msg] $msg
1652} {1 {wrong # args: should be "wm withdraw window"}}
1653
1654test wm-withdraw-2.1 {Misc errors} {
1655    deleteWindows
1656    toplevel .t
1657    toplevel .t2
1658    wm iconwindow .t .t2
1659    set result [list [catch {wm withdraw .t2} msg] $msg]
1660    destroy .t2
1661    set result
1662} {1 {can't withdraw .t2: it is an icon for .t}}
1663
1664test wm-withdraw-3.1 {} {
1665    update
1666    set result {}
1667    wm withdraw .t
1668    lappend result [wm state .t] [winfo ismapped .t]
1669    wm deiconify .t
1670    lappend result [wm state .t] [winfo ismapped .t]
1671} {withdrawn 0 normal 1}
1672
1673test wm-deletion-epoch-1.1 {Deletion epoch on multiple displays} {altDisplay} {
1674    # See Tk Bug #671330 "segfault when e.g. deiconifying destroyed window"
1675    deleteWindows
1676    set w [toplevel .t -screen $env(TK_ALT_DISPLAY)]
1677    wm deiconify $w         ;# this caches the WindowRep
1678    destroy .t
1679    list [catch {wm deiconify $w} msg] $msg
1680} {1 {bad window path name ".t"}}
1681
1682# FIXME:
1683
1684# Test delivery of virtual events to the WM. We could check to see
1685# if the window was raised after a button click for example.
1686# This sort of testing may not be possible.
1687
1688
1689deleteWindows
1690tcltest::cleanupTests
1691return
1692
1693
1694
1695