1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 01:52:55 +08:00

Add test coverage of invalid cases too

This commit is contained in:
Dean Herbert 2021-09-04 23:19:05 +09:00
parent 7b26e480e6
commit 94b34a5474

View File

@ -54,7 +54,7 @@ namespace osu.Game.Tests.Visual.Settings
}
[Test]
public void TestValidAfterRotation()
public void TestRotationValidity()
{
AddAssert("area valid", () => settings.AreaSelection.IsWithinBounds);
@ -75,6 +75,22 @@ namespace osu.Game.Tests.Visual.Settings
AddStep("rotate 0", () => tabletHandler.Rotation.Value = 0);
ensureValid();
AddStep("rotate 0", () => tabletHandler.Rotation.Value = 45);
ensureInvalid();
AddStep("rotate 0", () => tabletHandler.Rotation.Value = 0);
ensureValid();
}
[Test]
public void TestOffsetValidity()
{
ensureValid();
AddStep("move right", () => tabletHandler.AreaOffset.Value = Vector2.Zero);
ensureInvalid();
AddStep("move back", () => tabletHandler.AreaOffset.Value = tabletHandler.AreaSize.Value / 2);
ensureValid();
}
private void ensureValid()
@ -83,6 +99,12 @@ namespace osu.Game.Tests.Visual.Settings
AddAssert("area valid", () => settings.AreaSelection.IsWithinBounds);
}
private void ensureInvalid()
{
AddUntilStep("wait for transforms", () => settings.AreaSelection.ChildrenOfType<Container>().All(c => !c.Transforms.Any()));
AddAssert("area invalid", () => !settings.AreaSelection.IsWithinBounds);
}
public class TestTabletHandler : ITabletHandler
{
public Bindable<Vector2> AreaOffset { get; } = new Bindable<Vector2>();