test(selftests): verify TypingIpc state matches input bar
This commit is contained in:
@@ -346,6 +346,7 @@ public sealed class Plugin : IAsyncDalamudPlugin
|
|||||||
new SelfTests.ThemePickerCategoryStep(this),
|
new SelfTests.ThemePickerCategoryStep(this),
|
||||||
new SelfTests.SettingsWindowOpenStep(this),
|
new SelfTests.SettingsWindowOpenStep(this),
|
||||||
new SelfTests.OnOpenMainUiRoutesMainWindowStep(this),
|
new SelfTests.OnOpenMainUiRoutesMainWindowStep(this),
|
||||||
|
new SelfTests.TypingIpcStateStep(this),
|
||||||
new SelfTests.ConfigMigrationV20Step(this),
|
new SelfTests.ConfigMigrationV20Step(this),
|
||||||
new SelfTests.HoverSheenAllocStep(this),
|
new SelfTests.HoverSheenAllocStep(this),
|
||||||
new SelfTests.HonorificHeaderRenderStep(this),
|
new SelfTests.HonorificHeaderRenderStep(this),
|
||||||
|
|||||||
@@ -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() { }
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user