# This file is a Tcl script to test out the code in tkImgSVGnano.c, which reads
# and write SVG-format image files for photo widgets. The files is organized
# in the standard fashion for Tcl tests.
#
# Copyright (c) 2018 Rene Zaumseil
# All rights reserved.
package require tcltest 2.2
namespace import ::tcltest::*
eval tcltest::configure $argv
tcltest::loadTestedCommands
imageInit
namespace eval svgnano {
variable data
set data(plus) {}
set data(bad) {}
test imgSVGnano-1.1 {reading simple image} -setup {
catch {rename foo ""}
} -body {
image create photo foo -data $data(plus)
list [image width foo] [image height foo]
} -cleanup {
rename foo ""
} -result {100 100}
test imgSVGnano-1.2 {simple image with options} -setup {
catch {rename foo ""}
} -body {
image create photo foo -data $data(plus) -format {svg -dpi 100 -scale 3}
list [image width foo] [image height foo]
} -cleanup {
rename foo ""
} -result {300 300}
# test on crash found by Koen Danckaert
test imgSVGnano-1.3 {reformat image options} -setup {
catch {rename foo ""}
} -body {
image create photo foo -data $data(plus)
catch {foo configure -format {svg -scale}}
list {}
} -cleanup {
rename foo ""
} -result {{}}
test imgSVGnano-1.4 {image options} -setup {
catch {rename foo ""}
} -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-2.1 {reading a bad image} -body {
image create photo foo -format svg -data $data(bad)
} -returnCodes error -result {couldn't recognize image data}
test imgSVGnano-2.2 {using bad option} -body {
image create photo foo -data $data(plus) -format {svg -scale 0}
} -returnCodes error -result {-scale value must be positive}
test imgSVGnano-2.3 {using bad option} -body {
image create photo foo -data $data(plus)
foo configure -format {svg 1.0}
} -cleanup {
rename foo ""
} -returnCodes error -result {bad option "1.0": must be -dpi, -scale, or -unit}
};# end of namespace svgnano
namespace delete svgnano
imageFinish
cleanupTests
return
# Local Variables:
# mode: tcl
# fill-column: 78
# End: