The first sweep matched a character class that swallowed the digit, so a bare B1 slipped through while B1-2 was caught. Searching the whole A-Z space instead of guessing prefixes turned up 130-odd more: B0 through B6, C2, C3, D1, H2, M6, P7, P8, T2, W2, plus GP-04, KB-01, OD-1, PM-1, PM-3, SEC-01, TR-4, TR-7, UI-11, UI-12, XC-8 and API-3. Kept deliberately: 41 B4 01 is a byte signature, "N0" a format string, #L119-L128 a source anchor, LS4/LS6 are linkshells, and A=FF B=0C G=41 R=C2 explains a colour-channel order. Those look like codes and are not. Also translated the eight German comments left in the theme files and ImGuiUtil. Seven of them described what a palette does to which channel, which is worth reading -- just not in a second language in an otherwise English codebase.
108 lines
3.8 KiB
C#
108 lines
3.8 KiB
C#
using Dalamud.Bindings.ImGui;
|
|
using Dalamud.Plugin.SelfTest;
|
|
using HellionChat.Ui.Components;
|
|
|
|
namespace HellionChat.SelfTests;
|
|
|
|
// Width-threshold guard. Sidebar must report Icon-only at any width
|
|
// below Config.SidebarAutoSwitchThresholdPx and Expanded once that
|
|
// threshold is crossed. The probe also pins the exact-threshold case
|
|
// because the contract uses >= (the threshold itself is Expanded).
|
|
internal sealed class SidebarModeAutoSwitchStep : ISelfTestStep
|
|
{
|
|
private readonly Plugin plugin;
|
|
|
|
public SidebarModeAutoSwitchStep(Plugin plugin)
|
|
{
|
|
this.plugin = plugin;
|
|
}
|
|
|
|
public string Name => "Hellion Chat - Sidebar auto-switch threshold";
|
|
|
|
public SelfTestStepResult RunStep()
|
|
{
|
|
var sidebar = plugin.MainWindow.GetSidebarForSelfTest();
|
|
if (sidebar is null)
|
|
{
|
|
ImGui.Text("MainWindow.Sidebar reference is null");
|
|
return SelfTestStepResult.Fail;
|
|
}
|
|
|
|
var threshold = (float)Plugin.Config.SidebarAutoSwitchThresholdPx;
|
|
|
|
if (sidebar.IsExpanded(threshold - 1f))
|
|
{
|
|
ImGui.Text($"Sidebar reported Expanded below threshold ({threshold - 1f}px)");
|
|
return SelfTestStepResult.Fail;
|
|
}
|
|
|
|
if (!sidebar.IsExpanded(threshold))
|
|
{
|
|
ImGui.Text($"Sidebar should report Expanded at the threshold ({threshold}px)");
|
|
return SelfTestStepResult.Fail;
|
|
}
|
|
|
|
if (!sidebar.IsExpanded(threshold + 100f))
|
|
{
|
|
ImGui.Text($"Sidebar should report Expanded above threshold ({threshold + 100f}px)");
|
|
return SelfTestStepResult.Fail;
|
|
}
|
|
|
|
var iconWidth = sidebar.GetWidth(threshold - 1f);
|
|
var expandedWidth = sidebar.GetWidth(threshold + 100f);
|
|
if (iconWidth >= expandedWidth)
|
|
{
|
|
ImGui.Text(
|
|
$"Icon-only width ({iconWidth}) should be smaller than Expanded width ({expandedWidth})"
|
|
);
|
|
return SelfTestStepResult.Fail;
|
|
}
|
|
|
|
// The expanded width must come from Config.SidebarWidth, not the
|
|
// old fixed 150 constant. Drive the REAL GetWidth (the single source
|
|
// Sidebar.Draw consumes) with concrete values and assert the OBSERVED
|
|
// effect — in-range passthrough plus clamping — instead of mirroring the
|
|
// Math.Clamp logic (SelfTests/README.md forbids re-implementing helper
|
|
// logic in the test). Restore the config in finally so the live render
|
|
// path is untouched.
|
|
var savedSidebarWidth = Plugin.Config.SidebarWidth;
|
|
try
|
|
{
|
|
Plugin.Config.SidebarWidth = 220;
|
|
if (sidebar.GetWidth(threshold + 100f) != 220f)
|
|
{
|
|
ImGui.Text(
|
|
$"GetWidth expanded = {sidebar.GetWidth(threshold + 100f)}, expected in-range Config.SidebarWidth 220"
|
|
);
|
|
return SelfTestStepResult.Fail;
|
|
}
|
|
|
|
Plugin.Config.SidebarWidth = 9999;
|
|
if (sidebar.GetWidth(threshold + 100f) != Sidebar.MaxSidebarWidth)
|
|
{
|
|
ImGui.Text(
|
|
$"GetWidth expanded = {sidebar.GetWidth(threshold + 100f)}, expected clamp to MaxSidebarWidth {Sidebar.MaxSidebarWidth}"
|
|
);
|
|
return SelfTestStepResult.Fail;
|
|
}
|
|
|
|
Plugin.Config.SidebarWidth = 1;
|
|
if (sidebar.GetWidth(threshold + 100f) != Sidebar.MinSidebarWidth)
|
|
{
|
|
ImGui.Text(
|
|
$"GetWidth expanded = {sidebar.GetWidth(threshold + 100f)}, expected clamp to MinSidebarWidth {Sidebar.MinSidebarWidth}"
|
|
);
|
|
return SelfTestStepResult.Fail;
|
|
}
|
|
}
|
|
finally
|
|
{
|
|
Plugin.Config.SidebarWidth = savedSidebarWidth;
|
|
}
|
|
|
|
return SelfTestStepResult.Pass;
|
|
}
|
|
|
|
public void CleanUp() { }
|
|
}
|