Key events are asynchronous when testing terminal application, but for testing it is better when the behaviour is more deterministic. That is the reason for this PR.
To have more deterministic testing we introduce notification channel, which is used only during testing to find out when all the events were processed in the MainLoop.
The gocui.testNotify channel is initalized only when creating new testing, so it is used only during testing.
Counter gocui.testCounter is used when receiving timeEvent from tcell. Counter is increased for each such event, so when multiple synchronizations are triggered, all gets their reply.
The reply occurs at the end of MainLoop after the flush() function. This way the user/test can be sure that the screen was updated and can try to check if the screen looks as requested.
The timeEvent event is present in tcell but is used only in tcell application, so it shouldn't interfere with anything in gocui (tcell shouldn't post it in regular cases which gocui deals with).
Fixes #100
Key events are asynchronous when testing terminal application, but for testing it is better when the behaviour is more deterministic. That is the reason for this PR.
To have more deterministic testing we introduce notification channel, which is used only during testing to find out when all the events were processed in the MainLoop.
The
gocui.testNotify
channel is initalized only when creating new testing, so it is used only during testing.Counter
gocui.testCounter
is used when receivingtimeEvent
fromtcell
. Counter is increased for each such event, so when multiple synchronizations are triggered, all gets their reply.The reply occurs at the end of
MainLoop
after theflush()
function. This way the user/test can be sure that the screen was updated and can try to check if the screen looks as requested.The
timeEvent
event is present intcell
but is used only in tcell application, so it shouldn't interfere with anything ingocui
(tcell shouldn't post it in regular cases which gocui deals with).