mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 10:17:22 +01:00
The goal of this change is to let plugins register their own self-tests. We do this through the `ISelfTestRegistry` interface. For a plugin it would look like this: ```csharp [PluginService] public ISelfTestRegistry SelfTestRegistry // Somewhere that gets called by your plugin SelfTestRegistry.RegisterTestSteps([ new MySelfTestStep(), new MyOtherSelfTestStep() ]) ``` Where `MySelfTest` and `MyOtherSelfTest` are instances of the existing `ISelfTestStep` interface. The biggest changes are to `SelfTestWindow` and the introduction of `SelfTestWithResults`. I wanted to make sure test state wasn't lost when changing the dropdown state and I was finding it a bit annoying to work with the Dictionary now that we can't just rely on the index of the item. To fix this I moved all the "test run" state into `SelfTestWithResults`, most of the changes to `SelfTestWindow` are derived from that, other then the addition of the combo box. The documentation for this service is a bit sparse, but I wanted to put it up for review first before I invest a bunch of time making nice documentation. I'm keen to hear if we think this is useful or if any changes are needed.
58 lines
1.5 KiB
C#
58 lines
1.5 KiB
C#
using Dalamud.Bindings.ImGui;
|
|
using Dalamud.Game.Gui.PartyFinder;
|
|
using Dalamud.Game.Gui.PartyFinder.Types;
|
|
using Dalamud.Plugin.SelfTest;
|
|
|
|
namespace Dalamud.Interface.Internal.Windows.SelfTest.Steps;
|
|
|
|
/// <summary>
|
|
/// Test setup for Party Finder events.
|
|
/// </summary>
|
|
internal class PartyFinderSelfTestStep : ISelfTestStep
|
|
{
|
|
private bool subscribed = false;
|
|
private bool hasPassed = false;
|
|
|
|
/// <inheritdoc/>
|
|
public string Name => "Test Party Finder";
|
|
|
|
/// <inheritdoc/>
|
|
public SelfTestStepResult RunStep()
|
|
{
|
|
var partyFinderGui = Service<PartyFinderGui>.Get();
|
|
|
|
if (!this.subscribed)
|
|
{
|
|
partyFinderGui.ReceiveListing += this.PartyFinderOnReceiveListing;
|
|
this.subscribed = true;
|
|
}
|
|
|
|
if (this.hasPassed)
|
|
{
|
|
partyFinderGui.ReceiveListing -= this.PartyFinderOnReceiveListing;
|
|
this.subscribed = false;
|
|
return SelfTestStepResult.Pass;
|
|
}
|
|
|
|
ImGui.Text("Open Party Finder"u8);
|
|
|
|
return SelfTestStepResult.Waiting;
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
public void CleanUp()
|
|
{
|
|
var partyFinderGui = Service<PartyFinderGui>.Get();
|
|
|
|
if (this.subscribed)
|
|
{
|
|
partyFinderGui.ReceiveListing -= this.PartyFinderOnReceiveListing;
|
|
this.subscribed = false;
|
|
}
|
|
}
|
|
|
|
private void PartyFinderOnReceiveListing(IPartyFinderListing listing, IPartyFinderListingEventArgs args)
|
|
{
|
|
this.hasPassed = true;
|
|
}
|
|
}
|