2023-01-26 21:39:11 +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.
|
|
|
|
|
2023-10-18 12:41:00 +08:00
|
|
|
using System.Linq;
|
|
|
|
using NUnit.Framework;
|
2023-01-26 21:39:11 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
2023-10-18 12:41:00 +08:00
|
|
|
using osu.Framework.Testing;
|
2023-01-26 21:39:11 +08:00
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
using osu.Game.Overlays;
|
2023-10-18 12:41:00 +08:00
|
|
|
using osuTK.Input;
|
2023-01-26 21:39:11 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tests.Visual.UserInterface
|
|
|
|
{
|
2023-10-18 12:41:00 +08:00
|
|
|
public partial class TestSceneShearedSliderBar : OsuManualInputManagerTestScene
|
2023-01-26 21:39:11 +08:00
|
|
|
{
|
|
|
|
[Cached]
|
|
|
|
private OverlayColourProvider colourProvider { get; set; } = new OverlayColourProvider(OverlayColourScheme.Purple);
|
|
|
|
|
|
|
|
private readonly BindableDouble current = new BindableDouble(5)
|
|
|
|
{
|
|
|
|
Precision = 0.1f,
|
|
|
|
MinValue = 0,
|
|
|
|
MaxValue = 15
|
|
|
|
};
|
|
|
|
|
2023-10-18 12:41:00 +08:00
|
|
|
private ShearedSliderBar<double> slider = null!;
|
|
|
|
|
2023-01-26 21:39:11 +08:00
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
2023-10-18 12:41:00 +08:00
|
|
|
Child = slider = new ShearedSliderBar<double>
|
2023-01-26 21:39:11 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Current = current,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Width = 0.4f
|
|
|
|
};
|
|
|
|
}
|
2023-10-18 12:41:00 +08:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestNubDoubleClickRevertToDefault()
|
|
|
|
{
|
|
|
|
AddStep("set slider to 1", () => slider.Current.Value = 1);
|
|
|
|
|
|
|
|
AddStep("move mouse to nub", () => InputManager.MoveMouseTo(slider.ChildrenOfType<ShearedNub>().Single()));
|
|
|
|
|
|
|
|
AddStep("double click nub", () =>
|
|
|
|
{
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("slider is default", () => slider.Current.IsDefault);
|
|
|
|
}
|
2023-10-26 17:59:38 +08:00
|
|
|
|
|
|
|
[Test]
|
|
|
|
public void TestNubDoubleClickOnDisabledSliderDoesNothing()
|
|
|
|
{
|
|
|
|
AddStep("set slider to 1", () => slider.Current.Value = 1);
|
|
|
|
AddStep("disable slider", () => slider.Current.Disabled = true);
|
|
|
|
|
|
|
|
AddStep("move mouse to nub", () => InputManager.MoveMouseTo(slider.ChildrenOfType<ShearedNub>().Single()));
|
|
|
|
|
|
|
|
AddStep("double click nub", () =>
|
|
|
|
{
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
InputManager.Click(MouseButton.Left);
|
|
|
|
});
|
|
|
|
|
|
|
|
AddAssert("slider is still at 1", () => slider.Current.Value, () => Is.EqualTo(1));
|
|
|
|
}
|
2023-01-26 21:39:11 +08:00
|
|
|
}
|
|
|
|
}
|