mirror of
https://github.com/britzl/monarch.git
synced 2025-09-27 18:12:22 +02:00
Fix issue when a layout changes and there's an ongoing transition
This commit is contained in:
@@ -2,11 +2,13 @@ local deftest = require "deftest.deftest"
|
||||
|
||||
local test_monarch = require "test.test_monarch"
|
||||
local test_callback_tracker = require "test.test_callback_tracker"
|
||||
local test_transitions = require "test.test_transitions"
|
||||
|
||||
|
||||
function init(self)
|
||||
deftest.add(test_monarch)
|
||||
deftest.add(test_callback_tracker)
|
||||
deftest.add(test_transitions)
|
||||
deftest.run({
|
||||
coverage = { enabled = true },
|
||||
pattern = "",
|
||||
|
46
test/test_transitions.lua
Normal file
46
test/test_transitions.lua
Normal file
@@ -0,0 +1,46 @@
|
||||
local cowait = require "test.cowait"
|
||||
local mock_msg = require "test.msg"
|
||||
local mock_gui = require "deftest.mock.gui"
|
||||
local unload = require "deftest.util.unload"
|
||||
local monarch = require "monarch.monarch"
|
||||
local transitions = require "monarch.transitions.gui"
|
||||
local easing = require "monarch.transitions.easings"
|
||||
|
||||
return function()
|
||||
|
||||
describe("transitions", function()
|
||||
before(function()
|
||||
mock_msg.mock()
|
||||
mock_gui.mock()
|
||||
transitions = require "monarch.transitions.gui"
|
||||
end)
|
||||
|
||||
after(function()
|
||||
mock_msg.unmock()
|
||||
mock_gui.unmock()
|
||||
unload.unload("monarch%..*")
|
||||
end)
|
||||
|
||||
|
||||
it("should replay and immediately finish on layout change", function()
|
||||
function dummy_transition(node, to, easing, duration, delay, cb)
|
||||
print("dummy transition")
|
||||
end
|
||||
|
||||
local node = gui.new_box_node(vmath.vector3(), vmath.vector3(100, 100, 0))
|
||||
local duration = 2
|
||||
local t = transitions.create(node)
|
||||
.show_in(dummy_transition, easing.OUT, duration, delay or 0)
|
||||
.show_out(dummy_transition, easing.IN, duration, delay or 0)
|
||||
.back_in(dummy_transition, easing.OUT, duration, delay or 0)
|
||||
.back_out(dummy_transition, easing.IN, duration, delay or 0)
|
||||
|
||||
t.handle(monarch.TRANSITION.SHOW_IN)
|
||||
t.handle(hash("layout_changed"))
|
||||
local messages = mock_msg.messages(msg.url())
|
||||
assert(#messages == 1, "Expected one message to have been received")
|
||||
assert(messages[1].message_id == monarch.TRANSITION.DONE, "Expected a TRANSITION.DONE message")
|
||||
end)
|
||||
end)
|
||||
|
||||
end
|
Reference in New Issue
Block a user