Add DutyState to Self-Test

This commit is contained in:
MidoriKami 2023-01-26 14:49:41 -08:00
parent 34466227ce
commit f8919da11f
2 changed files with 53 additions and 0 deletions

View file

@ -0,0 +1,52 @@
using Dalamud.Game.DutyState;
using ImGuiNET;
namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps;
/// <summary>
/// Test setup for the DutyState service class.
/// </summary>
internal class DutyStateAgingStep : IAgingStep
{
private bool subscribed = false;
private bool hasPassed = false;
/// <inheritdoc/>
public string Name => "Test DutyState";
/// <inheritdoc/>
public SelfTestStepResult RunStep()
{
var dutyState = Service<DutyState>.Get();
ImGui.Text("Enter a duty now...");
if (!this.subscribed)
{
dutyState.DutyStarted += this.DutyStateOnDutyStarted;
this.subscribed = true;
}
if (this.hasPassed)
{
dutyState.DutyStarted -= this.DutyStateOnDutyStarted;
this.subscribed = false;
return SelfTestStepResult.Pass;
}
return SelfTestStepResult.Waiting;
}
/// <inheritdoc/>
public void CleanUp()
{
var dutyState = Service<DutyState>.Get();
dutyState.DutyStarted -= this.DutyStateOnDutyStarted;
}
private void DutyStateOnDutyStarted(object? sender, ushort e)
{
this.hasPassed = true;
}
}

View file

@ -42,6 +42,7 @@ internal class SelfTestWindow : Window
new PartyFinderAgingStep(),
new HandledExceptionAgingStep(),
new LogoutEventAgingStep(),
new DutyStateAgingStep(),
};
private readonly List<(SelfTestStepResult Result, TimeSpan? Duration)> stepResults = new();