test(selftests): verify OpenMainUi targets MainWindow not Settings
This commit is contained in:
@@ -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),
|
||||
|
||||
@@ -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() { }
|
||||
}
|
||||
Reference in New Issue
Block a user