2020-02-18 22:25:12 +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-10-28 03:27:29 +08:00
|
|
|
|
using System.Linq;
|
2020-02-18 22:47:44 +08:00
|
|
|
|
using NUnit.Framework;
|
2020-02-18 22:25:12 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
2020-02-18 22:47:44 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-02-18 22:25:12 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2020-02-18 22:47:44 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2020-02-18 22:25:12 +08:00
|
|
|
|
using osu.Game.Overlays;
|
|
|
|
|
using osu.Game.Overlays.BeatmapListing;
|
2020-02-18 22:47:44 +08:00
|
|
|
|
using osuTK;
|
2020-02-18 22:25:12 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
|
{
|
2020-04-21 14:13:19 +08:00
|
|
|
|
public class TestSceneBeatmapListingSearchControl : OsuTestScene
|
2020-02-18 22:25:12 +08:00
|
|
|
|
{
|
|
|
|
|
[Cached]
|
|
|
|
|
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Blue);
|
|
|
|
|
|
2020-04-21 14:13:19 +08:00
|
|
|
|
private readonly BeatmapListingSearchControl control;
|
2020-02-18 22:47:44 +08:00
|
|
|
|
|
2020-04-21 14:13:19 +08:00
|
|
|
|
public TestSceneBeatmapListingSearchControl()
|
2020-02-18 22:25:12 +08:00
|
|
|
|
{
|
2020-02-18 22:47:44 +08:00
|
|
|
|
OsuSpriteText query;
|
|
|
|
|
OsuSpriteText ruleset;
|
|
|
|
|
OsuSpriteText category;
|
2020-02-21 07:28:33 +08:00
|
|
|
|
OsuSpriteText genre;
|
|
|
|
|
OsuSpriteText language;
|
2020-10-28 02:22:20 +08:00
|
|
|
|
OsuSpriteText extra;
|
2020-10-28 04:14:48 +08:00
|
|
|
|
OsuSpriteText ranks;
|
2020-10-28 02:30:53 +08:00
|
|
|
|
OsuSpriteText played;
|
2020-02-18 22:25:12 +08:00
|
|
|
|
|
2020-04-21 14:13:19 +08:00
|
|
|
|
Add(control = new BeatmapListingSearchControl
|
2020-02-18 22:25:12 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
});
|
|
|
|
|
|
2020-02-18 22:47:44 +08:00
|
|
|
|
Add(new FillFlowContainer
|
2020-02-18 22:25:12 +08:00
|
|
|
|
{
|
2020-02-18 22:47:44 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Spacing = new Vector2(0, 5),
|
|
|
|
|
Children = new Drawable[]
|
2020-02-18 22:25:12 +08:00
|
|
|
|
{
|
2020-02-18 22:47:44 +08:00
|
|
|
|
query = new OsuSpriteText(),
|
|
|
|
|
ruleset = new OsuSpriteText(),
|
|
|
|
|
category = new OsuSpriteText(),
|
2020-02-21 07:28:33 +08:00
|
|
|
|
genre = new OsuSpriteText(),
|
|
|
|
|
language = new OsuSpriteText(),
|
2020-10-28 02:30:53 +08:00
|
|
|
|
extra = new OsuSpriteText(),
|
2020-10-28 04:14:48 +08:00
|
|
|
|
ranks = new OsuSpriteText(),
|
2020-10-28 02:30:53 +08:00
|
|
|
|
played = new OsuSpriteText()
|
2020-02-18 22:25:12 +08:00
|
|
|
|
}
|
2020-02-18 22:47:44 +08:00
|
|
|
|
});
|
2020-02-18 22:25:12 +08:00
|
|
|
|
|
2020-04-21 14:13:19 +08:00
|
|
|
|
control.Query.BindValueChanged(q => query.Text = $"Query: {q.NewValue}", true);
|
|
|
|
|
control.Ruleset.BindValueChanged(r => ruleset.Text = $"Ruleset: {r.NewValue}", true);
|
|
|
|
|
control.Category.BindValueChanged(c => category.Text = $"Category: {c.NewValue}", true);
|
|
|
|
|
control.Genre.BindValueChanged(g => genre.Text = $"Genre: {g.NewValue}", true);
|
|
|
|
|
control.Language.BindValueChanged(l => language.Text = $"Language: {l.NewValue}", true);
|
2020-10-29 00:44:13 +08:00
|
|
|
|
control.Extra.BindCollectionChanged((u, v) => extra.Text = $"Extra: {(control.Extra.Any() ? string.Join('.', control.Extra.Select(i => i.ToString().ToLowerInvariant())) : "")}", true);
|
|
|
|
|
control.Ranks.BindCollectionChanged((u, v) => ranks.Text = $"Ranks: {(control.Ranks.Any() ? string.Join('.', control.Ranks.Select(i => i.ToString())) : "")}", true);
|
2020-10-28 02:30:53 +08:00
|
|
|
|
control.Played.BindValueChanged(p => played.Text = $"Played: {p.NewValue}", true);
|
2020-02-18 22:47:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestCovers()
|
|
|
|
|
{
|
2020-04-21 14:13:19 +08:00
|
|
|
|
AddStep("Set beatmap", () => control.BeatmapSet = beatmap_set);
|
|
|
|
|
AddStep("Set beatmap (no cover)", () => control.BeatmapSet = no_cover_beatmap_set);
|
|
|
|
|
AddStep("Set null beatmap", () => control.BeatmapSet = null);
|
2020-02-18 22:47:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-18 23:04:39 +08:00
|
|
|
|
private static readonly BeatmapSetInfo beatmap_set = new BeatmapSetInfo
|
2020-02-18 22:47:44 +08:00
|
|
|
|
{
|
|
|
|
|
OnlineInfo = new BeatmapSetOnlineInfo
|
2020-02-18 22:25:12 +08:00
|
|
|
|
{
|
2020-02-18 22:47:44 +08:00
|
|
|
|
Covers = new BeatmapSetOnlineCovers
|
2020-02-18 22:25:12 +08:00
|
|
|
|
{
|
2020-02-18 22:47:44 +08:00
|
|
|
|
Cover = "https://assets.ppy.sh/beatmaps/1094296/covers/cover@2x.jpg?1581416305"
|
2020-02-18 22:25:12 +08:00
|
|
|
|
}
|
2020-02-18 22:47:44 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
2020-02-18 22:25:12 +08:00
|
|
|
|
|
2020-02-18 23:04:39 +08:00
|
|
|
|
private static readonly BeatmapSetInfo no_cover_beatmap_set = new BeatmapSetInfo
|
2020-02-18 22:47:44 +08:00
|
|
|
|
{
|
|
|
|
|
OnlineInfo = new BeatmapSetOnlineInfo
|
|
|
|
|
{
|
|
|
|
|
Covers = new BeatmapSetOnlineCovers
|
|
|
|
|
{
|
|
|
|
|
Cover = string.Empty
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2020-02-18 22:25:12 +08:00
|
|
|
|
}
|
|
|
|
|
}
|