diff options
author | dgp <dgp@noemail.net> | 2002-07-13 21:52:32 (GMT) |
---|---|---|
committer | dgp <dgp@noemail.net> | 2002-07-13 21:52:32 (GMT) |
commit | 701540fb99eaeea087e645b17d7b77ff54d494db (patch) | |
tree | e1c87e388ed78c9f631d3cf202385b697ce25ab6 | |
parent | d52603819a3ce8cbe539f4df35921657f50dd698 (diff) | |
download | tk-701540fb99eaeea087e645b17d7b77ff54d494db.zip tk-701540fb99eaeea087e645b17d7b77ff54d494db.tar.gz tk-701540fb99eaeea087e645b17d7b77ff54d494db.tar.bz2 |
* Converted more files to tcltest and factored out common code.
FossilOrigin-Name: d09771c3b3deef776329be024a510a5b648381f6
-rw-r--r-- | ChangeLog | 2 | ||||
-rw-r--r-- | tests/constraints.tcl | 2 | ||||
-rw-r--r-- | tests/geometry.test | 14 | ||||
-rw-r--r-- | tests/get.test | 17 | ||||
-rw-r--r-- | tests/grab.test | 14 | ||||
-rw-r--r-- | tests/grid.test | 13 | ||||
-rw-r--r-- | tests/id.test | 22 | ||||
-rw-r--r-- | tests/image.test | 93 | ||||
-rw-r--r-- | tests/imgBmap.test | 18 | ||||
-rw-r--r-- | tests/imgPPM.test | 18 | ||||
-rw-r--r-- | tests/imgPhoto.test | 97 | ||||
-rw-r--r-- | tests/listbox.test | 16 | ||||
-rw-r--r-- | tests/macEmbed.test | 27 | ||||
-rw-r--r-- | tests/unixEmbed.test | 4 | ||||
-rw-r--r-- | tests/unixWm.test | 4 | ||||
-rw-r--r-- | tests/winfo.test | 5 |
16 files changed, 166 insertions, 200 deletions
@@ -1,7 +1,7 @@ 2002-07-12 Don Porter <dgp@users.sf.net> * tests/constraints.tcl: Converted more files to tcltest and - * tests/[m-x]*.test: factored out common code. + * tests/[g-x]*.test: factored out common code. 2002-07-11 Don Porter <dgp@users.sf.net> diff --git a/tests/constraints.tcl b/tests/constraints.tcl index f58cf67..196c216 100644 --- a/tests/constraints.tcl +++ b/tests/constraints.tcl @@ -109,6 +109,8 @@ testConstraint altDisplay [info exists env(TK_ALT_DISPLAY)] testConstraint noExceed [expr {![testConstraint unix] || [catch {font actual "\{xyz"}]}] testConstraint testImageType [expr {[lsearch [image types] test] >= 0}] +testConstraint testembed [llength [info commands testembed]] +testConstraint testwrapper [llength [info commands testwrapper]] testConstraint fonts 1 destroy .e entry .e -width 0 -font {Helvetica -12} -bd 1 diff --git a/tests/geometry.test b/tests/geometry.test index 615ccc7..0f3fda3 100644 --- a/tests/geometry.test +++ b/tests/geometry.test @@ -7,15 +7,15 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: geometry.test,v 1.3 1999/04/16 01:51:37 stanton Exp $ +# RCS: @(#) $Id: geometry.test,v 1.4 2002/07/13 21:52:34 dgp Exp $ -if {[lsearch [namespace children] ::tcltest] == -1} { - source [file join [pwd] [file dirname [info script]] defs.tcl] -} +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 -foreach i [winfo children .] { - destroy $i -} wm geometry . 300x300 raise . update diff --git a/tests/get.test b/tests/get.test index bf6dc44..aae8010 100644 --- a/tests/get.test +++ b/tests/get.test @@ -6,15 +6,14 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: get.test,v 1.2 1999/04/16 01:51:38 stanton Exp $ - -if {[lsearch [namespace children] ::tcltest] == -1} { - source [file join [pwd] [file dirname [info script]] defs.tcl] -} - -eval destroy [winfo children .] -wm geometry . {} -raise . +# RCS: @(#) $Id: get.test,v 1.3 2002/07/13 21:52:34 dgp 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 button .b test get-1.1 {Tk_GetAnchorFromObj} { diff --git a/tests/grab.test b/tests/grab.test index b1fd106..4ad8aea 100644 --- a/tests/grab.test +++ b/tests/grab.test @@ -7,11 +7,14 @@ # Copyright (c) 1998-2000 by Ajuba Solutions. # All rights reserved. # -# RCS: @(#) $Id: grab.test,v 1.1 2000/08/04 00:46:33 ericm Exp $ +# RCS: @(#) $Id: grab.test,v 1.2 2002/07/13 21:52:34 dgp Exp $ -if {[lsearch [namespace children] ::tcltest] == -1} { - source [file join [pwd] [file dirname [info script]] defs.tcl] -} +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 # There's currently no way to test the actual grab effect, per se, # in an automated test. Therefore, this test suite only covers the @@ -177,3 +180,6 @@ test grab-5.2 {Tk_GrabObjCmd, grab set} { grab release . set result } [list "." "global"] + +tcltest::cleanupTests +return diff --git a/tests/grid.test b/tests/grid.test index 471226f..daeef7e 100644 --- a/tests/grid.test +++ b/tests/grid.test @@ -5,11 +5,14 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: grid.test,v 1.15 2001/09/30 19:01:58 pspjuth Exp $ - -if {[lsearch [namespace children] ::tcltest] == -1} { - source [file join [pwd] [file dirname [info script]] defs.tcl] -} +# RCS: @(#) $Id: grid.test,v 1.16 2002/07/13 21:52:34 dgp 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 # helper routine to return "." to a sane state after a test # The variable GRID_VERBOSE can be used to "look" at the result diff --git a/tests/id.test b/tests/id.test index bfaa741..7e3f958 100644 --- a/tests/id.test +++ b/tests/id.test @@ -6,20 +6,14 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: id.test,v 1.5 2001/09/21 20:38:18 hobbs Exp $ - -if {[lsearch [namespace children] ::tcltest] == -1} { - source [file join [pwd] [file dirname [info script]] defs.tcl] -} - -set ::tcltest::testConfig(testwrapper) \ - [llength [info commands testwrapper]] - -foreach i [winfo children .] { - destroy $i -} -wm geometry . {} -raise . +# RCS: @(#) $Id: id.test,v 1.6 2002/07/13 21:52:34 dgp 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 test id-1.1 {WindowIdCleanup, delaying window release} {unixOnly testwrapper} { bind all <Destroy> {lappend x %W} diff --git a/tests/image.test b/tests/image.test index cd6cb21..384c38a 100644 --- a/tests/image.test +++ b/tests/image.test @@ -7,25 +7,18 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: image.test,v 1.6 2000/11/29 15:47:05 dkf Exp $ +# RCS: @(#) $Id: image.test,v 1.7 2002/07/13 21:52:34 dgp Exp $ -if {[lsearch [namespace children] ::tcltest] == -1} { - source [file join [pwd] [file dirname [info script]] defs.tcl] -} +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 -if {[lsearch [image types] test] < 0} { - puts "This application hasn't been compiled with the \"test\" image" - puts "type, so I can't run this test. Are you sure you're using" - puts "tktest instead of wish?" - ::tcltest::cleanupTests - return -} - -foreach i [winfo children .] { - destroy $i -} -wm geometry . {} -raise . +namespace import -force tcltest::interpreter +namespace import -force tcltest::makeFile +namespace import -force tcltest::removeFile eval image delete [image names] canvas .c -highlightthickness 2 @@ -43,16 +36,16 @@ test image-1.3 {Tk_ImageCmd procedure, "create" option} { test image-1.4 {Tk_ImageCmd procedure, "create" option} { list [catch {image c bad_type} msg] $msg } {1 {image type "bad_type" doesn't exist}} -test image-1.5 {Tk_ImageCmd procedure, "create" option} { +test image-1.5 {Tk_ImageCmd procedure, "create" option} testImageType { list [image create test myimage] [image names] } {myimage myimage} -test image-1.6 {Tk_ImageCmd procedure, "create" option} { +test image-1.6 {Tk_ImageCmd procedure, "create" option} testImageType { scan [image create test] image%d first image create test myimage scan [image create test -variable x] image%d second expr $second-$first } {1} -test image-1.7 {Tk_ImageCmd procedure, "create" option} { +test image-1.7 {Tk_ImageCmd procedure, "create" option} testImageType { image delete myimage image create test myimage -variable x .c create image 100 50 -image myimage @@ -63,7 +56,7 @@ test image-1.7 {Tk_ImageCmd procedure, "create" option} { update set x } {{myimage free} {myimage free} {myimage delete} {myimage get} {myimage get} {myimage display 0 0 30 15 30 30} {myimage display 0 0 30 15 30 130}} -test image-1.8 {Tk_ImageCmd procedure, "create" option} { +test image-1.8 {Tk_ImageCmd procedure, "create" option} testImageType { .c delete all image create test myimage -variable x .c create image 100 50 -image myimage @@ -75,22 +68,19 @@ test image-1.8 {Tk_ImageCmd procedure, "create" option} { update set x } {{myimage get} {myimage get} {myimage display 0 0 30 15 30 30} {myimage display 0 0 30 15 30 130}} -test image-1.9 {Tk_ImageCmd procedure, "create" option} { +test image-1.9 {Tk_ImageCmd procedure, "create" option} testImageType { .c delete all eval image delete [image names] list [catch {image create test -badName foo} msg] $msg [image names] } {1 {bad option name "-badName"} {}} test image-1.10 {Tk_ImageCmd procedure, "create" option with "." as name} { - catch {removeFile script} - set fd [open script w] - puts $fd { + set script [makeFile { update puts [list [catch {image create photo .} msg] $msg] exit - } - close $fd - set x [list [catch {exec $::tcltest::tktest <script} msg] $msg] - file delete -force script + } script] + set x [list [catch {exec [interpreter] <$script} msg] $msg] + removeFile script set x } {0 {1 {this isn't a Tk applicationNULL main window}}} # I don't like the error message! @@ -98,7 +88,7 @@ test image-1.10 {Tk_ImageCmd procedure, "create" option with "." as name} { test image-2.1 {Tk_ImageCmd procedure, "delete" option} { list [catch {image delete} msg] $msg } {0 {}} -test image-2.2 {Tk_ImageCmd procedure, "delete" option} { +test image-2.2 {Tk_ImageCmd procedure, "delete" option} testImageType { .c delete all eval image delete [image names] image create test myimage @@ -108,7 +98,7 @@ test image-2.2 {Tk_ImageCmd procedure, "delete" option} { image d myimage img2 lappend result [image names] } {{img2 myimage} {}} -test image-2.3 {Tk_ImageCmd procedure, "delete" option} { +test image-2.3 {Tk_ImageCmd procedure, "delete" option} testImageType { .c delete all eval image delete [image names] image create test myimage @@ -125,7 +115,7 @@ test image-3.2 {Tk_ImageCmd procedure, "height" option} { test image-3.3 {Tk_ImageCmd procedure, "height" option} { list [catch {image height foo} msg] $msg } {1 {image "foo" doesn't exist}} -test image-3.4 {Tk_ImageCmd procedure, "height" option} { +test image-3.4 {Tk_ImageCmd procedure, "height" option} testImageType { image create test myimage set x [image h myimage] myimage changed 0 0 0 0 60 50 @@ -135,7 +125,7 @@ test image-3.4 {Tk_ImageCmd procedure, "height" option} { test image-4.1 {Tk_ImageCmd procedure, "names" option} { list [catch {image names x} msg] $msg } {1 {wrong # args: should be "image names"}} -test image-4.2 {Tk_ImageCmd procedure, "names" option} { +test image-4.2 {Tk_ImageCmd procedure, "names" option} testImageType { .c delete all eval image delete [image names] image create test myimage @@ -158,11 +148,11 @@ test image-5.2 {Tk_ImageCmd procedure, "type" option} { test image-5.3 {Tk_ImageCmd procedure, "type" option} { list [catch {image type foo} msg] $msg } {1 {image "foo" doesn't exist}} -test image-5.4 {Tk_ImageCmd procedure, "type" option} { +test image-5.4 {Tk_ImageCmd procedure, "type" option} testImageType { image create test myimage image type myimage } {test} -test image-5.5 {Tk_ImageCmd procedure, "type" option} { +test image-5.5 {Tk_ImageCmd procedure, "type" option} testImageType { image create test myimage .c create image 50 50 -image myimage image delete myimage @@ -172,7 +162,7 @@ test image-5.5 {Tk_ImageCmd procedure, "type" option} { test image-6.1 {Tk_ImageCmd procedure, "types" option} { list [catch {image types x} msg] $msg } {1 {wrong # args: should be "image types"}} -test image-6.2 {Tk_ImageCmd procedure, "types" option} { +test image-6.2 {Tk_ImageCmd procedure, "types" option} testImageType { lsort [image types] } {bitmap photo test} @@ -185,14 +175,14 @@ test image-7.2 {Tk_ImageCmd procedure, "width" option} { test image-7.3 {Tk_ImageCmd procedure, "width" option} { list [catch {image width foo} msg] $msg } {1 {image "foo" doesn't exist}} -test image-7.4 {Tk_ImageCmd procedure, "width" option} { +test image-7.4 {Tk_ImageCmd procedure, "width" option} testImageType { image create test myimage set x [image w myimage] myimage changed 0 0 0 0 60 50 list $x [image width myimage] } {30 60} -test image-8.1 {Tk_ImageCmd procedure, "inuse" option} { +test image-8.1 {Tk_ImageCmd procedure, "inuse" option} testImageType { catch {image delete myimage2} image create test myimage2 set res {} @@ -206,7 +196,7 @@ test image-8.1 {Tk_ImageCmd procedure, "inuse" option} { } [list 0 1] -test image-9.1 {Tk_ImageChanged procedure} { +test image-9.1 {Tk_ImageChanged procedure} testImageType { .c delete all eval image delete [image names] image create test foo -variable x @@ -217,7 +207,7 @@ test image-9.1 {Tk_ImageChanged procedure} { update set x } {{foo display 5 6 7 8 30 30}} -test image-9.2 {Tk_ImageChanged procedure} { +test image-9.2 {Tk_ImageChanged procedure} testImageType { .c delete all eval image delete [image names] image create test foo -variable x @@ -233,7 +223,7 @@ test image-9.2 {Tk_ImageChanged procedure} { test image-10.1 {Tk_GetImage procedure} { list [catch {.c create image 100 10 -image bad_name} msg] $msg } {1 {image "bad_name" doesn't exist}} -test image-10.2 {Tk_GetImage procedure} { +test image-10.2 {Tk_GetImage procedure} testImageType { image create test mytest catch {destroy .l} label .l -image mytest @@ -243,7 +233,7 @@ test image-10.2 {Tk_GetImage procedure} { set result } {1 {image "mytest" doesn't exist}} -test image-11.1 {Tk_FreeImage procedure} { +test image-11.1 {Tk_FreeImage procedure} testImageType { .c delete all eval image delete [image names] image create test foo -variable x @@ -257,7 +247,7 @@ test image-11.1 {Tk_FreeImage procedure} { update list [image names] $x } {foo {{foo free} {foo display 0 0 30 15 103 121}}} -test image-11.2 {Tk_FreeImage procedure} { +test image-11.2 {Tk_FreeImage procedure} testImageType { .c delete all eval image delete [image names] image create test foo -variable x @@ -276,7 +266,7 @@ test image-11.2 {Tk_FreeImage procedure} { # Non-portable, apparently due to differences in rounding: test image-12.1 {Tk_RedrawImage procedure, redisplay area clipping} \ - {nonPortable} { + {testImageType nonPortable} { .c delete all eval image delete [image names] image create test foo -variable x @@ -288,7 +278,7 @@ test image-12.1 {Tk_RedrawImage procedure, redisplay area clipping} \ set x } {{foo display 0 0 5 5 50 50}} test image-12.2 {Tk_RedrawImage procedure, redisplay area clipping} \ - {nonPortable} { + {testImageType nonPortable} { .c delete all eval image delete [image names] image create test foo -variable x @@ -300,7 +290,7 @@ test image-12.2 {Tk_RedrawImage procedure, redisplay area clipping} \ set x } {{foo display 10 0 20 5 30 50}} test image-12.3 {Tk_RedrawImage procedure, redisplay area clipping} \ - {nonPortable} { + {testImageType nonPortable} { .c delete all eval image delete [image names] image create test foo -variable x @@ -312,7 +302,7 @@ test image-12.3 {Tk_RedrawImage procedure, redisplay area clipping} \ set x } {{foo display 10 10 20 5 30 30}} test image-12.4 {Tk_RedrawImage procedure, redisplay area clipping} \ - {nonPortable} { + {testImageType nonPortable} { .c delete all eval image delete [image names] image create test foo -variable x @@ -324,7 +314,7 @@ test image-12.4 {Tk_RedrawImage procedure, redisplay area clipping} \ set x } {{foo display 0 10 5 5 50 30}} test image-12.5 {Tk_RedrawImage procedure, redisplay area clipping} \ - {nonPortable} { + {testImageType nonPortable} { .c delete all eval image delete [image names] image create test foo -variable x @@ -336,7 +326,7 @@ test image-12.5 {Tk_RedrawImage procedure, redisplay area clipping} \ set x } {{foo display 0 0 30 15 70 70}} test image-12.6 {Tk_RedrawImage procedure, redisplay area clipping} \ - {nonPortable} { + {testImageType nonPortable} { .c delete all eval image delete [image names] image create test foo -variable x @@ -348,7 +338,7 @@ test image-12.6 {Tk_RedrawImage procedure, redisplay area clipping} \ set x } {{foo display 5 5 20 5 30 30}} -test image-13.1 {Tk_SizeOfImage procedure} { +test image-13.1 {Tk_SizeOfImage procedure} testImageType { eval image delete [image names] image create test foo -variable x set result [list [image width foo] [image height foo]] @@ -356,7 +346,7 @@ test image-13.1 {Tk_SizeOfImage procedure} { lappend result [image width foo] [image height foo] } {30 15 85 60} -test image-13.2 {DeleteImage procedure} { +test image-13.2 {DeleteImage procedure} testImageType { .c delete all eval image delete [image names] image create test foo -variable x @@ -385,6 +375,5 @@ destroy .c eval image delete [image names] # cleanup -catch {removeFile script} ::tcltest::cleanupTests return diff --git a/tests/imgBmap.test b/tests/imgBmap.test index ffdafeb..ff301c6 100644 --- a/tests/imgBmap.test +++ b/tests/imgBmap.test @@ -7,17 +7,17 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: imgBmap.test,v 1.3 1999/04/16 01:51:38 stanton Exp $ +# RCS: @(#) $Id: imgBmap.test,v 1.4 2002/07/13 21:52:34 dgp Exp $ -if {[lsearch [namespace children] ::tcltest] == -1} { - source [file join [pwd] [file dirname [info script]] defs.tcl] -} +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 -foreach i [winfo children .] { - destroy $i -} -wm geometry . {} -raise . +namespace import -force tcltest::makeFile +namespace import -force tcltest::removeFile set data1 {#define foo_width 16 #define foo_height 16 diff --git a/tests/imgPPM.test b/tests/imgPPM.test index e9c8fd1..867f54a 100644 --- a/tests/imgPPM.test +++ b/tests/imgPPM.test @@ -6,17 +6,17 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: imgPPM.test,v 1.4 1999/12/03 07:15:10 hobbs Exp $ +# RCS: @(#) $Id: imgPPM.test,v 1.5 2002/07/13 21:52:34 dgp Exp $ -if {[lsearch [namespace children] ::tcltest] == -1} { - source [file join [pwd] [file dirname [info script]] defs.tcl] -} +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 -foreach i [winfo children .] { - destroy $i -} -wm geometry . {} -raise . +namespace import -force tcltest::makeFile +namespace import -force tcltest::removeFile eval image delete [image names] diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test index c69360c..f1101e6 100644 --- a/tests/imgPhoto.test +++ b/tests/imgPhoto.test @@ -9,17 +9,17 @@ # # Author: Paul Mackerras (paulus@cs.anu.edu.au) # -# RCS: @(#) $Id: imgPhoto.test,v 1.11 2002/07/11 13:01:30 dkf Exp $ +# RCS: @(#) $Id: imgPhoto.test,v 1.12 2002/07/13 21:52:34 dgp Exp $ -if {[lsearch [namespace children] ::tcltest] == -1} { - source [file join [pwd] [file dirname [info script]] defs.tcl] -} +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 -foreach i [winfo children .] { - destroy $i -} -wm geometry . {} -raise . +namespace import -force tcltest::makeFile +namespace import -force tcltest::removeFile eval image delete [image names] @@ -27,27 +27,20 @@ canvas .c pack .c update -# temporarily copy the README file from testsDir to tmpDir -if {![file exists README]} { - set newREADME [file join $::tcltest::workingDir README] - file copy [file join $::tcltest::testsDir README] $newREADME - set removeREADME 1 -} +set README [makeFile { +README -- Tk test suite design document. +} README] # find the teapot.ppm file for use in these tests # first look in $tk_library/demos/images/teapot.ppm # then look in <this file>/../../library/demos/images/teapot.ppm -# skip this file if you can't find the teapot.ppm file. +testConstraint hasTeapotPhoto 1 set teapotPhotoFile [file join $tk_library demos images teapot.ppm] if {![file exists $teapotPhotoFile]} { - set newLib [file dirname $::tcltest::testsDir] - set teapotPhotoFile \ - [file join $newLib library demos images teapot.ppm] + set newLib [file dirname [testsDirectory]] + set teapotPhotoFile [file join $newLib library demos images teapot.ppm] if {![file exists $teapotPhotoFile]} { - puts "Can't find [file join demos images teapot.ppm] in $tk_library" - puts "your Tk library is incomplete, so I am skipping imgPhoto tests." - ::tcltest::cleanupTests - return 0 + testConstraint hasTeapotPhoto } } @@ -60,15 +53,15 @@ test imgPhoto-1.2 {options for photo images} { list [catch {image create photo p1 -file no.such.file} err] \ [string tolower $err] } {1 {couldn't open "no.such.file": no such file or directory}} -test imgPhoto-1.3 {options for photo images} { +test imgPhoto-1.3 {options for photo images} hasTeapotPhoto hasTeapotPhoto { list [catch {image create photo p1 -file $teapotPhotoFile \ -format no.such.format} err] $err } {1 {image file format "no.such.format" is not supported}} -test imgPhoto-1.4 {options for photo images} { +test imgPhoto-1.4 {options for photo images} hasTeapotPhoto { image create photo p1 -file $teapotPhotoFile list [image width p1] [image height p1] } {256 256} -test imgPhoto-1.5 {options for photo images} { +test imgPhoto-1.5 {options for photo images} hasTeapotPhoto { image create photo p1 -file $teapotPhotoFile \ -format ppm -width 79 -height 83 list [image width p1] [image height p1] \ @@ -80,8 +73,8 @@ test imgPhoto-1.6 {options for photo images} { [lindex [p1 configure -palette] 4] } {2.2 2/2/2} test imgPhoto-1.7 {options for photo images} { - list [catch {image create photo p1 -file README} err] $err -} {1 {couldn't recognize data in image file "README"}} + list [catch {image create photo p1 -file $README} err] $err +} [subst {1 {couldn't recognize data in image file "$README"}}] test imgPhoto-1.8 {options for photo images} { list [catch {image create photo -blah blah} err] $err } {1 {unknown option "-blah"}} @@ -105,16 +98,16 @@ test imgPhoto-2.2 {ImgPhotoCreate procedure} { # set msg # } {couldn't open "bogus.img": no such file or directory} -test imgPhoto-3.1 {ImgPhotoConfigureMaster procedure} { +test imgPhoto-3.1 {ImgPhotoConfigureMaster procedure} hasTeapotPhoto { image create photo p1 -file $teapotPhotoFile p1 configure -file $teapotPhotoFile } {} -test imgPhoto-3.2 {ImgPhotoConfigureMaster procedure} { +test imgPhoto-3.2 {ImgPhotoConfigureMaster procedure} hasTeapotPhoto { image create photo p1 -file $teapotPhotoFile list [catch {p1 configure -file bogus} err] [string tolower $err] \ [image width p1] [image height p1] } {1 {couldn't open "bogus": no such file or directory} 256 256} -test imgPhoto-3.3 {ImgPhotoConfigureMaster procedure} { +test imgPhoto-3.3 {ImgPhotoConfigureMaster procedure} hasTeapotPhoto { image create photo p1 .c create image 10 10 -image p1 -tags p1.1 -anchor nw .c create image 300 10 -image p1 -tags p1.2 -anchor nw @@ -159,7 +152,7 @@ test imgPhoto-4.8 {ImgPhotoCmd procedure: configure option} { test imgPhoto-4.9 {ImgPhotoCmd procedure: configure option} { list [catch {p1 configure -palette {} -gamma} msg] $msg } {1 {value for "-gamma" missing}} -test imgPhoto-4.10 {ImgPhotoCmd procedure: copy option} { +test imgPhoto-4.10 {ImgPhotoCmd procedure: copy option} hasTeapotPhoto { image create photo p2 -file $teapotPhotoFile p1 configure -width 0 -height 0 -palette {} -gamma 1 p1 copy p2 @@ -218,7 +211,7 @@ test imgPhoto-4.21 {ImgPhotoCmd procedure: copy option} { p1 copy p2 -from 0 0 10 10 -shrink lappend result [image width p1] [image height p1] } {256 256 49 51 49 51 49 51 10 51 10 10} -test imgPhoto-4.22 {ImgPhotoCmd procedure: get option} { +test imgPhoto-4.22 {ImgPhotoCmd procedure: get option} hasTeapotPhoto { p1 read $teapotPhotoFile list [p1 get 100 100] [p1 get 150 100] [p1 get 100 150] } {{169 117 90} {172 115 84} {35 35 35}} @@ -247,23 +240,23 @@ test imgPhoto-4.29 {ImgPhotoCmd procedure: put option} { test imgPhoto-4.30 {ImgPhotoCmd procedure: read option} { list [catch {p1 read} err] $err } {1 {wrong # args: should be "p1 read fileName ?options?"}} -test imgPhoto-4.31 {ImgPhotoCmd procedure: read option} { +test imgPhoto-4.31 {ImgPhotoCmd procedure: read option} hasTeapotPhoto { list [catch {p1 read $teapotPhotoFile -zoom 2} err] $err } {1 {unrecognized option "-zoom": must be -format, -from, -shrink, or -to}} test imgPhoto-4.32 {ImgPhotoCmd procedure: read option} { list [catch {p1 read bogus} err] [string tolower $err] } {1 {couldn't open "bogus": no such file or directory}} -test imgPhoto-4.33 {ImgPhotoCmd procedure: read option} { +test imgPhoto-4.33 {ImgPhotoCmd procedure: read option} hasTeapotPhoto { list [catch {p1 read $teapotPhotoFile -format bogus} err] $err } {1 {image file format "bogus" is not supported}} test imgPhoto-4.34 {ImgPhotoCmd procedure: read option} { - list [catch {p1 read README} err] $err -} {1 {couldn't recognize data in image file "README"}} -test imgPhoto-4.35 {ImgPhotoCmd procedure: read option} { + list [catch {p1 read $README} err] $err +} [subst {1 {couldn't recognize data in image file "$README"}}] +test imgPhoto-4.35 {ImgPhotoCmd procedure: read option} hasTeapotPhoto { p1 read $teapotPhotoFile list [image width p1] [image height p1] [p1 get 120 120] } {256 256 {161 109 82}} -test imgPhoto-4.36 {ImgPhotoCmd procedure: read option} { +test imgPhoto-4.36 {ImgPhotoCmd procedure: read option} hasTeapotPhoto { p1 read $teapotPhotoFile -from 0 70 60 120 -to 10 10 -shrink list [image width p1] [image height p1] [p1 get 29 19] } {70 60 {244 180 144}} @@ -456,7 +449,7 @@ test imgPhoto-4.72 {ImgPhotoCmd procedure: copy with -compositingrule} { } {0 2 1 1 2 0} catch {rename checkImgTrans {}} -test imgPhoto-5.1 {ImgPhotoGet/Free procedures, shared instances} { +test imgPhoto-5.1 {ImgPhotoGet/Free procedures, shared instances} hasTeapotPhoto { eval image delete [image names] .c delete all image create photo p1 -file $teapotPhotoFile @@ -481,7 +474,7 @@ test imgPhoto-6.1 {ImgPhotoDisplay procedure, blank display} { update } {} -test imgPhoto-7.1 {ImgPhotoFree procedure, resource freeing} { +test imgPhoto-7.1 {ImgPhotoFree procedure, resource freeing} hasTeapotPhoto { eval image delete [image names] .c delete all image create photo p1 -file $teapotPhotoFile @@ -490,7 +483,7 @@ test imgPhoto-7.1 {ImgPhotoFree procedure, resource freeing} { .c delete all image delete p1 } {} -test imgPhoto-7.2 {ImgPhotoFree procedures, unlinking} { +test imgPhoto-7.2 {ImgPhotoFree procedures, unlinking} hasTeapotPhoto { image create photo p1 -file $teapotPhotoFile .c create image 10 10 -image p1 -anchor nw button .b1 -image p1 @@ -506,7 +499,7 @@ test imgPhoto-7.2 {ImgPhotoFree procedures, unlinking} { update .c delete all } {} -test imgPhoto-7.3 {ImgPhotoFree procedures, multiple visuals} { +test imgPhoto-7.3 {ImgPhotoFree procedures, multiple visuals} hasTeapotPhoto { image create photo p1 -file $teapotPhotoFile button .b1 -image p1 frame .f -visual best @@ -522,11 +515,11 @@ test imgPhoto-7.3 {ImgPhotoFree procedures, multiple visuals} { image delete p1 } {} -test imgPhoto-8.1 {ImgPhotoDelete procedure} { +test imgPhoto-8.1 {ImgPhotoDelete procedure} hasTeapotPhoto { image create photo p2 -file $teapotPhotoFile image delete p2 } {} -test imagePhoto-8.2 {ImgPhotoDelete procedure} { +test imagePhoto-8.2 {ImgPhotoDelete procedure} hasTeapotPhoto { image create photo p2 -file $teapotPhotoFile rename p2 newp2 set x [list [info command p2] [info command new*] [newp2 cget -file]] @@ -540,7 +533,7 @@ test imagePhoto-8.3 {ImgPhotoDelete procedure, name cleanup} { list [catch {p1 copy p2} msg] $msg } {1 {image "p2" doesn't exist or is not a photo image}} -test imagePhoto-9.1 {ImgPhotoCmdDeletedProc procedure} { +test imagePhoto-9.1 {ImgPhotoCmdDeletedProc procedure} hasTeapotPhoto { image create photo p2 -file $teapotPhotoFile rename p2 {} list [lsearch -exact [image names] p2] [catch {p2 foo} msg] $msg @@ -561,7 +554,7 @@ test imgPhoto-11.1 {Tk_FindPhoto} { list [catch {p1 copy i1} msg] $msg } {1 {image "i1" doesn't exist or is not a photo image}} -test imgPhoto-12.1 {Tk_PhotoPutZoomedBlock} { +test imgPhoto-12.1 {Tk_PhotoPutZoomedBlock} hasTeapotPhoto { image create photo p3 -file $teapotPhotoFile set result [list [p3 get 50 50] [p3 get 100 100]] p3 copy p3 -zoom 2 @@ -642,10 +635,8 @@ uqldP1TAOrbshqBb314Y2W7n3Qdpv7UNPCHpycUVbv6dnODy5sqzQldIe8H0 hciva9/Ovbv37+BzBgEEADs= " set photo [image create photo -data $data] - set filename [file join $::tcltest::workingDir imgPhoto-14.1.gif] - if {[file exists $filename]} { - catch {file delete -force $filename} - } + set filename [makeFile {} imgPhoto-14.1.gif] + removeFile imgPhoto-14.1.gif $photo write $filename -format gif set photo2 [image create photo -file $filename] set result [string equal [$photo data] [$photo2 data]] @@ -665,8 +656,6 @@ destroy .c eval image delete [image names] # cleanup -if {[info exists removeREADME]} { - catch {file delete -force $newREADME} -} +removeFile README ::tcltest::cleanupTests return diff --git a/tests/listbox.test b/tests/listbox.test index 0b1b7a0..3c8069d 100644 --- a/tests/listbox.test +++ b/tests/listbox.test @@ -6,17 +6,15 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: listbox.test,v 1.18 2002/06/21 02:38:54 hobbs Exp $ +# RCS: @(#) $Id: listbox.test,v 1.19 2002/07/13 21:52:34 dgp Exp $ -if {[lsearch [namespace children] ::tcltest] == -1} { - source [file join [pwd] [file dirname [info script]] defs.tcl] -} +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 -foreach i [winfo children .] { - destroy $i -} -wm geometry . {} -raise . set fixed {Courier -12} proc record args { diff --git a/tests/macEmbed.test b/tests/macEmbed.test index bd9cdbc..e5a7bab 100644 --- a/tests/macEmbed.test +++ b/tests/macEmbed.test @@ -6,7 +6,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: macEmbed.test,v 1.6 2002/07/13 20:28:35 dgp Exp $ +# RCS: @(#) $Id: macEmbed.test,v 1.7 2002/07/13 21:52:34 dgp Exp $ package require tcltest 2.1 namespace import -force tcltest::configure @@ -24,14 +24,7 @@ test macEmbed-1.2 {TkpUseWindow procedure, bad window identifier} {macOnly} { list [catch {toplevel .t -use 47} msg] $msg } {1 {The window ID 47 does not correspond to a valid Tk Window.}} -if {[string compare testembed [info commands testembed]] != 0} { - puts "This application hasn't been compiled with the testembed command," - puts "therefore I am skipping all of these tests." - ::tcltest::cleanupTests - return -} - -test macEmbed-1.3 {TkpUseWindow procedure, creating Container records} {macOnly} { +test macEmbed-1.3 {TkpUseWindow procedure, creating Container records} {testembed macOnly} { deleteWindows frame .f1 -container 1 -width 200 -height 50 frame .f2 -container 1 -width 200 -height 50 @@ -40,7 +33,7 @@ test macEmbed-1.3 {TkpUseWindow procedure, creating Container records} {macOnly} toplevel .t -use $w list [testembed] [expr [lindex [lindex [testembed all] 1] 0] - $w] } {{{XXX .f2 {} {}} {XXX .f1 XXX .t}} 0} -test macEmbed-1.4 {TkpUseWindow procedure, creating Container records} {macOnly} { +test macEmbed-1.4 {TkpUseWindow procedure, creating Container records} {testembed macOnly} testembed { deleteWindows frame .f1 -container 1 -width 200 -height 50 frame .f2 -container 1 -width 200 -height 50 @@ -55,7 +48,7 @@ test macEmbed-1.4 {TkpUseWindow procedure, creating Container records} {macOnly} # Can't think of any way to test the procedures TkpMakeWindow, # TkpMakeContainer, or EmbedErrorProc. -test macEmbed-2.1 {EmbeddedEventProc procedure} {macOnly} { +test macEmbed-2.1 {EmbeddedEventProc procedure} {testembed macOnly} { deleteWindows frame .f1 -container 1 -width 200 -height 50 pack .f1 @@ -66,7 +59,7 @@ test macEmbed-2.1 {EmbeddedEventProc procedure} {macOnly} { update testembed } {} -test macEmbed-2.2 {EmbeddedEventProc procedure} {macOnly} { +test macEmbed-2.2 {EmbeddedEventProc procedure} {testembed macOnly} { deleteWindows frame .f1 -container 1 -width 200 -height 50 pack .f1 @@ -75,7 +68,7 @@ test macEmbed-2.2 {EmbeddedEventProc procedure} {macOnly} { destroy .f1 testembed } {} -test macEmbed-2.3 {EmbeddedEventProc procedure} {macOnly} { +test macEmbed-2.3 {EmbeddedEventProc procedure} {testembed macOnly} { deleteWindows frame .f1 -container 1 -width 200 -height 50 pack .f1 @@ -86,7 +79,7 @@ test macEmbed-2.3 {EmbeddedEventProc procedure} {macOnly} { list [testembed] [winfo children .] } {{} {}} -test macEmbed-3.1 {EmbeddedEventProc procedure, detect creation} {macOnly} { +test macEmbed-3.1 {EmbeddedEventProc procedure, detect creation} {testembed macOnly} { deleteWindows frame .f1 -container 1 -width 200 -height 50 pack .f1 @@ -168,7 +161,7 @@ test macEmbed-4.1 {EmbedStructureProc procedure, configure events} {macOnly} { update winfo geometry .t1 } {180x100+0+0} -test macEmbed-4.2 {EmbedStructureProc procedure, destroy events} {macOnly} { +test macEmbed-4.2 {EmbedStructureProc procedure, destroy events} {testembed macOnly} { deleteWindows frame .f1 -container 1 -width 200 -height 50 pack .f1 @@ -205,7 +198,7 @@ test unixEmbed-5.1 {TkpClaimFocus procedure} {macOnly tempNotMac} { } {{{} .} .f1} catch {interp delete child} -test macEmbed-6.1 {EmbedWindowDeleted procedure, check parentPtr} {macOnly} { +test macEmbed-6.1 {EmbedWindowDeleted procedure, check parentPtr} {testembed macOnly} { deleteWindows frame .f1 -container 1 -width 200 -height 50 frame .f2 -container 1 -width 200 -height 50 @@ -220,7 +213,7 @@ test macEmbed-6.1 {EmbedWindowDeleted procedure, check parentPtr} {macOnly} { } set x } {{{XXX .f4 {} {}} {XXX .f3 {} {}} {XXX .f2 {} {}} {XXX .f1 {} {}}} {{XXX .f4 {} {}} {XXX .f2 {} {}} {XXX .f1 {} {}}} {{XXX .f2 {} {}} {XXX .f1 {} {}}} {{XXX .f2 {} {}}} {}} -test macEmbed-6.2 {EmbedWindowDeleted procedure, check embeddedPtr} {macOnly} { +test macEmbed-6.2 {EmbedWindowDeleted procedure, check embeddedPtr} {testembed macOnly} { deleteWindows frame .f1 -container 1 -width 200 -height 50 pack .f1 diff --git a/tests/unixEmbed.test b/tests/unixEmbed.test index 8b3cede..fbded5b 100644 --- a/tests/unixEmbed.test +++ b/tests/unixEmbed.test @@ -6,7 +6,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: unixEmbed.test,v 1.10 2002/07/13 20:28:35 dgp Exp $ +# RCS: @(#) $Id: unixEmbed.test,v 1.11 2002/07/13 21:52:34 dgp Exp $ package require tcltest 2.1 namespace import -force tcltest::configure @@ -91,8 +91,6 @@ test unixEmbed-1.4 {TkpUseWindow procedure, inheriting colormap} {unix nonPortab set result } {1} -testConstraint testembed [llength [info commands testembed]] - test unixEmbed-1.5 {TkpUseWindow procedure, creating Container records} {unix testembed} { deleteWindows frame .f1 -container 1 -width 200 -height 50 diff --git a/tests/unixWm.test b/tests/unixWm.test index 7bdd746..8c55ac5 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -7,7 +7,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: unixWm.test,v 1.22 2002/07/13 20:28:36 dgp Exp $ +# RCS: @(#) $Id: unixWm.test,v 1.23 2002/07/13 21:52:34 dgp Exp $ package require tcltest 2.1 namespace import -force tcltest::configure @@ -377,8 +377,6 @@ test unixWm-8.10.2 {test for memory leaks} unix { set x 1 } 1 -testConstraint testwrapper [llength [info commands testwrapper]] - test unixWm-9.1 {TkWmMapWindow procedure, client property} {unix testwrapper} { catch {destroy .t} toplevel .t -width 100 -height 50 diff --git a/tests/winfo.test b/tests/winfo.test index 89e6928..3f9a1c1 100644 --- a/tests/winfo.test +++ b/tests/winfo.test @@ -6,7 +6,7 @@ # Copyright (c) 1998-1999 by Scriptics Corporation. # All rights reserved. # -# RCS: @(#) $Id: winfo.test,v 1.8 2002/07/13 20:28:36 dgp Exp $ +# RCS: @(#) $Id: winfo.test,v 1.9 2002/07/13 21:52:34 dgp Exp $ package require tcltest 2.1 namespace import -force tcltest::configure @@ -15,9 +15,6 @@ configure -testdir [file join [pwd] [file dirname [info script]]] configure -loadfile [file join [testsDirectory] constraints.tcl] tcltest::loadTestedCommands -# Some tests require the testwrapper command -testConstraint testwrapper [llength [info commands testwrapper]] - # eatColors -- # Creates a toplevel window and allocates enough colors in it to # use up all the slots in the colormap. |