diff --git a/Dalamud/Interface/Internal/Windows/SelfTest/AgingSteps/LoginEventAgingStep.cs b/Dalamud/Interface/Internal/Windows/SelfTest/AgingSteps/LoginEventAgingStep.cs index 8a04febf9..27297083c 100644 --- a/Dalamud/Interface/Internal/Windows/SelfTest/AgingSteps/LoginEventAgingStep.cs +++ b/Dalamud/Interface/Internal/Windows/SelfTest/AgingSteps/LoginEventAgingStep.cs @@ -9,7 +9,7 @@ namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps /// internal class LoginEventAgingStep : IAgingStep { - private bool isSubscribed = false; + private bool subscribed = false; private bool hasPassed = false; /// @@ -20,16 +20,16 @@ namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps { ImGui.Text("Log in now..."); - if (!this.isSubscribed) + if (!this.subscribed) { dalamud.ClientState.OnLogin += this.ClientStateOnOnLogin; - this.isSubscribed = true; + this.subscribed = true; } if (this.hasPassed) { dalamud.ClientState.OnLogin -= this.ClientStateOnOnLogin; - this.isSubscribed = false; + this.subscribed = false; return SelfTestStepResult.Pass; } @@ -39,10 +39,10 @@ namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps /// public void CleanUp(Dalamud dalamud) { - if (this.isSubscribed) + if (this.subscribed) { dalamud.ClientState.OnLogin -= this.ClientStateOnOnLogin; - this.isSubscribed = false; + this.subscribed = false; } } diff --git a/Dalamud/Interface/Internal/Windows/SelfTest/AgingSteps/LogoutEventAgingStep.cs b/Dalamud/Interface/Internal/Windows/SelfTest/AgingSteps/LogoutEventAgingStep.cs new file mode 100644 index 000000000..0356c0dd2 --- /dev/null +++ b/Dalamud/Interface/Internal/Windows/SelfTest/AgingSteps/LogoutEventAgingStep.cs @@ -0,0 +1,54 @@ +using System; + +using ImGuiNET; + +namespace Dalamud.Interface.Internal.Windows.SelfTest.AgingSteps +{ + /// + /// Test setup for the login events. + /// + internal class LogoutEventAgingStep : IAgingStep + { + private bool subscribed = false; + private bool hasPassed = false; + + /// + public string Name => "Test Log-In"; + + /// + public SelfTestStepResult RunStep(Dalamud dalamud) + { + ImGui.Text("Log out now..."); + + if (!this.subscribed) + { + dalamud.ClientState.OnLogout += this.ClientStateOnOnLogout; + this.subscribed = true; + } + + if (this.hasPassed) + { + dalamud.ClientState.OnLogout -= this.ClientStateOnOnLogout; + this.subscribed = false; + return SelfTestStepResult.Pass; + } + + return SelfTestStepResult.Waiting; + } + + /// + public void CleanUp(Dalamud dalamud) + { + if (this.subscribed) + { + dalamud.ClientState.OnLogout -= this.ClientStateOnOnLogout; + this.subscribed = false; + } + } + + private void ClientStateOnOnLogout(object sender, EventArgs e) + { + this.hasPassed = true; + } + } +}