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:
1 parent
a82130edb0
commit
18c58fd117
5 files changed
+123
-20
No files matched your search
@@ -34,6 +34,9 @@ namespace Mods.CollectionEditTest
|
||||
/// </summary>
|
||||
public partial class CollectionEditTestDriverNode : Node
|
||||
{
|
||||
private int readinessToken = int.MinValue;
|
||||
private ulong readinessStarted;
|
||||
private ulong readinessFrame;
|
||||
public const string Flag = "--itest=collection_edit";
|
||||
|
||||
private const string GameId = "novel_template";
|
||||
@@ -54,7 +57,6 @@ namespace Mods.CollectionEditTest
|
||||
private int passed;
|
||||
private int step;
|
||||
private double elapsed;
|
||||
private double stepAt;
|
||||
private bool done;
|
||||
|
||||
public override void _Ready()
|
||||
@@ -69,6 +71,7 @@ namespace Mods.CollectionEditTest
|
||||
ModEventBus.Unsubscribe<SceneEnteredEvent>(OnSceneEntered);
|
||||
}
|
||||
|
||||
/// <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)
|
||||
@@ -82,9 +85,6 @@ namespace Mods.CollectionEditTest
|
||||
return;
|
||||
}
|
||||
|
||||
if (elapsed - stepAt < 0.25)
|
||||
return;
|
||||
stepAt = elapsed;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -110,8 +110,26 @@ namespace Mods.CollectionEditTest
|
||||
enteredScenes.Add(e.SceneName);
|
||||
}
|
||||
|
||||
// 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 && Menu != null && !Busy && !GodotSceneService.IsTransitioning, 120)) return;
|
||||
switch (step)
|
||||
{
|
||||
case 0:
|
||||
|
||||
Reference in new issue
Block a user