From 601b218119ff45ffe54c300b87312d747ae76864 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 3 Nov 2021 16:45:16 +0900 Subject: [PATCH] Add test coverage for characters which are invalid in zip storage --- .../Beatmaps/IO/ImportBeatmapTest.cs | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs index 935194db58..d68d43c998 100644 --- a/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs +++ b/osu.Game.Tests/Beatmaps/IO/ImportBeatmapTest.cs @@ -846,6 +846,42 @@ namespace osu.Game.Tests.Beatmaps.IO } } + // TODO: needs to be pulled across to realm implementation when this file is nuked. + [Test] + public void TestSaveRemovesInvalidCharactersFromPath() + { + // unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. + using (HeadlessGameHost host = new CleanRunHeadlessGameHost(nameof(ImportBeatmapTest))) + { + try + { + var osu = LoadOsuIntoHost(host); + + var manager = osu.Dependencies.Get(); + + var working = manager.CreateNew(new OsuRuleset().RulesetInfo, User.SYSTEM_USER); + + var beatmap = working.Beatmap; + + beatmap.BeatmapInfo.Version = "difficulty"; + beatmap.BeatmapInfo.Metadata = new BeatmapMetadata + { + Artist = "Artist/With\\Slashes", + Title = "Title", + AuthorString = "mapper", + }; + + manager.Save(beatmap.BeatmapInfo, working.Beatmap); + + Assert.AreEqual("Artist_With_Slashes - Title (mapper) [difficulty].osu", beatmap.BeatmapInfo.Path); + } + finally + { + host.Exit(); + } + } + } + [Test] public void TestCreateNewEmptyBeatmap() {