1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 10:32:55 +08:00
osu-lazer/osu.Game.Tests/Visual/Ranking/TestSceneExpandedPanelMiddleContent.cs

90 lines
3.1 KiB
C#
Raw Normal View History

2020-03-17 16:25:24 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation;
2020-03-17 16:25:24 +08:00
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Testing;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets;
2020-03-17 16:25:24 +08:00
using osu.Game.Rulesets.Osu;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking;
2020-03-17 16:25:24 +08:00
using osu.Game.Screens.Ranking.Expanded;
using osu.Game.Tests.Beatmaps;
using osu.Game.Users;
using osuTK;
namespace osu.Game.Tests.Visual.Ranking
{
public class TestSceneExpandedPanelMiddleContent : OsuTestScene
{
[Resolved]
private RulesetStore rulesetStore { get; set; }
[Test]
public void TestMapWithKnownMapper()
{
var author = new User { Username = "mapper_name" };
2020-06-11 13:55:49 +08:00
AddStep("show example score", () => showPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo)
{
Beatmap = createTestBeatmap(author)
}));
2020-03-18 02:39:19 +08:00
AddAssert("mapper name present", () => this.ChildrenOfType<OsuSpriteText>().Any(spriteText => spriteText.Current.Value == "mapper_name"));
}
[Test]
public void TestMapWithUnknownMapper()
{
2020-06-11 13:55:49 +08:00
AddStep("show example score", () => showPanel(new TestScoreInfo(new OsuRuleset().RulesetInfo)
{
Beatmap = createTestBeatmap(null)
}));
AddAssert("mapped by text not present", () =>
2021-03-17 18:07:29 +08:00
this.ChildrenOfType<OsuSpriteText>().All(spriteText => !containsAny(spriteText.Text.ToString(), "mapped", "by")));
}
2020-06-11 13:55:49 +08:00
private void showPanel(ScoreInfo score) => Child = new ExpandedPanelMiddleContentContainer(score);
2020-06-11 13:55:49 +08:00
private BeatmapInfo createTestBeatmap(User author)
2020-03-18 02:39:19 +08:00
{
2020-06-11 13:55:49 +08:00
var beatmap = new TestBeatmap(rulesetStore.GetRuleset(0)).BeatmapInfo;
beatmap.Metadata.Author = author;
beatmap.Metadata.Title = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong beatmap title";
beatmap.Metadata.Artist = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong beatmap artist";
2020-06-11 13:55:49 +08:00
return beatmap;
}
2020-03-17 16:25:24 +08:00
private bool containsAny(string text, params string[] stringsToMatch) => stringsToMatch.Any(text.Contains);
private class ExpandedPanelMiddleContentContainer : Container
{
2020-06-11 13:55:49 +08:00
public ExpandedPanelMiddleContentContainer(ScoreInfo score)
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Size = new Vector2(ScorePanel.EXPANDED_WIDTH, 700);
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4Extensions.FromHex("#444"),
},
new ExpandedPanelMiddleContent(score)
};
}
}
2020-03-17 16:25:24 +08:00
}
}