diff --git a/HellionChat/Plugin.cs b/HellionChat/Plugin.cs index df6fe3f..2b06dd0 100755 --- a/HellionChat/Plugin.cs +++ b/HellionChat/Plugin.cs @@ -346,6 +346,7 @@ public sealed class Plugin : IAsyncDalamudPlugin new SelfTests.ThemePickerCategoryStep(this), new SelfTests.SettingsWindowOpenStep(this), new SelfTests.OnOpenMainUiRoutesMainWindowStep(this), + new SelfTests.TypingIpcStateStep(this), new SelfTests.ConfigMigrationV20Step(this), new SelfTests.HoverSheenAllocStep(this), new SelfTests.HonorificHeaderRenderStep(this), diff --git a/HellionChat/SelfTests/TypingIpcStateStep.cs b/HellionChat/SelfTests/TypingIpcStateStep.cs new file mode 100644 index 0000000..b0fa4d1 --- /dev/null +++ b/HellionChat/SelfTests/TypingIpcStateStep.cs @@ -0,0 +1,73 @@ +using Dalamud.Bindings.ImGui; +using Dalamud.Plugin.SelfTest; + +namespace HellionChat.SelfTests; + +internal sealed class TypingIpcStateStep : ISelfTestStep +{ + private readonly Plugin _plugin; + + public TypingIpcStateStep(Plugin plugin) + { + _plugin = plugin; + } + + public string Name => "Hellion Chat - TypingIpc state reflects input bar"; + + public SelfTestStepResult RunStep() + { + // /xlperf typically runs without MainWindow open. TypingIpc.BuildState gates + // InputFocused on MainWindow.IsOpen (stale-state guard); without this setup + // InputFocused would be false regardless of the hook. Restore in finally so + // the test leaves no UI side-effect. + var initialMainWindowOpen = _plugin.MainWindow.IsOpen; + if (!initialMainWindowOpen) + { + _plugin.MainWindow.Toggle(); + } + + // Snapshot pending so we restore in-flight user input verbatim. + var initialPendingMessage = _plugin.InputBar.PendingMessage; + _plugin.InputBar.TestSetPendingMessageForSelfTest("hello"); + _plugin.InputBar.TestSetFocusedForSelfTest(true); + + try + { + var state = _plugin.TypingIpc.GetState(); + + if (!state.HasText) + { + ImGui.Text("HasText should be true"); + return SelfTestStepResult.Fail; + } + if (!state.IsTyping) + { + ImGui.Text("IsTyping should be true"); + return SelfTestStepResult.Fail; + } + if (state.TextLength != 5) + { + ImGui.Text($"TextLength should be 5, got {state.TextLength}"); + return SelfTestStepResult.Fail; + } + if (!state.InputFocused) + { + ImGui.Text("InputFocused should be true"); + return SelfTestStepResult.Fail; + } + + return SelfTestStepResult.Pass; + } + finally + { + _plugin.InputBar.TestSetPendingMessageForSelfTest(initialPendingMessage); + _plugin.InputBar.TestSetFocusedForSelfTest(null); + if (!initialMainWindowOpen) + { + _plugin.MainWindow.Toggle(); + } + } + } + + public void CleanUp() { } +}