2019-01-24 08:43:03 +00: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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2022-06-17 07:37:17 +00:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2017-09-25 03:52:01 +00:00
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Tests.Resources;
|
|
|
|
|
using osu.Game.Beatmaps.Formats;
|
2019-09-09 22:43:30 +00:00
|
|
|
|
using osu.Game.IO;
|
2018-02-15 03:56:22 +00:00
|
|
|
|
using osu.Game.IO.Archives;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-25 03:52:01 +00:00
|
|
|
|
namespace osu.Game.Tests.Beatmaps.IO
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
|
|
|
|
public class OszArchiveReaderTest
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
public void TestReadBeatmaps()
|
|
|
|
|
{
|
2019-01-28 09:19:57 +00:00
|
|
|
|
using (var osz = TestResources.GetTestBeatmapStream())
|
2017-09-25 03:52:01 +00:00
|
|
|
|
{
|
2018-02-15 03:56:22 +00:00
|
|
|
|
var reader = new ZipArchiveReader(osz);
|
2017-09-25 03:52:01 +00:00
|
|
|
|
string[] expected =
|
|
|
|
|
{
|
|
|
|
|
"Soleily - Renatus (Deif) [Platter].osu",
|
|
|
|
|
"Soleily - Renatus (Deif) [Rain].osu",
|
|
|
|
|
"Soleily - Renatus (Deif) [Salad].osu",
|
|
|
|
|
"Soleily - Renatus (ExPew) [Another].osu",
|
|
|
|
|
"Soleily - Renatus (ExPew) [Hyper].osu",
|
|
|
|
|
"Soleily - Renatus (ExPew) [Normal].osu",
|
|
|
|
|
"Soleily - Renatus (Gamu) [Hard].osu",
|
|
|
|
|
"Soleily - Renatus (Gamu) [Insane].osu",
|
|
|
|
|
"Soleily - Renatus (Gamu) [Normal].osu",
|
|
|
|
|
"Soleily - Renatus (MMzz) [Futsuu].osu",
|
|
|
|
|
"Soleily - Renatus (MMzz) [Muzukashii].osu",
|
|
|
|
|
"Soleily - Renatus (MMzz) [Oni].osu"
|
|
|
|
|
};
|
2021-10-27 04:04:41 +00:00
|
|
|
|
string[] maps = reader.Filenames.ToArray();
|
|
|
|
|
foreach (string map in expected)
|
2017-09-25 03:52:01 +00:00
|
|
|
|
Assert.Contains(map, maps);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-25 03:52:01 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestReadMetadata()
|
|
|
|
|
{
|
2019-01-28 09:19:57 +00:00
|
|
|
|
using (var osz = TestResources.GetTestBeatmapStream())
|
2017-09-25 03:52:01 +00:00
|
|
|
|
{
|
2018-02-15 03:56:22 +00:00
|
|
|
|
var reader = new ZipArchiveReader(osz);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-06-08 03:46:34 +00:00
|
|
|
|
Beatmap beatmap;
|
|
|
|
|
|
2019-09-09 22:43:30 +00:00
|
|
|
|
using (var stream = new LineBufferedReader(reader.GetStream("Soleily - Renatus (Deif) [Platter].osu")))
|
2018-06-08 03:46:34 +00:00
|
|
|
|
beatmap = Decoder.GetDecoder<Beatmap>(stream).Decode(stream);
|
|
|
|
|
|
|
|
|
|
var meta = beatmap.Metadata;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2022-01-12 13:34:07 +00:00
|
|
|
|
Assert.AreEqual(241526, beatmap.BeatmapInfo.BeatmapSet?.OnlineID);
|
2017-09-25 03:52:01 +00:00
|
|
|
|
Assert.AreEqual("Soleily", meta.Artist);
|
|
|
|
|
Assert.AreEqual("Soleily", meta.ArtistUnicode);
|
|
|
|
|
Assert.AreEqual("03. Renatus - Soleily 192kbps.mp3", meta.AudioFile);
|
2021-11-04 09:46:26 +00:00
|
|
|
|
Assert.AreEqual("Deif", meta.Author.Username);
|
2017-09-25 03:52:01 +00:00
|
|
|
|
Assert.AreEqual("machinetop_background.jpg", meta.BackgroundFile);
|
2018-05-27 18:48:09 +00:00
|
|
|
|
Assert.AreEqual(164471, meta.PreviewTime);
|
2017-09-25 03:52:01 +00:00
|
|
|
|
Assert.AreEqual(string.Empty, meta.Source);
|
|
|
|
|
Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", meta.Tags);
|
|
|
|
|
Assert.AreEqual("Renatus", meta.Title);
|
|
|
|
|
Assert.AreEqual("Renatus", meta.TitleUnicode);
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-25 03:52:01 +00:00
|
|
|
|
[Test]
|
|
|
|
|
public void TestReadFile()
|
|
|
|
|
{
|
2019-01-28 09:19:57 +00:00
|
|
|
|
using (var osz = TestResources.GetTestBeatmapStream())
|
2017-09-25 03:52:01 +00:00
|
|
|
|
{
|
2018-02-15 03:56:22 +00:00
|
|
|
|
var reader = new ZipArchiveReader(osz);
|
2019-04-01 03:44:46 +00:00
|
|
|
|
|
2021-10-24 14:51:49 +00:00
|
|
|
|
using (var stream = new StreamReader(reader.GetStream("Soleily - Renatus (Deif) [Platter].osu")))
|
2017-09-25 03:52:01 +00:00
|
|
|
|
{
|
|
|
|
|
Assert.AreEqual("osu file format v13", stream.ReadLine()?.Trim());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|