2019-02-05 08:50:32 +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.
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using NUnit.Framework;
|
2019-09-09 22:43:30 +00:00
|
|
|
using osu.Game.IO;
|
2019-02-05 08:50:32 +00:00
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osu.Game.Tests.Resources;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Tests.Skins
|
|
|
|
{
|
|
|
|
[TestFixture]
|
2019-02-05 09:09:15 +00:00
|
|
|
public class LegacySkinDecoderTest
|
2019-02-05 08:50:32 +00:00
|
|
|
{
|
2019-12-12 11:05:37 +00:00
|
|
|
[Test]
|
2019-12-12 09:16:19 +00:00
|
|
|
public void TestDecodeSkinColours()
|
2019-02-05 08:50:32 +00:00
|
|
|
{
|
|
|
|
var decoder = new LegacySkinDecoder();
|
2019-04-01 03:44:46 +00:00
|
|
|
|
2019-12-12 09:16:19 +00:00
|
|
|
using (var resStream = TestResources.OpenResource("skin.ini"))
|
2019-09-09 22:43:30 +00:00
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2019-02-05 08:50:32 +00:00
|
|
|
{
|
2019-12-12 09:16:19 +00:00
|
|
|
var comboColors = decoder.Decode(stream).ComboColours;
|
|
|
|
var expectedColors = new List<Color4>
|
2019-11-07 12:51:03 +00:00
|
|
|
{
|
2019-12-12 09:16:19 +00:00
|
|
|
new Color4(142, 199, 255, 255),
|
|
|
|
new Color4(255, 128, 128, 255),
|
|
|
|
new Color4(128, 255, 255, 255),
|
|
|
|
new Color4(100, 100, 100, 100),
|
|
|
|
};
|
2019-02-05 08:50:32 +00:00
|
|
|
|
2019-12-12 09:16:19 +00:00
|
|
|
Assert.AreEqual(expectedColors.Count, comboColors.Count);
|
|
|
|
for (int i = 0; i < expectedColors.Count; i++)
|
|
|
|
Assert.AreEqual(expectedColors[i], comboColors[i]);
|
|
|
|
}
|
|
|
|
}
|
2019-11-07 13:13:10 +00:00
|
|
|
|
2019-12-12 11:05:37 +00:00
|
|
|
[Test]
|
2019-12-12 09:16:19 +00:00
|
|
|
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;
|
2019-02-05 08:50:32 +00:00
|
|
|
|
|
|
|
Assert.AreEqual(expectedColors.Count, comboColors.Count);
|
|
|
|
for (int i = 0; i < expectedColors.Count; i++)
|
|
|
|
Assert.AreEqual(expectedColors[i], comboColors[i]);
|
|
|
|
}
|
|
|
|
}
|
2019-09-03 09:59:11 +00:00
|
|
|
|
2019-12-12 11:05:37 +00:00
|
|
|
[Test]
|
2019-12-12 09:16:19 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-03 09:59:11 +00:00
|
|
|
[Test]
|
|
|
|
public void TestDecodeGeneral()
|
|
|
|
{
|
|
|
|
var decoder = new LegacySkinDecoder();
|
|
|
|
|
|
|
|
using (var resStream = TestResources.OpenResource("skin.ini"))
|
2019-09-09 22:43:30 +00:00
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2019-09-03 09:59:11 +00:00
|
|
|
{
|
|
|
|
var config = decoder.Decode(stream);
|
|
|
|
|
|
|
|
Assert.AreEqual("test skin", config.SkinInfo.Name);
|
|
|
|
Assert.AreEqual("TestValue", config.ConfigDictionary["TestLookup"]);
|
|
|
|
}
|
|
|
|
}
|
2019-10-09 20:06:53 +00:00
|
|
|
|
2019-10-09 20:33:25 +00:00
|
|
|
[Test]
|
|
|
|
public void TestDecodeSpecifiedVersion()
|
|
|
|
{
|
|
|
|
var decoder = new LegacySkinDecoder();
|
|
|
|
using (var resStream = TestResources.OpenResource("skin-20.ini"))
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
Assert.AreEqual(2.0m, decoder.Decode(stream).LegacyVersion);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestDecodeLatestVersion()
|
|
|
|
{
|
|
|
|
var decoder = new LegacySkinDecoder();
|
|
|
|
using (var resStream = TestResources.OpenResource("skin-latest.ini"))
|
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
|
|
|
Assert.AreEqual(LegacySkinConfiguration.LATEST_VERSION, decoder.Decode(stream).LegacyVersion);
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestDecodeNoVersion()
|
2019-10-09 20:06:53 +00:00
|
|
|
{
|
|
|
|
var decoder = new LegacySkinDecoder();
|
2019-10-09 20:33:25 +00:00
|
|
|
using (var resStream = TestResources.OpenResource("skin-empty.ini"))
|
2019-10-09 20:06:53 +00:00
|
|
|
using (var stream = new LineBufferedReader(resStream))
|
2020-04-06 10:36:04 +00:00
|
|
|
Assert.That(decoder.Decode(stream).LegacyVersion, Is.EqualTo(1.0m));
|
2019-10-09 20:06:53 +00:00
|
|
|
}
|
2019-02-05 08:50:32 +00:00
|
|
|
}
|
|
|
|
}
|