74 lines
2.1 KiB
C#
74 lines
2.1 KiB
C#
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);
|
|
}
|
|
}
|