Skip to content

Commit

Permalink
Update test case to consider pen as touch
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte committed Jan 25, 2025
1 parent 67c36b2 commit 91e944d
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Input.StateChanges;
using osu.Framework.Input.States;
using osu.Framework.Testing;
using osu.Framework.Timing;
Expand Down Expand Up @@ -225,37 +224,27 @@ private void addHitCircleAtPen()
});
}

private void pressPen()
{
AddStep("Press pen", () =>
{
InputManager.MovePenTo(getSanePositionForPen(), TabletPenDeviceType.Direct);
InputManager.PressPen(TabletPenDeviceType.Direct);
});
}

private void releasePen()
{
AddStep("Release pen", () => InputManager.ReleasePen(TabletPenDeviceType.Direct));
}
private void pressPen() => beginTouch(TouchSource.PenTouch);

Check failure on line 227 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 227 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 227 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 227 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 227 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 227 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 227 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 227 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 227 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 227 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 227 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 227 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'TouchSource' does not contain a definition for 'PenTouch'
private void releasePen() => endTouch(TouchSource.PenTouch);

Check failure on line 228 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 228 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 228 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 228 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 228 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 228 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 228 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 228 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 228 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 228 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 228 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 228 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'TouchSource' does not contain a definition for 'PenTouch'

private void beginTouch(TouchSource source, Vector2? screenSpacePosition = null) =>
AddStep($"Begin touch for {source}", () => InputManager.BeginTouch(new Touch(source, screenSpacePosition ??= getSanePositionForTouch(source))));

private void endTouch(TouchSource source, Vector2? screenSpacePosition = null) =>
AddStep($"Release touch for {source}", () => InputManager.EndTouch(new Touch(source, screenSpacePosition ??= getSanePositionForTouch(source))));

private Vector2 getSanePositionForPen()
private Vector2 getSanePositionForPen() => getSanePositionForTouch(TouchSource.PenTouch);

Check failure on line 236 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 236 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 236 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 236 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 236 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 236 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 236 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 236 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 236 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 236 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 236 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 236 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'TouchSource' does not contain a definition for 'PenTouch'

private Vector2 getSanePositionForTouch(TouchSource source)
{
int index = source == TouchSource.PenTouch ? -1 : (int)source;

Check failure on line 240 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 240 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 240 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 240 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 240 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 240 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 240 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 240 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 240 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 240 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 240 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'TouchSource' does not contain a definition for 'PenTouch'

Check failure on line 240 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'TouchSource' does not contain a definition for 'PenTouch'

return new Vector2(
osuInputManager.ScreenSpaceDrawQuad.Centre.X + osuInputManager.ScreenSpaceDrawQuad.Width * -1 / 8,
osuInputManager.ScreenSpaceDrawQuad.Centre.X + osuInputManager.ScreenSpaceDrawQuad.Width * index / 8,
osuInputManager.ScreenSpaceDrawQuad.Centre.Y - 100
);
}

private Vector2 getSanePositionForTouch(TouchSource source)
=> getSanePositionForPen() + new Vector2(osuInputManager.ScreenSpaceDrawQuad.Width * (int)(1 + source) / 8, 0);

private void checkPositionIsAtPen() =>
AddAssert("Cursor position is correct", () => osuInputManager.CurrentState.Mouse.Position, () => Is.EqualTo(getSanePositionForPen()));

Expand All @@ -267,7 +256,6 @@ private void assertKeyCounter(int left, int right)

private void releaseAllInput()
{
AddStep("Release pen", () => InputManager.ReleasePen());
AddStep("Release all touches", () =>
{
config.SetValue(OsuSetting.MouseDisableButtons, false);
Expand Down Expand Up @@ -309,7 +297,7 @@ public void OnReleased(KeyBindingReleaseEvent<OsuAction> e)

public partial class TouchVisualiser : CompositeDrawable
{
private readonly Drawable?[] drawableTouches = new Drawable?[TouchState.MAX_TOUCH_COUNT];
private readonly Drawable?[] drawableTouches = new Drawable?[TouchState.MAX_SOURCES_COUNT];

Check failure on line 300 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'TouchState' does not contain a definition for 'MAX_SOURCES_COUNT'

Check failure on line 300 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, SingleThread)

'TouchState' does not contain a definition for 'MAX_SOURCES_COUNT'

Check failure on line 300 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'TouchState' does not contain a definition for 'MAX_SOURCES_COUNT'

Check failure on line 300 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Linux, ubuntu-latest, MultiThreaded)

'TouchState' does not contain a definition for 'MAX_SOURCES_COUNT'

Check failure on line 300 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'TouchState' does not contain a definition for 'MAX_SOURCES_COUNT'

Check failure on line 300 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Code Quality

'TouchState' does not contain a definition for 'MAX_SOURCES_COUNT'

Check failure on line 300 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'TouchState' does not contain a definition for 'MAX_SOURCES_COUNT'

Check failure on line 300 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, MultiThreaded)

'TouchState' does not contain a definition for 'MAX_SOURCES_COUNT'

Check failure on line 300 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'TouchState' does not contain a definition for 'MAX_SOURCES_COUNT'

Check failure on line 300 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Test (Windows, windows-latest, SingleThread)

'TouchState' does not contain a definition for 'MAX_SOURCES_COUNT'

Check failure on line 300 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'TouchState' does not contain a definition for 'MAX_SOURCES_COUNT'

Check failure on line 300 in osu.Game.Rulesets.Osu.Tests/TestSceneOsuTouchInputWithPen.cs

View workflow job for this annotation

GitHub Actions / Build only (Android)

'TouchState' does not contain a definition for 'MAX_SOURCES_COUNT'

public TouchVisualiser()
{
Expand Down

0 comments on commit 91e944d

Please sign in to comment.