1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 16:52:54 +08:00

Tidy up test scene

This commit is contained in:
Dean Herbert 2021-05-10 12:34:21 +09:00
parent 8fba655d2e
commit 0c973feb53

View File

@ -35,27 +35,13 @@ namespace osu.Game.Tests.Visual.SongSelect
AddStep($"switch to {ruleset.Name}", () => Ruleset.Value = ruleset); AddStep($"switch to {ruleset.Name}", () => Ruleset.Value = ruleset);
} }
private void createTest(Func<WorkingBeatmap> getBeatmap)
{
AddStep("setup display", () => Child = display = new BeatmapMetadataDisplay(getBeatmap(), new Bindable<IReadOnlyList<Mod>>(getRandomMods()), Empty())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(1.5f),
Alpha = 0f,
});
AddStep("fade in", () => display.FadeIn(400, Easing.OutQuint));
AddToggleStep("trigger loading", v => display.Loading = v);
}
[Test] [Test]
public void TestLocal([Values("Beatmap", "Some long title and stuff")] public void TestLocal([Values("Beatmap", "Some long title and stuff")]
string title, string title,
[Values("Trial", "Some1's very hardest difficulty")] [Values("Trial", "Some1's very hardest difficulty")]
string version) string version)
{ {
createTest(() => CreateWorkingBeatmap(new Beatmap showMetadataForBeatmap(() => CreateWorkingBeatmap(new Beatmap
{ {
BeatmapInfo = BeatmapInfo =
{ {
@ -72,7 +58,7 @@ namespace osu.Game.Tests.Visual.SongSelect
[Test] [Test]
public void TestRandomFromDatabase() public void TestRandomFromDatabase()
{ {
createTest(() => showMetadataForBeatmap(() =>
{ {
var allBeatmapSets = manager.GetAllUsableBeatmapSets(IncludedDetails.Minimal); var allBeatmapSets = manager.GetAllUsableBeatmapSets(IncludedDetails.Minimal);
if (allBeatmapSets.Count == 0) if (allBeatmapSets.Count == 0)
@ -85,10 +71,23 @@ namespace osu.Game.Tests.Visual.SongSelect
}); });
} }
private IReadOnlyList<Mod> getRandomMods() => Ruleset.Value.CreateInstance() private void showMetadataForBeatmap(Func<WorkingBeatmap> getBeatmap)
.GetAllMods() {
.OrderBy(_ => RNG.Next()) AddStep("setup display", () =>
.Take(5) {
.ToList(); var randomMods = Ruleset.Value.CreateInstance().GetAllMods().OrderBy(_ => RNG.Next()).Take(5).ToList();
Child = display = new BeatmapMetadataDisplay(getBeatmap(), new Bindable<IReadOnlyList<Mod>>(randomMods), Empty())
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(1.5f),
Alpha = 0f,
};
});
AddStep("fade in", () => display.FadeIn(400, Easing.OutQuint));
AddToggleStep("trigger loading", v => display.Loading = v);
}
} }
} }