1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 18:42:56 +08:00

Add test covering mod displays with too many mods

This commit is contained in:
Dean Herbert 2021-07-21 15:35:59 +09:00
parent 5bee06fd5f
commit b65e607941
3 changed files with 23 additions and 2 deletions

View File

@ -29,6 +29,12 @@ namespace osu.Game.Tests.Visual.Ranking
AddStep("show example score", () => showPanel(CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)), new TestScoreInfo(new OsuRuleset().RulesetInfo))); AddStep("show example score", () => showPanel(CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)), new TestScoreInfo(new OsuRuleset().RulesetInfo)));
} }
[Test]
public void TestExcessMods()
{
AddStep("show excess mods score", () => showPanel(CreateWorkingBeatmap(CreateBeatmap(new OsuRuleset().RulesetInfo)), new TestScoreInfo(new OsuRuleset().RulesetInfo, true)));
}
private void showPanel(WorkingBeatmap workingBeatmap, ScoreInfo score) private void showPanel(WorkingBeatmap workingBeatmap, ScoreInfo score)
{ {
Child = new ContractedPanelMiddleContentContainer(workingBeatmap, score); Child = new ContractedPanelMiddleContentContainer(workingBeatmap, score);

View File

@ -36,6 +36,17 @@ namespace osu.Game.Tests.Visual.Ranking
{ {
Beatmap = createTestBeatmap(author) Beatmap = createTestBeatmap(author)
})); }));
}
[Test]
public void TestExcessMods()
{
var author = new User { Username = "mapper_name" };
AddStep("show excess mods score", () => showPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo, true)
{
Beatmap = createTestBeatmap(author)
}));
AddAssert("mapper name present", () => this.ChildrenOfType<OsuSpriteText>().Any(spriteText => spriteText.Current.Value == "mapper_name")); AddAssert("mapper name present", () => this.ChildrenOfType<OsuSpriteText>().Any(spriteText => spriteText.Current.Value == "mapper_name"));
} }

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Linq;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
@ -13,7 +14,7 @@ namespace osu.Game.Tests
{ {
public class TestScoreInfo : ScoreInfo public class TestScoreInfo : ScoreInfo
{ {
public TestScoreInfo(RulesetInfo ruleset) public TestScoreInfo(RulesetInfo ruleset, bool excessMods = false)
{ {
User = new User User = new User
{ {
@ -25,7 +26,10 @@ namespace osu.Game.Tests
Beatmap = new TestBeatmap(ruleset).BeatmapInfo; Beatmap = new TestBeatmap(ruleset).BeatmapInfo;
Ruleset = ruleset; Ruleset = ruleset;
RulesetID = ruleset.ID ?? 0; RulesetID = ruleset.ID ?? 0;
Mods = new Mod[] { new TestModHardRock(), new TestModDoubleTime() };
Mods = excessMods
? ruleset.CreateInstance().GetAllMods().ToArray()
: new Mod[] { new TestModHardRock(), new TestModDoubleTime() };
TotalScore = 2845370; TotalScore = 2845370;
Accuracy = 0.95; Accuracy = 0.95;