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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2020-03-18 03:45:48 +08:00
|
|
|
using System.Linq;
|
2021-11-04 17:22:21 +08:00
|
|
|
using JetBrains.Annotations;
|
2020-03-18 02:33:01 +08:00
|
|
|
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;
|
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;
|
2024-03-29 18:16:31 +08:00
|
|
|
using osu.Game.Localisation;
|
2021-11-22 14:52:55 +08:00
|
|
|
using osu.Game.Models;
|
2020-03-18 03:45:48 +08:00
|
|
|
using osu.Game.Rulesets;
|
2021-07-20 13:46:22 +08:00
|
|
|
using osu.Game.Rulesets.Mods;
|
2020-03-17 16:25:24 +08:00
|
|
|
using osu.Game.Rulesets.Osu;
|
2024-03-29 18:16:31 +08:00
|
|
|
using osu.Game.Rulesets.Osu.Mods;
|
2020-03-17 16:25:24 +08:00
|
|
|
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;
|
2024-03-29 18:16:31 +08:00
|
|
|
using osu.Game.Screens.Ranking.Expanded.Statistics;
|
2020-03-17 16:25:24 +08:00
|
|
|
using osu.Game.Tests.Beatmaps;
|
2021-12-13 15:34:48 +08:00
|
|
|
using osu.Game.Tests.Resources;
|
2020-03-17 16:25:24 +08:00
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.Ranking
|
|
|
|
{
|
|
|
|
public partial 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
|
|
|
{
|
2021-11-22 14:52:55 +08:00
|
|
|
var author = new RealmUser { Username = "mapper_name" };
|
2020-03-18 02:33:01 +08:00
|
|
|
|
2021-12-13 15:34:48 +08:00
|
|
|
AddStep("show example score", () => showPanel(TestResources.CreateTestScoreInfo(createTestBeatmap(author))));
|
2021-07-21 14:35:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestExcessMods()
|
|
|
|
{
|
2021-12-13 15:41:29 +08:00
|
|
|
AddStep("show excess mods score", () =>
|
|
|
|
{
|
2021-11-22 14:52:55 +08:00
|
|
|
var author = new RealmUser { Username = "mapper_name" };
|
2021-12-13 15:41:29 +08:00
|
|
|
|
|
|
|
var score = TestResources.CreateTestScoreInfo(createTestBeatmap(author));
|
2023-07-05 04:39:26 +08:00
|
|
|
score.Mods = score.BeatmapInfo!.Ruleset.CreateInstance().CreateAllMods().ToArray();
|
2021-07-21 14:35:59 +08:00
|
|
|
|
2021-12-13 15:41:29 +08:00
|
|
|
showPanel(score);
|
|
|
|
});
|
2020-03-18 02:39:19 +08:00
|
|
|
|
2021-02-25 16:46:35 +08:00
|
|
|
AddAssert("mapper name present", () => this.ChildrenOfType<OsuSpriteText>().Any(spriteText => spriteText.Current.Value == "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
|
|
|
{
|
2021-11-22 14:52:55 +08:00
|
|
|
AddStep("show example score", () => showPanel(TestResources.CreateTestScoreInfo(createTestBeatmap(new RealmUser()))));
|
2020-03-18 03:45:48 +08:00
|
|
|
|
|
|
|
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")));
|
2021-07-20 13:46:22 +08:00
|
|
|
|
|
|
|
AddAssert("play time displayed", () => this.ChildrenOfType<ExpandedPanelMiddleContent.PlayedOnText>().Any());
|
|
|
|
}
|
|
|
|
|
2024-03-29 18:16:31 +08:00
|
|
|
[Test]
|
|
|
|
public void TestPPShownAsProvisionalWhenBeatmapHasNoLeaderboard()
|
|
|
|
{
|
|
|
|
AddStep("show example score", () =>
|
|
|
|
{
|
|
|
|
var beatmap = createTestBeatmap(new RealmUser());
|
|
|
|
beatmap.Status = BeatmapOnlineStatus.Graveyard;
|
|
|
|
showPanel(TestResources.CreateTestScoreInfo(beatmap));
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("pp display faded out", () =>
|
|
|
|
{
|
|
|
|
var ppDisplay = this.ChildrenOfType<PerformanceStatistic>().Single();
|
|
|
|
return ppDisplay.Alpha == 0.5 && ppDisplay.TooltipText == ResultsScreenStrings.NoPPForUnrankedBeatmaps;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestPPShownAsProvisionalWhenUnrankedModsArePresent()
|
|
|
|
{
|
|
|
|
AddStep("show example score", () =>
|
|
|
|
{
|
|
|
|
var score = TestResources.CreateTestScoreInfo(createTestBeatmap(new RealmUser()));
|
|
|
|
score.Mods = score.Mods.Append(new OsuModDifficultyAdjust()).ToArray();
|
|
|
|
showPanel(score);
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("pp display faded out", () =>
|
|
|
|
{
|
|
|
|
var ppDisplay = this.ChildrenOfType<PerformanceStatistic>().Single();
|
|
|
|
return ppDisplay.Alpha == 0.5 && ppDisplay.TooltipText == ResultsScreenStrings.NoPPForUnrankedMods;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-04-15 17:49:47 +08:00
|
|
|
[Test]
|
|
|
|
public void TestPPNotShownAsProvisionalIfClassicModIsPresentDueToLegacyScore()
|
|
|
|
{
|
|
|
|
AddStep("show example score", () =>
|
|
|
|
{
|
|
|
|
var score = TestResources.CreateTestScoreInfo(createTestBeatmap(new RealmUser()));
|
|
|
|
score.PP = 400;
|
|
|
|
score.Mods = score.Mods.Append(new OsuModClassic()).ToArray();
|
|
|
|
score.IsLegacyScore = true;
|
|
|
|
showPanel(score);
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("pp display faded out", () => this.ChildrenOfType<PerformanceStatistic>().Single().Alpha == 1);
|
|
|
|
}
|
|
|
|
|
2021-07-20 13:46:22 +08:00
|
|
|
[Test]
|
2021-07-20 18:05:08 +08:00
|
|
|
public void TestWithDefaultDate()
|
2021-07-20 13:46:22 +08:00
|
|
|
{
|
|
|
|
AddStep("show autoplay score", () =>
|
|
|
|
{
|
|
|
|
var ruleset = new OsuRuleset();
|
|
|
|
|
|
|
|
var mods = new Mod[] { ruleset.GetAutoplayMod() };
|
2021-11-22 14:52:55 +08:00
|
|
|
var beatmap = createTestBeatmap(new RealmUser());
|
2021-07-20 13:46:22 +08:00
|
|
|
|
2021-12-13 15:34:48 +08:00
|
|
|
var score = TestResources.CreateTestScoreInfo(beatmap);
|
|
|
|
|
|
|
|
score.Mods = mods;
|
|
|
|
score.Date = default;
|
|
|
|
|
|
|
|
showPanel(score);
|
2021-07-20 13:46:22 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("play time not displayed", () => !this.ChildrenOfType<ExpandedPanelMiddleContent.PlayedOnText>().Any());
|
2020-03-18 02:33:01 +08:00
|
|
|
}
|
|
|
|
|
2024-03-07 16:49:20 +08:00
|
|
|
[Test]
|
|
|
|
public void TestFailedSDisplay([Values] bool withFlair)
|
2024-03-07 14:48:54 +08:00
|
|
|
{
|
|
|
|
AddStep("show failed S score", () =>
|
|
|
|
{
|
|
|
|
var score = TestResources.CreateTestScoreInfo(createTestBeatmap(new RealmUser()));
|
|
|
|
score.Rank = ScoreRank.A;
|
|
|
|
score.Accuracy = 0.975;
|
|
|
|
showPanel(score, withFlair);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
private void showPanel(ScoreInfo score, bool withFlair = false) =>
|
|
|
|
Child = new ExpandedPanelMiddleContentContainer(score, withFlair);
|
2020-03-18 02:33:01 +08:00
|
|
|
|
2021-11-22 14:52:55 +08:00
|
|
|
private BeatmapInfo createTestBeatmap([NotNull] RealmUser author)
|
2020-03-18 02:39:19 +08:00
|
|
|
{
|
2023-06-24 22:07:01 +08:00
|
|
|
var beatmap = new TestBeatmap(rulesetStore.GetRuleset(0)!).BeatmapInfo;
|
2020-06-11 13:55:49 +08:00
|
|
|
|
2020-03-18 03:45:48 +08:00
|
|
|
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";
|
2022-06-07 12:05:03 +08:00
|
|
|
beatmap.DifficultyName = "Verrrrrrrrrrrrrrrrrrry looooooooooooooooooooooooong difficulty name";
|
2020-03-18 03:45:48 +08:00
|
|
|
|
2020-06-11 13:55:49 +08:00
|
|
|
return beatmap;
|
2020-03-18 03:45:48 +08:00
|
|
|
}
|
2020-03-17 16:25:24 +08:00
|
|
|
|
2020-03-18 03:45:48 +08:00
|
|
|
private bool containsAny(string text, params string[] stringsToMatch) => stringsToMatch.Any(text.Contains);
|
|
|
|
|
|
|
|
private partial class ExpandedPanelMiddleContentContainer : Container
|
|
|
|
{
|
2024-03-07 14:48:54 +08:00
|
|
|
public ExpandedPanelMiddleContentContainer(ScoreInfo score, bool withFlair)
|
2020-03-18 03:45:48 +08:00
|
|
|
{
|
|
|
|
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"),
|
|
|
|
},
|
2024-03-07 14:48:54 +08:00
|
|
|
new ExpandedPanelMiddleContent(score, withFlair)
|
2020-03-18 03:45:48 +08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
2020-03-17 16:25:24 +08:00
|
|
|
}
|
|
|
|
}
|