1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00

Add test coverage

This commit is contained in:
Dean Herbert 2020-11-24 17:59:18 +09:00
parent 09f2a85d71
commit 4eef6c0d40

View File

@ -86,5 +86,55 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
return Precision.AlmostEquals(first.EndPosition, second.Position);
});
}
[Test]
public void TestSecondCircleInSelectionAlsoSnaps()
{
AddStep("move mouse to centre", () => InputManager.MoveMouseTo(playfield.ScreenSpaceDrawQuad.Centre));
AddStep("disable distance snap", () => InputManager.Key(Key.Q));
AddStep("enter placement mode", () => InputManager.Key(Key.Number2));
AddStep("place first object", () => InputManager.Click(MouseButton.Left));
AddStep("move mouse right", () => InputManager.MoveMouseTo(playfield.ScreenSpaceDrawQuad.Centre + new Vector2(playfield.ScreenSpaceDrawQuad.Width * 0.2f, 0)));
AddStep("place second object", () => InputManager.Click(MouseButton.Left));
AddStep("move mouse down", () => InputManager.MoveMouseTo(playfield.ScreenSpaceDrawQuad.Centre + new Vector2(0, playfield.ScreenSpaceDrawQuad.Width * 0.2f)));
AddStep("place third object", () => InputManager.Click(MouseButton.Left));
AddStep("enter selection mode", () => InputManager.Key(Key.Number1));
AddStep("select objects 2 and 3", () => EditorBeatmap.SelectedHitObjects.AddRange(EditorBeatmap.HitObjects.Skip(1)));
AddStep("begin drag", () => InputManager.PressButton(MouseButton.Left));
AddStep("move mouse slightly off centre", () => InputManager.MoveMouseTo(playfield.ScreenSpaceDrawQuad.Centre + new Vector2(playfield.ScreenSpaceDrawQuad.Width * 0.02f, 0)));
AddAssert("object 3 snapped to 1", () =>
{
var objects = EditorBeatmap.HitObjects;
var first = (OsuHitObject)objects.First();
var third = (OsuHitObject)objects.Last();
return Precision.AlmostEquals(first.EndPosition, third.Position);
});
AddStep("move mouse slightly off centre", () => InputManager.MoveMouseTo(playfield.ScreenSpaceDrawQuad.Centre + new Vector2(playfield.ScreenSpaceDrawQuad.Width * -0.22f, playfield.ScreenSpaceDrawQuad.Width * 0.21f)));
AddAssert("object 2 snapped to 1", () =>
{
var objects = EditorBeatmap.HitObjects;
var first = (OsuHitObject)objects.First();
var second = (OsuHitObject)objects.ElementAt(1);
return Precision.AlmostEquals(first.EndPosition, second.Position);
});
AddStep("end drag", () => InputManager.ReleaseButton(MouseButton.Left));
}
}
}