mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 19:32:55 +08:00
Move test values to constants
This commit is contained in:
parent
7559012fb7
commit
5e634c1183
@ -47,7 +47,10 @@ namespace osu.Game.Tests.Visual.Background
|
|||||||
lightenDuringBreaks.Value = false;
|
lightenDuringBreaks.Value = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
[TestCase(0.6f, 0.3f)]
|
private const float test_user_dim = 0.6f;
|
||||||
|
private const float test_user_dim_lightened = test_user_dim - UserDimContainer.BREAK_LIGHTEN_AMOUNT;
|
||||||
|
|
||||||
|
[TestCase(test_user_dim, test_user_dim_lightened)]
|
||||||
[TestCase(0.2f, 0.0f)]
|
[TestCase(0.2f, 0.0f)]
|
||||||
[TestCase(0.0f, 0.0f)]
|
[TestCase(0.0f, 0.0f)]
|
||||||
public void TestBreakLightening(float userDim, float expectedBreakDim)
|
public void TestBreakLightening(float userDim, float expectedBreakDim)
|
||||||
@ -64,26 +67,26 @@ namespace osu.Game.Tests.Visual.Background
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestEnableSettingDuringBreak()
|
public void TestEnableSettingDuringBreak()
|
||||||
{
|
{
|
||||||
AddStep("set dim level 0.6", () => container.UserDimLevel.Value = 0.6f);
|
AddStep("set dim level 0.6", () => container.UserDimLevel.Value = test_user_dim);
|
||||||
|
|
||||||
AddStep("set break", () => isBreakTime.Value = true);
|
AddStep("set break", () => isBreakTime.Value = true);
|
||||||
AddUntilStep("not lightened", () => container.DimEqual(0.6f));
|
AddUntilStep("not lightened", () => container.DimEqual(test_user_dim));
|
||||||
AddStep("set lighten during break", () => lightenDuringBreaks.Value = true);
|
AddStep("set lighten during break", () => lightenDuringBreaks.Value = true);
|
||||||
AddUntilStep("has lightened", () => container.DimEqual(0.3f));
|
AddUntilStep("has lightened", () => container.DimEqual(test_user_dim_lightened));
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestDisableSettingDuringBreak()
|
public void TestDisableSettingDuringBreak()
|
||||||
{
|
{
|
||||||
AddStep("set dim level 0.6", () => container.UserDimLevel.Value = 0.6f);
|
AddStep("set dim level 0.6", () => container.UserDimLevel.Value = test_user_dim);
|
||||||
AddStep("set lighten during break", () => lightenDuringBreaks.Value = true);
|
AddStep("set lighten during break", () => lightenDuringBreaks.Value = true);
|
||||||
|
|
||||||
AddStep("set break", () => isBreakTime.Value = true);
|
AddStep("set break", () => isBreakTime.Value = true);
|
||||||
AddUntilStep("has lightened", () => container.DimEqual(0.3f));
|
AddUntilStep("has lightened", () => container.DimEqual(test_user_dim_lightened));
|
||||||
AddStep("clear lighten during break", () => lightenDuringBreaks.Value = false);
|
AddStep("clear lighten during break", () => lightenDuringBreaks.Value = false);
|
||||||
AddUntilStep("not lightened", () => container.DimEqual(0.6f));
|
AddUntilStep("not lightened", () => container.DimEqual(test_user_dim));
|
||||||
AddStep("clear break", () => isBreakTime.Value = false);
|
AddStep("clear break", () => isBreakTime.Value = false);
|
||||||
AddUntilStep("not lightened", () => container.DimEqual(0.6f));
|
AddUntilStep("not lightened", () => container.DimEqual(test_user_dim));
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestUserDimContainer : UserDimContainer
|
private class TestUserDimContainer : UserDimContainer
|
||||||
|
@ -19,7 +19,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Amount of lightening to apply to current dim level during break times.
|
/// Amount of lightening to apply to current dim level during break times.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const float break_lighten_amount = 0.3f;
|
public const float BREAK_LIGHTEN_AMOUNT = 0.3f;
|
||||||
|
|
||||||
protected const double BACKGROUND_FADE_DURATION = 800;
|
protected const double BACKGROUND_FADE_DURATION = 800;
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
protected Bindable<bool> ShowVideo { get; private set; }
|
protected Bindable<bool> ShowVideo { get; private set; }
|
||||||
|
|
||||||
private float breakLightening => LightenDuringBreaks.Value && IsBreakTime.Value ? break_lighten_amount : 0;
|
private float breakLightening => LightenDuringBreaks.Value && IsBreakTime.Value ? BREAK_LIGHTEN_AMOUNT : 0;
|
||||||
protected float DimLevel => Math.Max(EnableUserDim.Value ? (float)UserDimLevel.Value - breakLightening : 0, 0);
|
protected float DimLevel => Math.Max(EnableUserDim.Value ? (float)UserDimLevel.Value - breakLightening : 0, 0);
|
||||||
|
|
||||||
protected override Container<Drawable> Content => dimContent;
|
protected override Container<Drawable> Content => dimContent;
|
||||||
|
Loading…
Reference in New Issue
Block a user