82 lines
3.1 KiB
C#
82 lines
3.1 KiB
C#
using System.Collections.Generic;
|
|
using Dalamud.Bindings.ImGui;
|
|
using Dalamud.Game.Text.SeStringHandling.Payloads;
|
|
using Dalamud.Plugin.SelfTest;
|
|
|
|
namespace HellionChat.SelfTests;
|
|
|
|
// B2-1/B2-2: proves the WorldSuffixMode/NameFormMode reformat reaches the REAL
|
|
// render entry. Drives ChunkRenderer.DrawChunks (a SelfTests/README-sanctioned
|
|
// real entry that wires SenderNameDisplay.ForDisplay at ChunkRenderer.cs:54)
|
|
// with a synthetic ChunkSource.Sender chunk carrying a PlayerPayload, at a
|
|
// non-neutral NameFormMode, and reads the LastRenderedSenderText observability
|
|
// the real draw produced. NameFormMode.Initials + WorldSuffixMode.Never is
|
|
// world-independent ("Test Tester" -> "T. T."), so the assertion is
|
|
// deterministic without a live world lookup. The MessageList routing (its row
|
|
// methods pass message.Sender to DrawChunks) is gated by the reviewer-grep
|
|
// (Step 2.6) + in-game smoke, since the visible sender change needs real chat +
|
|
// the world sheet. Does NOT call SenderNameFormatter/ForDisplay in isolation
|
|
// (the false-green trap — both are green today on a path the message list never
|
|
// takes for the sender).
|
|
internal sealed class SenderNameReformatStep : ISelfTestStep
|
|
{
|
|
private readonly Plugin plugin;
|
|
|
|
public SenderNameReformatStep(Plugin plugin)
|
|
{
|
|
this.plugin = plugin;
|
|
}
|
|
|
|
public string Name => "Hellion Chat - sender name reformat";
|
|
|
|
public SelfTestStepResult RunStep()
|
|
{
|
|
var renderer = this.plugin.ChunkRenderer;
|
|
if (renderer is null)
|
|
{
|
|
ImGui.Text("Plugin.ChunkRenderer is null");
|
|
return SelfTestStepResult.Fail;
|
|
}
|
|
|
|
var savedForm = Plugin.Config.NameFormMode;
|
|
var savedSuffix = Plugin.Config.WorldSuffixMode;
|
|
var savedScreenshot = Plugin.Config.ScreenshotMode;
|
|
try
|
|
{
|
|
// Initials (non-neutral) so ForDisplay reformats; Never + screenshot
|
|
// off so the result is world-independent and the reformat is not
|
|
// skipped.
|
|
Plugin.Config.NameFormMode = NameFormMode.Initials;
|
|
Plugin.Config.WorldSuffixMode = WorldSuffixMode.Never;
|
|
Plugin.Config.ScreenshotMode = false;
|
|
|
|
// ForDisplay formats payload.PlayerName, not the chunk text.
|
|
var payload = new PlayerPayload("Test Tester", 1u);
|
|
var senderChunks = new List<Chunk>
|
|
{
|
|
new TextChunk(ChunkSource.Sender, payload, "Test Tester"),
|
|
};
|
|
|
|
renderer.DrawChunks(senderChunks);
|
|
|
|
if (renderer.LastRenderedSenderText != "T. T.")
|
|
{
|
|
ImGui.Text(
|
|
$"LastRenderedSenderText = '{renderer.LastRenderedSenderText}', expected 'T. T.' (Initials reformat through the real render path)"
|
|
);
|
|
return SelfTestStepResult.Fail;
|
|
}
|
|
|
|
return SelfTestStepResult.Pass;
|
|
}
|
|
finally
|
|
{
|
|
Plugin.Config.NameFormMode = savedForm;
|
|
Plugin.Config.WorldSuffixMode = savedSuffix;
|
|
Plugin.Config.ScreenshotMode = savedScreenshot;
|
|
}
|
|
}
|
|
|
|
public void CleanUp() { }
|
|
}
|