Skip to content

Commit

Permalink
Add failing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
bdach committed May 20, 2024
1 parent 85f85de commit 3b15c22
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions osu.Game.Tests/Visual/Navigation/TestScenePresentScore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,27 @@ public void TestPresentTwoImportsWithSameOnlineIDButDifferentHashes([Values] Sco
presentAndConfirm(secondImport, type);
}

[Test]
public void TestScoreRefetchIgnoresEmptyHash()
{
AddStep("enter song select", () => Game.ChildrenOfType<ButtonSystem>().Single().OnSolo?.Invoke());
AddUntilStep("song select is current", () => Game.ScreenStack.CurrentScreen is PlaySongSelect songSelect && songSelect.BeatmapSetsLoaded);

importScore(-1, hash: string.Empty);
importScore(3, hash: @"deadbeef");

// oftentimes a `PresentScore()` call will be given a `ScoreInfo` which is converted from an online score,
// in which cases the hash will generally not be available.
AddStep("present score", () => Game.PresentScore(new ScoreInfo { OnlineID = 3, Hash = string.Empty }));

AddUntilStep("wait for results", () => lastWaitedScreen != Game.ScreenStack.CurrentScreen && Game.ScreenStack.CurrentScreen is ResultsScreen);
AddUntilStep("correct score displayed", () =>
{
var score = ((ResultsScreen)Game.ScreenStack.CurrentScreen).Score!;
return score.OnlineID == 3 && score.Hash == "deadbeef";
});
}

private void returnToMenu()
{
// if we don't pause, there's a chance the track may change at the main menu out of our control (due to reaching the end of the track).
Expand All @@ -169,14 +190,14 @@ private void returnToMenu()
AddUntilStep("wait for menu", () => Game.ScreenStack.CurrentScreen is MainMenu);
}

private Func<ScoreInfo> importScore(int i, RulesetInfo? ruleset = null)
private Func<ScoreInfo> importScore(int i, RulesetInfo? ruleset = null, string? hash = null)
{
ScoreInfo? imported = null;
AddStep($"import score {i}", () =>
{
imported = Game.ScoreManager.Import(new ScoreInfo
{
Hash = Guid.NewGuid().ToString(),
Hash = hash ?? Guid.NewGuid().ToString(),
OnlineID = i,
BeatmapInfo = beatmap.Beatmaps.First(),
Ruleset = ruleset ?? new OsuRuleset().RulesetInfo,
Expand Down

0 comments on commit 3b15c22

Please sign in to comment.