1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 02:02:53 +08:00

Refactor test to better keep existing toggle values

I also changed the type of the button to `float` because it was mentally
hard to parse a default button that is tracking a `bool` state. Probably
not what we want for a test like this.
This commit is contained in:
Dean Herbert 2021-10-18 13:53:27 +09:00
parent 2a41e8bd1f
commit 50bde0fe38

View File

@ -18,10 +18,18 @@ namespace osu.Game.Tests.Visual.Settings
[Resolved]
private OsuColour colours { get; set; }
private float scale = 1;
private readonly Bindable<float> current = new Bindable<float>
{
Default = default,
Value = 1,
};
[Test]
public void TestBasic()
{
RestoreDefaultValueButton<bool> restoreDefaultValueButton = null;
RestoreDefaultValueButton<float> restoreDefaultValueButton = null;
AddStep("create button", () => Child = new Container
{
@ -33,21 +41,23 @@ namespace osu.Game.Tests.Visual.Settings
RelativeSizeAxes = Axes.Both,
Colour = colours.GreySeafoam
},
restoreDefaultValueButton = new RestoreDefaultValueButton<bool>
restoreDefaultValueButton = new RestoreDefaultValueButton<float>
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Current = new BindableBool(),
Scale = new Vector2(scale),
Current = current,
}
}
});
AddSliderStep("set scale", 1, 4, 1, scale =>
{
this.scale = scale;
if (restoreDefaultValueButton != null)
restoreDefaultValueButton.Scale = new Vector2(scale);
});
AddToggleStep("toggle default state", state => restoreDefaultValueButton.Current.Value = state);
AddToggleStep("toggle disabled state", state => restoreDefaultValueButton.Current.Disabled = state);
AddToggleStep("toggle default state", state => current.Value = state ? default : 1);
AddToggleStep("toggle disabled state", state => current.Disabled = state);
}
}
}