mirror of
https://github.com/ppy/osu
synced 2025-01-07 06:40:05 +00:00
Add test coverage of saving a failed score
This commit is contained in:
parent
0200ef1d48
commit
21433d4ecb
@ -8,14 +8,18 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Audio;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.ObjectExtensions;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Containers;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Screens.Ranking;
|
||||
using osu.Game.Tests.Resources;
|
||||
|
||||
@ -58,13 +62,30 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
|
||||
protected override bool HasCustomSteps => true;
|
||||
|
||||
protected override bool AllowFail => false;
|
||||
protected override bool AllowFail => allowFail;
|
||||
|
||||
private bool allowFail;
|
||||
|
||||
[Test]
|
||||
public void TestSaveFailedReplay()
|
||||
{
|
||||
AddStep("set fail", () => allowFail = true);
|
||||
AddStep("set no custom ruleset", () => customRuleset = null);
|
||||
|
||||
CreateTest();
|
||||
|
||||
AddUntilStep("fail screen displayed", () => Player.ChildrenOfType<FailOverlay>().First().State.Value == Visibility.Visible);
|
||||
AddUntilStep("score not in database", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID) == null));
|
||||
AddStep("click save button", () => Player.ChildrenOfType<SaveFailedScoreButton>().First().ChildrenOfType<OsuClickableContainer>().First().TriggerClick());
|
||||
AddUntilStep("score not in database", () => Realm.Run(r => r.Find<ScoreInfo>(Player.Score.ScoreInfo.ID) != null));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLastPlayedUpdated()
|
||||
{
|
||||
DateTimeOffset? getLastPlayed() => Realm.Run(r => r.Find<BeatmapInfo>(Beatmap.Value.BeatmapInfo.ID)?.LastPlayed);
|
||||
|
||||
AddStep("set no fail", () => allowFail = false);
|
||||
AddStep("set no custom ruleset", () => customRuleset = null);
|
||||
AddAssert("last played is null", () => getLastPlayed() == null);
|
||||
|
||||
@ -77,6 +98,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
[Test]
|
||||
public void TestScoreStoredLocally()
|
||||
{
|
||||
AddStep("set no fail", () => allowFail = false);
|
||||
AddStep("set no custom ruleset", () => customRuleset = null);
|
||||
|
||||
CreateTest();
|
||||
@ -94,6 +116,7 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
{
|
||||
Ruleset createCustomRuleset() => new CustomRuleset();
|
||||
|
||||
AddStep("set no fail", () => allowFail = false);
|
||||
AddStep("import custom ruleset", () => Realm.Write(r => r.Add(createCustomRuleset().RulesetInfo)));
|
||||
AddStep("set custom ruleset", () => customRuleset = createCustomRuleset());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user