1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 15:12:57 +08:00

Fix test failures

This commit is contained in:
smoogipoo 2020-06-11 14:55:49 +09:00
parent afa5b995f2
commit 7b012f1def
3 changed files with 25 additions and 19 deletions

View File

@ -19,6 +19,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets; using osu.Game.Rulesets;
using osu.Game.Rulesets.Osu;
using osu.Game.Rulesets.Osu.Mods; using osu.Game.Rulesets.Osu.Mods;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens; using osu.Game.Screens;
@ -27,6 +28,7 @@ using osu.Game.Screens.Play;
using osu.Game.Screens.Play.PlayerSettings; using osu.Game.Screens.Play.PlayerSettings;
using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking;
using osu.Game.Screens.Select; using osu.Game.Screens.Select;
using osu.Game.Tests.Beatmaps;
using osu.Game.Tests.Resources; using osu.Game.Tests.Resources;
using osu.Game.Users; using osu.Game.Users;
using osuTK; using osuTK;
@ -186,9 +188,15 @@ namespace osu.Game.Tests.Visual.Background
public void TestTransition() public void TestTransition()
{ {
performFullSetup(); performFullSetup();
FadeAccessibleResults results = null; FadeAccessibleResults results = null;
AddStep("Transition to Results", () => player.Push(results =
new FadeAccessibleResults(new ScoreInfo { User = new User { Username = "osu!" } }))); AddStep("Transition to Results", () => player.Push(results = new FadeAccessibleResults(new ScoreInfo
{
User = new User { Username = "osu!" },
Beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo
})));
AddUntilStep("Wait for results is current", () => results.IsCurrentScreen()); AddUntilStep("Wait for results is current", () => results.IsCurrentScreen());
AddUntilStep("Screen is undimmed, original background retained", () => AddUntilStep("Screen is undimmed, original background retained", () =>
songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && results.IsBlurCorrect()); songSelect.IsBackgroundUndimmed() && songSelect.IsBackgroundCurrent() && results.IsBlurCorrect());

View File

@ -4,7 +4,6 @@
using System.Linq; using System.Linq;
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -33,7 +32,10 @@ namespace osu.Game.Tests.Visual.Ranking
{ {
var author = new User { Username = "mapper_name" }; var author = new User { Username = "mapper_name" };
AddStep("show example score", () => showPanel(createTestBeatmap(author), new TestScoreInfo(new OsuRuleset().RulesetInfo))); AddStep("show example score", () => showPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo)
{
Beatmap = createTestBeatmap(author)
}));
AddAssert("mapper name present", () => this.ChildrenOfType<OsuSpriteText>().Any(spriteText => spriteText.Text == "mapper_name")); AddAssert("mapper name present", () => this.ChildrenOfType<OsuSpriteText>().Any(spriteText => spriteText.Text == "mapper_name"));
} }
@ -41,38 +43,34 @@ namespace osu.Game.Tests.Visual.Ranking
[Test] [Test]
public void TestMapWithUnknownMapper() public void TestMapWithUnknownMapper()
{ {
AddStep("show example score", () => showPanel(createTestBeatmap(null), new TestScoreInfo(new OsuRuleset().RulesetInfo))); AddStep("show example score", () => showPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo)
{
Beatmap = createTestBeatmap(null)
}));
AddAssert("mapped by text not present", () => AddAssert("mapped by text not present", () =>
this.ChildrenOfType<OsuSpriteText>().All(spriteText => !containsAny(spriteText.Text, "mapped", "by"))); this.ChildrenOfType<OsuSpriteText>().All(spriteText => !containsAny(spriteText.Text, "mapped", "by")));
} }
private void showPanel(WorkingBeatmap workingBeatmap, ScoreInfo score) private void showPanel(ScoreInfo score) => Child = new ExpandedPanelMiddleContentContainer(score);
{
Child = new ExpandedPanelMiddleContentContainer(workingBeatmap, score);
}
private WorkingBeatmap createTestBeatmap(User author) private BeatmapInfo createTestBeatmap(User author)
{ {
var beatmap = new TestBeatmap(rulesetStore.GetRuleset(0)); var beatmap = new TestBeatmap(rulesetStore.GetRuleset(0)).BeatmapInfo;
beatmap.Metadata.Author = author; beatmap.Metadata.Author = author;
beatmap.Metadata.Title = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong beatmap title"; beatmap.Metadata.Title = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong beatmap title";
beatmap.Metadata.Artist = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong beatmap artist"; beatmap.Metadata.Artist = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong beatmap artist";
return new TestWorkingBeatmap(beatmap); return beatmap;
} }
private bool containsAny(string text, params string[] stringsToMatch) => stringsToMatch.Any(text.Contains); private bool containsAny(string text, params string[] stringsToMatch) => stringsToMatch.Any(text.Contains);
private class ExpandedPanelMiddleContentContainer : Container private class ExpandedPanelMiddleContentContainer : Container
{ {
[Cached] public ExpandedPanelMiddleContentContainer(ScoreInfo score)
private Bindable<WorkingBeatmap> workingBeatmap { get; set; }
public ExpandedPanelMiddleContentContainer(WorkingBeatmap beatmap, ScoreInfo score)
{ {
workingBeatmap = new Bindable<WorkingBeatmap>(beatmap);
Anchor = Anchor.Centre; Anchor = Anchor.Centre;
Origin = Anchor.Centre; Origin = Anchor.Centre;
Size = new Vector2(ScorePanel.EXPANDED_WIDTH, 700); Size = new Vector2(ScorePanel.EXPANDED_WIDTH, 700);

View File

@ -53,7 +53,7 @@ namespace osu.Game.Screens.Ranking.Expanded
private void load() private void load()
{ {
var beatmap = score.Beatmap; var beatmap = score.Beatmap;
var metadata = beatmap.Metadata; var metadata = beatmap.BeatmapSet?.Metadata ?? beatmap.Metadata;
var creator = metadata.Author?.Username; var creator = metadata.Author?.Username;
var topStatistics = new List<StatisticDisplay> var topStatistics = new List<StatisticDisplay>