mirror of
https://github.com/osukey/osukey.git
synced 2025-06-09 21:37:59 +09:00
Use a shorter test beatmap for tests which need to run to completion
This commit is contained in:
parent
bc8e67ad7c
commit
541237ef16
@ -852,6 +852,21 @@ namespace osu.Game.Tests.Beatmaps.IO
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task<BeatmapSetInfo> LoadQuickOszIntoOsu(OsuGameBase osu)
|
||||||
|
{
|
||||||
|
var temp = TestResources.GetQuickTestBeatmapForImport();
|
||||||
|
|
||||||
|
var manager = osu.Dependencies.Get<BeatmapManager>();
|
||||||
|
|
||||||
|
var importedSet = await manager.Import(new ImportTask(temp));
|
||||||
|
|
||||||
|
ensureLoaded(osu);
|
||||||
|
|
||||||
|
waitForOrAssert(() => !File.Exists(temp), "Temporary file still exists after standard import", 5000);
|
||||||
|
|
||||||
|
return manager.GetAllUsableBeatmapSets().Find(beatmapSet => beatmapSet.ID == importedSet.ID);
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<BeatmapSetInfo> LoadOszIntoOsu(OsuGameBase osu, string path = null, bool virtualTrack = false)
|
public static async Task<BeatmapSetInfo> LoadOszIntoOsu(OsuGameBase osu, string path = null, bool virtualTrack = false)
|
||||||
{
|
{
|
||||||
var temp = path ?? TestResources.GetTestBeatmapForImport(virtualTrack);
|
var temp = path ?? TestResources.GetTestBeatmapForImport(virtualTrack);
|
||||||
|
Binary file not shown.
@ -13,8 +13,31 @@ namespace osu.Game.Tests.Resources
|
|||||||
|
|
||||||
public static Stream OpenResource(string name) => GetStore().GetStream($"Resources/{name}");
|
public static Stream OpenResource(string name) => GetStore().GetStream($"Resources/{name}");
|
||||||
|
|
||||||
public static Stream GetTestBeatmapStream(bool virtualTrack = false) => OpenResource($"Archives/241526 Soleily - Renatus{(virtualTrack ? "_virtual" : "")}.osz");
|
public static Stream GetTestBeatmapStream(bool virtualTrack = false, bool quick = false) => OpenResource($"Archives/241526 Soleily - Renatus{(virtualTrack ? "_virtual" : "")}{(quick ? "_quick" : "")}.osz");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve a path to a copy of a shortened (~10 second) beatmap archive with a virtual track.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This is intended for use in tests which need to run to completion as soon as possible and don't need to test a full length beatmap.</remarks>
|
||||||
|
/// <returns>A path to a copy of a beatmap archive (osz). Should be deleted after use.</returns>
|
||||||
|
public static string GetQuickTestBeatmapForImport()
|
||||||
|
{
|
||||||
|
var tempPath = Path.GetTempFileName() + ".osz";
|
||||||
|
|
||||||
|
using (var stream = GetTestBeatmapStream(true, true))
|
||||||
|
using (var newFile = File.Create(tempPath))
|
||||||
|
stream.CopyTo(newFile);
|
||||||
|
|
||||||
|
Assert.IsTrue(File.Exists(tempPath));
|
||||||
|
return tempPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieve a path to a copy of a full-fledged beatmap archive.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="virtualTrack">Whether the audio track should be virtual.</param>
|
||||||
|
/// <returns>A path to a copy of a beatmap archive (osz). Should be deleted after use.</returns>
|
||||||
public static string GetTestBeatmapForImport(bool virtualTrack = false)
|
public static string GetTestBeatmapForImport(bool virtualTrack = false)
|
||||||
{
|
{
|
||||||
var tempPath = Path.GetTempFileName() + ".osz";
|
var tempPath = Path.GetTempFileName() + ".osz";
|
||||||
|
@ -53,7 +53,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
|
|
||||||
PushAndConfirm(() => new TestSongSelect());
|
PushAndConfirm(() => new TestSongSelect());
|
||||||
|
|
||||||
AddStep("import beatmap", () => ImportBeatmapTest.LoadOszIntoOsu(Game, virtualTrack: true).Wait());
|
AddStep("import beatmap", () => ImportBeatmapTest.LoadQuickOszIntoOsu(Game).Wait());
|
||||||
|
|
||||||
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
|
AddUntilStep("wait for selected", () => !Game.Beatmap.IsDefault);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user