Skip to content

Commit e0dc749

Browse files
added test for far interaction scaling of bounds control
1 parent 0a3186c commit e0dc749

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

Assets/MixedRealityToolkit.Tests/PlayModeTests/Experimental/BoundsControlTests.cs

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,7 @@ private BoundsControl InstantiateSceneAndDefaultBbox()
5353
cube.transform.position = boundsControlStartCenter;
5454
BoundsControl bbox = cube.AddComponent<BoundsControl>();
5555

56-
MixedRealityPlayspace.PerformTransformation(
57-
p =>
58-
{
59-
p.position = Vector3.zero;
60-
p.LookAt(boundsControlStartCenter);
61-
});
56+
TestUtilities.PlayspaceToOriginLookingForward();
6257

6358
bbox.transform.localScale = boundsControlStartScale;
6459
bbox.Active = true;
@@ -158,7 +153,36 @@ public IEnumerator ScaleViaNearInteration()
158153
GameObject.Destroy(bbox.gameObject);
159154
// Wait for a frame to give Unity a change to actually destroy the object
160155
yield return null;
156+
}
157+
158+
/// <summary>
159+
/// Tests scaling of bounds control by grabbing a corner with the far interaction hand ray
160+
/// </summary>
161+
/// <returns></returns>
162+
[UnityTest]
163+
public IEnumerator ScaleViaFarInteraction()
164+
{
165+
BoundsControl bbox = InstantiateSceneAndDefaultBbox();
166+
yield return VerifyInitialBoundsCorrect(bbox);
167+
168+
Vector3 rightCornerInteractionPoint = new Vector3(0.184f, 0.078f, 0.79f); // position of hand for far interacting with front right corner
169+
Vector3 pointOnCube = new Vector3(-0.033f, -0.129f, 0.499f); // position where hand ray points on center of the test cube
170+
Vector3 scalePoint = new Vector3(0.165f, 0.267f, 0.794f); // end position for far interaction scaling
161171

172+
TestHand hand = new TestHand(Handedness.Left);
173+
yield return hand.Show(pointOnCube); //initially make sure that hand ray is pointed on cube surface so we won't go behind the cube with our ray
174+
yield return hand.MoveTo(rightCornerInteractionPoint);
175+
yield return hand.SetGesture(ArticulatedHandPose.GestureId.Pinch);
176+
yield return hand.MoveTo(scalePoint);
177+
var endBounds = bbox.GetComponent<BoxCollider>().bounds;
178+
Vector3 expectedCenter = new Vector3(0.0453f, 0.0453f, 1.455f);
179+
Vector3 expectedSize = Vector3.one * 0.59f;
180+
TestUtilities.AssertAboutEqual(endBounds.center, expectedCenter, "endBounds incorrect center");
181+
TestUtilities.AssertAboutEqual(endBounds.size, expectedSize, "endBounds incorrect size");
182+
183+
GameObject.Destroy(bbox.gameObject);
184+
// Wait for a frame to give Unity a change to actually destroy the object
185+
yield return null;
162186
}
163187

164188
/// <summary>

0 commit comments

Comments
 (0)