mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:52:55 +08:00
Merge pull request #19656 from smoogipoo/fix-gameplay-test-rerun
Fix gameplay tests crashing when run multiple times
This commit is contained in:
commit
47ca812faf
@ -10,6 +10,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
|
using osu.Game.Online.Spectator;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Scoring;
|
using osu.Game.Rulesets.Scoring;
|
||||||
@ -46,6 +47,9 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
public readonly List<JudgementResult> Results = new List<JudgementResult>();
|
public readonly List<JudgementResult> Results = new List<JudgementResult>();
|
||||||
|
|
||||||
|
[Resolved]
|
||||||
|
private SpectatorClient spectatorClient { get; set; }
|
||||||
|
|
||||||
public TestPlayer(bool allowPause = true, bool showResults = true, bool pauseOnFocusLost = false)
|
public TestPlayer(bool allowPause = true, bool showResults = true, bool pauseOnFocusLost = false)
|
||||||
: base(new PlayerConfiguration
|
: base(new PlayerConfiguration
|
||||||
{
|
{
|
||||||
@ -98,5 +102,15 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
ScoreProcessor.NewJudgement += r => Results.Add(r);
|
ScoreProcessor.NewJudgement += r => Results.Add(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Dispose(bool isDisposing)
|
||||||
|
{
|
||||||
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
|
// Specific to tests, the player can be disposed without OnExiting() ever being called.
|
||||||
|
// We should make sure that the gameplay session has finished even in this case.
|
||||||
|
if (LoadedBeatmapSuccessfully)
|
||||||
|
spectatorClient.EndPlaying(GameplayState);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user