📄 unixwm.test
字号:
# This file is a Tcl script to test out Tk's interactions with# the window manager, including the "wm" command. It is organized# in the standard fashion for Tcl tests.## Copyright (c) 1992-1994 The Regents of the University of California.# Copyright (c) 1994-1997 Sun Microsystems, Inc.## See the file "license.terms" for information on usage and redistribution# of this file, and for a DISCLAIMER OF ALL WARRANTIES.## SCCS: @(#) unixWm.test 1.46 97/10/27 16:15:36if {$tcl_platform(platform) != "unix"} { return}if {[string compare test [info procs test]] == 1} { source defs}proc sleep ms { global x after $ms {set x 1} vwait x}# Procedure to set up a collection of top-level windowsproc makeToplevels {} { foreach i [winfo child .] { destroy $i } foreach i {.raise1 .raise2 .raise3} { toplevel $i wm geom $i 150x100+0+0 update }}set i 1foreach geom {+20+80 +80+20 +0+0} { catch {destroy .t} test unixWm-1.$i {initial window position} { toplevel .t -width 200 -height 150 wm geom .t $geom update wm geom .t } 200x150$geom incr i}# The tests below are tricky because window managers don't all move# windows correctly. Try one motion and compute the window manager's# error, then factor this error into the actual tests. In other words,# this just makes sure that things are consistent between moves.set i 1catch {destroy .t}toplevel .t -width 100 -height 150wm geom .t +200+200updatewm geom .t +150+150updatescan [wm geom .t] %dx%d+%d+%d width height x yset xerr [expr 150-$x]set yerr [expr 150-$y]foreach geom {+20+80 +80+20 +0+0 -0-0 +0-0 -0+0 -10-5 -10+5 +10-5} { test unixWm-2.$i {moving window while mapped} { wm geom .t $geom update scan [wm geom .t] %dx%d%1s%d%1s%d width height xsign x ysign y format "%s%d%s%d" $xsign [eval expr $x$xsign$xerr] $ysign \ [eval expr $y$ysign$yerr] } $geom incr i}set i 1foreach geom {+20+80 +80+20 +0+0 -0-0 +0-0 -0+0 -10-5 -10+5 +10-5} { test unixWm-3.$i {moving window while iconified} { wm iconify .t sleep 200 wm geom .t $geom update wm deiconify .t scan [wm geom .t] %dx%d%1s%d%1s%d width height xsign x ysign y format "%s%d%s%d" $xsign [eval expr $x$xsign$xerr] $ysign \ [eval expr $y$ysign$yerr] } $geom incr i}set i 1foreach geom {+20+80 +100+40 +0+0} { test unixWm-4.$i {moving window while withdrawn} { wm withdraw .t sleep 200 wm geom .t $geom update wm deiconify .t wm geom .t } 100x150$geom incr i}test unixWm-5.1 {compounded state changes} {nonPortable} { catch {destroy .t} toplevel .t -width 200 -height 100 wm geometry .t +100+100 update wm withdraw .t wm deiconify .t list [winfo ismapped .t] [wm state .t]} {1 normal}test unixWm-5.2 {compounded state changes} {nonPortable} { catch {destroy .t} toplevel .t -width 200 -height 100 wm geometry .t +100+100 update wm withdraw .t wm deiconify .t wm withdraw .t list [winfo ismapped .t] [wm state .t]} {0 withdrawn}test unixWm-5.3 {compounded state changes} {nonPortable} { catch {destroy .t} toplevel .t -width 200 -height 100 wm geometry .t +100+100 update wm iconify .t wm deiconify .t wm iconify .t wm deiconify .t list [winfo ismapped .t] [wm state .t]} {1 normal}test unixWm-5.4 {compounded state changes} {nonPortable} { catch {destroy .t} toplevel .t -width 200 -height 100 wm geometry .t +100+100 update wm iconify .t wm deiconify .t wm iconify .t list [winfo ismapped .t] [wm state .t]} {0 iconic}test unixWm-5.5 {compounded state changes} {nonPortable} { catch {destroy .t} toplevel .t -width 200 -height 100 wm geometry .t +100+100 update wm iconify .t wm withdraw .t list [winfo ismapped .t] [wm state .t]} {0 withdrawn}test unixWm-5.6 {compounded state changes} {nonPortable} { catch {destroy .t} toplevel .t -width 200 -height 100 wm geometry .t +100+100 update wm iconify .t wm withdraw .t wm deiconify .t list [winfo ismapped .t] [wm state .t]} {1 normal}test unixWm-5.7 {compounded state changes} {nonPortable} { catch {destroy .t} toplevel .t -width 200 -height 100 wm geometry .t +100+100 update wm withdraw .t wm iconify .t list [winfo ismapped .t] [wm state .t]} {0 iconic}catch {destroy .t}toplevel .t -width 200 -height 100wm geom .t +10+10wm minsize .t 1 1updatetest unixWm-6.1 {size changes} { .t config -width 180 -height 150 update wm geom .t} 180x150+10+10test unixWm-6.2 {size changes} { wm geom .t 250x60 .t config -width 170 -height 140 update wm geom .t} 250x60+10+10test unixWm-6.3 {size changes} { wm geom .t 250x60 .t config -width 170 -height 140 wm geom .t {} update wm geom .t} 170x140+10+10test unixWm-6.4 {size changes} {nonPortable} { wm minsize .t 1 1 update puts stdout "Please resize window \"t\" with the mouse (but don't move it!)," puts -nonewline stdout "then hit return: " flush stdout gets stdin update set width [winfo width .t] set height [winfo height .t] .t config -width 230 -height 110 update incr width -[winfo width .t] incr height -[winfo height .t] wm geom .t {} update set w2 [winfo width .t] set h2 [winfo height .t] .t config -width 114 -height 261 update list $width $height $w2 $h2 [wm geom .t]} {0 0 230 110 114x261+10+10}# I don't know why the wait below is needed, but without it the test# fails under twm.sleep 200test unixWm-6.5 {window initially iconic} {nonPortable} { catch {destroy .t} toplevel .t -width 100 -height 30 wm geometry .t +0+0 wm title .t 2 wm iconify .t update idletasks wm withdraw .t wm deiconify .t list [winfo ismapped .t] [wm state .t]} {1 normal}catch {destroy .m}toplevel .mwm overrideredirect .m 1foreach i {{Test label} Another {Yet another} {Last label}} j {1 2 3} { label .m.$j -text $i}wm geometry .m +[expr 100 - [winfo vrootx .]]+[expr 200 - [winfo vrooty .]]updatetest unixWm-7.1 {override_redirect and Tk_MoveTopLevelWindow} { list [winfo ismapped .m] [wm state .m] [winfo x .m] [winfo y .m]} {1 normal 100 200}wm geometry .m +[expr 150 - [winfo vrootx .]]+[expr 210 - [winfo vrooty .]]updatetest unixWm-7.2 {override_redirect and Tk_MoveTopLevelWindow} { list [winfo ismapped .m] [wm state .m] [winfo x .m] [winfo y .m]} {1 normal 150 210}wm withdraw .mtest unixWm-7.3 {override_redirect and Tk_MoveTopLevelWindow} { list [winfo ismapped .m]} 0destroy .mcatch {destroy .t}test unixWm-8.1 {icon windows} { catch {destroy .t} catch {destroy .icon} toplevel .t -width 100 -height 30 wm geometry .t +0+0 toplevel .icon -width 50 -height 50 -bg red wm iconwindow .t .icon list [catch {wm withdraw .icon} msg] $msg} {1 {can't withdraw .icon: it is an icon for .t}}test unixWm-8.2 {icon windows} { catch {destroy .t} toplevel .t -width 100 -height 30 list [catch {wm iconwindow} msg] $msg} {1 {wrong # args: should be "wm option window ?arg ...?"}}test unixWm-8.3 {icon windows} { catch {destroy .t} toplevel .t -width 100 -height 30 list [catch {wm iconwindow .t b c} msg] $msg} {1 {wrong # arguments: must be "wm iconwindow window ?pathName?"}}test unixWm-8.4 {icon windows} { catch {destroy .t} catch {destroy .icon} toplevel .t -width 100 -height 30 wm geom .t +0+0 set result [wm iconwindow .t] toplevel .icon -width 50 -height 50 -bg red wm iconwindow .t .icon lappend result [wm iconwindow .t] [wm state .icon] wm iconwindow .t {} lappend result [wm iconwindow .t] [wm state .icon] update lappend result [winfo ismapped .t] [winfo ismapped .icon] wm iconify .t update lappend result [winfo ismapped .t] [winfo ismapped .icon]} {.icon icon {} withdrawn 1 0 0 0}test unixWm-8.5 {icon windows} { catch {destroy .t} toplevel .t -width 100 -height 30 list [catch {wm iconwindow .t .gorp} msg] $msg} {1 {bad window path name ".gorp"}}test unixWm-8.6 {icon windows} { catch {destroy .t} toplevel .t -width 100 -height 30 frame .t.icon -width 50 -height 50 -bg red list [catch {wm iconwindow .t .t.icon} msg] $msg} {1 {can't use .t.icon as icon window: not at top level}}test unixWm-8.7 {icon windows} { catch {destroy .t} catch {destroy .icon} toplevel .t -width 100 -height 30 wm geom .t +0+0 toplevel .icon -width 50 -height 50 -bg red toplevel .icon2 -width 50 -height 50 -bg green wm iconwindow .t .icon set result "[wm iconwindow .t] [wm state .icon] [wm state .icon2]" wm iconwindow .t .icon2 lappend result [wm iconwindow .t] [wm state .icon] [wm state .icon2]} {.icon icon normal .icon2 withdrawn icon}catch {destroy .icon2}test unixWm-8.8 {icon windows} { catch {destroy .t} catch {destroy .icon} toplevel .icon -width 50 -height 50 -bg red wm geom .icon +0+0 update set result [winfo ismapped .icon] toplevel .t -width 100 -height 30 wm geom .t +0+0 tkwait visibility .t ;# Needed to keep tvtwm happy. wm iconwindow .t .icon sleep 500 lappend result [winfo ismapped .t] [winfo ismapped .icon]} {1 1 0}test unixWm-8.9 {icon windows} {nonPortable} { # This test is non-portable because some window managers will # destroy an icon window when it's associated window is destroyed. catch {destroy .t} catch {destroy .icon} toplevel .t -width 100 -height 30 toplevel .icon -width 50 -height 50 -bg red wm geom .t +0+0 wm iconwindow .t .icon update set result "[wm state .icon] [winfo ismapped .t] [winfo ismapped .icon]" destroy .t wm geom .icon +0+0 update lappend result [winfo ismapped .icon] [wm state .icon] wm deiconify .icon update lappend result [winfo ismapped .icon] [wm state .icon]} {icon 1 0 0 withdrawn 1 normal}if {[string compare testwrapper [info commands testwrapper]] != 0} { puts "This application hasn't been compiled with the testwrapper command," puts "therefore I am skipping all of these tests." return}test unixWm-9.1 {TkWmMapWindow procedure, client property} {unixOnly} { catch {destroy .t} toplevel .t -width 100 -height 50 wm geom .t +0+0 wm client .t Test_String update testprop [testwrapper .t] WM_CLIENT_MACHINE} {Test_String}test unixWm-9.2 {TkWmMapWindow procedure, command property} {unixOnly} { catch {destroy .t} toplevel .t -width 100 -height 50 wm geom .t +0+0 wm command .t "test command" update
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -