Add test coverage of beatmap set overlay actually showing requested beatmap

This commit is contained in:
Dean Herbert 2022-02-22 17:08:09 +09:00
parent ed008267d7
commit 5efffa208a
2 changed files with 64 additions and 2 deletions

View File

@ -5,18 +5,50 @@
using NUnit.Framework;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapSet;
namespace osu.Game.Tests.Visual.Navigation
{
public class TestSceneStartupBeatmapDisplay : OsuGameTestScene
{
protected override TestOsuGame CreateTestGame() => new TestOsuGame(LocalStorage, API, new[] { "osu://b/75" });
private const int requested_beatmap_id = 75;
private const int requested_beatmap_set_id = 1;
protected override TestOsuGame CreateTestGame() => new TestOsuGame(LocalStorage, API, new[] { $"osu://b/{requested_beatmap_id}" });
[SetUp]
public void Setup() => Schedule(() =>
{
((DummyAPIAccess)API).HandleRequest = request =>
{
switch (request)
{
case GetBeatmapSetRequest gbr:
var apiBeatmapSet = CreateAPIBeatmapSet();
apiBeatmapSet.OnlineID = requested_beatmap_set_id;
apiBeatmapSet.Beatmaps = apiBeatmapSet.Beatmaps.Append(new APIBeatmap
{
DifficultyName = "Target difficulty",
OnlineID = requested_beatmap_id,
}).ToArray();
gbr.TriggerSuccess(apiBeatmapSet);
return true;
}
return false;
};
});
[Test]
public void TestBeatmapLink()
{
AddUntilStep("Beatmap overlay displayed", () => Game.ChildrenOfType<BeatmapSetOverlay>().FirstOrDefault()?.State.Value == Visibility.Visible);
AddUntilStep("Beatmap overlay showing content", () => Game.ChildrenOfType<BeatmapPicker>().FirstOrDefault()?.Beatmap.Value.OnlineID == requested_beatmap_id);
}
}
}

View File

@ -5,18 +5,48 @@
using NUnit.Framework;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
namespace osu.Game.Tests.Visual.Navigation
{
public class TestSceneStartupBeatmapSetDisplay : OsuGameTestScene
{
protected override TestOsuGame CreateTestGame() => new TestOsuGame(LocalStorage, API, new[] { "osu://s/1" });
private const int requested_beatmap_set_id = 1;
protected override TestOsuGame CreateTestGame() => new TestOsuGame(LocalStorage, API, new[] { $"osu://s/{requested_beatmap_set_id}" });
[SetUp]
public void Setup() => Schedule(() =>
{
((DummyAPIAccess)API).HandleRequest = request =>
{
switch (request)
{
case GetBeatmapSetRequest gbr:
var apiBeatmapSet = CreateAPIBeatmapSet();
apiBeatmapSet.OnlineID = requested_beatmap_set_id;
apiBeatmapSet.Beatmaps = apiBeatmapSet.Beatmaps.Append(new APIBeatmap
{
DifficultyName = "Target difficulty",
OnlineID = 75,
}).ToArray();
gbr.TriggerSuccess(apiBeatmapSet);
return true;
}
return false;
};
});
[Test]
public void TestBeatmapSetLink()
{
AddUntilStep("Beatmap overlay displayed", () => Game.ChildrenOfType<BeatmapSetOverlay>().FirstOrDefault()?.State.Value == Visibility.Visible);
AddUntilStep("Beatmap overlay showing content", () => Game.ChildrenOfType<BeatmapSetOverlay>().FirstOrDefault()?.Header.BeatmapSet.Value.OnlineID == requested_beatmap_set_id);
}
}
}