1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 21:27:24 +08:00

Move to TestPlayer and add null check

This commit is contained in:
Dan Balasescu 2022-08-09 15:05:05 +09:00
parent 6c671434ec
commit 00bdd52cff
2 changed files with 14 additions and 10 deletions

View File

@ -203,15 +203,5 @@ namespace osu.Game.Screens.Play
api.Queue(request);
return scoreSubmissionSource.Task;
}
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);
}
}
}

View File

@ -10,6 +10,7 @@ using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Game.Online.API;
using osu.Game.Online.Rooms;
using osu.Game.Online.Spectator;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
@ -46,6 +47,9 @@ namespace osu.Game.Tests.Visual
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)
: base(new PlayerConfiguration
{
@ -98,5 +102,15 @@ namespace osu.Game.Tests.Visual
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);
}
}
}