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;
|
2020-03-18 03:45:48 +08:00
|
|
|
using System.Linq;
|
2020-03-18 02:33:01 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
2020-03-18 03:45:48 +08:00
|
|
|
using osu.Framework.Bindables;
|
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;
|
2020-03-18 03:45:48 +08:00
|
|
|
using osu.Framework.Testing;
|
2020-03-18 02:33:01 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2020-03-18 03:45:48 +08:00
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Rulesets;
|
2020-03-17 16:25:24 +08:00
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
using osu.Game.Rulesets.Osu;
|
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
|
|
|
using osu.Game.Scoring;
|
2020-05-01 13:13:38 +08:00
|
|
|
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
|
|
|
|
{
|
2020-03-18 02:33:01 +08:00
|
|
|
[Resolved]
|
2020-03-18 03:45:48 +08:00
|
|
|
private RulesetStore rulesetStore { get; set; }
|
2020-03-18 02:33:01 +08:00
|
|
|
|
2020-03-18 03:45:48 +08:00
|
|
|
[Test]
|
|
|
|
public void TestMapWithKnownMapper()
|
2020-03-18 02:33:01 +08:00
|
|
|
{
|
2020-03-18 03:45:48 +08:00
|
|
|
var author = new User { Username = "mapper_name" };
|
2020-03-18 02:33:01 +08:00
|
|
|
|
2020-03-18 03:45:48 +08:00
|
|
|
AddStep("show example score", () => showPanel(createTestBeatmap(author), createTestScore()));
|
2020-03-18 02:39:19 +08:00
|
|
|
|
2020-03-18 03:45:48 +08:00
|
|
|
AddAssert("mapper name present", () => this.ChildrenOfType<OsuSpriteText>().Any(spriteText => spriteText.Text == "mapper_name"));
|
2020-03-18 02:33:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
2020-03-18 03:45:48 +08:00
|
|
|
public void TestMapWithUnknownMapper()
|
2020-03-18 02:33:01 +08:00
|
|
|
{
|
2020-03-18 03:45:48 +08:00
|
|
|
AddStep("show example score", () => showPanel(createTestBeatmap(null), createTestScore()));
|
|
|
|
|
|
|
|
AddAssert("mapped by text not present", () =>
|
|
|
|
this.ChildrenOfType<OsuSpriteText>().All(spriteText => !containsAny(spriteText.Text, "mapped", "by")));
|
2020-03-18 02:33:01 +08:00
|
|
|
}
|
|
|
|
|
2020-03-18 03:45:48 +08:00
|
|
|
private void showPanel(WorkingBeatmap workingBeatmap, ScoreInfo score)
|
2020-03-17 16:25:24 +08:00
|
|
|
{
|
2020-03-18 03:45:48 +08:00
|
|
|
Child = new ExpandedPanelMiddleContentContainer(workingBeatmap, score);
|
2020-03-18 02:33:01 +08:00
|
|
|
}
|
|
|
|
|
2020-03-18 03:45:48 +08:00
|
|
|
private WorkingBeatmap createTestBeatmap(User author)
|
2020-03-18 02:39:19 +08:00
|
|
|
{
|
2020-03-18 03:45:48 +08:00
|
|
|
var beatmap = new TestBeatmap(rulesetStore.GetRuleset(0));
|
|
|
|
beatmap.Metadata.Author = author;
|
2020-05-01 13:13:38 +08:00
|
|
|
beatmap.Metadata.Title = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong beatmap title";
|
|
|
|
beatmap.Metadata.Artist = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong beatmap artist";
|
2020-03-18 03:45:48 +08:00
|
|
|
|
|
|
|
return new TestWorkingBeatmap(beatmap);
|
|
|
|
}
|
2020-03-17 16:25:24 +08:00
|
|
|
|
|
|
|
private ScoreInfo createTestScore() => new ScoreInfo
|
|
|
|
{
|
|
|
|
User = new User
|
|
|
|
{
|
|
|
|
Id = 2,
|
|
|
|
Username = "peppy",
|
|
|
|
},
|
|
|
|
Beatmap = new TestBeatmap(new OsuRuleset().RulesetInfo).BeatmapInfo,
|
|
|
|
Mods = new Mod[] { new OsuModHardRock(), new OsuModDoubleTime() },
|
|
|
|
TotalScore = 999999,
|
|
|
|
Accuracy = 0.95,
|
|
|
|
MaxCombo = 999,
|
|
|
|
Rank = ScoreRank.S,
|
|
|
|
Date = DateTimeOffset.Now,
|
|
|
|
Statistics =
|
|
|
|
{
|
|
|
|
{ HitResult.Miss, 1 },
|
|
|
|
{ HitResult.Meh, 50 },
|
|
|
|
{ HitResult.Good, 100 },
|
|
|
|
{ HitResult.Great, 300 },
|
|
|
|
}
|
|
|
|
};
|
2020-03-18 03:45:48 +08:00
|
|
|
|
|
|
|
private bool containsAny(string text, params string[] stringsToMatch) => stringsToMatch.Any(text.Contains);
|
|
|
|
|
|
|
|
private class ExpandedPanelMiddleContentContainer : Container
|
|
|
|
{
|
|
|
|
[Cached]
|
|
|
|
private Bindable<WorkingBeatmap> workingBeatmap { get; set; }
|
|
|
|
|
|
|
|
public ExpandedPanelMiddleContentContainer(WorkingBeatmap beatmap, ScoreInfo score)
|
|
|
|
{
|
|
|
|
workingBeatmap = new Bindable<WorkingBeatmap>(beatmap);
|
|
|
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
Origin = Anchor.Centre;
|
2020-05-01 13:13:38 +08:00
|
|
|
Size = new Vector2(ScorePanel.EXPANDED_WIDTH, 700);
|
2020-03-18 03:45:48 +08:00
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Colour = Color4Extensions.FromHex("#444"),
|
|
|
|
},
|
|
|
|
new ExpandedPanelMiddleContent(score)
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2020-03-17 16:25:24 +08:00
|
|
|
}
|
|
|
|
}
|