Fix smoke gaps: recorder target + VK translation, player enum + null guard (#11)
This commit is contained in:
@@ -153,6 +153,66 @@ baselines:
|
||||
Assert.Single(s.Baselines);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlayerEngine_NullTarget_SkipsWithoutCalling()
|
||||
{
|
||||
var engine = new PlayerEngine();
|
||||
var host = new FakePlayerHost();
|
||||
var scenario = new Scenario
|
||||
{
|
||||
Steps =
|
||||
{
|
||||
new Step { Kind = StepKind.Click, Target = null },
|
||||
new Step { Kind = StepKind.Drag, Target = null },
|
||||
new Step { Kind = StepKind.Type, Target = null, Value = "hello" },
|
||||
},
|
||||
};
|
||||
|
||||
engine.Run(scenario, host);
|
||||
|
||||
Assert.Empty(host.Clicks);
|
||||
Assert.Empty(host.Drags);
|
||||
Assert.Empty(host.Types);
|
||||
Assert.Empty(host.Failures);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void PlayerEngine_WheelKind_DoesNotThrow()
|
||||
{
|
||||
var engine = new PlayerEngine();
|
||||
var host = new FakePlayerHost();
|
||||
var scenario = new Scenario
|
||||
{
|
||||
Steps =
|
||||
{
|
||||
new Step { Kind = StepKind.Wheel, Value = "-120" },
|
||||
new Step { Kind = StepKind.Focus },
|
||||
},
|
||||
};
|
||||
|
||||
engine.Run(scenario, host);
|
||||
Assert.Empty(host.Failures);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ScenarioLoader_ParsesWheelAndFocusKinds()
|
||||
{
|
||||
const string yaml = """
|
||||
name: wheel-focus
|
||||
steps:
|
||||
- kind: wheel
|
||||
value: "-120"
|
||||
- kind: focus
|
||||
target:
|
||||
uia_path: "Window/Edit"
|
||||
offset: [0.5, 0.5]
|
||||
""";
|
||||
var s = ScenarioLoader.LoadFromString(yaml);
|
||||
Assert.Equal(2, s.Steps.Count);
|
||||
Assert.Equal(StepKind.Wheel, s.Steps[0].Kind);
|
||||
Assert.Equal(StepKind.Focus, s.Steps[1].Kind);
|
||||
}
|
||||
|
||||
private static string LocateEngineSource([CallerFilePath] string here = "")
|
||||
{
|
||||
// here = .../tests/Recordingtest.Player.Tests/PlayerEngineTests.cs
|
||||
|
||||
73
tests/Recordingtest.Player.Tests/SmokeRegressionTests.cs
Normal file
73
tests/Recordingtest.Player.Tests/SmokeRegressionTests.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
using Recordingtest.Player.Model;
|
||||
using Xunit;
|
||||
|
||||
namespace Recordingtest.Player.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// Regression for issue #11 — smoke test against EG-BIM Modeler exposed
|
||||
/// recorder output that the player could not consume (wheel/focus kinds
|
||||
/// missing, null targets causing wild clicks). This test embeds a minimal
|
||||
/// yaml that mimics the real recorder output and runs it through the full
|
||||
/// ScenarioLoader -> PlayerEngine pipeline against a fake host.
|
||||
/// </summary>
|
||||
public class SmokeRegressionTests
|
||||
{
|
||||
private const string SmokeYaml = """
|
||||
name: smoke-regression
|
||||
description: mimics real recorder output
|
||||
sut:
|
||||
exe: "EG-BIM Modeler/EG-BIM Modeler.exe"
|
||||
startup_timeout_ms: 12000
|
||||
steps:
|
||||
- kind: wheel
|
||||
value: "-120"
|
||||
- kind: drag
|
||||
target:
|
||||
uia_path: "Window/Canvas"
|
||||
offset: [0.5, 0.5]
|
||||
value: "0.6,0.4"
|
||||
- kind: click
|
||||
- kind: type
|
||||
value: "BOX"
|
||||
target:
|
||||
uia_path: "Window/Edit"
|
||||
offset: [0.5, 0.5]
|
||||
- kind: focus
|
||||
- kind: hotkey
|
||||
value: "ctrl+c"
|
||||
target:
|
||||
uia_path: "Window/Canvas"
|
||||
offset: [0.5, 0.5]
|
||||
""";
|
||||
|
||||
[Fact]
|
||||
public void FullPipeline_ParsesAndRunsWithoutException()
|
||||
{
|
||||
var scenario = ScenarioLoader.LoadFromString(SmokeYaml);
|
||||
|
||||
Assert.Equal(6, scenario.Steps.Count);
|
||||
Assert.Equal(StepKind.Wheel, scenario.Steps[0].Kind);
|
||||
Assert.Equal(StepKind.Focus, scenario.Steps[4].Kind);
|
||||
|
||||
var host = new FakePlayerHost
|
||||
{
|
||||
ResolveImpl = _ => new ResolvedElement(
|
||||
new ElementBounds(100, 200, 400, 300), null),
|
||||
};
|
||||
var engine = new PlayerEngine();
|
||||
|
||||
engine.Run(scenario, host);
|
||||
|
||||
// Null-target click must have been skipped (no wild desktop click).
|
||||
// Only the drag step provides a target → 1 drag.
|
||||
Assert.Single(host.Drags);
|
||||
// Type step with target → 1 type call.
|
||||
Assert.Equal(new[] { "BOX" }, host.Types);
|
||||
// hotkey with target → 1 hotkey call.
|
||||
Assert.Contains("ctrl+c", host.Hotkeys);
|
||||
// No clicks (the click step had null target).
|
||||
Assert.Empty(host.Clicks);
|
||||
// No failure artifacts.
|
||||
Assert.Empty(host.Failures);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user