Skip to content

Commit

Permalink
add tests for axis scroll events
Browse files Browse the repository at this point in the history
  • Loading branch information
ffreyer committed Oct 2, 2023
1 parent bfb88c8 commit 7a2d231
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/events.jl
Original file line number Diff line number Diff line change
Expand Up @@ -441,4 +441,47 @@ Base.:(==)(l::Or, r::Or) = l.left == r.left && l.right == r.right
@test eventlog[7].px == Point2f(400, 400)
empty!(eventlog)
end

# TODO: test more
@testset "Axis Interactions" begin
f = Figure(resolution = (400, 400))
a = Axis(f[1, 1])
e = events(f)

names = (:rectanglezoom, :dragpan, :limitreset, :scrollzoom)
@test keys(a.interactions) == Set(names)

types = (Makie.RectangleZoom, Makie.DragPan, Makie.LimitReset, Makie.ScrollZoom)
for (name, type) in zip(names, types)
@test a.interactions[name][1] == true
@test a.interactions[name][2] isa type
end

blocked = Observable(true)
on(x -> blocked[] = false, e.scroll, priority = typemin(Int))

@assert !is_mouseinside(a.scene)
e.scroll[] = (0.0, 0.0)
@test !blocked[]
blocked[] = true
e.scroll[] = (0.0, 1.0)
@test !blocked[]

blocked[] = true
e.mouseposition[] = (200, 200)
e.scroll[] = (0.0, 0.0)
@test blocked[] # TODO: should it block?
blocked[] = true
e.scroll[] = (0.0, 1.0)
@test blocked[]

deactivate_interaction!.((a,), names)

blocked[] = true
e.scroll[] = (0.0, 0.0)
@test !blocked[]
blocked[] = true
e.scroll[] = (0.0, 1.0)
@test !blocked[]
end
end

0 comments on commit 7a2d231

Please sign in to comment.