1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 07:33:20 +08:00

Mark score failed on fail and exit

This commit is contained in:
Dean Herbert 2021-07-01 17:38:28 +09:00
parent 6e8d4e382e
commit 74c63e15be
4 changed files with 39 additions and 13 deletions

View File

@ -23,9 +23,14 @@ namespace osu.Game.Tests.Visual.Gameplay
protected override bool HasCustomSteps => true;
private bool allowFail;
protected override TestPlayer CreatePlayer(Ruleset ruleset)
{
SelectedMods.Value = new[] { ruleset.GetAllMods().OfType<ModNoFail>().First() };
SelectedMods.Value = !allowFail
? new[] { ruleset.GetAllMods().OfType<ModNoFail>().First() }
: Array.Empty<Mod>();
return new TestPlayer(false);
}
@ -34,7 +39,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
prepareTokenResponse(false);
CreateTest(() => { });
CreateTest(() => allowFail = false);
AddUntilStep("wait for token request", () => Player.TokenCreationRequested);
@ -43,7 +48,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddUntilStep("results displayed", () => Player.GetChildScreen() is ResultsScreen);
AddAssert("ensure no submission", () => !Player.SubmissionRequested);
AddAssert("ensure no submission", () => Player.SubmittedScore == null);
}
[Test]
@ -51,7 +56,7 @@ namespace osu.Game.Tests.Visual.Gameplay
{
prepareTokenResponse(true);
CreateTest(() => { });
CreateTest(() => allowFail = false);
AddUntilStep("wait for token request", () => Player.TokenCreationRequested);
@ -59,8 +64,7 @@ namespace osu.Game.Tests.Visual.Gameplay
AddStep("seek to completion", () => Player.GameplayClockContainer.Seek(Player.DrawableRuleset.Objects.Last().GetEndTime()));
AddUntilStep("results displayed", () => Player.GetChildScreen() is ResultsScreen);
AddAssert("ensure submission", () => Player.SubmissionRequested);
AddAssert("ensure passing submission", () => Player.SubmittedScore?.ScoreInfo.Passed == true);
}
[Test]
@ -68,12 +72,26 @@ namespace osu.Game.Tests.Visual.Gameplay
{
prepareTokenResponse(false);
CreateTest(() => { });
CreateTest(() => allowFail = false);
AddUntilStep("wait for token request", () => Player.TokenCreationRequested);
AddStep("exit", () => Player.Exit());
AddAssert("ensure no submission", () => Player.SubmittedScore == null);
}
[Test]
public void TestSubmissionOnFail()
{
prepareTokenResponse(true);
CreateTest(() => allowFail = true);
AddUntilStep("wait for token request", () => Player.TokenCreationRequested);
AddUntilStep("wait for fail", () => Player.HasFailed);
AddStep("exit", () => Player.Exit());
AddAssert("ensure no submission", () => !Player.SubmissionRequested);
AddAssert("ensure failing submission", () => Player.SubmittedScore?.ScoreInfo.Passed == false);
}
[Test]
@ -81,11 +99,11 @@ namespace osu.Game.Tests.Visual.Gameplay
{
prepareTokenResponse(true);
CreateTest(() => { });
CreateTest(() => allowFail = false);
AddUntilStep("wait for token request", () => Player.TokenCreationRequested);
AddStep("exit", () => Player.Exit());
AddUntilStep("wait for submission", () => Player.SubmissionRequested);
AddAssert("ensure failing submission", () => Player.SubmittedScore?.ScoreInfo.Passed == false);
}
private void prepareTokenResponse(bool validToken)

View File

@ -768,6 +768,7 @@ namespace osu.Game.Screens.Play
return false;
HasFailed = true;
Score.ScoreInfo.Passed = false;
// There is a chance that we could be in a paused state as the ruleset's internal clock (see FrameStabilityContainer)
// could process an extra frame after the GameplayClock is stopped.
@ -950,6 +951,10 @@ namespace osu.Game.Screens.Play
{
screenSuspension?.Expire();
// if arriving here and the results screen preparation task hasn't run, it's safe to say the user has not completed the beatmap.
if (prepareScoreForDisplayTask == null)
Score.ScoreInfo.Passed = false;
// EndPlaying() is typically called from ReplayRecorder.Dispose(). Disposal is currently asynchronous.
// To resolve test failures, forcefully end playing synchronously when this screen exits.
// Todo: Replace this with a more permanent solution once osu-framework has a synchronous cleanup method.

View File

@ -113,9 +113,11 @@ namespace osu.Game.Screens.Play
public override bool OnExiting(IScreen next)
{
var exiting = base.OnExiting(next);
submitScore(Score);
return base.OnExiting(next);
return exiting;
}
/// <summary>

View File

@ -40,7 +40,8 @@ namespace osu.Game.Tests.Visual
public new HealthProcessor HealthProcessor => base.HealthProcessor;
public bool TokenCreationRequested { get; private set; }
public bool SubmissionRequested { get; private set; }
public Score SubmittedScore { get; private set; }
public new bool PauseCooldownActive => base.PauseCooldownActive;
@ -66,7 +67,7 @@ namespace osu.Game.Tests.Visual
protected override APIRequest<MultiplayerScore> CreateSubmissionRequest(Score score, long token)
{
SubmissionRequested = true;
SubmittedScore = score;
return base.CreateSubmissionRequest(score, token);
}