From c19e976000ade9f485703372069f9dc2feb6b77b Mon Sep 17 00:00:00 2001 From: Jared Wahlstrand Date: Fri, 25 Aug 2023 19:10:14 -0400 Subject: [PATCH] improve coverage --- examples/dialogs.jl | 2 +- src/displays.jl | 4 +--- test/gui/displays.jl | 5 +++++ test/gui/examples.jl | 7 ++++++- test/gui/listviews.jl | 3 +++ test/gui/misc.jl | 7 +++++++ test/{ => gui}/style_test.css | 0 7 files changed, 23 insertions(+), 5 deletions(-) rename test/{ => gui}/style_test.css (100%) diff --git a/examples/dialogs.jl b/examples/dialogs.jl index e50cbe49..76f267f8 100644 --- a/examples/dialogs.jl +++ b/examples/dialogs.jl @@ -34,7 +34,7 @@ input_dialog_button = GtkButton("Input dialog") push!(box, input_dialog_button) function open_input_dialog(b) - input_dialog("Enter your information", "") do t + input_dialog("Enter your information", "", (("Cancel", 0), ("Accept", 1)), main_window) do t @async println("response was ",t) end end diff --git a/src/displays.jl b/src/displays.jl index ec3b3051..4fed6d4f 100644 --- a/src/displays.jl +++ b/src/displays.jl @@ -10,9 +10,7 @@ function screen_size(widget=nothing) d=G_.get_display(widget) else d=G_.get_default() # gdk_display_get_default - if d===nothing - error("No default display, no way to return screen_size") - end + d===nothing && error("No default display, no way to return screen_size") end m=G_.get_monitors(d) diff --git a/test/gui/displays.jl b/test/gui/displays.jl index 9b6d8b96..815b5841 100644 --- a/test/gui/displays.jl +++ b/test/gui/displays.jl @@ -21,6 +21,11 @@ pic2 = GtkPicture(pb) texture = GdkTexture(pb) @test width(texture)==100 @test height(texture)==100 + +# test ambiguous constructor handling +@test_throws ErrorException GtkPicture(nothing) +@test_throws ErrorException GtkImage(nothing) +@test_throws ErrorException GtkVideo(nothing) end @testset "progressbar" begin diff --git a/test/gui/examples.jl b/test/gui/examples.jl index bed7813c..5824df4e 100644 --- a/test/gui/examples.jl +++ b/test/gui/examples.jl @@ -34,5 +34,10 @@ end include(joinpath(@__DIR__, "..", "..", "examples", "dialogs.jl")) destroy(main_window) end - + +@testset "Listbox" begin + include(joinpath(@__DIR__, "..", "..", "examples", "listbox.jl")) + destroy(main_window) +end + end diff --git a/test/gui/listviews.jl b/test/gui/listviews.jl index 57e0121e..6dddf332 100644 --- a/test/gui/listviews.jl +++ b/test/gui/listviews.jl @@ -5,6 +5,9 @@ win = GtkWindow("Listview demo") sw = GtkScrolledWindow() push!(win, sw) +slist0 = GtkStringList() +@test length(slist0) == 0 + slist = GtkStringList(["Apple","Orange","Kiwi"]) model = GLib.GListModel(slist) push!(slist, "Mango") diff --git a/test/gui/misc.jl b/test/gui/misc.jl index f1cb0588..be5e03d8 100644 --- a/test/gui/misc.jl +++ b/test/gui/misc.jl @@ -70,6 +70,7 @@ b12 = GtkButton(:mnemonic,"_second") push!(g1, b12) b21 = GtkButton(:label,"first") b22 = GtkButton(:icon_name,"document-open-symbolic") +@test_throws ErrorException GtkButton(:shiny,"shiny") push!(g2, b22) pushfirst!(g2, b21) push!(g2, GtkSeparator(:h)) @@ -151,6 +152,12 @@ b3 = GtkBuilder(s,-1) win = b3["a_window"] destroy(win) +b4 = GtkBuilder() +push!(b4; filename="test.ui") + +b5 = GtkBuilder() +push!(b5; buffer=s) + end @testset "CssProviderLeaf(filename=\"...\")" begin diff --git a/test/style_test.css b/test/gui/style_test.css similarity index 100% rename from test/style_test.css rename to test/gui/style_test.css