From ac5f62d0e528e4414d6f9f70193e5279e3072041 Mon Sep 17 00:00:00 2001 From: Tamas Nagy Date: Sun, 21 Oct 2018 10:30:06 -0700 Subject: [PATCH] add testing for raw svg output --- test/REQUIRE | 1 + test/misc.jl | 4 ++-- test/runtests.jl | 4 ++++ test/svg.jl | 19 +++++++++++++++++++ 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 test/svg.jl diff --git a/test/REQUIRE b/test/REQUIRE index 486553b4..49540cc5 100644 --- a/test/REQUIRE +++ b/test/REQUIRE @@ -1 +1,2 @@ Cairo +EzXML \ No newline at end of file diff --git a/test/misc.jl b/test/misc.jl index e43908b4..05c22e51 100644 --- a/test/misc.jl +++ b/test/misc.jl @@ -147,7 +147,7 @@ end Random.seed!(23) withoutcompose = rand() Random.seed!(23) - draw(SVG(), compose(context())) + draw(SVG(10cm, 8cm, false), compose(context())) withcompose = rand() @test withoutcompose == withcompose end @@ -161,4 +161,4 @@ end @test getfield.(img1.vector_properties[Compose.Property{Compose.FillOpacityPrimitive}].primitives, :value) == [0.3, 0.3] @test occursin("fill-opacity=\"0.3\"", a) @test all(occursin.(["fill=\"rgba(255,0,0,1)\"","fill=\"rgba(0,0,255,1)\""], a)) -end +end diff --git a/test/runtests.jl b/test/runtests.jl index ec6115e2..34f0a8fa 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,6 +1,10 @@ using Compose +using Test include("misc.jl") +@testset "SVG Correctness Tests" begin + include("svg.jl") +end include("immerse.jl") # Run the examples diff --git a/test/svg.jl b/test/svg.jl new file mode 100644 index 00000000..dcf98dd7 --- /dev/null +++ b/test/svg.jl @@ -0,0 +1,19 @@ +using Test +using EzXML +using Colors +using Measures + +@testset "Issue 267" begin + c = compose(context(), fill(["red", "blue"]), + [context(), fill("green"), circle([0.25, 0.75], [0.5], [0.25])]) + img = SVG(8cm, 6cm, false) + draw(img, c) + svgxml = root(parsexml(String(img.out.data))) + # get all grouped values that have the fill attribute + fillcolors = nodecontent.(findall("//ns:g[@fill]/@fill", svgxml, ["ns"=>namespace(svgxml)])) + # there should only be a single color (because green should clobber the red + # and blue colors) + @test length(fillcolors) == 1 + # make sure it's green + @test fillcolors[1] == "rgba(0,128,0,1)" +end \ No newline at end of file