2020-01-28 16:59:14 +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.
|
|
|
|
|
2020-09-11 06:12:05 +08:00
|
|
|
using System.Linq;
|
2020-01-28 16:59:14 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-09-11 06:12:05 +08:00
|
|
|
using osu.Framework.Testing;
|
2020-01-28 16:59:14 +08:00
|
|
|
using osu.Game.Beatmaps;
|
2022-01-26 11:19:05 +08:00
|
|
|
using osu.Game.Database;
|
2021-11-24 16:59:23 +08:00
|
|
|
using osu.Game.Graphics.Containers;
|
2020-01-28 16:59:14 +08:00
|
|
|
using osu.Game.Overlays.Music;
|
2021-11-24 16:59:23 +08:00
|
|
|
using osu.Game.Tests.Resources;
|
2020-01-28 16:59:14 +08:00
|
|
|
using osuTK;
|
2020-09-11 06:12:05 +08:00
|
|
|
using osuTK.Input;
|
2020-01-28 16:59:14 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
{
|
2020-09-11 06:12:05 +08:00
|
|
|
public class TestScenePlaylistOverlay : OsuManualInputManagerTestScene
|
2020-01-28 16:59:14 +08:00
|
|
|
{
|
2022-01-26 14:12:01 +08:00
|
|
|
private readonly BindableList<Live<BeatmapSetInfo>> beatmapSets = new BindableList<Live<BeatmapSetInfo>>();
|
2020-01-28 16:59:14 +08:00
|
|
|
|
2020-09-11 06:12:05 +08:00
|
|
|
private PlaylistOverlay playlistOverlay;
|
|
|
|
|
2022-01-26 14:12:01 +08:00
|
|
|
private Live<BeatmapSetInfo> first;
|
2021-11-24 16:59:23 +08:00
|
|
|
|
2020-01-28 16:59:14 +08:00
|
|
|
[SetUp]
|
|
|
|
public void Setup() => Schedule(() =>
|
|
|
|
{
|
|
|
|
Child = new Container
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Size = new Vector2(300, 500),
|
2020-09-11 06:12:05 +08:00
|
|
|
Child = playlistOverlay = new PlaylistOverlay
|
2020-01-28 16:59:14 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
State = { Value = Visibility.Visible }
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
beatmapSets.Clear();
|
|
|
|
|
|
|
|
for (int i = 0; i < 100; i++)
|
|
|
|
{
|
2022-01-26 11:19:05 +08:00
|
|
|
beatmapSets.Add(TestResources.CreateTestBeatmapSetInfo().ToLiveUnmanaged());
|
2020-01-28 16:59:14 +08:00
|
|
|
}
|
|
|
|
|
2021-11-24 16:59:23 +08:00
|
|
|
first = beatmapSets.First();
|
|
|
|
|
2020-09-11 06:12:05 +08:00
|
|
|
playlistOverlay.BeatmapSets.BindTo(beatmapSets);
|
2020-01-28 16:59:14 +08:00
|
|
|
});
|
2020-09-11 06:12:05 +08:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestRearrangeItems()
|
|
|
|
{
|
|
|
|
AddUntilStep("wait for animations to complete", () => !playlistOverlay.Transforms.Any());
|
|
|
|
|
|
|
|
AddStep("hold 1st item handle", () =>
|
|
|
|
{
|
2022-01-26 14:12:01 +08:00
|
|
|
var handle = this.ChildrenOfType<OsuRearrangeableListItem<Live<BeatmapSetInfo>>.PlaylistItemHandle>().First();
|
2020-09-11 06:12:05 +08:00
|
|
|
InputManager.MoveMouseTo(handle.ScreenSpaceDrawQuad.Centre);
|
|
|
|
InputManager.PressButton(MouseButton.Left);
|
|
|
|
});
|
|
|
|
|
|
|
|
AddStep("drag to 5th", () =>
|
|
|
|
{
|
|
|
|
var item = this.ChildrenOfType<PlaylistItem>().ElementAt(4);
|
2022-01-22 01:39:01 +08:00
|
|
|
InputManager.MoveMouseTo(item.ScreenSpaceDrawQuad.BottomLeft);
|
2020-09-11 06:12:05 +08:00
|
|
|
});
|
|
|
|
|
2021-11-24 11:16:08 +08:00
|
|
|
AddAssert("song 1 is 5th", () => beatmapSets[4].Equals(first));
|
2020-09-11 06:12:05 +08:00
|
|
|
|
|
|
|
AddStep("release handle", () => InputManager.ReleaseButton(MouseButton.Left));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestFiltering()
|
|
|
|
{
|
|
|
|
AddStep("set filter to \"10\"", () =>
|
|
|
|
{
|
|
|
|
var filterControl = playlistOverlay.ChildrenOfType<FilterControl>().Single();
|
|
|
|
filterControl.Search.Current.Value = "10";
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("results filtered correctly",
|
|
|
|
() => playlistOverlay.ChildrenOfType<PlaylistItem>()
|
|
|
|
.Where(item => item.MatchingFilter)
|
|
|
|
.All(item => item.FilterTerms.Any(term => term.Contains("10"))));
|
|
|
|
}
|
2020-01-28 16:59:14 +08:00
|
|
|
}
|
|
|
|
}
|