diff --git a/Assets/Tests/InputSystem/Plugins/DeviceSimulatorTests.cs b/Assets/Tests/InputSystem/Plugins/DeviceSimulatorTests.cs index b2254be877..7a513aa16b 100644 --- a/Assets/Tests/InputSystem/Plugins/DeviceSimulatorTests.cs +++ b/Assets/Tests/InputSystem/Plugins/DeviceSimulatorTests.cs @@ -1,4 +1,4 @@ -#if UNITY_EDITOR && UNITY_2021_1_OR_NEWER +#if UNITY_EDITOR using System.Collections; using System.Reflection; diff --git a/Assets/Tests/InputSystem/Plugins/UITests.cs b/Assets/Tests/InputSystem/Plugins/UITests.cs index fe077139b0..359eee0e71 100644 --- a/Assets/Tests/InputSystem/Plugins/UITests.cs +++ b/Assets/Tests/InputSystem/Plugins/UITests.cs @@ -31,9 +31,7 @@ using UnityEditor.SceneManagement; #endif -#if UNITY_2021_2_OR_NEWER using UnityEngine.UIElements; -#endif #pragma warning disable CS0649 ////TODO: app focus handling @@ -399,13 +397,7 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p } yield return null; - const int kHaveMovementEvents = -#if UNITY_2021_2_OR_NEWER - 1 -#else - 0 -#endif - ; + const int kHaveMovementEvents = 1; Assert.That(scene.leftChildReceiver.events, Has.Count.EqualTo((isTouch ? 3 : 1) + kHaveMovementEvents)); Assert.That(scene.parentReceiver.events, Has.Count.EqualTo(1 + kHaveMovementEvents)); @@ -486,7 +478,6 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p // Touch has no ability to point without pressing so pointer enter event is followed // right by pointer down event. -#if UNITY_2021_2_OR_NEWER // PointerMove. Assert.That(scene.leftChildReceiver.events[0 + kHaveMovementEvents].type, Is.EqualTo(EventType.PointerMove)); Assert.That(scene.leftChildReceiver.events[0 + kHaveMovementEvents].pointerData.button, Is.EqualTo(PointerEventData.InputButton.Left)); @@ -514,7 +505,6 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p Assert.That(scene.leftChildReceiver.events[0 + kHaveMovementEvents].pointerData.pointerPressRaycast.gameObject, Is.Null); Assert.That(scene.leftChildReceiver.events[0 + kHaveMovementEvents].pointerData.pointerPressRaycast.screenPosition, Is.EqualTo(default(Vector2)).Using(Vector2EqualityComparer.Instance)); -#endif // PointerDown. Assert.That(scene.leftChildReceiver.events[1 + kHaveMovementEvents].type, Is.EqualTo(EventType.PointerDown)); @@ -741,7 +731,6 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p AllEvents("pointerCurrentRaycast.screenPosition", secondScreenPosition), // PointerMove. -#if UNITY_2021_2_OR_NEWER OneEvent("type", EventType.PointerMove), OneEvent("dragging", false), // Again, pointer movement is processed exclusively "from" the left button. @@ -755,7 +744,6 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p OneEvent("lastPress", clickButton == PointerEventData.InputButton.Left ? null : scene.leftGameObject), OneEvent("pointerPressRaycast.gameObject", clickButton == PointerEventData.InputButton.Left ? scene.leftGameObject : null), OneEvent("pointerPressRaycast.screenPosition", clickButton == PointerEventData.InputButton.Left ? firstScreenPosition : Vector2.zero), -#endif // BeginDrag. OneEvent("type", EventType.BeginDrag), @@ -788,12 +776,7 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p ); Assert.That(scene.rightChildReceiver.events, Is.Empty); - Assert.That(scene.parentReceiver.events, - EventSequence( -#if UNITY_2021_2_OR_NEWER - OneEvent("type", EventType.PointerMove) -#endif - ) + Assert.That(scene.parentReceiver.events, EventSequence(OneEvent("type", EventType.PointerMove)) ); scene.leftChildReceiver.events.Clear(); @@ -819,12 +802,7 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p Assert.That(scene.eventSystem.IsPointerOverGameObject(pointerId), Is.True); // Should not have seen pointer enter/exit on parent (we only moved from one of its // children to another) but *should* have seen a move event. - Assert.That(scene.parentReceiver.events, - EventSequence( -#if UNITY_2021_2_OR_NEWER - OneEvent("type", EventType.PointerMove) -#endif - ) + Assert.That(scene.parentReceiver.events, EventSequence(OneEvent("type", EventType.PointerMove)) ); if (isTracked) @@ -852,7 +830,6 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p // press positions on the moves will be zero. // PointerMove. -#if UNITY_2021_2_OR_NEWER OneEvent("type", EventType.PointerMove), OneEvent("button", PointerEventData.InputButton.Left), OneEvent("pointerEnter", scene.leftGameObject), @@ -867,7 +844,6 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p OneEvent("dragging", clickButton == PointerEventData.InputButton.Left ? true : false), OneEvent("pointerPressRaycast.gameObject", clickButton == PointerEventData.InputButton.Left ? scene.leftGameObject : null), OneEvent("pointerPressRaycast.screenPosition", clickButton == PointerEventData.InputButton.Left ? firstScreenPosition : Vector2.zero), -#endif // PointerExit. OneEvent("type", EventType.PointerExit), @@ -927,10 +903,8 @@ public IEnumerator UI_CanDriveUIFromPointer(string deviceLayout, UIPointerType p AllEvents("pointerPressRaycast.gameObject", clickButton == PointerEventData.InputButton.Left ? scene.leftGameObject : null), AllEvents("pointerPressRaycast.screenPosition", clickButton == PointerEventData.InputButton.Left ? firstScreenPosition : Vector2.zero), - OneEvent("type", EventType.PointerEnter) -#if UNITY_2021_2_OR_NEWER - , OneEvent("type", EventType.PointerMove) -#endif + OneEvent("type", EventType.PointerEnter), + OneEvent("type", EventType.PointerMove) ) ); @@ -1892,7 +1866,6 @@ public IEnumerator UI_CanReleaseAndPressTouchesOnSameFrame() .Matches((UICallbackReceiver.Event e) => e.pointerData.pointerType == UIPointerType.Touch).And .Matches((UICallbackReceiver.Event e) => e.pointerData.position == secondPosition)); -#if UNITY_2021_2_OR_NEWER Assert.That(scene.rightChildReceiver.events, Has.Exactly(1).With.Property("type").EqualTo(EventType.PointerMove).And .Matches((UICallbackReceiver.Event e) => e.pointerData.device == touchScreen).And @@ -1900,7 +1873,6 @@ public IEnumerator UI_CanReleaseAndPressTouchesOnSameFrame() .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)); -#endif // Pointer 3 Assert.That(scene.rightChildReceiver.events, @@ -2025,12 +1997,10 @@ public IEnumerator UI_CanUseTouchSimulationWithUI() AllEvents("pointerType", UIPointerType.Touch), AllEvents("touchId", 1), AllEvents("position", scene.From640x480ToScreen(180, 180)), - OneEvent("type", EventType.PointerEnter) -#if UNITY_2021_2_OR_NEWER - , OneEvent("type", EventType.PointerMove) -#endif - , OneEvent("type", EventType.PointerDown) - , OneEvent("type", EventType.InitializePotentialDrag) + OneEvent("type", EventType.PointerEnter), + OneEvent("type", EventType.PointerMove), + OneEvent("type", EventType.PointerDown), + OneEvent("type", EventType.InitializePotentialDrag) ) ); @@ -2149,10 +2119,8 @@ public IEnumerator UI_CanDriveUIFromMultipleTrackedDevices() AllEvents("pointerId", trackedDevice1.deviceId), AllEvents("device", trackedDevice1), AllEvents("trackedDeviceOrientation", scene.GetLookAtQuaternion(Vector3.zero, scene.leftGameObject)), - OneEvent("type", EventType.PointerEnter) -#if UNITY_2021_2_OR_NEWER - , OneEvent("type", EventType.PointerMove) -#endif + OneEvent("type", EventType.PointerEnter), + OneEvent("type", EventType.PointerMove) ) ); Assert.That(scene.rightChildReceiver.events, Is.Empty); @@ -2169,10 +2137,8 @@ public IEnumerator UI_CanDriveUIFromMultipleTrackedDevices() AllEvents("pointerId", trackedDevice2.deviceId), AllEvents("device", trackedDevice2), AllEvents("trackedDeviceOrientation", scene.GetLookAtQuaternion(Vector3.zero, scene.leftGameObject, Vector3.left)), - OneEvent("type", EventType.PointerEnter) -#if UNITY_2021_2_OR_NEWER - , OneEvent("type", EventType.PointerMove) -#endif + OneEvent("type", EventType.PointerEnter), + OneEvent("type", EventType.PointerMove) ) ); Assert.That(scene.rightChildReceiver.events, Is.Empty); @@ -2230,9 +2196,7 @@ public IEnumerator UI_CanDriveUIFromMultipleTrackedDevices() AllEvents("pointerId", trackedDevice1.deviceId), AllEvents("device", trackedDevice1), AllEvents("trackedDeviceOrientation", scene.GetLookAtQuaternion(Vector3.zero, scene.rightGameObject)), -#if UNITY_2021_2_OR_NEWER OneEvent("type", EventType.PointerMove), -#endif OneEvent("type", EventType.PointerExit) ) ); @@ -2242,10 +2206,8 @@ public IEnumerator UI_CanDriveUIFromMultipleTrackedDevices() AllEvents("pointerId", trackedDevice1.deviceId), AllEvents("device", trackedDevice1), AllEvents("trackedDeviceOrientation", scene.GetLookAtQuaternion(Vector3.zero, scene.rightGameObject)), - OneEvent("type", EventType.PointerEnter) -#if UNITY_2021_2_OR_NEWER - , OneEvent("type", EventType.PointerMove) -#endif + OneEvent("type", EventType.PointerEnter), + OneEvent("type", EventType.PointerMove) ) ); @@ -2262,9 +2224,7 @@ public IEnumerator UI_CanDriveUIFromMultipleTrackedDevices() AllEvents("pointerId", trackedDevice2.deviceId), AllEvents("device", trackedDevice2), AllEvents("trackedDeviceOrientation", scene.GetLookAtQuaternion(Vector3.zero, scene.rightGameObject, Vector3.right)), -#if UNITY_2021_2_OR_NEWER OneEvent("type", EventType.PointerMove), -#endif OneEvent("type", EventType.PointerExit) ) ); @@ -2275,9 +2235,7 @@ public IEnumerator UI_CanDriveUIFromMultipleTrackedDevices() AllEvents("device", trackedDevice2), AllEvents("trackedDeviceOrientation", scene.GetLookAtQuaternion(Vector3.zero, scene.rightGameObject, Vector3.right)), OneEvent("type", EventType.PointerEnter) -#if UNITY_2021_2_OR_NEWER , OneEvent("type", EventType.PointerMove) -#endif ) ); } @@ -2601,12 +2559,7 @@ public IEnumerator UI_CanGetRaycastResultMatchingEvent() var raycastResult = scene.uiModule.GetLastRaycastResult(trackedDevice.deviceId); Assert.That(raycastResult.isValid, Is.True); - //2021.2 added an additional move event. -#if UNITY_2021_2_OR_NEWER Assert.That(scene.leftChildReceiver.events, Has.Count.EqualTo(2)); -#else - Assert.That(scene.leftChildReceiver.events, Has.Count.EqualTo(1)); -#endif Assert.That(scene.leftChildReceiver.events[0].pointerData, Is.Not.Null); var eventRaycastResult = scene.leftChildReceiver.events[0].pointerData.pointerCurrentRaycast; @@ -4041,9 +3994,7 @@ public IEnumerator UI_CanOperateUIToolkitInterface_UsingInputSystemUIInputModule ////FIXME: as of a time of writing, this line is broken on trunk due to the bug in UITK // The bug is https://fogbugz.unity3d.com/f/cases/1323488/ // just adding a define as a safeguard measure to reenable it when trunk goes to next version cycle -#if UNITY_2021_3_OR_NEWER Assert.That(scrollView.verticalScroller.value, Is.GreaterThan(0)); -#endif // Try a button press with the gamepad. // NOTE: The current version of UITK does not focus the button automatically. Fix for that is in the pipe. @@ -4171,9 +4122,7 @@ public IEnumerator UI_WhenAppLosesAndRegainsFocus_WhileUIButtonIsPressed_UIButto Assert.That(scene.leftChildReceiver.events, EventSequence( OneEvent("type", EventType.PointerEnter), -#if UNITY_2021_2_OR_NEWER OneEvent("type", EventType.PointerMove), -#endif OneEvent("type", EventType.PointerDown), OneEvent("type", EventType.InitializePotentialDrag) ) @@ -4636,9 +4585,7 @@ private enum EventType PointerUp, PointerEnter, PointerExit, -#if UNITY_2021_2_OR_NEWER PointerMove, -#endif Select, Deselect, InitializePotentialDrag, @@ -4653,11 +4600,8 @@ private enum EventType } private class UICallbackReceiver : MonoBehaviour, IPointerClickHandler, IPointerDownHandler, IPointerEnterHandler, -#if UNITY_2021_2_OR_NEWER - IPointerMoveHandler, -#endif - IPointerExitHandler, IPointerUpHandler, IMoveHandler, ISelectHandler, IDeselectHandler, IInitializePotentialDragHandler, - IBeginDragHandler, IDragHandler, IEndDragHandler, IDropHandler, ISubmitHandler, ICancelHandler, IScrollHandler + IPointerMoveHandler, IPointerExitHandler, IPointerUpHandler, IMoveHandler, ISelectHandler, IDeselectHandler, + IInitializePotentialDragHandler, IBeginDragHandler, IDragHandler, IEndDragHandler, IDropHandler, ISubmitHandler, ICancelHandler, IScrollHandler { public struct Event { @@ -4709,14 +4653,11 @@ public void OnPointerUp(PointerEventData eventData) events.Add(new Event(EventType.PointerUp, ClonePointerEventData(eventData))); } -#if UNITY_2021_2_OR_NEWER public void OnPointerMove(PointerEventData eventData) { events.Add(new Event(EventType.PointerMove, ClonePointerEventData(eventData))); } -#endif - public void OnMove(AxisEventData eventData) { events.Add(new Event(EventType.Move, CloneAxisEventData(eventData))); @@ -4824,7 +4765,6 @@ private static ExtendedPointerEventData ClonePointerEventData(PointerEventData e pointerType = extendedEventData.pointerType, trackedDeviceOrientation = extendedEventData.trackedDeviceOrientation, trackedDevicePosition = extendedEventData.trackedDevicePosition, -#if UNITY_2021_1_OR_NEWER pressure = eventData.pressure, tangentialPressure = eventData.tangentialPressure, altitudeAngle = eventData.altitudeAngle, @@ -4832,7 +4772,6 @@ private static ExtendedPointerEventData ClonePointerEventData(PointerEventData e twist = eventData.twist, radius = eventData.radius, radiusVariance = eventData.radiusVariance, -#endif #if UNITY_2022_3_OR_NEWER displayIndex = eventData.displayIndex, #endif