1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 06:02:56 +08:00
osu-lazer/osu.Game.Tests/Visual/Settings/TestSceneSettingsItem.cs

44 lines
1.5 KiB
C#
Raw Normal View History

2021-03-03 02:18:01 +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 System.Linq;
using NUnit.Framework;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Game.Overlays.Settings;
using osu.Game.Overlays;
2021-03-03 02:18:01 +08:00
namespace osu.Game.Tests.Visual.Settings
{
[TestFixture]
public class TestSceneSettingsItem : OsuTestScene
{
[Test]
public void TestRestoreDefaultValueButtonVisibility()
{
TestSettingsTextBox textBox = null;
AddStep("create settings item", () => Child = textBox = new TestSettingsTextBox
{
Current = new Bindable<string>
{
Default = "test",
Value = "test"
}
});
AddAssert("restore button hidden", () => textBox.RestoreDefaultValueButton.Alpha == 0);
AddStep("change value from default", () => textBox.Current.Value = "non-default");
AddUntilStep("restore button shown", () => textBox.RestoreDefaultValueButton.Alpha > 0);
AddStep("restore default", () => textBox.Current.SetDefault());
AddUntilStep("restore button hidden", () => textBox.RestoreDefaultValueButton.Alpha == 0);
}
private class TestSettingsTextBox : SettingsTextBox
{
public Drawable RestoreDefaultValueButton => this.ChildrenOfType<RestoreDefaultValueButton<string>>().Single();
2021-03-03 02:18:01 +08:00
}
}
}