diff options
author | oehhar <harald.oehlmann@elmicron.de> | 2019-08-19 07:42:56 (GMT) |
---|---|---|
committer | oehhar <harald.oehlmann@elmicron.de> | 2019-08-19 07:42:56 (GMT) |
commit | fc29f2e9f600d019c7c373811de1401dd084aba0 (patch) | |
tree | 81484da5754bf615d10396041b2799c26ac0768b /tests | |
parent | 8a17419e45b890b4da2a3eaa8f80d1a41c916cf9 (diff) | |
parent | ed20571d50e43ed0f2849f1846e2c93daee0146c (diff) | |
download | tk-fc29f2e9f600d019c7c373811de1401dd084aba0.zip tk-fc29f2e9f600d019c7c373811de1401dd084aba0.tar.gz tk-fc29f2e9f600d019c7c373811de1401dd084aba0.tar.bz2 |
Merge branch 'tip-545-svg-options' after positive vote
Diffstat (limited to 'tests')
-rw-r--r-- | tests/imgSVGnano.test | 133 |
1 files changed, 127 insertions, 6 deletions
diff --git a/tests/imgSVGnano.test b/tests/imgSVGnano.test index a7470df..f2ad233 100644 --- a/tests/imgSVGnano.test +++ b/tests/imgSVGnano.test @@ -27,6 +27,12 @@ namespace eval svgnano { "> </svg>} + tcltest::makeFile $data(plus) plus.svg + set data(plusFilePath) [file join [tcltest::configure -tmpdir] plus.svg] + + tcltest::makeFile $data(bad) bad.svg + set data(badFilePath) [file join [tcltest::configure -tmpdir] bad.svg] + test imgSVGnano-1.1 {reading simple image} -setup { catch {rename foo ""} } -body { @@ -61,17 +67,42 @@ test imgSVGnano-1.4 {image options} -setup { } -body { image create photo foo -data $data(plus) foo configure -format {svg -scale 2} - foo configure -format {svg -unit pt} - foo configure -format {svg -unit mm} - foo configure -format {svg -unit cm} - foo configure -format {svg -unit in} - foo configure -format {svg -unit px} foo configure -format {svg -dpi 600} list [image width foo] [image height foo] } -cleanup { rename foo "" } -result {100 100} +test imgSVGnano-1.5 {reading simple image from file} -setup { + catch {rename foo ""} +} -body { + image create photo foo -file $data(plusFilePath) + list [image width foo] [image height foo] +} -cleanup { + rename foo "" +} -result {100 100} +test imgSVGnano-1.6 {simple image with options} -setup { + catch {rename foo ""} +} -body { + image create photo foo -file $data(plusFilePath) -format {svg -dpi 100 -scale 3} + list [image width foo] [image height foo] +} -cleanup { + rename foo "" +} -result {300 300} +test imgSVGnano-1.7 {Very small scale gives 1x1 image} -body { + image create photo foo -format "svg -scale 0.000001"\ + -data $data(plus) + list [image width foo] [image height foo] +} -cleanup { + rename foo "" +} -result {1 1} +test imgSVGnano-1.8 {Very small scale gives 1x1 image from file} -body { + image create photo foo -format "svg -scale 0.000001"\ + -file $data(plusFilePath) + list [image width foo] [image height foo] +} -cleanup { + rename foo "" +} -result {1 1} test imgSVGnano-2.1 {reading a bad image} -body { image create photo foo -format svg -data $data(bad) @@ -84,7 +115,97 @@ test imgSVGnano-2.3 {using bad option} -body { foo configure -format {svg 1.0} } -cleanup { rename foo "" -} -returnCodes error -result {bad option "1.0": must be -dpi, -scale, or -unit} +} -returnCodes error -result {bad option "1.0": must be -dpi, -scale, -scaletoheight, or -scaletowidth} +test imgSVGnano-2.4 {reading a bad image from file} -body { + image create photo foo -format svg -file $data(badFilePath) +} -returnCodes error -match glob\ + -result {couldn't recognize data in image file "*/win/bad.svg"} + +# -scaletoheight and -scaletowidth options +test imgSVGnano-3.1 {multiple scale options} -body { + image create photo foo -format "svg -scale 1 -scaletowidth 20"\ + -data $data(bad) +} -returnCodes error -result {only one of -scale, -scaletoheight, -scaletowidth may be given} + +test imgSVGnano-3.2 {no number parameter to -scaletowidth} -body { + image create photo foo -format "svg -scaletowidth invalid"\ + -data $data(plus) +} -returnCodes error -result {expected integer but got "invalid"} + +test imgSVGnano-3.3 {no number parameter to -scaletoheight} -body { + image create photo foo -format "svg -scaletoheight invalid"\ + -data $data(plus) +} -returnCodes error -result {expected integer but got "invalid"} + +test imgSVGnano-3.4 {zero parameter to -scaletowidth} -body { + image create photo foo -format "svg -scaletowidth 0"\ + -data $data(plus) +} -returnCodes error -result {-scaletowidth value must be positive} + +test imgSVGnano-3.5 {zero parameter to -scaletoheight} -body { + image create photo foo -format "svg -scaletoheight 0"\ + -data $data(plus) +} -returnCodes error -result {-scaletoheight value must be positive} + +test imgSVGnano-3.6 {no number parameter to -scaletoheight} -body { + image create photo foo -format "svg -scaletoheight invalid"\ + -data $data(plus) +} -returnCodes error -result {expected integer but got "invalid"} + +test imgSVGnano-3.7 {Option -scaletowidth} -body { + image create photo foo -format "svg -scaletowidth 20"\ + -data $data(plus) + image width foo +} -cleanup { + rename foo "" +} -result {20} + +test imgSVGnano-3.8 {Option -scaletoheight} -body { + image create photo foo -format "svg -scaletoheight 20"\ + -data $data(plus) + image height foo +} -cleanup { + rename foo "" +} -result {20} + +test imgSVGnano-3.10 {change from -scaletoheight to -scale} -body { + set res {} + image create photo foo -format "svg -scaletoheight 16"\ + -data $data(plus) + lappend res [image width foo] [image height foo] + foo configure -format "svg -scale 2" + lappend res [image width foo] [image height foo] +} -cleanup { + rename foo "" + unset res +} -result {16 16 200 200} + +# svg file access +test imgSVGnano-4.1 {reread file on configure -scale} -setup { + catch {rename foo ""} + set res {} +} -body { + image create photo foo -file $data(plusFilePath) + lappend res [image width foo] [image height foo] + foo configure -format "svg -scale 2" + lappend res [image width foo] [image height foo] +} -cleanup { + rename foo "" + unset res +} -result {100 100 200 200} + + +test imgSVGnano-4.2 {error on file not accessible on reread due to configure} -setup { + catch {rename foo ""} + tcltest::makeFile $data(plus) tmpplus.svg + image create photo foo -file [file join [tcltest::configure -tmpdir] tmpplus.svg] + tcltest::removeFile tmpplus.svg +} -body { + foo configure -format "svg -scale 2" +} -cleanup { + rename foo "" + tcltest::removeFile tmpplus.svg +} -returnCodes error -match glob -result {couldn't open "*/tmpplus.svg": no such file or directory} };# end of namespace svgnano |