test(selftests): implement ColorEditorBufferStep against editing buffer
This commit is contained in:
@@ -1,27 +1,67 @@
|
|||||||
using Dalamud.Bindings.ImGui;
|
using Dalamud.Bindings.ImGui;
|
||||||
using Dalamud.Plugin.SelfTest;
|
using Dalamud.Plugin.SelfTest;
|
||||||
|
using HellionChat.Themes;
|
||||||
|
|
||||||
namespace HellionChat.SelfTests;
|
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
|
internal sealed class ColorEditorBufferStep : ISelfTestStep
|
||||||
{
|
{
|
||||||
|
private readonly Plugin _plugin;
|
||||||
|
|
||||||
public ColorEditorBufferStep(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()
|
public SelfTestStepResult RunStep()
|
||||||
{
|
{
|
||||||
ImGui.TextDisabled(
|
var registry = _plugin.ThemeRegistry;
|
||||||
"Pending ColorEditor integration — placeholder selftest, no probe runs."
|
var originalActive = registry.Active;
|
||||||
);
|
var fired = 0;
|
||||||
return SelfTestStepResult.Pass;
|
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() { }
|
public void CleanUp() { }
|
||||||
|
|||||||
Reference in New Issue
Block a user