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.
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<float> current = new Bindable<float>
{
Default = default,
Value = 1,
};
[Test]
public void TestBasic()
protected override Drawable CreateContent() => new Container
{
RevertToDefaultButton<float> revertToDefaultButton = null!;
AddStep("create button", () => Child = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colourProvider.Background2,
},
revertToDefaultButton = new RevertToDefaultButton<float>
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Child = new RevertToDefaultButton<float>
{
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<float>>())
revertToDefaultButton.Parent!.Scale = new Vector2(scale);
});
AddToggleStep("toggle default state", state => current.Value = state ? default : 1);
AddToggleStep("toggle disabled state", state => current.Disabled = state);