Skip to content

Commit

Permalink
Add pointerId to the asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
jfreire-unity committed Oct 21, 2024
1 parent 7b87f3d commit c645468
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Assets/Tests/InputSystem/Plugins/UITests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1729,6 +1729,9 @@ public IEnumerator UI_CanReleaseAndPressTouchesOnSameFrame()
BeginTouch(1, firstPosition);
yield return null;

var pointerIdTouch1 = ExtendedPointerEventData.MakePointerIdForTouch(touchScreen.deviceId, 1);
var pointerIdTouch2 = ExtendedPointerEventData.MakePointerIdForTouch(touchScreen.deviceId, 2);

Assert.That(scene.eventSystem.IsPointerOverGameObject(), Is.True);
Assert.That(scene.eventSystem.IsPointerOverGameObject(touchScreen.deviceId), Is.True);
Assert.That(scene.eventSystem.IsPointerOverGameObject(1), Is.True);
Expand All @@ -1738,12 +1741,14 @@ public IEnumerator UI_CanReleaseAndPressTouchesOnSameFrame()
Has.Exactly(1).With.Property("type").EqualTo(EventType.PointerEnter).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.device == touchScreen).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.touchId == 1).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerId == pointerIdTouch1).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerType == UIPointerType.Touch).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.position == firstPosition));
Assert.That(scene.leftChildReceiver.events,
Has.Exactly(1).With.Property("type").EqualTo(EventType.PointerDown).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.device == touchScreen).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.touchId == 1).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerId == pointerIdTouch1).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerType == UIPointerType.Touch).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.position == firstPosition));
Assert.That(scene.rightChildReceiver.events, Is.Empty);
Expand All @@ -1766,20 +1771,23 @@ public IEnumerator UI_CanReleaseAndPressTouchesOnSameFrame()
Has.Exactly(1).With.Property("type").EqualTo(EventType.PointerUp).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.device == touchScreen).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.touchId == 1).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerId == pointerIdTouch1).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerType == UIPointerType.Touch).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.position == firstPosition));

Assert.That(scene.rightChildReceiver.events,
Has.Exactly(1).With.Property("type").EqualTo(EventType.PointerEnter).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.device == touchScreen).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.touchId == 2).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerId == pointerIdTouch2).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerType == UIPointerType.Touch).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.position == secondPosition));

Assert.That(scene.rightChildReceiver.events,
Has.Exactly(1).With.Property("type").EqualTo(EventType.PointerDown).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.device == touchScreen).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.touchId == 2).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerId == pointerIdTouch2).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerType == UIPointerType.Touch).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.position == secondPosition));

Expand All @@ -1799,13 +1807,15 @@ public IEnumerator UI_CanReleaseAndPressTouchesOnSameFrame()
Has.Exactly(1).With.Property("type").EqualTo(EventType.PointerExit).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.device == touchScreen).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.touchId == 1).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerId == pointerIdTouch1).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerType == UIPointerType.Touch).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.position == firstPosition));

Assert.That(scene.rightChildReceiver.events,
Has.Exactly(1).With.Property("type").EqualTo(EventType.PointerUp).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.device == touchScreen).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.touchId == 2).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerId == pointerIdTouch2).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerType == UIPointerType.Touch).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.position == secondPosition));

Expand All @@ -1825,6 +1835,7 @@ public IEnumerator UI_CanReleaseAndPressTouchesOnSameFrame()
Has.Exactly(1).With.Property("type").EqualTo(EventType.PointerExit).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.device == touchScreen).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.touchId == 2).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerId == pointerIdTouch2).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.pointerType == UIPointerType.Touch).And
.Matches((UICallbackReceiver.Event e) => e.pointerData.position == secondPosition));
}
Expand Down

0 comments on commit c645468

Please sign in to comment.