feat: Add triggerQuitOnInitForTest to GameScreen for deterministic testing

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-23 17:52:02 +01:00
parent ae3b0deb04
commit 3a7ec50abf
2 changed files with 10 additions and 11 deletions
@@ -135,6 +135,10 @@ class GameScreen extends StatefulWidget {
@visibleForTesting
final bool skipEngineBootstrapForTest;
/// Triggers the quit flow during init for deterministic widget tests.
@visibleForTesting
final bool triggerQuitOnInitForTest;
/// Creates a gameplay screen driven by [wolf3d].
const GameScreen({
required this.wolf3d,
@@ -142,6 +146,7 @@ class GameScreen extends StatefulWidget {
this.hostShortcutRegistry = HostShortcutRegistry.defaults,
this.appExitHandler,
this.skipEngineBootstrapForTest = false,
this.triggerQuitOnInitForTest = false,
super.key,
});
@@ -164,6 +169,9 @@ class _GameScreenState extends State<GameScreen> {
void initState() {
super.initState();
if (widget.skipEngineBootstrapForTest) {
if (widget.triggerQuitOnInitForTest) {
unawaited(_quitApplication());
}
return;
}
@@ -262,9 +270,6 @@ class _GameScreenState extends State<GameScreen> {
await quit;
}
@visibleForTesting
Future<void> debugQuitForTest() => _quitApplication();
@override
Widget build(BuildContext context) {
final engine = _engine;