Skip to content

Commit

Permalink
Merge pull request #127 from Gnimuc/tests
Browse files Browse the repository at this point in the history
Add some real tests
  • Loading branch information
JamesWrigley authored Jun 30, 2024
2 parents 14fad04 + e7a0d55 commit 5397056
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 24 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,14 @@ jobs:
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
- uses: julia-actions/[email protected]
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

# We add ModernGL and GLFW so that the backend extensions will be loaded too
- run: |
julia --project=. -e '
using Pkg
Pkg.add(["ModernGL", "GLFW"])
import CImGui, ModernGL, GLFW
'
tests:
name: Tests - Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
Expand Down Expand Up @@ -68,9 +72,11 @@ jobs:
- uses: julia-actions/julia-runtest@v1
with:
prefix: xvfb-run -a -s '-screen 0 1024x768x24'
- uses: julia-actions/[email protected]
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v4
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}

docs:
name: Documentation
Expand Down
7 changes: 0 additions & 7 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,3 @@ CSyntax = "0.4"
GLFW = "3"
ModernGL = "1"
julia = "1.9"

[extras]
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Printf", "Test"]
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[deps]
CImGui = "5d785b6c-b76f-510e-a07c-3070796c7e87"
GLFW = "f7f18e0c-5ee9-5ccd-a5bf-e8befd85ed98"
ImGuiTestEngine = "464e2eba-0a11-4ed3-b274-413caa1a1cca"
ModernGL = "66fc600b-dfda-50eb-8b99-91cfa97b1301"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
77 changes: 67 additions & 10 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,14 +1,71 @@
using CImGui
using Test
import CImGui as ig
using ImGuiTestEngine
import ImGuiTestEngine as te
import ModernGL, GLFW

@testset "CImGui.jl" begin
# if CI only run if linux given xvfb is available in CI
if !haskey(ENV, "CI") || Sys.islinux() && Sys.WORD_SIZE == 64
withenv("AUTO_CLOSE_DEMO" => "5") do
include(joinpath("..", "demo", "demo.jl"))
Base.invokelatest(official_demo)
end
else
@warn "Tests not run" haskey(ENV, "CI") Sys.islinux() Sys.WORD_SIZE
ig.set_backend(:GlfwOpenGL3)


include(joinpath(@__DIR__, "../demo/demo.jl"))

@testset "Official demo" begin
@test ig.imgui_version() isa VersionNumber
engine = te.CreateContext()

@register_test(engine, "Official demo", "Hiding demo window") do ctx
@imcheck GetWindowByRef("Dear ImGui Demo") != nothing

SetRef("Hello, world!")
ItemClick("Demo Window") # This should hide the demo window

@imcheck GetWindowByRef("Dear ImGui Demo") == nothing
end

official_demo(; engine)

te.DestroyContext(engine)
end

include(joinpath(@__DIR__, "../examples/demo.jl"))

@testset "Julia demo" begin
engine = te.CreateContext()#; exit_on_completion=false, show_test_window=true)
# engine_io = te.GetIO(engine)
# engine_io.ConfigRunSpeed = te.RunSpeed_Normal

@register_test(engine, "Julia demo", "About window") do ctx
SetRef("ImGui Demo")
MenuClick("Help/About Dear ImGui")

Yield() # Let it run another frame so that the new window can be drawn
@imcheck GetWindowByRef("//About Dear ImGui") != nothing

SetRef("About Dear ImGui")
ItemCheck("Config\\/Build Information")
end

@register_test(engine, "Configuration", "ConfigFlags") do ctx
SetRef("ImGui Demo")
ItemClick("Configuration")
ItemClick("Configuration##2")
SetRef("ImGui Demo/Configuration##2")
ItemCheck("io.ConfigFlags: NoMouse")
end

@register_test(engine, "Widgets", "Selectables") do ctx
SetRef("ImGui Demo")
ItemClick("Widgets")
ItemClick("Selectables")
ItemClick("Selectables/Basic")
SetRef("ImGui Demo/Selectables/Basic")
ItemDoubleClick("5. I am double clickable")

SetRef("ImGui Demo")
ItemClick("Plots Widgets")
end

julia_demo(; engine)

te.DestroyContext(engine)
end

0 comments on commit 5397056

Please sign in to comment.