1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 21:42:55 +08:00
osu-lazer/osu.Game.Tests/Visual/TestCaseUpdateableBeatmapBackgroundSprite.cs

64 lines
2.3 KiB
C#
Raw Normal View History

// 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;
namespace osu.Game.Tests.Visual
{
public class TestCaseUpdateableBeatmapBackgroundSprite : OsuTestCase
{
private TestUpdateableBeatmapBackgroundSprite backgroundSprite;
2018-12-25 18:17:32 +08:00
[Resolved]
private BeatmapManager beatmaps { get; set; }
[BackgroundDependencyLoader]
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);
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);
AddStep("load null beatmap", () => beatmapBindable.Value = null);
2019-03-19 16:24:26 +08:00
AddUntilStep("wait for cleanup...", () => backgroundSprite.ChildCount == 1);
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)
{
2019-03-19 16:24:26 +08:00
AddUntilStep("wait for api response", () => req.Result != null);
AddStep("load online beatmap", () => beatmapBindable.Value = new BeatmapInfo
{
BeatmapSet = req.Result?.ToBeatmapSet(rulesets)
});
2019-03-19 16:24:26 +08:00
AddUntilStep("wait for cleanup...", () => backgroundSprite.ChildCount == 1);
}
else
2018-12-25 18:17:32 +08:00
{
AddStep("online (login first)", () => { });
}
2018-12-25 18:17:32 +08:00
}
private class TestUpdateableBeatmapBackgroundSprite : UpdateableBeatmapBackgroundSprite
{
public int ChildCount => InternalChildren.Count;
}
2018-12-25 18:17:32 +08:00
}
}