2019-01-24 16:43:03 +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.
|
2018-12-25 18:17:32 +08:00
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
using osu.Framework.Bindables;
|
2018-12-25 18:17:32 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
|
|
|
using osu.Game.Online.API;
|
|
|
|
using osu.Game.Online.API.Requests;
|
|
|
|
using osu.Game.Rulesets;
|
|
|
|
using osu.Game.Tests.Beatmaps.IO;
|
|
|
|
|
2019-03-25 00:02:36 +08:00
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
2018-12-25 18:17:32 +08:00
|
|
|
{
|
|
|
|
public class TestCaseUpdateableBeatmapBackgroundSprite : OsuTestCase
|
|
|
|
{
|
2019-03-06 17:55:01 +08:00
|
|
|
private TestUpdateableBeatmapBackgroundSprite backgroundSprite;
|
2018-12-25 18:17:32 +08:00
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private BeatmapManager beatmaps { get; set; }
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2019-03-13 11:56:47 +08:00
|
|
|
private void load(OsuGameBase osu, IAPIProvider api, RulesetStore rulesets)
|
2018-12-25 18:17:32 +08:00
|
|
|
{
|
|
|
|
Bindable<BeatmapInfo> beatmapBindable = new Bindable<BeatmapInfo>();
|
|
|
|
|
|
|
|
var imported = ImportBeatmapTest.LoadOszIntoOsu(osu);
|
|
|
|
|
2019-03-06 17:55:01 +08:00
|
|
|
Child = backgroundSprite = new TestUpdateableBeatmapBackgroundSprite { RelativeSizeAxes = Axes.Both };
|
2018-12-25 18:17:32 +08:00
|
|
|
|
|
|
|
backgroundSprite.Beatmap.BindTo(beatmapBindable);
|
|
|
|
|
|
|
|
var req = new GetBeatmapSetRequest(1);
|
|
|
|
api.Queue(req);
|
|
|
|
|
2019-03-06 17:55:01 +08:00
|
|
|
AddStep("load null beatmap", () => beatmapBindable.Value = null);
|
2019-03-19 16:24:26 +08:00
|
|
|
AddUntilStep("wait for cleanup...", () => backgroundSprite.ChildCount == 1);
|
2019-03-06 17:55:01 +08:00
|
|
|
AddStep("load imported beatmap", () => beatmapBindable.Value = imported.Beatmaps.First());
|
2019-03-19 16:24:26 +08:00
|
|
|
AddUntilStep("wait for cleanup...", () => backgroundSprite.ChildCount == 1);
|
2018-12-25 18:17:32 +08:00
|
|
|
|
|
|
|
if (api.IsLoggedIn)
|
2018-12-26 19:42:47 +08:00
|
|
|
{
|
2019-03-19 16:24:26 +08:00
|
|
|
AddUntilStep("wait for api response", () => req.Result != null);
|
2019-03-06 17:55:01 +08:00
|
|
|
AddStep("load online beatmap", () => beatmapBindable.Value = new BeatmapInfo
|
2018-12-26 19:42:47 +08:00
|
|
|
{
|
|
|
|
BeatmapSet = req.Result?.ToBeatmapSet(rulesets)
|
|
|
|
});
|
2019-03-19 16:24:26 +08:00
|
|
|
AddUntilStep("wait for cleanup...", () => backgroundSprite.ChildCount == 1);
|
2018-12-26 19:42:47 +08:00
|
|
|
}
|
|
|
|
else
|
2018-12-25 18:17:32 +08:00
|
|
|
{
|
2018-12-26 19:42:47 +08:00
|
|
|
AddStep("online (login first)", () => { });
|
|
|
|
}
|
2018-12-25 18:17:32 +08:00
|
|
|
}
|
2019-03-06 17:55:01 +08:00
|
|
|
|
|
|
|
private class TestUpdateableBeatmapBackgroundSprite : UpdateableBeatmapBackgroundSprite
|
|
|
|
{
|
|
|
|
public int ChildCount => InternalChildren.Count;
|
|
|
|
}
|
2018-12-25 18:17:32 +08:00
|
|
|
}
|
|
|
|
}
|