Timing Issues using `Input` with `InputSender`
Opened this issue · 0 comments
bitwes commented
Versions
- Godot: 4.x
- GUT: 9.x
Known Timing Issues:
- Some amount of awaiting must occur before the first input test is run to ensure that tests pass. This can cause inconsistent results when running a single test, single script, or full run. In local testing waiting 10 frames before the first test is run gave consistent results. This delay appears to only be needed once per run, but that has not been confirmed.
func before_all():
await wait_frames(10)
- If you do not await after calling
release_all
inafter_each
, then the events do not have time to propagate.
func after_each():
_sender.release_all()
_sender.clear()
# Wait for key release to be processed. Otherwise the key release is
# leaked to the next test and it detects an extra key release.
await wait_frames(1)
Approach(es?)
GutInputTest
Subclass
Creating a GutInputTest
that extends GutTest
could perform these awaits automatically and could provide additional features that are helpful when writing input tests.
- This class could provide specific
InputSender
s automatically. AnInputSender
usingInput
might be the only one. - It could automatically call
clear
andrelease_all
at the appropriate times for instances ofInputSender
. - There wouldn't be reason you couldn't just use this new class for all your tests, but they will be a tiny bit slower, so this should warn if no input tests were created. How would it tell? There's probably a way. No warning should appear when running a single test.
- Using
InputSender
inGutTest
would be deprecated.