feat: Add triggerQuitOnInitForTest to GameScreen for deterministic testing
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user