diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneRangeSlider.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneRangeSlider.cs index d0e3ff737c..b780764e7f 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneRangeSlider.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneRangeSlider.cs @@ -5,6 +5,7 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; +using osu.Framework.Testing; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays; using osuTK; @@ -30,10 +31,12 @@ public partial class TestSceneRangeSlider : OsuTestScene Precision = 0.1f }; - [Test] - public void TestBasic() + private RangeSlider rangeSlider = null!; + + [SetUpSteps] + public void SetUpSteps() { - AddStep("create Control", () => Child = new RangeSlider + AddStep("create control", () => Child = rangeSlider = new RangeSlider { Width = 200, Anchor = Anchor.Centre, @@ -47,15 +50,30 @@ public void TestBasic() DefaultStringUpperBound = "End", MinRange = 10 }); - AddStep("Test Range", () => + } + + [Test] + public void TestAdjustRange() + { + AddAssert("Initial lower bound is correct", () => rangeSlider.LowerBound.Value, () => Is.EqualTo(0).Within(0.1f)); + AddAssert("Initial upper bound is correct", () => rangeSlider.UpperBound.Value, () => Is.EqualTo(100).Within(0.1f)); + + AddStep("Adjust range", () => { customStart.Value = 50; customEnd.Value = 75; }); + + AddAssert("Adjusted lower bound is correct", () => rangeSlider.LowerBound.Value, () => Is.EqualTo(50).Within(0.1f)); + AddAssert("Adjusted upper bound is correct", () => rangeSlider.UpperBound.Value, () => Is.EqualTo(75).Within(0.1f)); + AddStep("Test nub pushing", () => { customStart.Value = 90; }); + + AddAssert("Pushed lower bound is correct", () => rangeSlider.LowerBound.Value, () => Is.EqualTo(90).Within(0.1f)); + AddAssert("Pushed upper bound is correct", () => rangeSlider.UpperBound.Value, () => Is.EqualTo(100).Within(0.1f)); } } } diff --git a/osu.Game/Graphics/UserInterface/RangeSlider.cs b/osu.Game/Graphics/UserInterface/RangeSlider.cs index c8306b70fb..483119cd58 100644 --- a/osu.Game/Graphics/UserInterface/RangeSlider.cs +++ b/osu.Game/Graphics/UserInterface/RangeSlider.cs @@ -22,6 +22,7 @@ public partial class RangeSlider : CompositeDrawable /// public Bindable LowerBound { + get => lowerBound.Current; set => lowerBound.Current = value; } @@ -30,6 +31,7 @@ public Bindable LowerBound /// public Bindable UpperBound { + get => upperBound.Current; set => upperBound.Current = value; }