2019-09-20 18:19:43 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2019-09-25 16:42:27 +08:00
|
|
|
using NUnit.Framework;
|
|
|
|
using osu.Framework.Bindables;
|
2019-09-20 18:19:43 +08:00
|
|
|
using osu.Framework.Graphics;
|
2019-09-25 16:53:08 +08:00
|
|
|
using osu.Game.Graphics.UserInterfaceV2;
|
2019-09-25 16:42:27 +08:00
|
|
|
using osuTK.Input;
|
2019-09-20 18:19:43 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
{
|
2020-03-23 09:01:33 +08:00
|
|
|
public class TestSceneSwitchButton : OsuManualInputManagerTestScene
|
2019-09-20 18:19:43 +08:00
|
|
|
{
|
2019-09-25 16:42:27 +08:00
|
|
|
private SwitchButton switchButton;
|
|
|
|
|
|
|
|
[SetUp]
|
|
|
|
public void Setup() => Schedule(() =>
|
2019-09-20 18:19:43 +08:00
|
|
|
{
|
2019-09-25 16:42:27 +08:00
|
|
|
Child = switchButton = new SwitchButton
|
2019-09-20 18:19:43 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
};
|
2019-09-25 16:42:27 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestChangeThroughInput()
|
|
|
|
{
|
|
|
|
AddStep("move to switch button", () => InputManager.MoveMouseTo(switchButton));
|
|
|
|
AddStep("click on", () => InputManager.Click(MouseButton.Left));
|
|
|
|
AddStep("click off", () => InputManager.Click(MouseButton.Left));
|
|
|
|
}
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestChangeThroughBindable()
|
|
|
|
{
|
|
|
|
BindableBool bindable = null;
|
|
|
|
|
|
|
|
AddStep("bind bindable", () => switchButton.Current.BindTo(bindable = new BindableBool()));
|
|
|
|
AddStep("toggle bindable", () => bindable.Toggle());
|
|
|
|
AddStep("toggle bindable", () => bindable.Toggle());
|
2019-09-20 18:19:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|