mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 16:06:06 +08:00
Add test coverage of failing validity checks
This commit is contained in:
parent
16beb2c90c
commit
8d44f059ec
@ -2,11 +2,10 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Input.Handlers.Tablet;
|
using osu.Framework.Input.Handlers.Tablet;
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Testing;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.Settings.Sections.Input;
|
using osu.Game.Overlays.Settings.Sections.Input;
|
||||||
@ -17,22 +16,34 @@ namespace osu.Game.Tests.Visual.Settings
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class TestSceneTabletSettings : OsuTestScene
|
public class TestSceneTabletSettings : OsuTestScene
|
||||||
{
|
{
|
||||||
[BackgroundDependencyLoader]
|
private TestTabletHandler tabletHandler;
|
||||||
private void load(GameHost host)
|
private TabletSettings settings;
|
||||||
{
|
|
||||||
var tabletHandler = new TestTabletHandler();
|
|
||||||
|
|
||||||
AddRange(new Drawable[]
|
[SetUpSteps]
|
||||||
|
public void SetUpSteps()
|
||||||
|
{
|
||||||
|
AddStep("create settings", () =>
|
||||||
{
|
{
|
||||||
new TabletSettings(tabletHandler)
|
tabletHandler = new TestTabletHandler();
|
||||||
|
|
||||||
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.None,
|
settings = new TabletSettings(tabletHandler)
|
||||||
Width = SettingsPanel.PANEL_WIDTH,
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
RelativeSizeAxes = Axes.None,
|
||||||
Origin = Anchor.TopCentre,
|
Width = SettingsPanel.PANEL_WIDTH,
|
||||||
}
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
}
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
AddStep("set square size", () => tabletHandler.SetTabletSize(new Vector2(100, 100)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestVariousTabletSizes()
|
||||||
|
{
|
||||||
AddStep("Test with wide tablet", () => tabletHandler.SetTabletSize(new Vector2(160, 100)));
|
AddStep("Test with wide tablet", () => tabletHandler.SetTabletSize(new Vector2(160, 100)));
|
||||||
AddStep("Test with square tablet", () => tabletHandler.SetTabletSize(new Vector2(300, 300)));
|
AddStep("Test with square tablet", () => tabletHandler.SetTabletSize(new Vector2(300, 300)));
|
||||||
AddStep("Test with tall tablet", () => tabletHandler.SetTabletSize(new Vector2(100, 300)));
|
AddStep("Test with tall tablet", () => tabletHandler.SetTabletSize(new Vector2(100, 300)));
|
||||||
@ -40,6 +51,24 @@ namespace osu.Game.Tests.Visual.Settings
|
|||||||
AddStep("Test no tablet present", () => tabletHandler.SetTabletSize(Vector2.Zero));
|
AddStep("Test no tablet present", () => tabletHandler.SetTabletSize(Vector2.Zero));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestValidAfterRotation()
|
||||||
|
{
|
||||||
|
AddAssert("area valid", () => settings.AreaSelection.IsWithinBounds);
|
||||||
|
|
||||||
|
AddStep("rotate 90", () => tabletHandler.Rotation.Value = 90);
|
||||||
|
AddAssert("area valid", () => settings.AreaSelection.IsWithinBounds);
|
||||||
|
|
||||||
|
AddStep("rotate 180", () => tabletHandler.Rotation.Value = 180);
|
||||||
|
AddAssert("area valid", () => settings.AreaSelection.IsWithinBounds);
|
||||||
|
|
||||||
|
AddStep("rotate 360", () => tabletHandler.Rotation.Value = 360);
|
||||||
|
AddAssert("area valid", () => settings.AreaSelection.IsWithinBounds);
|
||||||
|
|
||||||
|
AddStep("rotate 0", () => tabletHandler.Rotation.Value = 0);
|
||||||
|
AddAssert("area valid", () => settings.AreaSelection.IsWithinBounds);
|
||||||
|
}
|
||||||
|
|
||||||
public class TestTabletHandler : ITabletHandler
|
public class TestTabletHandler : ITabletHandler
|
||||||
{
|
{
|
||||||
public Bindable<Vector2> AreaOffset { get; } = new Bindable<Vector2>();
|
public Bindable<Vector2> AreaOffset { get; } = new Bindable<Vector2>();
|
||||||
|
Loading…
Reference in New Issue
Block a user