diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2008-08-26 13:58:28 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2008-08-26 13:58:28 (GMT) |
commit | a34b8c16d23b6d6e0f1d9b5b27914b8bee13914a (patch) | |
tree | ee9ba280fecefa420e7597aeb75eb4717110cfba | |
parent | 592e5d08bbcc63aa24c100875c7a80e0fb87ba5d (diff) | |
download | tk-a34b8c16d23b6d6e0f1d9b5b27914b8bee13914a.zip tk-a34b8c16d23b6d6e0f1d9b5b27914b8bee13914a.tar.gz tk-a34b8c16d23b6d6e0f1d9b5b27914b8bee13914a.tar.bz2 |
Tidy up the photo image tests a bit more.
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | tests/imgPhoto.test | 472 |
2 files changed, 240 insertions, 242 deletions
@@ -1,8 +1,12 @@ +2008-08-26 Donal K. Fellows <dkf@users.sf.net> + + * tests/imgPhoto.test: More style improvements. + 2008-08-25 Todd M. Helfter <tmh@users.sourceforge.net> - * library/menu.tcl : Do not flip to the arrow cursor on menus. - This was a Motif convention. Current behavior is maintained if - tk_strictMotif is enabled. [Bug 1023955] + * library/menu.tcl: Do not flip to the arrow cursor on menus. This was + a Motif convention. Current behavior is maintained iff tk_strictMotif + is enabled. [Bug 1023955] 2008-08-25 Donal K. Fellows <dkf@users.sf.net> diff --git a/tests/imgPhoto.test b/tests/imgPhoto.test index d2884d2..fffb1bc 100644 --- a/tests/imgPhoto.test +++ b/tests/imgPhoto.test @@ -1,56 +1,66 @@ -# This file is a Tcl script to test out the "photo" image type and the -# other procedures in the file tkImgPhoto.c. It is organized in the -# standard fashion for Tcl tests. +# This file is a Tcl script to test out the "photo" image type and the other +# procedures in the file tkImgPhoto.c. It is organized in the standard fashion +# for Tcl tests. # # Copyright (c) 1994 The Australian National University # Copyright (c) 1994-1997 Sun Microsystems, Inc. # Copyright (c) 1998-1999 by Scriptics Corporation. +# Copyright (c) 2002-2008 Donal K. Fellows # All rights reserved. # # Author: Paul Mackerras (paulus@cs.anu.edu.au) # -# RCS: @(#) $Id: imgPhoto.test,v 1.31 2008/08/17 19:40:33 aniap Exp $ +# RCS: @(#) $Id: imgPhoto.test,v 1.32 2008/08/26 13:58:32 dkf Exp $ package require tcltest 2.2 namespace import ::tcltest::* -eval tcltest::configure $argv +tcltest::configure {*}$argv tcltest::loadTestedCommands # Used for 4.65 - 4.73 tests -# Now for some heftier testing, checking that setting and resetting of -# pixels' transparency status doesn't "leak" with any one-off errors. -proc checkImgTrans {img width height} { - set result {} +# Now for some heftier testing, checking that setting and resetting of pixels' +# transparency status doesn't "leak" with any one-off errors. +proc foreachPixel {img xVar yVar script} { + upvar 1 $xVar x $yVar y + set width [image width $img] + set height [image height $img] for {set x 0} {$x<$width} {incr x} { - for {set y 0} {$y<$height} {incr y} { - if {[$img transparency get $x $y]} { - lappend result $x $y - } + for {set y 0} {$y<$height} {incr y} { + uplevel 1 $script + } } +} +proc checkImgTrans {img} { + set result {} + foreachPixel $img x y { + if {[$img transparency get $x $y]} { + lappend result $x,$y + } } return $result } -eval image delete [image names] +image delete {*}[image names] set README [makeFile { README -- Tk test suite design document. } README-imgPhoto] - # find the teapot.ppm file for use in these tests set teapotPhotoFile [file join [file dirname [info script]] teapot.ppm] testConstraint hasTeapotPhoto [file exists $teapotPhotoFile] +# ---------------------------------------------------------------------- + test imgPhoto-1.1 {options for photo images} -body { image create photo photo1 -width 79 -height 83 list [photo1 cget -width] [photo1 cget -height] \ - [image width photo1] [image height photo1] + [image width photo1] [image height photo1] } -cleanup { image delete photo1 } -result {79 83 79 83} test imgPhoto-1.2 {options for photo images} -body { list [catch {image create photo photo1 -file no.such.file} err] \ - [string tolower $err] + [string tolower $err] } -result {1 {couldn't open "no.such.file": no such file or directory}} test imgPhoto-1.3 {options for photo images} -constraints hasTeapotPhoto -body { image create photo photo1 -file $teapotPhotoFile -format no.such.format @@ -63,7 +73,7 @@ test imgPhoto-1.4 {options for photo images} -constraints hasTeapotPhoto -body { } -result {256 256} test imgPhoto-1.5 {options for photo images} -constraints hasTeapotPhoto -body { image create photo photo1 -file $teapotPhotoFile \ - -format ppm -width 79 -height 83 + -format ppm -width 79 -height 83 list [image width photo1] [image height photo1] [photo1 cget -file] [photo1 cget -format] } -cleanup { image delete photo1 @@ -74,9 +84,9 @@ test imgPhoto-1.6 {options for photo images} -body { } -cleanup { image delete photo1 } -result {2.2 2/2/2} -test imgPhoto-1.7 {options for photo images} -body { +test imgPhoto-1.7 {options for photo images} -returnCodes error -body { image create photo photo1 -file $README -} -returnCodes error -result [subst {couldn't recognize data in image file "$README"}] +} -result [subst {couldn't recognize data in image file "$README"}] test imgPhoto-1.8 {options for photo images} -body { image create photo -blah blah } -returnCodes error -result {unknown option "-blah"} @@ -90,17 +100,18 @@ test imgPhoto-1.11 {options for photo images - error case} -body { image create photo photo1 -format } -returnCodes error -result {value for "-format" missing} - -test imgPhoto-2.1 {ImgPhotoCreate procedure} -body { - eval image delete [image names] +test imgPhoto-2.1 {ImgPhotoCreate procedure} -setup { + image delete {*}[image names] +} -body { catch {image create photo -blah blah} image names } -result {} -test imgPhoto-2.2 {ImgPhotoCreate procedure} -body { - eval image delete [image names] +test imgPhoto-2.2 {ImgPhotoCreate procedure} -setup { + image delete {*}[image names] +} -body { image create photo image1 list [info commands image1] [image names] \ - [image width image1] [image height image1] + [image width image1] [image height image1] } -cleanup { image delete image1 } -result {image1 image1 0 0} @@ -112,9 +123,8 @@ test imgPhoto-2.2 {ImgPhotoCreate procedure} -body { # set msg # } {couldn't open "bogus.img": no such file or directory} - test imgPhoto-3.1 {ImgPhotoConfigureMaster procedure} -constraints { - hasTeapotPhoto + hasTeapotPhoto } -body { image create photo photo1 -file $teapotPhotoFile photo1 configure -file $teapotPhotoFile @@ -122,7 +132,7 @@ test imgPhoto-3.1 {ImgPhotoConfigureMaster procedure} -constraints { image delete photo1 } -result {} test imgPhoto-3.2 {ImgPhotoConfigureMaster procedure} -constraints { - hasTeapotPhoto + hasTeapotPhoto } -body { image create photo photo1 -file $teapotPhotoFile list [catch {photo1 configure -file bogus} err] [string tolower $err] \ @@ -131,7 +141,7 @@ test imgPhoto-3.2 {ImgPhotoConfigureMaster procedure} -constraints { image delete photo1 } -result {1 {couldn't open "bogus": no such file or directory} 256 256} test imgPhoto-3.3 {ImgPhotoConfigureMaster procedure} -constraints { - hasTeapotPhoto + hasTeapotPhoto } -setup { destroy .c pack [canvas .c] @@ -149,21 +159,20 @@ test imgPhoto-3.3 {ImgPhotoConfigureMaster procedure} -constraints { image delete photo1 } -result {256 256 {10 10 266 266} {300 10 556 266}} - test imgPhoto-4.1 {ImgPhotoCmd procedure} -setup { image create photo photo1 } -body { photo1 -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {wrong # args: should be "photo1 option ?arg ...?"} +} -result {wrong # args: should be "photo1 option ?arg ...?"} test imgPhoto-4.2 {ImgPhotoCmd procedure} -setup { image create photo photo1 } -body { photo1 blah -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {bad option "blah": must be blank, cget, configure, copy, data, get, put, read, redither, transparency, or write} +} -match glob -result {bad option "blah": must be *} test imgPhoto-4.3 {ImgPhotoCmd procedure: blank option} -setup { image create photo photo1 } -body { @@ -192,7 +201,7 @@ test imgPhoto-4.6 {ImgPhotoCmd procedure: configure option} -setup { llength [photo1 configure] } -cleanup { image delete photo1 -} -result {7} +} -result 7 test imgPhoto-4.7 {ImgPhotoCmd procedure: configure option} -setup { image create photo photo1 } -body { @@ -216,7 +225,7 @@ test imgPhoto-4.9 {ImgPhotoCmd procedure: configure option} -setup { image delete photo1 } -returnCodes error -result {value for "-gamma" missing} test imgPhoto-4.10 {ImgPhotoCmd procedure: copy option} -constraints { - hasTeapotPhoto + hasTeapotPhoto } -setup { image create photo photo1 image create photo photo2 -width 25 -height 30 @@ -232,32 +241,32 @@ test imgPhoto-4.11 {ImgPhotoCmd procedure: copy option} -setup { image create photo photo1 } -body { photo1 copy -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {wrong # args: should be "photo1 copy source-image ?-compositingrule rule? ?-from x1 y1 x2 y2? ?-to x1 y1 x2 y2? ?-zoom x y? ?-subsample x y?"} +} -result {wrong # args: should be "photo1 copy source-image ?-compositingrule rule? ?-from x1 y1 x2 y2? ?-to x1 y1 x2 y2? ?-zoom x y? ?-subsample x y?"} test imgPhoto-4.12 {ImgPhotoCmd procedure: copy option} -setup { image create photo photo1 } -body { photo1 copy blah -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {image "blah" doesn't exist or is not a photo image} +} -result {image "blah" doesn't exist or is not a photo image} test imgPhoto-4.13 {ImgPhotoCmd procedure: copy option} -setup { image create photo photo1 image create photo photo2 } -body { photo1 copy photo2 -blah -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 photo2 -} -returnCodes error -result {unrecognized option "-blah": must be -compositingrule, -from, -shrink, -subsample, -to, or -zoom} +} -result {unrecognized option "-blah": must be -compositingrule, -from, -shrink, -subsample, -to, or -zoom} test imgPhoto-4.14 {ImgPhotoCmd procedure: copy option} -setup { image create photo photo1 image create photo photo2 } -body { photo1 copy photo2 -from -to -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 photo2 -} -returnCodes error -result {the "-from" option requires one to four integer values} +} -result {the "-from" option requires one to four integer values} test imgPhoto-4.15 {ImgPhotoCmd procedure: copy option} -constraints { hasTeapotPhoto } -setup { @@ -304,7 +313,7 @@ test imgPhoto-4.18 {ImgPhotoCmd procedure: copy option} -constraints { image delete photo1 photo2 } -result {120 100 {169 99 47}} test imgPhoto-4.19 {ImgPhotoCmd procedure: copy option} -constraints { - hasTeapotPhoto + hasTeapotPhoto } -setup { image create photo photo1 image create photo photo2 -file $teapotPhotoFile @@ -349,7 +358,7 @@ test imgPhoto-4.21 {ImgPhotoCmd procedure: copy option} -constraints { image delete photo1 photo2 } -result {256 256 49 51 49 51 49 51 10 51 10 10} test imgPhoto-4.22 {ImgPhotoCmd procedure: get option} -constraints { - hasTeapotPhoto + hasTeapotPhoto } -setup { image create photo photo1 } -body { @@ -383,16 +392,16 @@ test imgPhoto-4.26 {ImgPhotoCmd procedure: put option} -setup { image create photo photo1 } -body { photo1 put -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {wrong # args: should be "photo1 put data ?-option value ...?"} +} -result {wrong # args: should be "photo1 put data ?-option value ...?"} test imgPhoto-4.27 {ImgPhotoCmd procedure: put option} -setup { image create photo photo1 } -body { photo1 put {{white} {white white}} -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {all elements of color list must have the same number of elements} +} -result {all elements of color list must have the same number of elements} test imgPhoto-4.28 {ImgPhotoCmd procedure: put option} -setup { image create photo photo1 } -body { @@ -412,18 +421,18 @@ test imgPhoto-4.30 {ImgPhotoCmd procedure: read option} -setup { image create photo photo1 } -body { photo1 read -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {wrong # args: should be "photo1 read fileName ?-option value ...?"} +} -result {wrong # args: should be "photo1 read fileName ?-option value ...?"} test imgPhoto-4.31 {ImgPhotoCmd procedure: read option} -constraints { - hasTeapotPhoto + hasTeapotPhoto } -setup { image create photo photo1 } -body { photo1 read $teapotPhotoFile -zoom 2 -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {unrecognized option "-zoom": must be -format, -from, -shrink, or -to} +} -result {unrecognized option "-zoom": must be -format, -from, -shrink, or -to} test imgPhoto-4.32 {ImgPhotoCmd procedure: read option} -setup { image create photo photo1 } -body { @@ -432,7 +441,7 @@ test imgPhoto-4.32 {ImgPhotoCmd procedure: read option} -setup { image delete photo1 } -result {1 {couldn't open "bogus": no such file or directory}} test imgPhoto-4.33 {ImgPhotoCmd procedure: read option} -constraints { - hasTeapotPhoto + hasTeapotPhoto } -setup { image create photo photo1 } -body { @@ -444,11 +453,11 @@ test imgPhoto-4.34 {ImgPhotoCmd procedure: read option} -setup { image create photo photo1 } -body { photo1 read $README -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result [subst {couldn't recognize data in image file "$README"}] +} -result [subst {couldn't recognize data in image file "$README"}] test imgPhoto-4.35 {ImgPhotoCmd procedure: read option} -constraints { - hasTeapotPhoto + hasTeapotPhoto } -setup { image create photo photo1 } -body { @@ -458,7 +467,7 @@ test imgPhoto-4.35 {ImgPhotoCmd procedure: read option} -constraints { image delete photo1 } -result {256 256 {161 109 82}} test imgPhoto-4.36 {ImgPhotoCmd procedure: read option} -constraints { - hasTeapotPhoto + hasTeapotPhoto } -setup { image create photo photo1 } -body { @@ -479,9 +488,9 @@ test imgPhoto-4.38 {ImgPhotoCmd procedure: write option} -setup { image create photo photo1 } -body { photo1 write -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {wrong # args: should be "photo1 write fileName ?-option value ...?"} +} -result {wrong # args: should be "photo1 write fileName ?-option value ...?"} test imgPhoto-4.39 {ImgPhotoCmd procedure: write option} -setup { image create photo photo1 } -body { @@ -489,37 +498,34 @@ test imgPhoto-4.39 {ImgPhotoCmd procedure: write option} -setup { } -cleanup { image delete photo1 } -returnCodes error -result {image file format "bogus" is unknown} - test imgPhoto-4.40 {ImgPhotoCmd procedure: transparency option} -setup { image create photo photo1 -} -setup { - image create photo photo1 } -body { photo1 transparency -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {wrong # args: should be "photo1 transparency option ?arg ...?"} +} -result {wrong # args: should be "photo1 transparency option ?arg ...?"} test imgPhoto-4.41 {ImgPhotoCmd procedure: transparency get option} -setup { image create photo photo1 } -body { photo1 transparency get -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {wrong # args: should be "photo1 transparency get x y"} +} -result {wrong # args: should be "photo1 transparency get x y"} test imgPhoto-4.42 {ImgPhotoCmd procedure: transparency get option} -setup { image create photo photo1 } -body { photo1 transparency get 0 -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {wrong # args: should be "photo1 transparency get x y"} +} -result {wrong # args: should be "photo1 transparency get x y"} test imgPhoto-4.43 {ImgPhotoCmd procedure: transparency get option} -setup { image create photo photo1 } -body { photo1 transparency get 0 0 0 -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {wrong # args: should be "photo1 transparency get x y"} +} -result {wrong # args: should be "photo1 transparency get x y"} test imgPhoto-4.44 {ImgPhotoCmd procedure: transparency get option} -setup { image create photo photo1 } -body { @@ -546,30 +552,30 @@ test imgPhoto-4.47 {ImgPhotoCmd procedure: transparency get option} -setup { image create photo photo1 } -body { photo1 transparency get 1 0 -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {photo1 transparency get: coordinates out of range} +} -result {photo1 transparency get: coordinates out of range} test imgPhoto-4.48 {ImgPhotoCmd procedure: transparency get option} -setup { image create photo photo1 } -body { photo1 transparency get -1 0 -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {photo1 transparency get: coordinates out of range} +} -result {photo1 transparency get: coordinates out of range} test imgPhoto-4.49 {ImgPhotoCmd procedure: transparency get option} -setup { image create photo photo1 } -body { photo1 transparency get 0 1 -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {photo1 transparency get: coordinates out of range} +} -result {photo1 transparency get: coordinates out of range} test imgPhoto-4.50 {ImgPhotoCmd procedure: transparency get option} -setup { image create photo photo1 } -body { photo1 transparency get 0 -1 -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {photo1 transparency get: coordinates out of range} +} -result {photo1 transparency get: coordinates out of range} test imgPhoto-4.51 {ImgPhotoCmd procedure: transparency get option} -setup { image create photo photo1 } -body { @@ -583,30 +589,30 @@ test imgPhoto-4.52 {ImgPhotoCmd procedure: transparency set option} -setup { image create photo photo1 } -body { photo1 transparency set -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {wrong # args: should be "photo1 transparency set x y boolean"} +} -result {wrong # args: should be "photo1 transparency set x y boolean"} test imgPhoto-4.53 {ImgPhotoCmd procedure: transparency set option} -setup { image create photo photo1 } -body { photo1 transparency set 0 -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {wrong # args: should be "photo1 transparency set x y boolean"} +} -result {wrong # args: should be "photo1 transparency set x y boolean"} test imgPhoto-4.54 {ImgPhotoCmd procedure: transparency set option} -setup { image create photo photo1 } -body { photo1 transparency set 0 0 -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {wrong # args: should be "photo1 transparency set x y boolean"} +} -result {wrong # args: should be "photo1 transparency set x y boolean"} test imgPhoto-4.55 {ImgPhotoCmd procedure: transparency set option} -setup { image create photo photo1 } -body { photo1 transparency set 0 0 0 0 -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {wrong # args: should be "photo1 transparency set x y boolean"} +} -result {wrong # args: should be "photo1 transparency set x y boolean"} test imgPhoto-4.56 {ImgPhotoCmd procedure: transparency set option} -setup { image create photo photo1 } -body { @@ -632,30 +638,30 @@ test imgPhoto-4.59 {ImgPhotoCmd procedure: transparency set option} -setup { image create photo photo1 } -body { photo1 transparency set 1 0 0 -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {photo1 transparency set: coordinates out of range} +} -result {photo1 transparency set: coordinates out of range} test imgPhoto-4.60 {ImgPhotoCmd procedure: transparency set option} -setup { image create photo photo1 } -body { photo1 transparency set -1 0 0 -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {photo1 transparency set: coordinates out of range} +} -result {photo1 transparency set: coordinates out of range} test imgPhoto-4.61 {ImgPhotoCmd procedure: transparency set option} -setup { image create photo photo1 } -body { photo1 transparency set 0 1 0 -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {photo1 transparency set: coordinates out of range} +} -result {photo1 transparency set: coordinates out of range} test imgPhoto-4.62 {ImgPhotoCmd procedure: transparency set option} -setup { image create photo photo1 } -body { photo1 transparency set 0 -1 0 -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 -} -returnCodes error -result {photo1 transparency set: coordinates out of range} +} -result {photo1 transparency set: coordinates out of range} test imgPhoto-4.63 {ImgPhotoCmd procedure: transparency set option} -setup { image create photo photo1 } -body { @@ -674,14 +680,13 @@ test imgPhoto-4.64 {ImgPhotoCmd procedure: transparency set option} -setup { } -cleanup { image delete photo1 } -result 1 - -# Now for some heftier testing, checking that setting and resetting of -# pixels' transparency status doesn't "leak" with any one-off errors. +# Now for some heftier testing, checking that setting and resetting of pixels' +# transparency status doesn't "leak" with any one-off errors. test imgPhoto-4.65 {ImgPhotoCmd procedure: transparency get option} -setup { image create photo photo1 } -body { photo1 put white -to 0 0 3 3 - checkImgTrans photo1 3 3 + checkImgTrans photo1 } -cleanup { image delete photo1 } -result {} @@ -690,61 +695,52 @@ test imgPhoto-4.66 {ImgPhotoCmd procedure: transparency get option} -setup { } -body { photo1 put white -to 0 0 3 3 photo1 blank - checkImgTrans photo1 3 3 -v -result {0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2} - + checkImgTrans photo1 +v -result {0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2} test imgPhoto-4.67 {ImgPhotoCmd procedure: transparency set option} -setup { image create photo photo1 -} -body { proc checkImgTransLoopSetReset {img width height} { - set result {} - for {set x 0} {$x<$width} {incr x} { - for {set y 0} {$y<$height} {incr y} { - $img put white -to 0 0 3 3 - $img transparency set $x $y 1 - set result [concat $result [checkImgTrans $img $width $height]] - lappend result , - $img transparency set $x $y 0 - set result [concat $result [checkImgTrans $img $width $height]] - lappend result . - } - } - return $result + set result {} + foreachPixel img x y { + $img put white -to 0 0 3 3 + $img transparency set $x $y 1 + lappend result {*}[checkImgTrans $img] + append result : + $img transparency set $x $y 0 + lappend result {*}[checkImgTrans $img] + append result . + } + return $result } - +} -body { photo1 put white -to 0 0 3 3 checkImgTransLoopSetReset photo1 3 3 } -cleanup { rename checkImgTransLoopSetReset {} image delete photo1 -} -result {0 0 , . 0 1 , . 0 2 , . 1 0 , . 1 1 , . 1 2 , . 2 0 , . 2 1 , . 2 2 , .} - +} -result {0,0:. 0,1:. 0,2:. 1,0:. 1,1:. 1,2:. 2,0:. 2,1:. 2,2:.} test imgPhoto-4.68 {ImgPhotoCmd procedure: transparency set option} -setup { image create photo photo1 -} -body { proc checkImgTransLoopResetSet {img width height} { - set result {} - for {set x 0} {$x<$width} {incr x} { - for {set y 0} {$y<$height} {incr y} { - $img blank - $img transparency set $x $y 0 - set result [concat $result [checkImgTrans $img $width $height]] - lappend result , - $img transparency set $x $y 1 - set result [concat $result [checkImgTrans $img $width $height]] - lappend result . - } - } - return $result + set result {} + foreachPixel $img x y { + $img blank + $img transparency set $x $y 0 + lappend result {*}[checkImgTrans $img] + append result : + $img transparency set $x $y 1 + lappend result {*}[checkImgTrans $img] + append result . + } + return $result } - +} -body { photo1 put white -to 0 0 3 3 checkImgTransLoopResetSet photo1 3 3 } -cleanup { catch {rename checkImgTransLoopResetSet {}} image delete photo1 -} -result {0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 2 1 0 1 1 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 1 0 1 1 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 1 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 2 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 1 2 0 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 1 1 2 2 1 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 2 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 . 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 , 0 0 0 1 0 2 1 0 1 1 1 2 2 0 2 1 2 2 .} - +} -result {0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2: 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2. 0,0 0,2 1,0 1,1 1,2 2,0 2,1 2,2: 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2. 0,0 0,1 1,0 1,1 1,2 2,0 2,1 2,2: 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2. 0,0 0,1 0,2 1,1 1,2 2,0 2,1 2,2: 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2. 0,0 0,1 0,2 1,0 1,2 2,0 2,1 2,2: 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2. 0,0 0,1 0,2 1,0 1,1 2,0 2,1 2,2: 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2. 0,0 0,1 0,2 1,0 1,1 1,2 2,1 2,2: 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2. 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,2: 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2. 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1: 0,0 0,1 0,2 1,0 1,1 1,2 2,0 2,1 2,2.} test imgPhoto-4.69 {ImgPhotoCmd procedure: copy with -compositingrule} -setup { # Test the compositing rules for copying images image create photo photo1 -width 3 -height 3 @@ -760,9 +756,9 @@ test imgPhoto-4.70 {ImgPhotoCmd procedure: copy with -compositingrule} -setup { image create photo photo2 -width 2 -height 2 } -body { photo1 copy photo2 -to 1 1 -compositingrule BAD -} -cleanup { +} -returnCodes error -cleanup { image delete photo1 photo2 -} -returnCodes error -result {bad compositing rule "BAD": must be overlay or set} +} -result {bad compositing rule "BAD": must be overlay or set} test imgPhoto-4.71 {ImgPhotoCmd procedure: copy with -compositingrule} -setup { # Test the compositing rules for copying images image create photo photo1 -width 3 -height 3 @@ -775,7 +771,7 @@ test imgPhoto-4.71 {ImgPhotoCmd procedure: copy with -compositingrule} -setup { photo2 put white -to 0 0 2 2 photo2 transparency set 0 0 true photo1 copy photo2 -to 1 1 - checkImgTrans photo1 3 3 + checkImgTrans photo1 } -cleanup { image delete photo1 photo2 } -result {0 2 2 0} @@ -790,7 +786,7 @@ test imgPhoto-4.72 {ImgPhotoCmd procedure: copy with -compositingrule} -setup { photo2 put white -to 0 0 2 2 photo2 transparency set 0 0 true photo1 copy photo2 -to 1 1 -compositingrule overlay - checkImgTrans photo1 3 3 + checkImgTrans photo1 } -cleanup { image delete photo1 photo2 } -result {0 2 2 0} @@ -805,18 +801,17 @@ test imgPhoto-4.73 {ImgPhotoCmd procedure: copy with -compositingrule} -setup { photo2 put white -to 0 0 2 2 photo2 transparency set 0 0 true photo1 copy photo2 -to 1 1 -compositingrule set - checkImgTrans photo1 3 3 + checkImgTrans photo1 } -cleanup { image delete photo1 photo2 } -result {0 2 1 1 2 0} - test imgPhoto-5.1 {ImgPhotoGet/Free procedures, shared instances} -constraints { - hasTeapotPhoto + hasTeapotPhoto } -setup { destroy .c pack [canvas .c] - eval image delete [image names] + image delete {*}[image names] } -body { image create photo photo1 -file $teapotPhotoFile .c create image 0 0 -image photo1 -tags photo1.1 @@ -834,11 +829,10 @@ test imgPhoto-5.1 {ImgPhotoGet/Free procedures, shared instances} -constraints { destroy .c } -result {} - -test imgPhoto-6.1 {ImgPhotoDisplay procedure, blank display} } -setup { +test imgPhoto-6.1 {ImgPhotoDisplay procedure, blank display} -setup { destroy .c pack [canvas .c] - eval image delete [image names] + image delete {*}[image names] } -body { image create photo photo1 -width 10 -height 10 photo1 blank @@ -849,13 +843,12 @@ test imgPhoto-6.1 {ImgPhotoDisplay procedure, blank display} } -setup { image delete photo1 } -result {} - test imgPhoto-7.1 {ImgPhotoFree procedure, resource freeing} -constraints { - hasTeapotPhoto + hasTeapotPhoto } -setup { destroy .c pack [canvas .c] - eval image delete [image names] + image delete {*}[image names] } -body { image create photo photo1 -file $teapotPhotoFile .c create image 0 0 -image photo1 -anchor nw @@ -866,10 +859,10 @@ test imgPhoto-7.1 {ImgPhotoFree procedure, resource freeing} -constraints { destroy .c } -result {} test imgPhoto-7.2 {ImgPhotoFree procedures, unlinking} -constraints { - hasTeapotPhoto + hasTeapotPhoto } -setup { deleteWindows - eval image delete [image names] + image delete {*}[image names] } -body { image create photo photo1 -file $teapotPhotoFile pack [canvas .c] @@ -891,10 +884,10 @@ test imgPhoto-7.2 {ImgPhotoFree procedures, unlinking} -constraints { image delete photo1 } -result {} test imgPhoto-7.3 {ImgPhotoFree procedures, multiple visuals} -constraints { - hasTeapotPhoto + hasTeapotPhoto } -setup { deleteWindows - eval image delete [image names] + image delete {*}[image names] } -body { image create photo photo1 -file $teapotPhotoFile button .b1 -image photo1 @@ -911,71 +904,67 @@ test imgPhoto-7.3 {ImgPhotoFree procedures, multiple visuals} -constraints { image delete photo1 } -result {} - test imgPhoto-8.1 {ImgPhotoDelete procedure} -constraints hasTeapotPhoto -body { image create photo photo2 -file $teapotPhotoFile image delete photo2 } -result {} test imgPhoto-8.2 {ImgPhotoDelete procedure} -constraints { - hasTeapotPhoto + hasTeapotPhoto +} -setup { + set x {} } -body { image create photo photo2 -file $teapotPhotoFile rename photo2 newphoto2 - set x [list [info command photo2] [info command new*] [newphoto2 cget -file]] + lappend x [info command photo2] [info command new*] [newphoto2 cget -file] image delete photo2 - append x [info command new*] -} -result [list {} newphoto2 $teapotPhotoFile] + lappend x [info command new*] +} -result [list {} newphoto2 $teapotPhotoFile {}] test imgPhoto-8.3 {ImgPhotoDelete procedure, name cleanup} -body { image create photo photo1 image create photo photo2 -width 10 -height 10 image delete photo2 photo1 copy photo2 -} -cleanup { - eval image delete [image names] -} -returnCodes error -result {image "photo2" doesn't exist or is not a photo image} - +} -returnCodes error -cleanup { + image delete {*}[image names] +} -result {image "photo2" doesn't exist or is not a photo image} test imgPhoto-9.1 {ImgPhotoCmdDeletedProc procedure} -constraints { - hasTeapotPhoto + hasTeapotPhoto } -body { image create photo photo2 -file $teapotPhotoFile rename photo2 {} list [lsearch -exact [image names] photo2] [catch {photo2 foo} msg] $msg } -result {-1 1 {invalid command name "photo2"}} - test imgPhoto-10.1 {Tk_ImgPhotoPutBlock procedure} -setup { - eval image delete [image names] + image delete {*}[image names] } -body { image create photo photo1 - photo1 put {{#ff0000 #ff0000 #ff0000 #ff0000 #ff0000 #ff0000 #ff0000 #ff0000}} -to 0 0 - photo1 put {{#00ff00 #00ff00}} -to 2 0 + photo1 put "{#ff0000 #ff0000 #ff0000 #ff0000 #ff0000 #ff0000 #ff0000 #ff0000}" -to 0 0 + photo1 put "{#00ff00 #00ff00}" -to 2 0 list [photo1 get 2 0] [photo1 get 3 0] [photo1 get 4 0] } -result {{0 255 0} {0 255 0} {255 0 0}} - test imgPhoto-11.1 {Tk_FindPhoto} -setup { - eval image delete [image names] + image delete {*}[image names] } -body { image create bitmap i1 image create photo photo1 photo1 copy i1 } -cleanup { - eval image delete [image names] + image delete {*}[image names] } -returnCodes error -result {image "i1" doesn't exist or is not a photo image} - test imgPhoto-12.1 {Tk_PhotoPutZoomedBlock} -constraints hasTeapotPhoto -body { image create photo p3 -file $teapotPhotoFile set result [list [p3 get 50 50] [p3 get 100 100]] p3 copy p3 -zoom 2 lappend result [image width p3] [image height p3] [p3 get 100 100] +} -cleanup { image delete p3 - set result } -result {{19 92 192} {169 117 90} 512 512 {19 92 192}} - -test imgPhoto-13.1 {check separation of images in different interpreters} -body { +test imgPhoto-13.1 {check separation of images in different interpreters} -setup { image delete {*}[image names] set data { R0lGODlhQgBkAPUAANbWxs7Wxs7OxsbOxsbGxsbGvb3Gvca9vcDAwL21vbW1vbW1tbWtta2t @@ -1012,83 +1001,79 @@ test imgPhoto-13.1 {check separation of images in different interpreters} -body interp create x2 x1 eval {load {} Tk} x2 eval {load {} Tk} +} -body { x1 eval [list image create photo T1_data -data $data] x2 eval [list image create photo T1_data -data $data] - unset data +} -cleanup { interp delete x1 interp delete x2 -} -result {} +} -result T1_data - -test imgPhoto-14.1 {GIF writes work correctly} -body { - set data "R0lGODlhYwA5APcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgAysnGy8hKzM -hASs3MTcjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA -AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMDAwP8AAAD/ -AP//AAAA//8A/wD//////ywAAAAAYwA5AAAI/wAZCBxIsKDBgwgTKlzIsKHD -hxAjSpxIsaLFixgzatzIsaPHjyBDihxJsqTJkyhTqlzJsqXLlzBjypxJs6bN -mzhz6tzJs6fPn0CDCh1KtKhRiwoSKEXAtGlTpUqPGkyagOmCq1edNsWalWkC -BUSXIuDqFepBqFWtZv3KU+zYrkrBSqT6dgECtjOTbu16NwFHvV3lshRLti/J -qlgRCE6ZuO9ik4Dt+k0ZVyZiyVIvXr77ODPEy5g9T4zMWfTEzXdNz1VbWvXn -uqldP1TAOrbshqBb314Y2W7n3Qdpv7UNPCHpycUVbv6dnODy5sqzQldIe8H0 -hciva9/Ovbv37+BzBgEEADs= -" - set photo [image create photo -data $data] - set filename [makeFile {} imgPhoto-14.1.gif] - removeFile imgPhoto-14.1.gif - $photo write $filename -format gif - set photo2 [image create photo -file $filename] - string equal [$photo data] [$photo2 data] +test imgPhoto-14.1 {GIF writes work correctly} -setup { + set data { + R0lGODlhYwA5APcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgAysnGy8hKzM + hASs3MTcjAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMDAwP8AAAD/ + AP//AAAA//8A/wD//////ywAAAAAYwA5AAAI/wAZCBxIsKDBgwgTKlzIsKHD + hxAjSpxIsaLFixgzatzIsaPHjyBDihxJsqTJkyhTqlzJsqXLlzBjypxJs6bN + mzhz6tzJs6fPn0CDCh1KtKhRiwoSKEXAtGlTpUqPGkyagOmCq1edNsWalWkC + BUSXIuDqFepBqFWtZv3KU+zYrkrBSqT6dgECtjOTbu16NwFHvV3lshRLti/J + qlgRCE6ZuO9ik4Dt+k0ZVyZiyVIvXr77ODPEy5g9T4zMWfTEzXdNz1VbWvXn + uqldP1TAOrbshqBb314Y2W7n3Qdpv7UNPCHpycUVbv6dnODy5sqzQldIe8H0 + hciva9/Ovbv37+BzBgEEADs= + } + set tmpfilename [makeFile {} imgPhoto-14.1.gif] + removeFile $tmpfilename +} -body { + image create photo photo1 -data $data + photo1 write $tmpfilename -format gif + image create photo photo2 -file $tmpfilename + string equal [photo1 data] [photo2 data] } -cleanup { - image delete $photo $photo2 - catch {file delete -force $filename} + catch {image delete photo1 photo2} + catch {file delete -force $tmpfilename} } -result 1 -test imgPhoto-14.2 {GIF -index handler buffer sizing} -body { - # Bug 1458234 makes this crash when trying to access buffers of the - # wrong size, caused when the initial frame is not the largest frame. +test imgPhoto-14.2 {GIF -index handler buffer sizing} -setup { set data { R0lGODlhIAAgAKEAAPkOSQsi7////////yH/C05FVFNDQVBFMi4wAwEAAAAh +QQJMgAAACwGAAYAFAAUAAACEYyPqcvtD6OctNqLs968+68VACH5BAkyAAEA LAMAAwAaABoAAAI0jH+gq+gfmFzQzUsr3gBybn1gIm5kaUaoubbuC8fyTNel Ohv1CSO533u8KrgbUfc5Ci/EAgA7 } +} -body { + # Bug 1458234 makes this crash when trying to access buffers of the wrong + # size, caused when the initial frame is not the largest frame. set i [image create photo] - $i configure -data $data -format {gif -index 2} } -cleanup { image delete $i } -returnCodes error -result {no image data for this index} - - test imgPhoto-14.3 {GIF -index interleaving and small frames} -body { - # Interleaved GIFs used to crash us when a smaller subsequent frame - # was accessed. + # Interleaved GIFs used to crash us when a smaller subsequent frame was + # accessed. set i [image create photo] - $i configure -format {GIF -index 1} -data { R0lGODdhAQAFAPAAAP8AAAAAACwAAAAAAQAFAEACAoRdACwAAAAAAQAEAEACAoRRADs= } } -cleanup { image delete $i } - -test imgPhoto-14.4 {GIF buffer overflow} -body { - # This crashes Tk up to 8.4.17 and 8.5.0 - set i [image create photo] - $i configure -data { +test imgPhoto-14.4 {GIF buffer overflow} -setup { + set data { R0lGODlhCgAKAPcAAAAAAIAAAACAAICAAAAAgIAAgACAgICAgMDAwP8AAAD/ AP//AAAA//8A/wD//////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA @@ -1108,35 +1093,44 @@ test imgPhoto-14.4 {GIF buffer overflow} -body { mf9mzP9m//+ZAP+ZM/+ZZv+Zmf+ZzP+Z///MAP/MM//MZv/Mmf/MzP/M//// AP//M///Zv//mf//zP///yH5BAEAABAALAAAAAAKAAoAABUSAAD/HEiwoMGD CBMqXMiwYcKAADs= - } + } +} -body { + # This crashes Tk up to 8.4.17 and 8.5.0 + set i [image create photo] + $i configure -data $data } -cleanup { image delete $i } -returnCodes error -result {malformed image} - test imgPhoto-15.1 {photo images can fail to allocate memory gracefully} -constraints { - nonPortable + nonPortable } -body { - # This is not portable to very large machines with more around - # 3GB of free memory available... + # This is not portable to very large machines with more than around 3GB of + # free memory available... image create photo -width 32000 -height 32000 } -returnCodes error -result {not enough free memory for image buffer} - -test imgPhoto-16.1 {copying to self doesn't access freed memory} -body { - # Bug 877950 makes this crash when trying to copy out of a deallocated area +test imgPhoto-16.1 {copying to self doesn't access freed memory} -setup { set i [image create photo] +} -body { + # Bug 877950 makes this crash when trying to copy out of a deallocated + # area. $i put red -to 0 0 1000 1000 $i copy $i -from 0 0 1000 1000 -to 500 0 +} -cleanup { image delete $i } -result {} +# ---------------------------------------------------------------------- + catch {rename checkImgTrans {}} -eval image delete [image names] +image delete {*}[image names] # cleanup removeFile README-imgPhoto cleanupTests return - +# Local variables: +# mode: tcl +# End: |