diff options
author | aniap <aniap> | 2008-08-28 08:52:05 (GMT) |
---|---|---|
committer | aniap <aniap> | 2008-08-28 08:52:05 (GMT) |
commit | 7e6d5b3fd3337023a42b2ac04b2f16166953b02d (patch) | |
tree | aa7de761e87fa2ed8f82401a5e61b935969201cf /tests/place.test | |
parent | 17d41c87b3ea1ed10b1170baa6813c808421e089 (diff) | |
download | tk-7e6d5b3fd3337023a42b2ac04b2f16166953b02d.zip tk-7e6d5b3fd3337023a42b2ac04b2f16166953b02d.tar.gz tk-7e6d5b3fd3337023a42b2ac04b2f16166953b02d.tar.bz2 |
Update to tcltest2
Diffstat (limited to 'tests/place.test')
-rw-r--r-- | tests/place.test | 437 |
1 files changed, 256 insertions, 181 deletions
diff --git a/tests/place.test b/tests/place.test index c2a4042..7602766 100644 --- a/tests/place.test +++ b/tests/place.test @@ -5,9 +5,10 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: place.test,v 1.11 2004/09/16 18:01:20 pspjuth Exp $ +# RCS: @(#) $Id: place.test,v 1.12 2008/08/28 08:52:05 aniap Exp $ -package require tcltest 2.1 +package require tcltest 2.2 +namespace import ::tcltest::* eval tcltest::configure $argv tcltest::loadTestedCommands @@ -17,6 +18,7 @@ testConstraint memory [llength [info commands memory]] # XXX - This test file is woefully incomplete. At present, only a # few of the features are tested. +# Widgets used in tests 1.* - 8.* toplevel .t -width 300 -height 200 -bd 0 wm geom .t +0+0 frame .t.f -width 154 -height 84 -bd 2 -relief raised @@ -24,145 +26,181 @@ place .t.f -x 48 -y 38 frame .t.f2 -width 30 -height 60 -bd 2 -relief raised update -test place-1.1 {Tk_PlaceCmd procedure, "info" option} { +test place-1.1 {Tk_PlaceCmd procedure, "info" option} -setup { + place forget .t.f2 +} -body { place .t.f2 -x 0 place info .t.f2 -} {-in .t -x 0 -relx 0 -y 0 -rely 0 -width {} -relwidth {} -height {} -relheight {} -anchor nw -bordermode inside} -test place-1.2 {Tk_PlaceCmd procedure, "info" option} { +} -result {-in .t -x 0 -relx 0 -y 0 -rely 0 -width {} -relwidth {} -height {} -relheight {} -anchor nw -bordermode inside} +test place-1.2 {Tk_PlaceCmd procedure, "info" option} -setup { + place forget .t.f2 +} -body { place .t.f2 -x 1 -y 2 -width 3 -height 4 -relx 0.1 -rely 0.2 \ - -relwidth 0.3 -relheight 0.4 -anchor se -in .t.f \ - -bordermode outside + -relwidth 0.3 -relheight 0.4 -anchor se -in .t.f \ + -bordermode outside place info .t.f2 -} {-in .t.f -x 1 -relx 0.1 -y 2 -rely 0.2 -width 3 -relwidth 0.3 -height 4 -relheight 0.4 -anchor se -bordermode outside} -test place-1.3 {Tk_PlaceCmd procedure, "info" option} { +} -result {-in .t.f -x 1 -relx 0.1 -y 2 -rely 0.2 -width 3 -relwidth 0.3 -height 4 -relheight 0.4 -anchor se -bordermode outside} +test place-1.3 {Tk_PlaceCmd procedure, "info" option} -setup { + place forget .t.f2 + destroy .t.a.b +} -body { # Make sure the result is built as a proper list by using a space in parent frame ".t.a b" place .t.f2 -x 1 -y 2 -width {} -height 4 -relx 0.2 -rely 0.2 \ - -relwidth 0.3 -relheight {} -anchor w -in ".t.a b" \ - -bordermode ignore - set res [place info .t.f2] - destroy ".t.a b" - set res -} {-in {.t.a b} -x 1 -relx 0.2 -y 2 -rely 0.2 -width {} -relwidth 0.3 -height 4 -relheight {} -anchor w -bordermode ignore} - -test place-2.1 {ConfigureSlave procedure, -height option} { - list [catch {place .t.f2 -height abcd} msg] $msg -} {1 {bad screen distance "abcd"}} -test place-2.2 {ConfigureSlave procedure, -height option} { + -relwidth 0.3 -relheight {} -anchor w -in ".t.a b" \ + -bordermode ignore + place info .t.f2 +} -cleanup { + destroy ".t.a.b" +} -result {-in {.t.a b} -x 1 -relx 0.2 -y 2 -rely 0.2 -width {} -relwidth 0.3 -height 4 -relheight {} -anchor w -bordermode ignore} + + +test place-2.1 {ConfigureSlave procedure, -height option} -body { + place .t.f2 -height abcd +} -returnCodes error -result {bad screen distance "abcd"} +test place-2.2 {ConfigureSlave procedure, -height option} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -height 40 update winfo height .t.f2 -} {40} -test place-2.3 {ConfigureSlave procedure, -height option} { +} -result {40} +test place-2.3 {ConfigureSlave procedure, -height option} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -height 120 update place .t.f2 -height {} update winfo height .t.f2 -} {60} +} -result {60} -test place-3.1 {ConfigureSlave procedure, -relheight option} { - list [catch {place .t.f2 -relheight abcd} msg] $msg -} {1 {expected floating-point number but got "abcd"}} -test place-3.2 {ConfigureSlave procedure, -relheight option} { + +test place-3.1 {ConfigureSlave procedure, -relheight option} -body { + place .t.f2 -relheight abcd +} -returnCodes error -result {expected floating-point number but got "abcd"} +test place-3.2 {ConfigureSlave procedure, -relheight option} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -relheight .5 update winfo height .t.f2 -} {40} -test place-3.3 {ConfigureSlave procedure, -relheight option} { +} -result {40} +test place-3.3 {ConfigureSlave procedure, -relheight option} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -relheight .8 update place .t.f2 -relheight {} update winfo height .t.f2 -} {60} +} -result {60} + -test place-4.1 {ConfigureSlave procedure, bad -in options} { +test place-4.1 {ConfigureSlave procedure, bad -in options} -setup { + place forget .t.f2 +} -body { + place .t.f2 -in .t.f2 +} -returnCodes error -result {can't place .t.f2 relative to itself} +test place-4.2 {ConfigureSlave procedure, bad -in option} -setup { place forget .t.f2 - list [catch {place .t.f2 -in .t.f2} msg] $msg -} [list 1 "can't place .t.f2 relative to itself"] -test place-4.2 {ConfigureSlave procedure, bad -in option} { +} -body { + set result [list [winfo manager .t.f2]] + catch {place .t.f2 -in .t.f2} + lappend result [winfo manager .t.f2] +} -result {{} {}} +test place-4.3 {ConfigureSlave procedure, bad -in option} -setup { place forget .t.f2 - list [winfo manager .t.f2] \ - [catch {place .t.f2 -in .t.f2} err] $err \ - [winfo manager .t.f2] -} {{} 1 {can't place .t.f2 relative to itself} {}} -test place-4.3 {ConfigureSlave procedure, bad -in option} { +} -body { + winfo manager .t.f2 + place .t.f2 -in .t.f2 +} -returnCodes error -result {can't place .t.f2 relative to itself} +test place-4.4 {ConfigureSlave procedure, bad -in option} -setup { place forget .t.f2 - list [catch {place .t.f2 -in .} msg] $msg -} [list 1 "can't place .t.f2 relative to ."] +} -body { + place .t.f2 -in . +} -returnCodes error -result {can't place .t.f2 relative to .} -test place-5.1 {ConfigureSlave procedure, -relwidth option} { - list [catch {place .t.f2 -relwidth abcd} msg] $msg -} {1 {expected floating-point number but got "abcd"}} -test place-5.2 {ConfigureSlave procedure, -relwidth option} { + +test place-5.1 {ConfigureSlave procedure, -relwidth option} -body { + place .t.f2 -relwidth abcd +} -returnCodes error -result {expected floating-point number but got "abcd"} +test place-5.2 {ConfigureSlave procedure, -relwidth option} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -relwidth .5 update winfo width .t.f2 -} {75} -test place-5.3 {ConfigureSlave procedure, -relwidth option} { +} -result {75} +test place-5.3 {ConfigureSlave procedure, -relwidth option} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -relwidth .8 update place .t.f2 -relwidth {} update winfo width .t.f2 -} {30} +} -result {30} -test place-6.1 {ConfigureSlave procedure, -width option} { - list [catch {place .t.f2 -width abcd} msg] $msg -} {1 {bad screen distance "abcd"}} -test place-6.2 {ConfigureSlave procedure, -width option} { +test place-6.1 {ConfigureSlave procedure, -width option} -body { + place .t.f2 -width abcd +} -returnCodes error -result {bad screen distance "abcd"} +test place-6.2 {ConfigureSlave procedure, -width option} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -width 100 update winfo width .t.f2 -} {100} -test place-6.3 {ConfigureSlave procedure, -width option} { +} -result {100} +test place-6.3 {ConfigureSlave procedure, -width option} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -width 120 update place .t.f2 -width {} update winfo width .t.f2 -} {30} +} -result {30} + -test place-7.1 {ReconfigurePlacement procedure, computing position} { +test place-7.1 {ReconfigurePlacement procedure, computing position} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -x -2 -relx .5 -y 3 -rely .4 update winfo geometry .t.f2 -} {30x60+123+75} -test place-7.2 {ReconfigurePlacement procedure, position rounding} { +} -result {30x60+123+75} +test place-7.2 {ReconfigurePlacement procedure, position rounding} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -x -1.4 -y -2.3 update winfo geometry .t.f2 -} {30x60+49+38} -test place-7.3 {ReconfigurePlacement procedure, position rounding} { +} -result {30x60+49+38} +test place-7.3 {ReconfigurePlacement procedure, position rounding} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -x 1.4 -y 2.3 update winfo geometry .t.f2 -} {30x60+51+42} -test place-7.4 {ReconfigurePlacement procedure, position rounding} { +} -result {30x60+51+42} +test place-7.4 {ReconfigurePlacement procedure, position rounding} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -x -1.6 -y -2.7 update winfo geometry .t.f2 -} {30x60+48+37} -test place-7.5 {ReconfigurePlacement procedure, position rounding} { +} -result {30x60+48+37} +test place-7.5 {ReconfigurePlacement procedure, position rounding} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -x 1.6 -y 2.7 update winfo geometry .t.f2 -} {30x60+52+43} -test place-7.6 {ReconfigurePlacement procedure, position rounding} { +} -result {30x60+52+43} +test place-7.6 {ReconfigurePlacement procedure, position rounding} -setup { + destroy .t.f3 +} -body { frame .t.f3 -width 100 -height 100 -bg #f00000 -bd 0 place .t.f3 -x 0 -y 0 raise .t.f2 @@ -170,38 +208,44 @@ test place-7.6 {ReconfigurePlacement procedure, position rounding} { place .t.f2 -in .t.f3 -relx .303 -rely .406 -relwidth .304 -relheight .206 update winfo geometry .t.f2 -} {31x20+30+41} -catch {destroy .t.f3} -test place-7.7 {ReconfigurePlacement procedure, computing size} { +} -cleanup { + destroy .t.f3 +} -result {31x20+30+41} +test place-7.7 {ReconfigurePlacement procedure, computing size} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -width 120 -height 89 update list [winfo width .t.f2] [winfo height .t.f2] -} {120 89} -test place-7.8 {ReconfigurePlacement procedure, computing size} { +} -result {120 89} +test place-7.8 {ReconfigurePlacement procedure, computing size} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -relwidth .4 -relheight .5 update list [winfo width .t.f2] [winfo height .t.f2] -} {60 40} -test place-7.9 {ReconfigurePlacement procedure, computing size} { +} -result {60 40} +test place-7.9 {ReconfigurePlacement procedure, computing size} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -width 10 -relwidth .4 -height -4 -relheight .5 update list [winfo width .t.f2] [winfo height .t.f2] -} {70 36} -test place-7.10 {ReconfigurePlacement procedure, computing size} { +} -result {70 36} +test place-7.10 {ReconfigurePlacement procedure, computing size} -setup { place forget .t.f2 +} -body { place .t.f2 -in .t.f -width 10 -relwidth .4 -height -4 -relheight .5 place .t.f2 -width {} -relwidth {} -height {} -relheight {} update list [winfo width .t.f2] [winfo height .t.f2] -} {30 60} +} -result {30 60} -test place-8.1 {MasterStructureProc, mapping and unmapping slaves} { +test place-8.1 {MasterStructureProc, mapping and unmapping slaves} -setup { place forget .t.f2 place forget .t.f +} -body { place .t.f2 -relx 1.0 -rely 1.0 -anchor sw update set result [winfo ismapped .t.f2] @@ -214,10 +258,11 @@ test place-8.1 {MasterStructureProc, mapping and unmapping slaves} { wm deiconify .t update lappend result [winfo ismapped .t.f2] -} {1 0 40 30 0 1} -test place-8.2 {MasterStructureProc, mapping and unmapping slaves} { +} -result {1 0 40 30 0 1} +test place-8.2 {MasterStructureProc, mapping and unmapping slaves} -setup { place forget .t.f2 place forget .t.f +} -body { place .t.f -x 0 -y 0 -width 200 -height 100 place .t.f2 -in .t.f -relx 1.0 -rely 1.0 -anchor sw -width 50 -height 20 update @@ -231,130 +276,153 @@ test place-8.2 {MasterStructureProc, mapping and unmapping slaves} { wm deiconify .t update lappend result [winfo ismapped .t.f2] -} {1 0 42 32 0 1} - -test place-9.1 {PlaceObjCmd} { - list [catch {place} msg] $msg -} [list 1 "wrong # args: should be \"place option|pathName args\""] -test place-9.2 {PlaceObjCmd} { - list [catch {place foo} msg] $msg -} [list 1 "wrong # args: should be \"place option|pathName args\""] -test place-9.3 {PlaceObjCmd} { - catch {destroy .foo} - list [catch {place .foo bar} msg] $msg -} [list 1 "bad window path name \".foo\""] -test place-9.4 {PlaceObjCmd} { - catch {destroy .foo} - list [catch {place bar .foo} msg] $msg -} [list 1 "bad window path name \".foo\""] -test place-9.5 {PlaceObjCmd} { - catch {destroy .foo} +} -result {1 0 42 32 0 1} +destroy .t + + +test place-9.1 {PlaceObjCmd} -body { + place +} -returnCodes error -result {wrong # args: should be "place option|pathName args"} +test place-9.2 {PlaceObjCmd} -body { + place foo +} -returnCodes error -result {wrong # args: should be "place option|pathName args"} +test place-9.3 {PlaceObjCmd} -setup { + destroy .foo +} -body { + place .foo bar +} -returnCodes error -result {bad window path name ".foo"} +test place-9.4 {PlaceObjCmd} -setup { + destroy .foo +} -body { + place bar .foo +} -cleanup { + destroy .foo +} -returnCodes error -result {bad window path name ".foo"} +test place-9.5 {PlaceObjCmd} -setup { + destroy .foo +} -body { frame .foo - set res [list [catch {place badopt .foo} msg] $msg] + place badopt .foo +} -cleanup { destroy .foo - set res -} [list 1 "bad option \"badopt\": must be configure, forget, info, or slaves"] -test place-9.6 {PlaceObjCmd, configure errors} { - catch {destroy .foo} +} -returnCodes error -result {bad option "badopt": must be configure, forget, info, or slaves} +test place-9.6 {PlaceObjCmd, configure errors} -setup { + destroy .foo +} -body { frame .foo - set res [list [catch {place configure .foo} msg] $msg] + place configure .foo +} -cleanup { + destroy .foo +} -returnCodes ok -result {} +test place-9.7 {PlaceObjCmd, configure errors} -setup { destroy .foo - set res -} [list 0 ""] -test place-9.7 {PlaceObjCmd, configure errors} { - catch {destroy .foo} +} -body { frame .foo - set res [list [catch {place configure .foo bar} msg] $msg] + place configure .foo bar +} -cleanup { + destroy .foo +} -returnCodes ok -result {} +test place-9.8 {PlaceObjCmd, configure} -setup { destroy .foo - set res -} [list 0 ""] -test place-9.8 {PlaceObjCmd, configure} { - catch {destroy .foo} +} -body { frame .foo place .foo -x 0 -y 0 - set res [place configure .foo] + place configure .foo +} -cleanup { destroy .foo - set res -} [list {-anchor {} {} nw nw} {-bordermode {} {} inside inside} {-height {} {} {} {}} {-in {} {} {} .} {-relheight {} {} {} {}} {-relwidth {} {} {} {}} {-relx {} {} 0 0.0} {-rely {} {} 0 0.0} {-width {} {} {} {}} {-x {} {} 0 0} {-y {} {} 0 0}] -test place-9.9 {PlaceObjCmd, configure} { - catch {destroy .foo} +} -result [list {-anchor {} {} nw nw} {-bordermode {} {} inside inside} {-height {} {} {} {}} {-in {} {} {} .} {-relheight {} {} {} {}} {-relwidth {} {} {} {}} {-relx {} {} 0 0.0} {-rely {} {} 0 0.0} {-width {} {} {} {}} {-x {} {} 0 0} {-y {} {} 0 0}] +test place-9.9 {PlaceObjCmd, configure} -setup { + destroy .foo +} -body { frame .foo place .foo -x 0 -y 0 - set res [place configure .foo -x] + place configure .foo -x +} -cleanup { + destroy .foo +} -result {-x {} {} 0 0} +test place-9.10 {PlaceObjCmd, forget errors} -setup { destroy .foo - set res -} [list -x {} {} 0 0] -test place-9.10 {PlaceObjCmd, forget errors} { - catch {destroy .foo} +} -body { frame .foo - set res [list [catch {place forget .foo bar} msg] $msg] + place forget .foo bar +} -cleanup { destroy .foo - set res -} [list 1 "wrong # args: should be \"place forget pathName\""] -test place-9.11 {PlaceObjCmd, info errors} { - catch {destroy .foo} +} -returnCodes error -result {wrong # args: should be "place forget pathName"} +test place-9.11 {PlaceObjCmd, info errors} -setup { + destroy .foo +} -body { frame .foo - set res [list [catch {place info .foo bar} msg] $msg] + place info .foo bar +} -cleanup { + destroy .foo +} -returnCodes error -result {wrong # args: should be "place info pathName"} +test place-9.12 {PlaceObjCmd, slaves errors} -setup { destroy .foo - set res -} [list 1 "wrong # args: should be \"place info pathName\""] -test place-9.12 {PlaceObjCmd, slaves errors} { - catch {destroy .foo} +} -body { frame .foo - set res [list [catch {place slaves .foo bar} msg] $msg] + place slaves .foo bar +} -cleanup { destroy .foo - set res -} [list 1 "wrong # args: should be \"place slaves pathName\""] - -test place-10.1 {ConfigureSlave} { - catch {destroy .foo} +} -returnCodes error -result {wrong # args: should be "place slaves pathName"} + + +test place-10.1 {ConfigureSlave} -setup { + destroy .foo +} -body { frame .foo - set res [list [catch {place .foo -badopt} msg] $msg] + place .foo -badopt +} -cleanup { destroy .foo - set res -} [list 1 "unknown option \"-badopt\""] -test place-10.2 {ConfigureSlave} { - catch {destroy .foo} +} -returnCodes error -result {unknown option "-badopt"} +test place-10.2 {ConfigureSlave} -setup { + destroy .foo +} -body { frame .foo - set res [list [catch {place .foo -anchor} msg] $msg] + place .foo -anchor +} -cleanup { + destroy .foo +} -returnCodes error -result {value for "-anchor" missing} +test place-10.3 {ConfigureSlave} -setup { destroy .foo - set res -} [list 1 "value for \"-anchor\" missing"] -test place-10.3 {ConfigureSlave} { - catch {destroy .foo} +} -body { frame .foo - set res [list [catch {place .foo -bordermode j} msg] $msg] + place .foo -bordermode j +} -cleanup { + destroy .foo +} -returnCodes error -result {bad bordermode "j": must be inside, outside, or ignore} +test place-10.4 {ConfigureSlave} -setup { destroy .foo - set res -} [list 1 "bad bordermode \"j\": must be inside, outside, or ignore"] -test place-10.4 {ConfigureSlave} { - catch {destroy .foo} +} -body { frame .foo - set res [list [catch {place configure .foo -x 0 -y} msg] $msg] + place configure .foo -x 0 -y +} -cleanup { + destroy .foo +} -returnCodes error -result {value for "-y" missing} + + +test place-11.1 {PlaceObjCmd, slaves command} -setup { destroy .foo - set res -} [list 1 "value for \"-y\" missing"] - -test place-11.1 {PlaceObjCmd, slaves command} { - catch {destroy .foo} +} -body { frame .foo - set res [place slaves .foo] + place slaves .foo +} -cleanup { destroy .foo - set res -} {} -test place-11.2 {PlaceObjCmd, slaves command} { - catch {destroy .foo .bar} +} -result {} +test place-11.2 {PlaceObjCmd, slaves command} -setup { + destroy .foo .bar +} -body { frame .foo frame .bar place .bar -in .foo - set res [place slaves .foo] - destroy .foo - destroy .bar - set res -} [list .bar] + place slaves .foo +} -cleanup { + destroy .foo .bar +} -result [list .bar] + -test place-12.1 {PlaceObjCmd, forget command} { - catch {destroy .foo} +test place-12.1 {PlaceObjCmd, forget command} -setup { + destroy .foo +} -body { frame .foo place .foo -width 50 -height 50 update @@ -362,11 +430,14 @@ test place-12.1 {PlaceObjCmd, forget command} { place forget .foo update lappend res [winfo ismapped .foo] +} -cleanup { destroy .foo - set res -} [list 1 0] +} -result {1 0} + -test place-13.1 {test respect for internalborder} { +test place-13.1 {test respect for internalborder} -setup { + destroy .pack +} -body { toplevel .pack wm geometry .pack 200x200 frame .pack.l -width 15 -height 10 @@ -379,11 +450,13 @@ test place-13.1 {test respect for internalborder} { .pack.lf configure -labelanchor e -padx 3 -pady 5 update lappend res [winfo geometry .pack.lf.f] +} -cleanup { destroy .pack - set res -} {196x188+2+10 177x186+5+7} +} -result {196x188+2+10 177x186+5+7} -test place-14.1 {memory leak testing} -setup { + +test place-14.1 {memory leak testing} -constraints memory -setup { + destroy .f proc getbytes {} { set lines [split [memory info] "\n"] lindex [lindex $lines 3] 3 @@ -402,7 +475,7 @@ test place-14.1 {memory leak testing} -setup { } return $res } -} -constraints memory -body { +} -body { # Test all manners of forgetting a slave frame .f frame .f.f @@ -418,14 +491,16 @@ test place-14.1 {memory leak testing} -setup { frame .f frame .f.f } -} -result {0 0 0} -cleanup { +} -cleanup { destroy .f rename getbytes {} rename stress {} -} +} -result {0 0 0} -catch {destroy .t} # cleanup cleanupTests return + + + |