mirror of
https://github.com/britzl/monarch.git
synced 2025-06-27 02:17:53 +02:00
Added monarch.is_loaded()
This commit is contained in:
parent
c473aa053c
commit
84944f3f22
@ -228,6 +228,17 @@ function M.is_visible(id)
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Check if a screen is loaded
|
||||||
|
-- @param id (string|hash)
|
||||||
|
-- @return true if the screen is loaded
|
||||||
|
function M.is_loaded(id)
|
||||||
|
assert(id, "You must provide a screen id")
|
||||||
|
id = tohash(id)
|
||||||
|
assert(screens[id], ("There is no screen registered with id %s"):format(tostring(id)))
|
||||||
|
return screens[id].loaded
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Check if a screen is a popup
|
--- Check if a screen is a popup
|
||||||
-- @param id Screen id
|
-- @param id Screen id
|
||||||
-- @return true if the screen is a popup
|
-- @return true if the screen is a popup
|
||||||
|
@ -142,12 +142,12 @@ return function()
|
|||||||
monarch.show(SCREEN1)
|
monarch.show(SCREEN1)
|
||||||
assert(wait_until_stack({ SCREEN1 }))
|
assert(wait_until_stack({ SCREEN1 }))
|
||||||
assert(wait_until_visible(SCREEN1))
|
assert(wait_until_visible(SCREEN1))
|
||||||
|
|
||||||
monarch.show(SCREEN2)
|
monarch.show(SCREEN2)
|
||||||
assert(wait_until_stack({ SCREEN1, SCREEN2 }))
|
assert(wait_until_stack({ SCREEN1, SCREEN2 }))
|
||||||
assert(wait_until_hidden(SCREEN1))
|
assert(wait_until_hidden(SCREEN1))
|
||||||
assert(wait_until_visible(SCREEN2))
|
assert(wait_until_visible(SCREEN2))
|
||||||
|
|
||||||
monarch.show(POPUP1)
|
monarch.show(POPUP1)
|
||||||
assert(wait_until_stack({ SCREEN1, SCREEN2, POPUP1 }))
|
assert(wait_until_stack({ SCREEN1, SCREEN2, POPUP1 }))
|
||||||
assert(wait_until_hidden(SCREEN1))
|
assert(wait_until_hidden(SCREEN1))
|
||||||
@ -155,6 +155,17 @@ return function()
|
|||||||
assert(wait_until_visible(POPUP1))
|
assert(wait_until_visible(POPUP1))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it("should be able to tell if a screen is loaded or not", function()
|
||||||
|
assert(not monarch.is_loaded(SCREEN1))
|
||||||
|
monarch.show(SCREEN1)
|
||||||
|
assert(wait_until_visible(SCREEN1))
|
||||||
|
assert(monarch.is_loaded(SCREEN1))
|
||||||
|
|
||||||
|
monarch.hide(SCREEN1)
|
||||||
|
assert(wait_until_hidden(SCREEN1))
|
||||||
|
assert(not monarch.is_loaded(SCREEN1))
|
||||||
|
end)
|
||||||
|
|
||||||
it("should be able to show a screen without adding it to the stack", function()
|
it("should be able to show a screen without adding it to the stack", function()
|
||||||
monarch.show(BACKGROUND, { no_stack = true })
|
monarch.show(BACKGROUND, { no_stack = true })
|
||||||
assert(wait_until_visible(BACKGROUND), "Background was never shown")
|
assert(wait_until_visible(BACKGROUND), "Background was never shown")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user