diff --git a/src/examples.jl b/src/examples.jl index 9e382eef..6dd1b7f4 100644 --- a/src/examples.jl +++ b/src/examples.jl @@ -86,8 +86,9 @@ yaxis!("YLABEL", :log10) PlotExample("Images", "Plot an image. y-axis is set to flipped", [:(begin - import FileIO, PlotReferenceImages - img = FileIO.load(joinpath(dirname(pathof(PlotReferenceImages)), "..", "Plots","pyplot","0.7.0","ref1.png")) + import FileIO + path = download("http://juliaplots.org/PlotReferenceImages.jl/Plots/pyplot/0.7.0/ref1.png") + img = FileIO.load(path) plot(img) end)] ), diff --git a/test/imgcomp.jl b/test/imgcomp.jl index c8ae9966..e61a47c9 100644 --- a/test/imgcomp.jl +++ b/test/imgcomp.jl @@ -1,15 +1,3 @@ -using VisualRegressionTests -using Plots -using Random -using BinaryProvider -using Test - -default(size=(500,300)) - - -# TODO: use julia's Condition type and the wait() and notify() functions to initialize a Window, then wait() on a condition that -# is referenced in a button press callback (the button clicked callback will call notify() on that condition) - import Plots._current_plots_version # Taken from MakieGallery @@ -43,10 +31,11 @@ const ref_image_dir = download_reference() function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = isinteractive(), sigma = [1,1], tol = 1e-2) Plots._debugMode.on = debug example = Plots._examples[idx] + Plots.theme(:default) @info("Testing plot: $pkg:$idx:$(example.header)") backend(pkg) backend() - + default(size=(500,300)) # ensure consistent results Random.seed!(1234) @@ -83,7 +72,10 @@ function image_comparison_tests(pkg::Symbol, idx::Int; debug = false, popup = is # test function func = (fn, idx) -> begin - map(eval, example.exprs) + expr = Expr(:block) + append!(expr.args, example.exprs) + eval(expr) + png(joinpath(@__DIR__, "testimgs", "test$idx.png")) png(fn) end diff --git a/test/runtests.jl b/test/runtests.jl index 167eb6a1..8e6ef9c1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,10 +1,11 @@ -module PlotsTests - -using Pkg +using VisualRegressionTests +using Plots +using Random +using BinaryProvider +using Test +using FileIO include("imgcomp.jl") - - # don't actually show the plots Random.seed!(1234) default(show=false, reuse=true) @@ -21,14 +22,6 @@ img_tol = isinteractive() ? 1e-2 : 10e-2 end end -# @static if isinteractive() -# @testset "PyPlot" begin -# @test pyplot() == Plots.PyPlotBackend() -# @test backend() == Plots.PyPlotBackend() -# -# image_comparison_facts(:pyplot, tol=img_tol, skip = [2, 25, 30, 31]) -# end -# end @testset "UnicodePlots" begin @test unicodeplots() == Plots.UnicodePlotsBackend() @@ -43,68 +36,6 @@ end @test isa(display(p), Nothing) == true end -# The plotlyjs testimages return a connection error on travis: -# connect: connection refused (ECONNREFUSED) - -# @static if isinteractive() -# @testset "PlotlyJS" begin -# @test plotlyjs() == Plots.PlotlyJSBackend() -# @test backend() == Plots.PlotlyJSBackend() -# -# image_comparison_facts(:plotlyjs, -# skip=[ -# 2, # animation (skipped for speed) -# 25, -# 27, # (polar plots) takes very long / not working -# 30, -# 31, # animation (skipped for speed) -# ], -# tol=img_tol) -# end -# end - -# InspectDR returns that error on travis: -# ERROR: LoadError: InitError: Cannot open display: -# in Gtk.GLib.GError(::Gtk.##229#230) at /home/travis/.julia/v0.5/Gtk/src/GLib/gerror.jl:17 - -# @testset "InspectDR" begin -# @test inspectdr() == Plots.InspectDRBackend() -# @test backend() == Plots.InspectDRBackend() -# -# image_comparison_facts(:inspectdr, -# skip=[ -# 2, # animation -# 6, # heatmap not defined -# 10, # heatmap not defined -# 22, # contour not defined -# 23, # pie not defined -# 27, # polar plot not working -# 28, # heatmap not defined -# 31, # animation -# ], -# tol=img_tol) -# end - - -# @testset "Plotly" begin -# @test plotly() == Plots.PlotlyBackend() -# @test backend() == Plots.PlotlyBackend() -# -# # # until png generation is reliable on OSX, just test on linux -# # @static Sys.islinux() && image_comparison_facts(:plotly, only=[1,3,4,7,8,9,10,11,12,14,15,20,22,23,27], tol=img_tol) -# end - -# @testset "PlotlyJS" begin -# @test plotlyjs() == Plots.PlotlyJSBackend() -# @test backend() == Plots.PlotlyJSBackend() -# -# # as long as we can plot anything without error, it should be the same as Plotly -# image_comparison_facts(:plotlyjs, only=[1], tol=img_tol) -# end - - - - @testset "Axes" begin p = plot() axis = p.subplots[1][:xaxis] @@ -122,44 +53,3 @@ end @testset "NoFail" begin histogram([1, 0, 0, 0, 0, 0]) end - -# tests for preprocessing recipes - -# @testset "recipes" begin - - # user recipe - - # type T end - # @recipe function f(::T) - # line := (3,0.3,:red) - # marker := (20,0.5,:blue,:o) - # bg := :yellow - # rand(10) - # end - # plot(T()) - - # plot recipe - - # @recipe function f(::Type{Val{:hiplt}},plt::Plot) - # line := (3,0.3,:red) - # marker := (20,0.5,:blue,:o) - # t := :path - # bg:=:green - # () - # end - # plot(rand(10),t=:hiplt) - - # series recipe - - # @recipe function f(::Type{Val{:hi}},x,y,z) - # line := (3,0.3,:red) - # marker := (20,0.5,:blue,:o) - # t := :path - # () - # end - # plot(rand(10),t=:hiplt) - -# end - - -end # module