1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-18 08:52:54 +08:00
osu-lazer/osu.Game.Tests/Visual/Settings/TestSceneRevertToDefaultButton.cs

54 lines
1.8 KiB
C#
Raw Normal View History

2021-10-16 03:44:56 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
2021-10-16 03:44:56 +08:00
using osu.Game.Overlays;
using osu.Game.Tests.Visual.UserInterface;
2021-10-16 03:44:56 +08:00
using osuTK;
namespace osu.Game.Tests.Visual.Settings
{
public partial class TestSceneRevertToDefaultButton : ThemeComparisonTestScene
2021-10-16 03:44:56 +08:00
{
private float scale = 1;
private readonly Bindable<float> current = new Bindable<float>
{
Default = default,
Value = 1,
};
protected override Drawable CreateContent() => new Container
2021-10-16 03:44:56 +08:00
{
AutoSizeAxes = Axes.Both,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Child = new RevertToDefaultButton<float>
2021-10-16 03:44:56 +08:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(scale),
Current = current,
}
};
[Test]
public void TestStates()
{
2023-07-14 04:28:26 +08:00
AddStep("create content", () => CreateThemedContent(OverlayColourScheme.Purple));
2021-10-16 03:44:56 +08:00
AddSliderStep("set scale", 1, 4, 1, scale =>
{
this.scale = scale;
foreach (var revertToDefaultButton in this.ChildrenOfType<RevertToDefaultButton<float>>())
revertToDefaultButton.Parent!.Scale = new Vector2(scale);
2021-10-16 03:44:56 +08:00
});
AddToggleStep("toggle default state", state => current.Value = state ? default : 1);
AddToggleStep("toggle disabled state", state => current.Disabled = state);
2021-10-16 03:44:56 +08:00
}
}
}