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() { } +}