Add test for hit objects

This commit is contained in:
Drew DeVault
2016-10-10 13:08:07 -04:00
committed by Dean Herbert
parent 7a4501323b
commit c39179d299
2 changed files with 30 additions and 9 deletions

View File

@ -1,8 +1,10 @@
using System; using System;
using System.IO; using System.IO;
using NUnit.Framework; using NUnit.Framework;
using OpenTK;
using OpenTK.Graphics; using OpenTK.Graphics;
using osu.Game.Beatmaps.Formats; using osu.Game.Beatmaps.Formats;
using osu.Game.Beatmaps.Objects.Osu;
using osu.Game.Beatmaps.Samples; using osu.Game.Beatmaps.Samples;
using osu.Game.GameModes.Play; using osu.Game.GameModes.Play;
using osu.Game.Tests.Resources; using osu.Game.Tests.Resources;
@ -37,8 +39,8 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", meta.Tags); Assert.AreEqual("MBC7 Unisphere 地球ヤバイEP Chikyu Yabai", meta.Tags);
Assert.AreEqual("Renatus", meta.Title); Assert.AreEqual("Renatus", meta.Title);
Assert.AreEqual("Renatus", meta.TitleUnicode); Assert.AreEqual("Renatus", meta.TitleUnicode);
} }
} }
[Test] [Test]
public void TestDecodeGeneral() public void TestDecodeGeneral()
@ -55,8 +57,8 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual(PlayMode.Osu, beatmap.Mode); Assert.AreEqual(PlayMode.Osu, beatmap.Mode);
Assert.AreEqual(false, beatmap.LetterboxInBreaks); Assert.AreEqual(false, beatmap.LetterboxInBreaks);
Assert.AreEqual(false, beatmap.WidescreenStoryboard); Assert.AreEqual(false, beatmap.WidescreenStoryboard);
} }
} }
[Test] [Test]
public void TestDecodeEditor() public void TestDecodeEditor()
@ -78,8 +80,8 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual(4, beatmap.BeatDivisor); Assert.AreEqual(4, beatmap.BeatDivisor);
Assert.AreEqual(4, beatmap.GridSize); Assert.AreEqual(4, beatmap.GridSize);
Assert.AreEqual(2, beatmap.TimelineZoom); Assert.AreEqual(2, beatmap.TimelineZoom);
} }
} }
[Test] [Test]
public void TestDecodeDifficulty() public void TestDecodeDifficulty()
@ -95,8 +97,8 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual(9, difficulty.ApproachRate); Assert.AreEqual(9, difficulty.ApproachRate);
Assert.AreEqual(1.8f, difficulty.SliderMultiplier); Assert.AreEqual(1.8f, difficulty.SliderMultiplier);
Assert.AreEqual(2, difficulty.SliderTickRate); Assert.AreEqual(2, difficulty.SliderTickRate);
} }
} }
[Test] [Test]
public void TestDecodeColors() public void TestDecodeColors()
@ -117,6 +119,25 @@ namespace osu.Game.Tests.Beatmaps.Formats
Assert.AreEqual(expected.Length, beatmap.ComboColors.Count); Assert.AreEqual(expected.Length, beatmap.ComboColors.Count);
for (int i = 0; i < expected.Length; i++) for (int i = 0; i < expected.Length; i++)
Assert.AreEqual(expected[i], beatmap.ComboColors[i]); Assert.AreEqual(expected[i], beatmap.ComboColors[i]);
}
}
[Test]
public void TestDecodeHitObjects()
{
var decoder = new OsuLegacyDecoder();
using (var stream = Resource.OpenResource("Soleily - Renatus (Gamu) [Insane].osu"))
{
var beatmap = decoder.Decode(new StreamReader(stream));
var slider = beatmap.HitObjects[0] as Slider;
Assert.IsNotNull(slider);
Assert.AreEqual(new Vector2(192, 168), slider.Position);
Assert.AreEqual(956, slider.StartTime);
Assert.AreEqual(SampleType.None, slider.Sample.Type);
var circle = beatmap.HitObjects[1] as Circle;
Assert.IsNotNull(circle);
Assert.AreEqual(new Vector2(304, 56), circle.Position);
Assert.AreEqual(1285, circle.StartTime);
Assert.AreEqual(SampleType.Clap, circle.Sample.Type); Assert.AreEqual(SampleType.Clap, circle.Sample.Type);
} }
} }

View File

@ -44,7 +44,7 @@ namespace osu.Game.Beatmaps.Objects.Osu
} }
result.Position = new Vector2(int.Parse(split[0]), int.Parse(split[1])); result.Position = new Vector2(int.Parse(split[0]), int.Parse(split[1]));
result.StartTime = double.Parse(split[2]); result.StartTime = double.Parse(split[2]);
result.Sample = new HitSampleInfo { Type = (SampleType)int.Parse(split[3]) }; result.Sample = new HitSampleInfo { Type = (SampleType)int.Parse(split[4]) };
result.NewCombo = combo; result.NewCombo = combo;
// TODO: "addition" field // TODO: "addition" field
return result; return result;