102 lines
3.6 KiB
C#
102 lines
3.6 KiB
C#
using Dalamud.Bindings.ImGui;
|
|
using Dalamud.Plugin.SelfTest;
|
|
using HellionChat.Integrations;
|
|
|
|
namespace HellionChat.SelfTests;
|
|
|
|
// Verifies the About-tab integrations status. The pure HonorificStatus.Resolve
|
|
// covers the three-state mapping (false-green-free); driving the real AboutTab
|
|
// render once proves the render path actually calls the resolver (sets
|
|
// LastHonorificStatusKey). Set -> Draw -> Assert happen in ONE synchronous
|
|
// RunStep so a between-frame Honorific IPC callback can't clobber the seam
|
|
// state; the prior service state is restored in CleanUp.
|
|
internal sealed class AboutIntegrationsStatusStep : ISelfTestStep
|
|
{
|
|
private readonly Plugin plugin;
|
|
|
|
private HonorificService? _svc;
|
|
private bool _prevAvailable;
|
|
private (uint Major, uint Minor)? _prevVersion;
|
|
private HonorificTitleData? _prevTitle;
|
|
private bool _snapshotted;
|
|
|
|
public AboutIntegrationsStatusStep(Plugin plugin)
|
|
{
|
|
this.plugin = plugin;
|
|
}
|
|
|
|
public string Name => "Hellion Chat - About integrations status";
|
|
|
|
public SelfTestStepResult RunStep()
|
|
{
|
|
// AboutTab.Draw renders DrawBrand/coming-soon under _fonts.FontAwesome.Push;
|
|
// wait until the atlas is built so the render can't misbehave. Returned
|
|
// BEFORE any snapshot/Set, so no seam state leaks (same guard as the header
|
|
// step; precedent FoxBannerTextureSmokeStep).
|
|
if (!plugin.FontManager.FontsReady)
|
|
{
|
|
return SelfTestStepResult.Waiting;
|
|
}
|
|
|
|
// Pure mapping (incl. the isAvailable=true + null boundary -> NotInstalled).
|
|
if (
|
|
HonorificStatus.Resolve(true, (3, 1)) != HonorificStatusKind.Detected
|
|
|| HonorificStatus.Resolve(false, (2, 5)) != HonorificStatusKind.Incompatible
|
|
|| HonorificStatus.Resolve(false, null) != HonorificStatusKind.NotInstalled
|
|
|| HonorificStatus.Resolve(true, null) != HonorificStatusKind.NotInstalled
|
|
)
|
|
{
|
|
ImGui.Text("HonorificStatus.Resolve mapping is wrong");
|
|
return SelfTestStepResult.Fail;
|
|
}
|
|
|
|
var about = plugin.SettingsWindow.GetAboutTabForSelfTest();
|
|
if (about is null)
|
|
{
|
|
ImGui.Text("SettingsWindow.AboutTab reference is null");
|
|
return SelfTestStepResult.Fail;
|
|
}
|
|
|
|
_svc = plugin.MainWindow.GetHonorificHeaderForSelfTest()?.GetServiceForSelfTest();
|
|
if (_svc is null)
|
|
{
|
|
ImGui.Text("HonorificService reference is null");
|
|
return SelfTestStepResult.Fail;
|
|
}
|
|
|
|
_prevAvailable = _svc.IsAvailable;
|
|
_prevVersion = _svc.DetectedApiVersion;
|
|
_prevTitle = _svc.CurrentTitle;
|
|
_snapshotted = true;
|
|
|
|
try
|
|
{
|
|
// Drive the real render once and confirm the resolver is wired in.
|
|
_svc.TestOnly_SetState(true, (3, 1), null);
|
|
about.Draw();
|
|
if (about.LastHonorificStatusKey != HonorificStatusKind.Detected.ToString())
|
|
{
|
|
ImGui.Text(
|
|
$"About render did not resolve Detected (got {about.LastHonorificStatusKey})"
|
|
);
|
|
return SelfTestStepResult.Fail;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
ImGui.Text($"AboutTab.Draw threw: {ex.GetType().Name}: {ex.Message}");
|
|
return SelfTestStepResult.Fail;
|
|
}
|
|
|
|
return SelfTestStepResult.Pass;
|
|
}
|
|
|
|
public void CleanUp()
|
|
{
|
|
if (!_snapshotted || _svc is null)
|
|
return;
|
|
_svc.TestOnly_SetState(_prevAvailable, _prevVersion, _prevTitle);
|
|
_snapshotted = false;
|
|
}
|
|
}
|