test(selftests): implement ColorEditorBufferStep against editing buffer

This commit is contained in:
2026-05-26 22:50:13 +02:00
parent 730e15d108
commit 4595de5efc
+49 -9
View File
@@ -1,28 +1,68 @@
using Dalamud.Bindings.ImGui;
using Dalamud.Plugin.SelfTest;
using HellionChat.Themes;
namespace HellionChat.SelfTests;
// Placeholder. The real working-buffer test (Cancel discards, Save
// persists) lands once the ColorPicker component arrives in a later
// cycle. Listed in the registry today so /xlperf shows the slot as
// pending instead of silently missing.
internal sealed class ColorEditorBufferStep : ISelfTestStep
{
private readonly Plugin _plugin;
public ColorEditorBufferStep(Plugin plugin)
{
_ = plugin;
_plugin = plugin;
}
public string Name => "Hellion Chat - Color editor buffer (pending)";
public string Name => "Hellion Chat - Color editor buffer";
public SelfTestStepResult RunStep()
{
ImGui.TextDisabled(
"Pending ColorEditor integration — placeholder selftest, no probe runs."
);
var registry = _plugin.ThemeRegistry;
var originalActive = registry.Active;
var fired = 0;
Action handler = () => fired++;
try
{
registry.OnEditingBufferChanged += handler;
registry.BeginEditing(originalActive);
if (registry.EditingThemeBuffer is null)
{
ImGui.Text("EditingThemeBuffer should not be null after BeginEditing");
return SelfTestStepResult.Fail;
}
var mutatedColors = registry.EditingThemeBuffer.Colors with { Primary = 0xFF112233 };
registry.UpdateEditingBuffer(mutatedColors);
if (fired != 1)
{
ImGui.Text($"Expected OnEditingBufferChanged once, got {fired}");
return SelfTestStepResult.Fail;
}
registry.DiscardEditingBuffer();
if (registry.EditingThemeBuffer is not null)
{
ImGui.Text("EditingThemeBuffer should be null after Discard");
return SelfTestStepResult.Fail;
}
if (registry.Active != originalActive)
{
ImGui.Text("Active theme should be unchanged after Discard");
return SelfTestStepResult.Fail;
}
return SelfTestStepResult.Pass;
}
finally
{
registry.OnEditingBufferChanged -= handler;
}
}
public void CleanUp() { }
}