From 6b9dabbd3c776800f10e0ccad7253fda22edec5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 13 Jul 2023 21:54:28 +0200 Subject: [PATCH] Rewrite test scene to show non-themed and themed variants --- .../TestSceneRevertToDefaultButton.cs | 51 ++++++++----------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/osu.Game.Tests/Visual/Settings/TestSceneRevertToDefaultButton.cs b/osu.Game.Tests/Visual/Settings/TestSceneRevertToDefaultButton.cs index bfef120358..0e31757396 100644 --- a/osu.Game.Tests/Visual/Settings/TestSceneRevertToDefaultButton.cs +++ b/osu.Game.Tests/Visual/Settings/TestSceneRevertToDefaultButton.cs @@ -2,58 +2,49 @@ // See the LICENCE file in the repository root for full licence text. using NUnit.Framework; -using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Shapes; +using osu.Framework.Testing; using osu.Game.Overlays; +using osu.Game.Tests.Visual.UserInterface; using osuTK; namespace osu.Game.Tests.Visual.Settings { - public partial class TestSceneRevertToDefaultButton : OsuTestScene + public partial class TestSceneRevertToDefaultButton : ThemeComparisonTestScene { private float scale = 1; - [Cached] - private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple); - private readonly Bindable current = new Bindable { Default = default, Value = 1, }; - [Test] - public void TestBasic() + protected override Drawable CreateContent() => new Container { - RevertToDefaultButton revertToDefaultButton = null!; - - AddStep("create button", () => Child = new Container + AutoSizeAxes = Axes.Both, + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Child = new RevertToDefaultButton { - RelativeSizeAxes = Axes.Both, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = colourProvider.Background2, - }, - revertToDefaultButton = new RevertToDefaultButton - { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Scale = new Vector2(scale), - Current = current, - } - } - }); + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Scale = new Vector2(scale), + Current = current, + } + }; + + [Test] + public void TestStates() + { + CreateThemedContent(OverlayColourScheme.Purple); AddSliderStep("set scale", 1, 4, 1, scale => { this.scale = scale; - if (revertToDefaultButton != null) - revertToDefaultButton.Scale = new Vector2(scale); + foreach (var revertToDefaultButton in this.ChildrenOfType>()) + revertToDefaultButton.Parent!.Scale = new Vector2(scale); }); AddToggleStep("toggle default state", state => current.Value = state ? default : 1); AddToggleStep("toggle disabled state", state => current.Disabled = state);