Skip to content

Commit aba24a9

Browse files
added rotate with ggv test
1 parent 4b6eaef commit aba24a9

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

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

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,56 @@ public IEnumerator RotateViaNearInteraction()
238238
yield return null;
239239
}
240240

241+
/// <summary>
242+
/// Test bounds control rotation via hololens 1 interaction / GGV
243+
/// Verifies gameobject has rotation in one axis only applied and no other transform changes happen during interaction
244+
/// </summary>
245+
[UnityTest]
246+
public IEnumerator RotateViaHololens1Interaction()
247+
{
248+
249+
250+
BoundsControl control = InstantiateSceneAndDefaultBbox();
251+
yield return VerifyInitialBoundsCorrect(control);
252+
PlayModeTestUtilities.PushHandSimulationProfile();
253+
PlayModeTestUtilities.SetHandSimulationMode(HandSimulationMode.Gestures);
254+
255+
// move camera to look at rotation sphere
256+
CameraCache.Main.transform.LookAt(new Vector3(0.248f, 0.001f, 1.226f)); // rotation sphere front right
257+
258+
var startHandPos = new Vector3(0.364f, -0.157f, 0.437f);
259+
var endPoint = new Vector3(0.141f, -0.163f, 0.485f);
260+
261+
// perform tab with hand and drag to left
262+
TestHand rightHand = new TestHand(Handedness.Right);
263+
yield return rightHand.Show(startHandPos);
264+
yield return rightHand.SetGesture(ArticulatedHandPose.GestureId.Pinch);
265+
yield return rightHand.MoveTo(endPoint);
266+
267+
// make sure only Y axis rotation was performed and no other transform values have changed
268+
Vector3 expectedPosition = new Vector3(0f, 0f, 1.5f);
269+
Vector3 expectedSize = Vector3.one * 0.5f;
270+
float angle;
271+
Vector3 axis = new Vector3();
272+
control.transform.rotation.ToAngleAxis(out angle, out axis);
273+
float expectedAngle = 86f;
274+
float angleDiff = Mathf.Abs(expectedAngle - angle);
275+
Vector3 expectedAxis = new Vector3(0f, 1f, 0f);
276+
TestUtilities.AssertAboutEqual(axis, expectedAxis, "Rotated around wrong axis");
277+
Assert.IsTrue(angleDiff <= 1f, "cube didn't rotate as expected");
278+
TestUtilities.AssertAboutEqual(control.transform.position, expectedPosition, "cube moved while rotating");
279+
TestUtilities.AssertAboutEqual(control.transform.localScale, expectedSize, "cube scaled while rotating");
280+
281+
GameObject.Destroy(control.gameObject);
282+
// Wait for a frame to give Unity a change to actually destroy the object
283+
yield return null;
284+
285+
// Restore the input simulation profile
286+
PlayModeTestUtilities.PopHandSimulationProfile();
287+
288+
yield return null;
289+
}
290+
241291
/// <summary>
242292
/// Tests scaling of bounds control by grabbing a corner with the far interaction hand ray
243293
/// </summary>

0 commit comments

Comments
 (0)