1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 18:47:27 +08:00

Also add test coverage of positional updates

This commit is contained in:
Dean Herbert 2023-01-16 21:02:37 +09:00
parent eaaab2e76d
commit ab3d632112

View File

@ -77,16 +77,21 @@ namespace osu.Game.Rulesets.Osu.Tests
assertKeyCounter(1, 0); assertKeyCounter(1, 0);
checkPressed(OsuAction.LeftButton); checkPressed(OsuAction.LeftButton);
checkPosition(TouchSource.Touch1);
beginTouch(TouchSource.Touch2); beginTouch(TouchSource.Touch2);
assertKeyCounter(1, 1); assertKeyCounter(1, 1);
checkPressed(OsuAction.LeftButton); checkPressed(OsuAction.LeftButton);
checkPressed(OsuAction.RightButton); checkPressed(OsuAction.RightButton);
checkPosition(TouchSource.Touch2);
// Subsequent touches should be ignored. // Subsequent touches should be ignored (except position).
beginTouch(TouchSource.Touch3); beginTouch(TouchSource.Touch3);
checkPosition(TouchSource.Touch3);
beginTouch(TouchSource.Touch4); beginTouch(TouchSource.Touch4);
checkPosition(TouchSource.Touch4);
assertKeyCounter(1, 1); assertKeyCounter(1, 1);
@ -105,12 +110,14 @@ namespace osu.Game.Rulesets.Osu.Tests
assertKeyCounter(0, 0); assertKeyCounter(0, 0);
checkNotPressed(OsuAction.LeftButton); checkNotPressed(OsuAction.LeftButton);
checkPosition(TouchSource.Touch1);
beginTouch(TouchSource.Touch2); beginTouch(TouchSource.Touch2);
assertKeyCounter(0, 0); assertKeyCounter(0, 0);
checkNotPressed(OsuAction.LeftButton); checkNotPressed(OsuAction.LeftButton);
checkNotPressed(OsuAction.RightButton); checkNotPressed(OsuAction.RightButton);
checkPosition(TouchSource.Touch2);
} }
[Test] [Test]
@ -219,6 +226,9 @@ namespace osu.Game.Rulesets.Osu.Tests
); );
} }
private void checkPosition(TouchSource touchSource) =>
AddAssert("Cursor position is correct", () => osuInputManager.CurrentState.Mouse.Position, () => Is.EqualTo(getSanePositionForSource(touchSource)));
private void assertKeyCounter(int left, int right) private void assertKeyCounter(int left, int right)
{ {
AddAssert($"The left key was pressed {left} times", () => leftKeyCounter.CountPresses, () => Is.EqualTo(left)); AddAssert($"The left key was pressed {left} times", () => leftKeyCounter.CountPresses, () => Is.EqualTo(left));