Skip to content

Commit

Permalink
add testing for raw svg output
Browse files Browse the repository at this point in the history
  • Loading branch information
tlnagy committed Oct 21, 2018
1 parent 4f368e8 commit ac5f62d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
1 change: 1 addition & 0 deletions test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Cairo
EzXML
4 changes: 2 additions & 2 deletions test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -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
Expand Down
19 changes: 19 additions & 0 deletions test/svg.jl
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ac5f62d

Please sign in to comment.