Skip to content

Commit

Permalink
add test case for different sizing.
Browse files Browse the repository at this point in the history
  • Loading branch information
andy840119 committed Apr 30, 2022
1 parent 241b513 commit d900cbb
Showing 1 changed file with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -89,18 +92,19 @@ 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;
karaokeSpriteText.LeftLyricTextShaders = new[]
{
GetShaderByType<OutlineShader>().With(s =>
{
s.Radius = 10;
s.Radius = outline_radius;
s.Colour = Color4Extensions.FromHex(left_text_color);
s.OutlineColour = Color4Extensions.FromHex(left_outline_color);
})
Expand All @@ -109,44 +113,46 @@ public void TestApplyOutlineShader()
{
GetShaderByType<OutlineShader>().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);
})
};
});
}

[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);
karaokeSpriteText.LeftLyricTextShaders = new[]
{
GetShaderByType<ShadowShader>().With(s =>
{
s.ShadowOffset = new Vector2(10);
s.ShadowOffset = new Vector2(shadow_sizing);
s.ShadowColour = Color4Extensions.FromHex(left_shadow_color);
})
};
karaokeSpriteText.RightLyricTextShaders = new[]
{
GetShaderByType<ShadowShader>().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;
Expand All @@ -158,13 +164,13 @@ public void TestApplyOutlineAndShadowShader()
{
GetShaderByType<OutlineShader>().With(s =>
{
s.Radius = 10;
s.Radius = outline_radius;
s.Colour = Color4Extensions.FromHex(left_text_color);
s.OutlineColour = Color4Extensions.FromHex(left_outline_color);
}),
GetShaderByType<ShadowShader>().With(s =>
{
s.ShadowOffset = new Vector2(10);
s.ShadowOffset = new Vector2(shadow_sizing);
s.ShadowColour = Color4Extensions.FromHex(left_shadow_color);
})
}
Expand All @@ -178,13 +184,13 @@ public void TestApplyOutlineAndShadowShader()
{
GetShaderByType<OutlineShader>().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<ShadowShader>().With(s =>
{
s.ShadowOffset = new Vector2(10);
s.ShadowOffset = new Vector2(differentSizing ? shadow_sizing * 2 : shadow_sizing);
s.ShadowColour = Color4Extensions.FromHex(right_shadow_color);
})
}
Expand All @@ -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;
Expand Down

0 comments on commit d900cbb

Please sign in to comment.