From 125a41c6a0e24bf5e72fac7efec8b6e0f665a92c Mon Sep 17 00:00:00 2001 From: Jon Kazama Date: Tue, 26 May 2026 23:01:26 +0200 Subject: [PATCH] test(selftests): verify OpenMainUi targets MainWindow not Settings --- HellionChat/Plugin.cs | 1 + .../OnOpenMainUiRoutesMainWindowStep.cs | 45 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 HellionChat/SelfTests/OnOpenMainUiRoutesMainWindowStep.cs diff --git a/HellionChat/Plugin.cs b/HellionChat/Plugin.cs index 4f987ca..df6fe3f 100755 --- a/HellionChat/Plugin.cs +++ b/HellionChat/Plugin.cs @@ -345,6 +345,7 @@ public sealed class Plugin : IAsyncDalamudPlugin new SelfTests.ColorEditorBufferStep(this), new SelfTests.ThemePickerCategoryStep(this), new SelfTests.SettingsWindowOpenStep(this), + new SelfTests.OnOpenMainUiRoutesMainWindowStep(this), new SelfTests.ConfigMigrationV20Step(this), new SelfTests.HoverSheenAllocStep(this), new SelfTests.HonorificHeaderRenderStep(this), diff --git a/HellionChat/SelfTests/OnOpenMainUiRoutesMainWindowStep.cs b/HellionChat/SelfTests/OnOpenMainUiRoutesMainWindowStep.cs new file mode 100644 index 0000000..d17d46a --- /dev/null +++ b/HellionChat/SelfTests/OnOpenMainUiRoutesMainWindowStep.cs @@ -0,0 +1,45 @@ +using Dalamud.Bindings.ImGui; +using Dalamud.Plugin.SelfTest; + +namespace HellionChat.SelfTests; + +internal sealed class OnOpenMainUiRoutesMainWindowStep : ISelfTestStep +{ + private readonly Plugin _plugin; + + public OnOpenMainUiRoutesMainWindowStep(Plugin plugin) + { + _plugin = plugin; + } + + public string Name => "Hellion Chat - OpenMainUi routes to MainWindow"; + + public SelfTestStepResult RunStep() + { + var settingsBefore = _plugin.SettingsWindow.IsOpen; + var mainBefore = _plugin.MainWindow.IsOpen; + + _plugin.MainWindow.Toggle(); + + var mainAfter = _plugin.MainWindow.IsOpen; + var settingsAfter = _plugin.SettingsWindow.IsOpen; + + // Restore original state. + _plugin.MainWindow.Toggle(); + + if (mainAfter == mainBefore) + { + ImGui.Text("MainWindow did not toggle"); + return SelfTestStepResult.Fail; + } + if (settingsAfter != settingsBefore) + { + ImGui.Text("SettingsWindow state changed unexpectedly"); + return SelfTestStepResult.Fail; + } + + return SelfTestStepResult.Pass; + } + + public void CleanUp() { } +}