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