Skip to content

Commit 20d6987

Browse files
committed
Restore a commented-out test and Ignore it instead
1 parent bcc49a4 commit 20d6987

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

org.mixedrealitytoolkit.spatialmanipulation/Tests/Runtime/ObjectManipulatorTests.cs

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@
44
// Disable "missing XML comment" warning for tests. While nice to have, this documentation is not required.
55
#pragma warning disable CS1591
66

7-
using MixedReality.Toolkit;
87
using MixedReality.Toolkit.Core.Tests;
9-
using MixedReality.Toolkit.Input.Tests;
8+
using MixedReality.Toolkit.Input;
109
using MixedReality.Toolkit.Input.Simulation;
10+
using MixedReality.Toolkit.Input.Tests;
1111
using NUnit.Framework;
1212
using System;
1313
using System.Collections;
14+
using System.Collections.Generic;
1415
using UnityEngine;
1516
using UnityEngine.TestTools;
1617
using UnityEngine.XR.Interaction.Toolkit;
1718
using HandshapeId = MixedReality.Toolkit.Input.HandshapeTypes.HandshapeId;
1819
using MovementType = UnityEngine.XR.Interaction.Toolkit.XRBaseInteractable.MovementType;
19-
using MixedReality.Toolkit.Input;
2020

2121
namespace MixedReality.Toolkit.SpatialManipulation.Runtime.Tests
2222
{
@@ -537,7 +537,6 @@ public IEnumerator ObjectManipulatorOneHandMoveFar()
537537
}
538538
}
539539

540-
541540
/// <summary>
542541
/// This tests that the gaze pointer can be used to directly invoke the manipulation logic via simulated pointer events, used
543542
/// for scenarios like voice-driven movement using the gaze pointer.
@@ -744,29 +743,27 @@ public IEnumerator TestObjManipTargetChange()
744743

745744
Assert.IsTrue(cube1.transform.position.CloseEnoughTo(cube1Pos), "Cube1 moved when it shouldn't have!");
746745
Assert.IsTrue(!cube2.transform.position.CloseEnoughTo(cube2Pos), "Cube2 didn't move when it should have!");
747-
746+
748747
// Cube2 should be facing the user.
749748
Assert.IsTrue(cube2.transform.forward.CloseEnoughTo(-(cube2.transform.position - Camera.main.transform.position).normalized), "Cube2 didn't stay facing user!");
750-
751749
}
752750

753751
#endregion
754752

755753
#region Two Handed Manipulation Tests
756754

