mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 23:12:56 +08:00
Add test coverage of invalid cases too
This commit is contained in:
parent
7b26e480e6
commit
94b34a5474
@ -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>();
|
||||
|
Loading…
Reference in New Issue
Block a user