1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Rewrite test scene to show non-themed and themed variants

This commit is contained in:
Bartłomiej Dach 2023-07-13 21:54:28 +02:00
parent eeb50e2700
commit 6b9dabbd3c
No known key found for this signature in database

View File

@ -2,58 +2,49 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using NUnit.Framework; using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Testing;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Game.Tests.Visual.UserInterface;
using osuTK; using osuTK;
namespace osu.Game.Tests.Visual.Settings namespace osu.Game.Tests.Visual.Settings
{ {
public partial class TestSceneRevertToDefaultButton : OsuTestScene public partial class TestSceneRevertToDefaultButton : ThemeComparisonTestScene
{ {
private float scale = 1; private float scale = 1;
[Cached]
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
private readonly Bindable<float> current = new Bindable<float> private readonly Bindable<float> current = new Bindable<float>
{ {
Default = default, Default = default,
Value = 1, Value = 1,
}; };
[Test] protected override Drawable CreateContent() => new Container
public void TestBasic()
{ {
RevertToDefaultButton<float> revertToDefaultButton = null!; AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
AddStep("create button", () => Child = new Container Origin = Anchor.Centre,
Child = new RevertToDefaultButton<float>
{ {
RelativeSizeAxes = Axes.Both, Anchor = Anchor.Centre,
Children = new Drawable[] Origin = Anchor.Centre,
{ Scale = new Vector2(scale),
new Box Current = current,
{ }
RelativeSizeAxes = Axes.Both, };
Colour = colourProvider.Background2,
}, [Test]
revertToDefaultButton = new RevertToDefaultButton<float> public void TestStates()
{ {
Anchor = Anchor.Centre, CreateThemedContent(OverlayColourScheme.Purple);
Origin = Anchor.Centre,
Scale = new Vector2(scale),
Current = current,
}
}
});
AddSliderStep("set scale", 1, 4, 1, scale => AddSliderStep("set scale", 1, 4, 1, scale =>
{ {
this.scale = scale; this.scale = scale;
if (revertToDefaultButton != null) foreach (var revertToDefaultButton in this.ChildrenOfType<RevertToDefaultButton<float>>())
revertToDefaultButton.Scale = new Vector2(scale); revertToDefaultButton.Parent!.Scale = new Vector2(scale);
}); });
AddToggleStep("toggle default state", state => current.Value = state ? default : 1); AddToggleStep("toggle default state", state => current.Value = state ? default : 1);
AddToggleStep("toggle disabled state", state => current.Disabled = state); AddToggleStep("toggle disabled state", state => current.Disabled = state);