757-
// This test is not yet working due to some confusion as to how the centroid math works with the current object manipulator
758-
759-
/*
760755
/// <summary>
761756
/// Test that the grab centroid is calculated correctly while rotating
762757
/// the hands during a two-hand near interaction grab.
763758
/// </summary>
764-
[UnityTest]
759+
[UnityTest, Ignore("This test is not yet working due to some confusion as to how the centroid math works with the current object manipulator")]
765760
public IEnumerator ObjectManipulatorTwoHandedCentroid()
766761
{
767762
InputTestUtilities.DisableGazeInteractor();
763+
yield return RuntimeTestUtilities.WaitForUpdates();
768764

769765
InputTestUtilities.InitializeCameraToOriginAndForward();
766+
yield return RuntimeTestUtilities.WaitForUpdates();
770767

771768
// Set up cube with ObjectManipulator
772769
var testObject = GameObject.CreatePrimitive(PrimitiveType.Cube);
@@ -780,17 +777,21 @@ public IEnumerator ObjectManipulatorTwoHandedCentroid()
780777
objectManipulator.SmoothingFar = false;
781778
objectManipulator.SmoothingNear = false;
782779
// Configuring for two-handed interaction
783-
objectManipulator.selectMode = UnityEngine.XR.Interaction.Toolkit.InteractableSelectMode.Multiple;
780+
objectManipulator.selectMode = InteractableSelectMode.Multiple;
784781

785782
TestHand rightHand = new TestHand(Handedness.Right);
786783
TestHand leftHand = new TestHand(Handedness.Left);
784+
yield return RuntimeTestUtilities.WaitForUpdates();
787785

788786
yield return rightHand.Show(Vector3.zero);
787+
yield return RuntimeTestUtilities.WaitForUpdates();
789788
yield return leftHand.Show(Vector3.zero);
789+
yield return RuntimeTestUtilities.WaitForUpdates();
790790

791791
yield return rightHand.MoveTo(new Vector3(0.1f, -0.1f, 0.8f));
792+
yield return RuntimeTestUtilities.WaitForUpdates();
792793
yield return leftHand.MoveTo(new Vector3(-0.1f, -0.1f, 0.8f));
793-
yield return null;
794+
yield return RuntimeTestUtilities.WaitForUpdates();
794795

795796
// Only testing move/rotate centroid position
796797
objectManipulator.AllowedManipulations = TransformFlags.Move | TransformFlags.Scale;
@@ -804,8 +805,10 @@ public IEnumerator ObjectManipulatorTwoHandedCentroid()
804805
objectManipulator.selectExited.AddListener((med) => manipulationEndedCount++);
805806

806807
// Grab the box.
807-
yield return rightHand.SetGesture(GestureId.Pinch);
808-
yield return leftHand.SetGesture(GestureId.Pinch);
808+
yield return rightHand.SetHandshape(HandshapeId.Pinch);
809+
yield return RuntimeTestUtilities.WaitForUpdates();
810+
yield return leftHand.SetHandshape(HandshapeId.Pinch);
811+
yield return RuntimeTestUtilities.WaitForUpdates();
809812

810813
// Previously we checked that we didn't move after two pinches, however, due to the hand position shifting slighting on pinch, this is not applicable
811814
// TODO, address in the future?
@@ -815,14 +818,11 @@ public IEnumerator ObjectManipulatorTwoHandedCentroid()
815818
// The ObjectManipulator should recognize that we've begun manipulation.
816819
Assert.IsTrue(manipulationStartedCount > 0);
817820

818-
yield return RuntimeTestUtilities.WaitForEnterKey();
819-
820821
// Move both hands outwards; the object may be scaled but the position should remain the same.
821822
yield return rightHand.MoveTo(new Vector3(0.2f, -0.1f, 0.8f));
823+
yield return RuntimeTestUtilities.WaitForUpdates();
822824
yield return leftHand.MoveTo(new Vector3(-0.2f, -0.1f, 0.8f));
823-
824-
825-
yield return RuntimeTestUtilities.WaitForEnterKey();
825+
yield return RuntimeTestUtilities.WaitForUpdates();
826826

827827
// Should *still* not have moved!
828828
// TestUtilities.AssertAboutEqual(testObject.transform.position, initialObjectPosition, $"Object moved when it shouldn't have! Position: {testObject.transform.position:F5}", 0.00001f);
@@ -853,8 +853,10 @@ public IEnumerator ObjectManipulatorTwoHandedCentroid()
853853
yield return MoveHandsAndCheckCentroid(testCondition.Item1, testCondition.Item2, leftHand, rightHand, objectManipulator, initialObjectPosition, originalCentroid, testObject.transform);
854854
}
855855

856-
yield return rightHand.SetGesture(GestureId.Open);
857-
yield return leftHand.SetGesture(GestureId.Open);
856+
yield return rightHand.SetHandshape(HandshapeId.Open);
857+
yield return RuntimeTestUtilities.WaitForUpdates();
858+
yield return leftHand.SetHandshape(HandshapeId.Open);
859+
yield return RuntimeTestUtilities.WaitForUpdates();
858860
}
859861

860862
/// <summary>
@@ -870,11 +872,15 @@ private IEnumerator MoveHandsAndCheckCentroid(Vector3 handRotationEuler, Vector3
870872
{
871873
// Rotate the hands.
872874
yield return rightHand.RotateTo(Quaternion.Euler(handRotationEuler.x, handRotationEuler.y, handRotationEuler.z));
875+
yield return RuntimeTestUtilities.WaitForUpdates();
873876
yield return leftHand.RotateTo(Quaternion.Euler(handRotationEuler.x, -handRotationEuler.y, -handRotationEuler.z));
877+
yield return RuntimeTestUtilities.WaitForUpdates();
874878

875879
// Move the hands.
876880
yield return rightHand.MoveTo(new Vector3(handPosition.x, handPosition.y, handPosition.z));
881+
yield return RuntimeTestUtilities.WaitForUpdates();
877882
yield return leftHand.MoveTo(new Vector3(-handPosition.x, handPosition.y, handPosition.z));
883+
yield return RuntimeTestUtilities.WaitForUpdates();
878884

879885
// Recalculate the new grab centroid.
880886
var leftGrabPoint = om.interactorsSelecting[0].transform.position;
@@ -888,7 +894,6 @@ private IEnumerator MoveHandsAndCheckCentroid(Vector3 handRotationEuler, Vector3
888894
TestUtilities.AssertAboutEqual(testObject.transform.position, originalObjectPosition + centroidDelta,
889895
$"Object moved did not move according to the delta! Actual position: {testObject.transform.position:F5}, should be {originalObjectPosition + centroidDelta}", 0.00001f);
890896
}
891-
*/
892897

893898
#endregion
894899

@@ -1287,4 +1292,4 @@ public IEnumerator ObjectManipulatorFarThrow()
12871292
*/
12881293
}
12891294
}
1290-
#pragma warning restore CS1591
1295+
#pragma warning restore CS1591

0 commit comments

Comments
 (0)