Files
HellionChat/HellionChat/SelfTests/FontPushSmokeStep.cs
T
JonKazama-Hellion 4059b363a3 test(selftests): add FontManager ctor and push smoke steps
Two new self-test steps for the hybrid FontManager:

- FontManagerCtorSmokeStep proves all five handles land on the manager
  after Phase-1 resolve (ItalicFont nullable per Config.ItalicEnabled)
  and that no atlas-load exception is sitting on any of them
- FontPushSmokeStep proves IFontHandle.Push() returns without throwing
  for the two main delegate handles right after plugin load

Both steps run on the framework thread via the xlperf self-test path
and are registered alongside the existing theme-switch step in
SelfTestRegistry.
2026-05-17 18:34:33 +02:00

47 lines
1.3 KiB
C#

using Dalamud.Bindings.ImGui;
using Dalamud.Plugin.SelfTest;
namespace HellionChat.SelfTests;
// Push-safety smoke: IFontHandle.Push() is contracted safe regardless
// of the Available state, so this step proves the ctor-built handles
// can be pushed even right after plugin load. Self-test steps run on
// the framework thread via the xlperf path, so the push call itself
// stays main-thread-safe.
internal sealed class FontPushSmokeStep : ISelfTestStep
{
private readonly Plugin plugin;
public FontPushSmokeStep(Plugin plugin)
{
this.plugin = plugin;
}
public string Name => "Hellion Chat - FontManager push smoke";
public SelfTestStepResult RunStep()
{
var fm = this.plugin.FontManager;
if (fm?.RegularFont is null || fm.FontAwesome is null)
{
ImGui.Text("RegularFont or FontAwesome missing - see FontManager ctor smoke");
return SelfTestStepResult.Fail;
}
try
{
using (fm.RegularFont.Push()) { }
using (fm.FontAwesome.Push()) { }
}
catch (Exception e)
{
ImGui.Text($"Push threw: {e.GetType().Name}: {e.Message}");
return SelfTestStepResult.Fail;
}
return SelfTestStepResult.Pass;
}
public void CleanUp() { }
}