This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
171 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,8 @@ jobs: | |
- uses: julia-actions/julia-runtest@v1 | ||
with: | ||
prefix: ${{ matrix.prefix }} | ||
env: | ||
JULIA_NUM_THREADS: 2 | ||
- uses: julia-actions/[email protected] | ||
continue-on-error: true | ||
- uses: julia-actions/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
@testset "eventloop" begin | ||
@testset "control" begin | ||
before = Gtk.auto_idle[] | ||
|
||
@testset "basics" begin | ||
Gtk.auto_idle[] = true | ||
Gtk.enable_eventloop(false) | ||
@test !Gtk.is_eventloop_running() | ||
Gtk.enable_eventloop(true) | ||
@test Gtk.is_eventloop_running() | ||
Gtk.enable_eventloop(false) | ||
@test !Gtk.is_eventloop_running() | ||
end | ||
|
||
@testset "pause_eventloop" begin | ||
|
||
@testset "pauses then restarts" begin | ||
Gtk.enable_eventloop(true) | ||
@test Gtk.is_eventloop_running() | ||
Gtk.pause_eventloop() do | ||
@test !Gtk.is_eventloop_running() | ||
end | ||
@test Gtk.is_eventloop_running() | ||
end | ||
|
||
@testset "doesn't restart a stopping eventloop" begin | ||
Gtk.enable_eventloop(false) | ||
c = GtkCanvas() | ||
win = GtkWindow(c) | ||
showall(win) | ||
sleep(1) | ||
@test Gtk.is_eventloop_running() | ||
destroy(win) | ||
# the eventloop is likely still stopping here | ||
Gtk.pause_eventloop() do | ||
@test !Gtk.is_eventloop_running() | ||
end | ||
@test !Gtk.is_eventloop_running() | ||
end | ||
|
||
@testset "observes auto_idle = false" begin | ||
Gtk.auto_idle[] = false | ||
Gtk.enable_eventloop(true) | ||
Gtk.pause_eventloop() do | ||
@test Gtk.is_eventloop_running() | ||
end | ||
@test Gtk.is_eventloop_running() | ||
end | ||
|
||
@testset "observes force = true" begin | ||
Gtk.auto_idle[] = false | ||
Gtk.enable_eventloop(true) | ||
Gtk.pause_eventloop(force = true) do | ||
@test !Gtk.is_eventloop_running() | ||
end | ||
@test Gtk.is_eventloop_running() | ||
end | ||
|
||
# Note: Test disabled because this isn't true. The event loop takes some time to stop. | ||
# TODO: Figure out how to wait in the handle_auto_idle callbacks | ||
|
||
# @testset "eventloop is stopped immediately after a destroy(win) completes" begin | ||
# c = GtkCanvas() | ||
# win = GtkWindow(c) | ||
# showall(win) | ||
# @test Gtk.is_eventloop_running() | ||
# destroy(win) | ||
# @test !Gtk.is_eventloop_running() | ||
# end | ||
end | ||
|
||
Gtk.auto_idle[] = before | ||
end | ||
|
||
@testset "Multithreading" begin | ||
@testset "no blocking when eventloop is paused" begin | ||
Gtk.auto_idle[] = true | ||
Threads.nthreads() < 1 && @warn "Threads.nthreads() == 1. Multithread blocking tests are not effective" | ||
|
||
function multifoo() | ||
Threads.@threads for _ in 1:Threads.nthreads() | ||
sleep(0.1) | ||
end | ||
end | ||
|
||
Gtk.enable_eventloop(false) | ||
win = Gtk.Window("Multithread test", 400, 300) | ||
showall(win) | ||
@test Gtk.is_eventloop_running() | ||
for i in 1:10 | ||
Gtk.pause_eventloop() do | ||
@test !Gtk.is_eventloop_running() | ||
t = @elapsed multifoo() # should take slightly more than 0.1 seconds | ||
@test t < 4.5 # given the Glib uv_prepare timeout is 5000 ms | ||
end | ||
end | ||
@test Gtk.is_eventloop_running() | ||
destroy(win) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ include("gui.jl") | |
include("list.jl") | ||
include("misc.jl") | ||
include("text.jl") | ||
include("eventloop.jl") | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters