2020-02-18 12:21:55 +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.
|
|
|
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Allocation;
|
2020-08-21 14:05:56 +08:00
|
|
|
using osu.Framework.Audio.Track;
|
2022-01-03 16:31:12 +08:00
|
|
|
using osu.Framework.Extensions;
|
2023-01-28 22:59:50 +08:00
|
|
|
using osu.Framework.Extensions.ObjectExtensions;
|
2020-02-18 12:21:55 +08:00
|
|
|
using osu.Framework.Testing;
|
|
|
|
using osu.Game.Audio;
|
|
|
|
using osu.Game.Beatmaps;
|
2022-06-20 14:14:57 +08:00
|
|
|
using osu.Game.Database;
|
2020-02-18 12:21:55 +08:00
|
|
|
using osu.Game.Tests.Resources;
|
|
|
|
using osu.Game.Tests.Visual;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Skins
|
|
|
|
{
|
|
|
|
[HeadlessTest]
|
|
|
|
public partial class TestSceneBeatmapSkinResources : OsuTestScene
|
|
|
|
{
|
|
|
|
[Resolved]
|
2023-01-28 22:59:50 +08:00
|
|
|
private BeatmapManager beatmaps { get; set; } = null!;
|
2020-08-21 14:05:56 +08:00
|
|
|
|
2023-01-28 22:59:50 +08:00
|
|
|
[Test]
|
|
|
|
public void TestRetrieveOggAudio()
|
2020-02-18 12:21:55 +08:00
|
|
|
{
|
2023-01-28 22:59:50 +08:00
|
|
|
IWorkingBeatmap beatmap = null!;
|
2022-01-10 11:39:49 +08:00
|
|
|
|
2023-01-28 22:59:50 +08:00
|
|
|
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", () =>
|
2022-01-10 11:39:49 +08:00
|
|
|
{
|
2023-01-28 22:59:50 +08:00
|
|
|
using (var track = beatmap.LoadTrack())
|
|
|
|
return track is not TrackVirtual;
|
2022-01-10 11:39:49 +08:00
|
|
|
});
|
2020-02-18 12:21:55 +08:00
|
|
|
}
|
|
|
|
|
2023-01-28 23:02:11 +08:00
|
|
|
[Test]
|
|
|
|
public void TestRetrievalWithConflictingFilenames()
|
|
|
|
{
|
|
|
|
IWorkingBeatmap beatmap = null!;
|
|
|
|
|
|
|
|
AddStep("import beatmap", () => beatmap = importBeatmapFromArchives(@"conflicting-filenames-beatmap.osz"));
|
|
|
|
AddAssert("texture is non-null", () => beatmap.Skin.GetTexture(@"spinner-osu") != null);
|
|
|
|
AddAssert("sample is non-null", () => beatmap.Skin.GetSample(new SampleInfo(@"spinner-osu")) != null);
|
|
|
|
}
|
|
|
|
|
2023-01-28 22:59:50 +08:00
|
|
|
private IWorkingBeatmap importBeatmapFromArchives(string filename)
|
2022-07-28 16:58:13 +08:00
|
|
|
{
|
2023-01-28 22:59:50 +08:00
|
|
|
var imported = beatmaps.Import(new ImportTask(TestResources.OpenResource($@"Archives/{filename}"), filename)).GetResultSafely();
|
|
|
|
return imported.AsNonNull().PerformRead(s => beatmaps.GetWorkingBeatmap(s.Beatmaps[0]));
|
|
|
|
}
|
2020-02-18 12:21:55 +08:00
|
|
|
}
|
|
|
|
}
|