Combine all test data BeatmapSetInfo creation into a single method

This commit is contained in:
Dean Herbert
2021-11-24 17:59:23 +09:00
parent 5ff62a8e04
commit 0c819b9cfb
6 changed files with 160 additions and 262 deletions

View File

@ -1,16 +1,16 @@
// 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;
using System.Linq;
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Graphics.Containers;
using osu.Game.Overlays.Music;
using osu.Game.Tests.Resources;
using osuTK;
using osuTK.Input;
@ -22,6 +22,8 @@ namespace osu.Game.Tests.Visual.UserInterface
private PlaylistOverlay playlistOverlay;
private BeatmapSetInfo first;
[SetUp]
public void Setup() => Schedule(() =>
{
@ -43,19 +45,11 @@ namespace osu.Game.Tests.Visual.UserInterface
for (int i = 0; i < 100; i++)
{
beatmapSets.Add(new BeatmapSetInfo
{
Metadata = new BeatmapMetadata
{
// Create random metadata, then we can check if sorting works based on these
Artist = "Some Artist " + RNG.Next(0, 9),
Title = $"Some Song {i + 1}",
AuthorString = "Some Guy " + RNG.Next(0, 9),
},
DateAdded = DateTimeOffset.UtcNow,
});
beatmapSets.Add(TestResources.CreateTestBeatmapSetInfo());
}
first = beatmapSets.First();
playlistOverlay.BeatmapSets.BindTo(beatmapSets);
});
@ -66,7 +60,7 @@ namespace osu.Game.Tests.Visual.UserInterface
AddStep("hold 1st item handle", () =>
{
var handle = this.ChildrenOfType<PlaylistItem.PlaylistItemHandle>().First();
var handle = this.ChildrenOfType<OsuRearrangeableListItem<BeatmapSetInfo>.PlaylistItemHandle>().First();
InputManager.MoveMouseTo(handle.ScreenSpaceDrawQuad.Centre);
InputManager.PressButton(MouseButton.Left);
});
@ -77,7 +71,7 @@ namespace osu.Game.Tests.Visual.UserInterface
InputManager.MoveMouseTo(item.ScreenSpaceDrawQuad.Centre);
});
AddAssert("song 1 is 5th", () => beatmapSets[4].Metadata.Title == "Some Song 1");
AddAssert("song 1 is 5th", () => beatmapSets[4] == first);
AddStep("release handle", () => InputManager.ReleaseButton(MouseButton.Left));
}