From b8327ed877b61ac867210f7b611240c28063fdc7 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sun, 5 Apr 2020 00:30:10 +0300 Subject: [PATCH 1/2] Add test for osu!catch skin colour decoding Tests the skin configuration CatchTheBeat section's colours decoding part --- .../CatchSkinColourDecodingTest.cs | 36 +++++++++++++++++++ .../Resources/special-skin/skin.ini | 4 +++ .../Skinning/CatchLegacySkinTransformer.cs | 2 +- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 osu.Game.Rulesets.Catch.Tests/CatchSkinColourDecodingTest.cs create mode 100644 osu.Game.Rulesets.Catch.Tests/Resources/special-skin/skin.ini diff --git a/osu.Game.Rulesets.Catch.Tests/CatchSkinColourDecodingTest.cs b/osu.Game.Rulesets.Catch.Tests/CatchSkinColourDecodingTest.cs new file mode 100644 index 0000000000..57228210d6 --- /dev/null +++ b/osu.Game.Rulesets.Catch.Tests/CatchSkinColourDecodingTest.cs @@ -0,0 +1,36 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using NUnit.Framework; +using osu.Framework.IO.Stores; +using osu.Game.Rulesets.Catch.Skinning; +using osu.Game.Skinning; +using osuTK.Graphics; + +namespace osu.Game.Rulesets.Catch.Tests +{ + [TestFixture] + public class CatchSkinColourDecodingTest + { + [Test] + public void TestCatchSkinColourDecoding() + { + var store = new NamespacedResourceStore(new DllResourceStore(GetType().Assembly), "Resources/special-skin"); + var rawSkin = new TestLegacySkin(new SkinInfo { Name = "special-skin" }, store); + var skin = new CatchLegacySkinTransformer(rawSkin); + + Assert.AreEqual(new Color4(232, 185, 35, 255), skin.GetHyperDashCatcherColour()?.Value); + Assert.AreEqual(new Color4(232, 74, 35, 255), skin.GetHyperDashCatcherAfterImageColour()?.Value); + Assert.AreEqual(new Color4(0, 255, 255, 255), skin.GetHyperDashFruitColour()?.Value); + } + + private class TestLegacySkin : LegacySkin + { + public TestLegacySkin(SkinInfo skin, IResourceStore storage) + // Bypass LegacySkinResourceStore to avoid returning null for retrieving files due to bad skin info (SkinInfo.Files = null). + : base(skin, storage, null, "skin.ini") + { + } + } + } +} diff --git a/osu.Game.Rulesets.Catch.Tests/Resources/special-skin/skin.ini b/osu.Game.Rulesets.Catch.Tests/Resources/special-skin/skin.ini new file mode 100644 index 0000000000..96d50f1451 --- /dev/null +++ b/osu.Game.Rulesets.Catch.Tests/Resources/special-skin/skin.ini @@ -0,0 +1,4 @@ +[CatchTheBeat] +HyperDash: 232,185,35 +HyperDashFruit: 0,255,255 +HyperDashAfterImage: 232,74,35 diff --git a/osu.Game.Rulesets.Catch/Skinning/CatchLegacySkinTransformer.cs b/osu.Game.Rulesets.Catch/Skinning/CatchLegacySkinTransformer.cs index 65e6e6f209..ba939157ea 100644 --- a/osu.Game.Rulesets.Catch/Skinning/CatchLegacySkinTransformer.cs +++ b/osu.Game.Rulesets.Catch/Skinning/CatchLegacySkinTransformer.cs @@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Catch.Skinning { private readonly ISkin source; - public CatchLegacySkinTransformer(ISkinSource source) + public CatchLegacySkinTransformer(ISkin source) { this.source = source; } From ff6642190f0d6e85cdff7eb3b2998fef0f9fb974 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 14 May 2020 07:26:47 +0300 Subject: [PATCH 2/2] Update colour retrieval logic --- .../CatchSkinColourDecodingTest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/osu.Game.Rulesets.Catch.Tests/CatchSkinColourDecodingTest.cs b/osu.Game.Rulesets.Catch.Tests/CatchSkinColourDecodingTest.cs index 57228210d6..7deeec527f 100644 --- a/osu.Game.Rulesets.Catch.Tests/CatchSkinColourDecodingTest.cs +++ b/osu.Game.Rulesets.Catch.Tests/CatchSkinColourDecodingTest.cs @@ -19,9 +19,9 @@ namespace osu.Game.Rulesets.Catch.Tests var rawSkin = new TestLegacySkin(new SkinInfo { Name = "special-skin" }, store); var skin = new CatchLegacySkinTransformer(rawSkin); - Assert.AreEqual(new Color4(232, 185, 35, 255), skin.GetHyperDashCatcherColour()?.Value); - Assert.AreEqual(new Color4(232, 74, 35, 255), skin.GetHyperDashCatcherAfterImageColour()?.Value); - Assert.AreEqual(new Color4(0, 255, 255, 255), skin.GetHyperDashFruitColour()?.Value); + Assert.AreEqual(new Color4(232, 185, 35, 255), skin.GetConfig(CatchSkinColour.HyperDash)?.Value); + Assert.AreEqual(new Color4(232, 74, 35, 255), skin.GetConfig(CatchSkinColour.HyperDashAfterImage)?.Value); + Assert.AreEqual(new Color4(0, 255, 255, 255), skin.GetConfig(CatchSkinColour.HyperDashFruit)?.Value); } private class TestLegacySkin : LegacySkin