39 lines
1.6 KiB
C#
39 lines
1.6 KiB
C#
namespace Recordingtest.Player.Tests;
|
|
|
|
internal sealed class FakePlayerHost : IPlayerHost
|
|
{
|
|
public Func<string, ResolvedElement?> ResolveImpl { get; set; } =
|
|
_ => new ResolvedElement(new ElementBounds(100, 200, 50, 40), null);
|
|
public Func<string, bool> WaitForImpl { get; set; } = _ => true;
|
|
|
|
public List<ScreenPoint> Clicks { get; } = new();
|
|
public List<string> Types { get; } = new();
|
|
public List<(ScreenPoint From, ScreenPoint To)> Drags { get; } = new();
|
|
public List<string> Hotkeys { get; } = new();
|
|
public List<(int AfterStep, string SaveAs)> Checkpoints { get; } = new();
|
|
public List<(int StepIndex, string Reason)> Failures { get; } = new();
|
|
public List<string> Resolved { get; } = new();
|
|
public List<string> WaitedFor { get; } = new();
|
|
|
|
public ResolvedElement? ResolveElement(string uiaPath, TimeSpan timeout)
|
|
{
|
|
Resolved.Add(uiaPath);
|
|
return ResolveImpl(uiaPath);
|
|
}
|
|
|
|
public bool WaitFor(string waitForHint, TimeSpan timeout)
|
|
{
|
|
WaitedFor.Add(waitForHint);
|
|
return WaitForImpl(waitForHint);
|
|
}
|
|
|
|
public void Click(ScreenPoint point) => Clicks.Add(point);
|
|
public void Type(string text) => Types.Add(text);
|
|
public void Drag(ScreenPoint from, ScreenPoint to) => Drags.Add((from, to));
|
|
public void Hotkey(string keys) => Hotkeys.Add(keys);
|
|
public void CaptureCheckpoint(int afterStep, string saveAs) =>
|
|
Checkpoints.Add((afterStep, saveAs));
|
|
public void CaptureFailureArtifacts(int stepIndex, string reason) =>
|
|
Failures.Add((stepIndex, reason));
|
|
}
|