From d900cbbc31917e51b9ab492a361399f646af0c4a Mon Sep 17 00:00:00 2001 From: andy840119 Date: Sat, 30 Apr 2022 21:18:21 +0800 Subject: [PATCH] add test case for different sizing. --- .../TestSceneKaraokeSpriteTextTransforms.cs | 43 +++++++++++-------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/osu.Framework.Font.Tests/Visual/Sprites/TestSceneKaraokeSpriteTextTransforms.cs b/osu.Framework.Font.Tests/Visual/Sprites/TestSceneKaraokeSpriteTextTransforms.cs index 546591f..c97ef3b 100644 --- a/osu.Framework.Font.Tests/Visual/Sprites/TestSceneKaraokeSpriteTextTransforms.cs +++ b/osu.Framework.Font.Tests/Visual/Sprites/TestSceneKaraokeSpriteTextTransforms.cs @@ -24,6 +24,9 @@ public class TestSceneKaraokeSpriteTextTransforms : BackgroundGridTestScene private const string right_outline_color = "#5932CC"; private const string right_shadow_color = "#3D2D6B"; + private const int outline_radius = 10; + private const int shadow_sizing = 10; + private const double start_time = 1000; private const double end_time = 5000; private const double exrea_time = 500; @@ -89,10 +92,11 @@ public void TestNoneShader() }); } - [Test] - public void TestApplyOutlineShader() + [TestCase(false)] + [TestCase(true)] + public void TestApplyOutlineShader(bool differentSizing) { - AddStep("Apply shader", () => + AddStep(getApplyDescription(differentSizing), () => { karaokeSpriteText.LeftTextColour = Color4.White; karaokeSpriteText.RightTextColour = Color4.White; @@ -100,7 +104,7 @@ public void TestApplyOutlineShader() { GetShaderByType().With(s => { - s.Radius = 10; + s.Radius = outline_radius; s.Colour = Color4Extensions.FromHex(left_text_color); s.OutlineColour = Color4Extensions.FromHex(left_outline_color); }) @@ -109,7 +113,7 @@ public void TestApplyOutlineShader() { GetShaderByType().With(s => { - s.Radius = 10; + s.Radius = differentSizing ? outline_radius * 2 : outline_radius; s.Colour = Color4Extensions.FromHex(right_text_color); s.OutlineColour = Color4Extensions.FromHex(right_outline_color); }) @@ -117,10 +121,11 @@ public void TestApplyOutlineShader() }); } - [Test] - public void TestApplyShadowShader() + [TestCase(false)] + [TestCase(true)] + public void TestApplyShadowShader(bool differentSizing) { - AddStep("Apply shadow", () => + AddStep(getApplyDescription(differentSizing), () => { karaokeSpriteText.LeftTextColour = Color4Extensions.FromHex(left_text_color); karaokeSpriteText.RightTextColour = Color4Extensions.FromHex(right_text_color); @@ -128,7 +133,7 @@ public void TestApplyShadowShader() { GetShaderByType().With(s => { - s.ShadowOffset = new Vector2(10); + s.ShadowOffset = new Vector2(shadow_sizing); s.ShadowColour = Color4Extensions.FromHex(left_shadow_color); }) }; @@ -136,17 +141,18 @@ public void TestApplyShadowShader() { GetShaderByType().With(s => { - s.ShadowOffset = new Vector2(10); + s.ShadowOffset = new Vector2(differentSizing ? shadow_sizing * 2 : shadow_sizing); s.ShadowColour = Color4Extensions.FromHex(right_shadow_color); }) }; }); } - [Test] - public void TestApplyOutlineAndShadowShader() + [TestCase(false)] + [TestCase(true)] + public void TestApplyOutlineAndShadowShader(bool differentSizing) { - AddStep("Apply shader", () => + AddStep(getApplyDescription(differentSizing), () => { karaokeSpriteText.LeftTextColour = Color4.White; karaokeSpriteText.RightTextColour = Color4.White; @@ -158,13 +164,13 @@ public void TestApplyOutlineAndShadowShader() { GetShaderByType().With(s => { - s.Radius = 10; + s.Radius = outline_radius; s.Colour = Color4Extensions.FromHex(left_text_color); s.OutlineColour = Color4Extensions.FromHex(left_outline_color); }), GetShaderByType().With(s => { - s.ShadowOffset = new Vector2(10); + s.ShadowOffset = new Vector2(shadow_sizing); s.ShadowColour = Color4Extensions.FromHex(left_shadow_color); }) } @@ -178,13 +184,13 @@ public void TestApplyOutlineAndShadowShader() { GetShaderByType().With(s => { - s.Radius = 10; + s.Radius = differentSizing ? outline_radius * 2 : outline_radius; s.Colour = Color4Extensions.FromHex(right_text_color); s.OutlineColour = Color4Extensions.FromHex(right_outline_color); }), GetShaderByType().With(s => { - s.ShadowOffset = new Vector2(10); + s.ShadowOffset = new Vector2(differentSizing ? shadow_sizing * 2 : shadow_sizing); s.ShadowColour = Color4Extensions.FromHex(right_shadow_color); }) } @@ -193,6 +199,9 @@ public void TestApplyOutlineAndShadowShader() }); } + private string getApplyDescription(bool applyDifferentSizing) + => applyDifferentSizing ? "Apply shader with different sizing" : "Apply shader"; + private class TestKaraokeSpriteText : KaraokeSpriteText { public override bool RemoveCompletedTransforms => false;