summaryrefslogtreecommitdiffstats
path: root/tests/imgPhoto.test
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2002-07-13 21:52:33 (GMT)
committerdgp <dgp@users.sourceforge.net>2002-07-13 21:52:33 (GMT)
commit213541e4a3a5a49415c0f9f8d37a5cbce28f89f7 (patch)
treee1c87e388ed78c9f631d3cf202385b697ce25ab6 /tests/imgPhoto.test
parent05961d4dc9e4b65d07feac195998ca0f969b06d9 (diff)
downloadtk-213541e4a3a5a49415c0f9f8d37a5cbce28f89f7.zip
tk-213541e4a3a5a49415c0f9f8d37a5cbce28f89f7.tar.gz
tk-213541e4a3a5a49415c0f9f8d37a5cbce28f89f7.tar.bz2
* Converted more files to tcltest and factored out common code.
Diffstat (limited to 'tests/imgPhoto.test')
-rw-r--r--tests/imgPhoto.test97
1 files changed, 43 insertions, 54 deletions
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