1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Split combo colour decoding to small test cases

This commit is contained in:
Salman Ahmed 2019-12-12 12:16:19 +03:00
parent 5bf6e57eb0
commit 81c8493038

View File

@ -13,43 +13,21 @@ namespace osu.Game.Tests.Skins
[TestFixture]
public class LegacySkinDecoderTest
{
[TestCase(true)]
[TestCase(false)]
[TestCase(false, false)]
public void TestDecodeSkinColours(bool hasColours, bool canFallback = true)
public void TestDecodeSkinColours()
{
var decoder = new LegacySkinDecoder();
using (var resStream = TestResources.OpenResource(hasColours ? "skin.ini" : "skin-empty.ini"))
using (var resStream = TestResources.OpenResource("skin.ini"))
using (var stream = new LineBufferedReader(resStream))
{
var skinConfiguration = decoder.Decode(stream);
skinConfiguration.AllowDefaultComboColoursFallback = canFallback;
var comboColors = skinConfiguration.ComboColours;
if (!canFallback && !hasColours)
var comboColors = decoder.Decode(stream).ComboColours;
var expectedColors = new List<Color4>
{
Assert.IsNull(comboColors);
return;
}
List<Color4> expectedColors;
if (hasColours)
{
expectedColors = new List<Color4>
{
new Color4(142, 199, 255, 255),
new Color4(255, 128, 128, 255),
new Color4(128, 255, 255, 255),
new Color4(100, 100, 100, 100),
};
}
else
{
expectedColors = SkinConfiguration.DefaultComboColours;
}
new Color4(142, 199, 255, 255),
new Color4(255, 128, 128, 255),
new Color4(128, 255, 255, 255),
new Color4(100, 100, 100, 100),
};
Assert.AreEqual(expectedColors.Count, comboColors.Count);
for (int i = 0; i < expectedColors.Count; i++)
@ -57,6 +35,35 @@ namespace osu.Game.Tests.Skins
}
}
public void TestDecodeEmptySkinColours()
{
var decoder = new LegacySkinDecoder();
using (var resStream = TestResources.OpenResource("skin-empty.ini"))
using (var stream = new LineBufferedReader(resStream))
{
var comboColors = decoder.Decode(stream).ComboColours;
var expectedColors = SkinConfiguration.DefaultComboColours;
Assert.AreEqual(expectedColors.Count, comboColors.Count);
for (int i = 0; i < expectedColors.Count; i++)
Assert.AreEqual(expectedColors[i], comboColors[i]);
}
}
public void TestDecodeEmptySkinColoursNoFallback()
{
var decoder = new LegacySkinDecoder();
using (var resStream = TestResources.OpenResource("skin-empty.ini"))
using (var stream = new LineBufferedReader(resStream))
{
var skinConfiguration = decoder.Decode(stream);
skinConfiguration.AllowDefaultComboColoursFallback = false;
Assert.IsNull(skinConfiguration.ComboColours);
}
}
[Test]
public void TestDecodeGeneral()
{