Skip to content

Commit 6aa7fcb

Browse files
committed
Add GUI test
Also fixes the doc build
1 parent f173ba2 commit 6aa7fcb

File tree

5 files changed

+26
-5
lines changed

5 files changed

+26
-5
lines changed

.github/workflows/CI.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ jobs:
6969
Pkg.develop(PackageSpec(path=pwd()))
7070
Pkg.instantiate()
7171
- uses: julia-actions/julia-buildpkg@v1
72+
with:
73+
prefix: xvfb-run
7274
- uses: julia-actions/julia-docdeploy@v1
75+
with:
76+
prefix: xvfb-run
7377
env:
7478
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7579
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}

docs/src/assets/Picture.png

2.62 MB
Binary file not shown.

docs/src/assets/Picture.png

2.53 MB
Loading

src/gui.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11

2-
function gui(outbase, files; colors=distinguishable_colors(15, [RGB(1, 1, 1)]; dropseed=true))
2+
function gui(
3+
outbase, files;
4+
colors=distinguishable_colors(15, [RGB(1, 1, 1)]; dropseed=true),
5+
btnclick = Condition(), # used for testing
6+
whichbutton = Ref{Symbol}(), # used for testing
7+
)
38
channelpct(x) = string(round(Int, x * 100)) * '%'
49

510
outbase, _ = splitext(outbase)
@@ -60,8 +65,6 @@ function gui(outbase, files; colors=distinguishable_colors(15, [RGB(1, 1, 1)]; d
6065
push!(cbs, cb)
6166
end
6267
# Add "Done & Next" and "Skip" buttons
63-
btnclick = Condition()
64-
whichbutton = Ref{Symbol}()
6568
donebtn = button("Done & Next")
6669
skipbtn = button("Skip")
6770
push!(guibx, donebtn)
@@ -129,6 +132,8 @@ function gui(outbase, files; colors=distinguishable_colors(15, [RGB(1, 1, 1)]; d
129132
end
130133
end
131134
destroy(win)
135+
notify(btnclick) # used in testing
136+
return
132137
end
133138
gui(outbase, glob::Glob.GlobMatch; kwargs...) = gui(outbase, Glob.glob(glob); kwargs...)
134139

src/segment.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ function segment_image(
1414
)
1515
seg = unseeded_region_growing(img, threshold)
1616
if prune
17-
println("Pruning segments smaller than $min_size pixels")
17+
# println("Pruning segments smaller than $min_size pixels")
1818
seg = prune_segments(seg, label -> segment_pixel_count(seg, label) < min_size, (l1, l2) -> colordiff(segment_mean(seg, l1), segment_mean(seg, l2)))
1919
end
2020
return seg
@@ -75,7 +75,7 @@ function spots(
7575
label = seg.image_indexmap
7676
R = CartesianIndices(label)
7777
Ibegin, Iend = extrema(R)
78-
I1 = one(Ibegin)
78+
I1 = oneunit(Ibegin)
7979
centroidsacc = Dict{Int, Tuple{Int, Int, Int}}() # accumulator for centroids
8080
nadj = Dict{Tuple{Int, Int}, Int}() # number of times two segments are adjacent
8181
for idx in R

test/runtests.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,16 @@ using Test
4040
process_images(tmpfile, glob"*.png"; dirname=testdir)
4141
data = XLSX.readtable(tmpfile, "Picture")
4242
@test isa(data, XLSX.DataTable)
43+
44+
# Test the gui
45+
rm(tmpfile, force=true)
46+
btnclick = Condition()
47+
whichbutton = Ref{Symbol}()
48+
@async gui(tmpfile, [joinpath(testdir, "Picture.png")]; btnclick, whichbutton)
49+
sleep(5)
50+
whichbutton[] = :done
51+
notify(btnclick)
52+
wait(btnclick)
53+
@test isfile(tmpfile)
54+
@test isfile(splitext(tmpfile)[1] * ".jld2")
4355
end

0 commit comments

Comments
 (0)