started work on imgcomp tests
This commit is contained in:
parent
3facc116c8
commit
781aa86568
@ -1,5 +1,20 @@
|
||||
|
||||
|
||||
# TODO:
|
||||
"""
|
||||
- load Contours.jl similar to DataFrames
|
||||
- method to build grid from x/y/z vectors
|
||||
- method to wrap contours creation
|
||||
- method to plot contours as custom shapes (TODO: create Stroke and Fill types and add markerstroke/markerfill args)
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
# # ----------------------------------------------------------
|
||||
# # ----------------------------------------------------------
|
||||
|
||||
|
||||
# immutable Vertex
|
||||
# x::Float64
|
||||
# y::Float64
|
||||
|
||||
85
test/imgcomp.jl
Normal file
85
test/imgcomp.jl
Normal file
@ -0,0 +1,85 @@
|
||||
|
||||
# macro test_approx_eq_sigma_eps(A, B, sigma, eps)
|
||||
|
||||
include("../docs/example_generation.jl")
|
||||
|
||||
|
||||
# # make and display one plot
|
||||
# function test_examples(pkg::Symbol, idx::Int; debug = true)
|
||||
# Plots._debugMode.on = debug
|
||||
# println("Testing plot: $pkg:$idx:$(examples[idx].header)")
|
||||
# backend(pkg)
|
||||
# backend()
|
||||
# map(eval, examples[idx].exprs)
|
||||
# plt = current()
|
||||
# gui(plt)
|
||||
# plt
|
||||
# end
|
||||
|
||||
using Plots, Gtk.ShortNames
|
||||
|
||||
function makeImageWidget(fn)
|
||||
img = @Image(fn)
|
||||
vbox = @Box(:v)
|
||||
push!(vbox, img)
|
||||
show(img)
|
||||
vbox
|
||||
end
|
||||
|
||||
"Show a Gtk popup with both images and a confirmation whether we should replace the new image with the old one"
|
||||
function isTempImageCorrect(tmpfn, reffn)
|
||||
|
||||
# add the images
|
||||
imgbox = @Box(:h)
|
||||
push!(imgbox, makeImageWidget(tmpfn))
|
||||
push!(imgbox, makeImageWidget(reffn))
|
||||
|
||||
# add the buttons
|
||||
keepbtn = @Button("KEEP")
|
||||
overwritebtn = @Button("OVERWRITE")
|
||||
btnbox = @Box(:h)
|
||||
push!(btnbox, keepbtn)
|
||||
push!(btnbox, overwritebtn)
|
||||
|
||||
# create the window
|
||||
box = @Box(:v)
|
||||
push!(box, imgbox)
|
||||
push!(box, btnbox)
|
||||
w = @Window(@Frame(box))
|
||||
end
|
||||
|
||||
|
||||
function image_comparison_tests(pkg::Symbol, idx::Int; debug = true)
|
||||
|
||||
# first
|
||||
Plots._debugMode.on = debug
|
||||
info("Testing plot: $pkg:$idx:$(examples[idx].header)")
|
||||
backend(pkg)
|
||||
backend()
|
||||
map(eval, PlotExamples.examples[idx].exprs)
|
||||
|
||||
# save the png
|
||||
tmpfn = tempname() * ".png"
|
||||
png(tmpfn)
|
||||
|
||||
# load the saved png
|
||||
tmpimg = imread(tmpfn)
|
||||
|
||||
# load the reference image
|
||||
reffn = joinpath(Pkg.dir("Plots"), "test", "refimg", pkg, "$idx.png")
|
||||
refimg = imread(reffn)
|
||||
|
||||
# run the test
|
||||
@test_approx_eq_sigma_eps(tmpimg, refimg, sigma, eps)
|
||||
end
|
||||
|
||||
function image_comparison_tests(pkg::Symbol; debug = false)
|
||||
for i in 1:length(PlotExamples.examples)
|
||||
# try
|
||||
image_comparison_tests(pkgname, i, debug=debug)
|
||||
# catch ex
|
||||
# # TODO: put error info into markdown?
|
||||
# warn("Example $pkgname:$i:$(examples[i].header) failed with: $ex")
|
||||
# end
|
||||
end
|
||||
end
|
||||
Loading…
x
Reference in New Issue
Block a user