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.
This commit is contained in:
@@ -317,7 +317,11 @@ public sealed class Plugin : IAsyncDalamudPlugin
|
|||||||
if (_lifecycle is not null)
|
if (_lifecycle is not null)
|
||||||
await _lifecycle.LoadAsync(cancellationToken).ConfigureAwait(false);
|
await _lifecycle.LoadAsync(cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
SelfTestRegistry.RegisterTestSteps([new SelfTests.ThemeSwitchSelfTestStep(this)]);
|
SelfTestRegistry.RegisterTestSteps([
|
||||||
|
new SelfTests.ThemeSwitchSelfTestStep(this),
|
||||||
|
new SelfTests.FontManagerCtorSmokeStep(this),
|
||||||
|
new SelfTests.FontPushSmokeStep(this),
|
||||||
|
]);
|
||||||
|
|
||||||
if (!Config.FirstRunCompleted)
|
if (!Config.FirstRunCompleted)
|
||||||
FirstRunWizard.IsOpen = true;
|
FirstRunWizard.IsOpen = true;
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
using Dalamud.Bindings.ImGui;
|
||||||
|
using Dalamud.Plugin.SelfTest;
|
||||||
|
|
||||||
|
namespace HellionChat.SelfTests;
|
||||||
|
|
||||||
|
// Verifies the FontManager came out of the DI container with every
|
||||||
|
// handle attached and no atlas-load failure on any of them. ItalicFont
|
||||||
|
// is allowed to be null when ItalicEnabled is off.
|
||||||
|
internal sealed class FontManagerCtorSmokeStep : ISelfTestStep
|
||||||
|
{
|
||||||
|
private readonly Plugin plugin;
|
||||||
|
|
||||||
|
public FontManagerCtorSmokeStep(Plugin plugin)
|
||||||
|
{
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name => "Hellion Chat - FontManager ctor smoke";
|
||||||
|
|
||||||
|
public SelfTestStepResult RunStep()
|
||||||
|
{
|
||||||
|
var fm = this.plugin.FontManager;
|
||||||
|
if (fm is null)
|
||||||
|
{
|
||||||
|
ImGui.Text("Plugin.FontManager is null");
|
||||||
|
return SelfTestStepResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fm.Axis is null)
|
||||||
|
{
|
||||||
|
ImGui.Text("Axis handle is null");
|
||||||
|
return SelfTestStepResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fm.AxisItalic is null)
|
||||||
|
{
|
||||||
|
ImGui.Text("AxisItalic handle is null");
|
||||||
|
return SelfTestStepResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fm.FontAwesome is null)
|
||||||
|
{
|
||||||
|
ImGui.Text("FontAwesome handle is null");
|
||||||
|
return SelfTestStepResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fm.RegularFont is null)
|
||||||
|
{
|
||||||
|
ImGui.Text("RegularFont handle is null");
|
||||||
|
return SelfTestStepResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Plugin.Config.ItalicEnabled && fm.ItalicFont is null)
|
||||||
|
{
|
||||||
|
ImGui.Text("ItalicEnabled is on but ItalicFont handle is null");
|
||||||
|
return SelfTestStepResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fm.Axis.LoadException is { } e1)
|
||||||
|
{
|
||||||
|
ImGui.Text($"Axis load exception: {e1.Message}");
|
||||||
|
return SelfTestStepResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fm.AxisItalic.LoadException is { } e2)
|
||||||
|
{
|
||||||
|
ImGui.Text($"AxisItalic load exception: {e2.Message}");
|
||||||
|
return SelfTestStepResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fm.FontAwesome.LoadException is { } e3)
|
||||||
|
{
|
||||||
|
ImGui.Text($"FontAwesome load exception: {e3.Message}");
|
||||||
|
return SelfTestStepResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fm.RegularFont.LoadException is { } e4)
|
||||||
|
{
|
||||||
|
ImGui.Text($"RegularFont load exception: {e4.Message}");
|
||||||
|
return SelfTestStepResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fm.ItalicFont?.LoadException is { } e5)
|
||||||
|
{
|
||||||
|
ImGui.Text($"ItalicFont load exception: {e5.Message}");
|
||||||
|
return SelfTestStepResult.Fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
return SelfTestStepResult.Pass;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void CleanUp() { }
|
||||||
|
}
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
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() { }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user