test: replace fixed waits with observable GUI readiness

Advance integration drivers only after their requested controls, game state or file effects are observable. Preserve the behavioral assertions and shared viewport capture pipeline.
This commit is contained in:
cthangover committed 2026-11-13 17:48:45 +01:00
1 parent a82130edb0
commit 18c58fd117
5 files changed
+123 -20

No files matched your search

@@ -34,6 +34,9 @@ namespace Mods.HotReloadTest
/// </summary>
public partial class HotReloadTestDriverNode : Node
{
private int readinessToken = int.MinValue;
private ulong readinessStarted;
private ulong readinessFrame;
public const string Flag = "--itest=hot_reload";
private const string LibId = "hot_reload_probe_lib";
@@ -48,7 +51,6 @@ namespace Mods.HotReloadTest
private int passed;
private int step;
private double elapsed;
private double stepAt;
private bool done;
private GameLaunchArgs startSelection;
private string modsRoot;
@@ -67,6 +69,7 @@ namespace Mods.HotReloadTest
private void OnReloaded(ModSetReloadedEvent e) => reloads.Add(e);
/// <summary>Advances when observable scene/UI readiness has held for two real frames; the watchdog remains active.</summary>
public override void _Process(double delta)
{
if (done)
@@ -80,9 +83,6 @@ namespace Mods.HotReloadTest
return;
}
if (elapsed - stepAt < 0.25)
return;
stepAt = elapsed;
try
{
@@ -97,8 +97,26 @@ namespace Mods.HotReloadTest
private static bool Busy => GameSession.IsSwitching || ModManager.Instance.IsReloading || ModHotReloadService.IsReloadRunning;
// Deferred UI/scene work must finish before the original assertions run.
private bool WaitForReadyFrames(int token, bool ready, double timeoutSeconds = 30)
{
var now = global::Godot.Time.GetTicksMsec();
if (readinessToken != token)
{
readinessToken = token;
readinessStarted = now;
readinessFrame = 0;
}
if (now - readinessStarted > timeoutSeconds * 1000)
throw new global::System.TimeoutException($"readiness at step {token}: scene/UI did not become ready");
if (!ready) { readinessFrame = 0; return false; }
if (readinessFrame == 0) readinessFrame = global::Godot.Engine.GetProcessFrames();
return global::Godot.Engine.GetProcessFrames() - readinessFrame >= 2;
}
private void RunStep()
{
if (!WaitForReadyFrames(step, Boot.IsReady && GetTree().CurrentScene != null && !Busy, 120)) return;
switch (step)
{
case 0: