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/TestSceneRestoreDefaultValueButton.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

64 lines
2.0 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.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics;
using osu.Game.Overlays;
using osuTK;
namespace osu.Game.Tests.Visual.Settings
{
public class TestSceneRestoreDefaultValueButton : OsuTestScene
{
[Resolved]
private OsuColour colours { get; set; }
private float scale = 1;
private readonly Bindable<float> current = new Bindable<float>
{
Default = default,
Value = 1,
};
2021-10-16 03:44:56 +08:00
[Test]
public void TestBasic()
{
RestoreDefaultValueButton<float> restoreDefaultValueButton = null;
2021-10-16 03:44:56 +08:00
AddStep("create button", () => Child = new Container
{
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = colours.GreySeaFoam
2021-10-16 03:44:56 +08:00
},
restoreDefaultValueButton = new RestoreDefaultValueButton<float>
2021-10-16 03:44:56 +08:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Scale = new Vector2(scale),
Current = current,
2021-10-16 03:44:56 +08:00
}
}
});
AddSliderStep("set scale", 1, 4, 1, scale =>
{
this.scale = scale;
2021-10-16 03:44:56 +08:00
if (restoreDefaultValueButton != null)
restoreDefaultValueButton.Scale = new Vector2(scale);
});
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
}
}
}