Adjust beatmap skin resources test to facilitate loading many

This commit is contained in:
Bartłomiej Dach 2023-01-28 15:59:50 +01:00
parent 9bdb78791f
commit 55a045b2b2
No known key found for this signature in database
1 changed files with 14 additions and 18 deletions

View File

@ -1,12 +1,11 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
#nullable disable
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Audio.Track; using osu.Framework.Audio.Track;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Audio; using osu.Game.Audio;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
@ -20,29 +19,26 @@ namespace osu.Game.Tests.Skins
public partial class TestSceneBeatmapSkinResources : OsuTestScene public partial class TestSceneBeatmapSkinResources : OsuTestScene
{ {
[Resolved] [Resolved]
private BeatmapManager beatmaps { get; set; } private BeatmapManager beatmaps { get; set; } = null!;
private IWorkingBeatmap beatmap; [Test]
public void TestRetrieveOggAudio()
[BackgroundDependencyLoader]
private void load()
{ {
var imported = beatmaps.Import(new ImportTask(TestResources.OpenResource("Archives/ogg-beatmap.osz"), "ogg-beatmap.osz")).GetResultSafely(); IWorkingBeatmap beatmap = null!;
imported?.PerformRead(s => AddStep("import beatmap", () => beatmap = importBeatmapFromArchives(@"ogg-beatmap.osz"));
AddAssert("sample is non-null", () => beatmap.Skin.GetSample(new SampleInfo(@"sample")) != null);
AddAssert("track is non-null", () =>
{ {
beatmap = beatmaps.GetWorkingBeatmap(s.Beatmaps[0]); using (var track = beatmap.LoadTrack())
return track is not TrackVirtual;
}); });
} }
[Test] private IWorkingBeatmap importBeatmapFromArchives(string filename)
public void TestRetrieveOggSample() => AddAssert("sample is non-null", () => beatmap.Skin.GetSample(new SampleInfo("sample")) != null);
[Test]
public void TestRetrieveOggTrack() => AddAssert("track is non-null", () =>
{ {
using (var track = beatmap.LoadTrack()) var imported = beatmaps.Import(new ImportTask(TestResources.OpenResource($@"Archives/{filename}"), filename)).GetResultSafely();
return track is not TrackVirtual; return imported.AsNonNull().PerformRead(s => beatmaps.GetWorkingBeatmap(s.Beatmaps[0]));
}); }
} }
} }