public IEnumerator TestClickEvents() { PlayModeTestUtilities.PushHandSimulationProfile(); PlayModeTestUtilities.SetHandSimulationMode(HandSimulationMode.Gestures); // Subscribe to interactable's on click so we know the click went through bool wasClicked = false; interactable.OnClick.AddListener(() => { wasClicked = true; }); var testHand = new TestHand(Handedness.Right); yield return(testHand.Show(Vector3.zero)); CameraCache.Main.transform.LookAt(interactable.transform); yield return(testHand.SetGesture(ArticulatedHandPose.GestureId.Pinch)); yield return(testHand.SetGesture(ArticulatedHandPose.GestureId.Open)); yield return(testHand.Hide()); Assert.True(wasClicked); PlayModeTestUtilities.PopHandSimulationProfile(); }
public IEnumerator TestAssembleInteractableAndFarManip() { GameObject pinchSliderObject; PinchSlider slider; // This should not throw exception AssembleSlider(Vector3.forward, Vector3.zero, out pinchSliderObject, out slider); Debug.Assert(slider.SliderValue == 0.5, "Slider should have value 0.5 at start"); // Set up ggv simulation PlayModeTestUtilities.PushHandSimulationProfile(); PlayModeTestUtilities.SetHandSimulationMode(ControllerSimulationMode.HandGestures); var rightHand = new TestHand(Handedness.Right); Vector3 initialPos = new Vector3(0.05f, 0, 1.0f); yield return(rightHand.Show(initialPos)); yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.Pinch)); yield return(rightHand.Move(new Vector3(0.1f, 0, 0))); yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.Open)); yield return(rightHand.Hide()); Assert.That(slider.SliderValue, Is.GreaterThan(0.5)); // clean up GameObject.Destroy(pinchSliderObject); PlayModeTestUtilities.PopHandSimulationProfile(); }
public IEnumerator PrefabGGVZoom() { InstantiateFromPrefab(); PlayModeTestUtilities.SetHandSimulationMode(HandSimulationMode.Gestures); TestHand handRight = new TestHand(Handedness.Right); yield return(handRight.Show(new Vector3(0.0f, 0.0f, 0.6f))); TestHand handLeft = new TestHand(Handedness.Left); yield return(handLeft.Show(new Vector3(-0.1f, 0.0f, 0.6f))); yield return(handRight.SetGesture(ArticulatedHandPose.GestureId.Pinch)); yield return(handLeft.SetGesture(ArticulatedHandPose.GestureId.Pinch)); yield return(handRight.Move(new Vector3(0.005f, 0.0f, 0.0f), 10)); yield return(handLeft.Move(new Vector3(-0.005f, 0.0f, 0.0f), 10)); Assert.AreEqual(0.5, panZoom.CurrentScale, 0.1, "slate did not zoom in using two ggv hands"); yield return(handRight.Hide()); yield return(handLeft.Hide()); }
public IEnumerator ScaleViaHoloLens1Interaction() { var bbox = InstantiateSceneAndDefaultBbox(); yield return(null); yield return(null); var bounds = bbox.GetComponent <BoxCollider>().bounds; var startCenter = new Vector3(0, 0, 1.5f); var startSize = new Vector3(.5f, .5f, .5f); TestUtilities.AssertAboutEqual(bounds.center, startCenter, "bbox incorrect center at start"); TestUtilities.AssertAboutEqual(bounds.size, startSize, "bbox incorrect size at start"); PlayModeTestUtilities.PushHandSimulationProfile(); PlayModeTestUtilities.SetHandSimulationMode(HandSimulationMode.Gestures); CameraCache.Main.transform.LookAt(bbox.ScaleCorners[3].transform); var startHandPos = CameraCache.Main.transform.TransformPoint(new Vector3(0.1f, 0f, 1.5f)); TestHand rightHand = new TestHand(Handedness.Right); yield return(rightHand.Show(startHandPos)); yield return(rightHand.SetGesture(ArticulatedHandPose.GestureId.Pinch)); // After pinching, center should remain the same var afterPinchbounds = bbox.GetComponent <BoxCollider>().bounds; TestUtilities.AssertAboutEqual(afterPinchbounds.center, startCenter, "bbox incorrect center after pinch"); TestUtilities.AssertAboutEqual(afterPinchbounds.size, startSize, "bbox incorrect size after pinch"); var delta = new Vector3(0.1f, 0.1f, 0f); yield return(rightHand.Move(delta)); var endBounds = bbox.GetComponent <BoxCollider>().bounds; TestUtilities.AssertAboutEqual(endBounds.center, new Vector3(0.033f, 0.033f, 1.467f), "endBounds incorrect center"); TestUtilities.AssertAboutEqual(endBounds.size, Vector3.one * .561f, "endBounds incorrect size", 0.02f); GameObject.Destroy(bbox.gameObject); // Wait for a frame to give Unity a change to actually destroy the object yield return(null); // Restore the input simulation profile PlayModeTestUtilities.PopHandSimulationProfile(); yield return(null); }
public IEnumerator TestGaze() { PointerStateContainer gazeOn = new PointerStateContainer() { GazePointerEnabled = true, GGVPointerEnabled = true, PokePointerEnabled = null, SpherePointerEnabled = null, LinePointerEnabled = null }; // set input simulation mode to GGV PlayModeTestUtilities.SetHandSimulationMode(HandSimulationMode.Gestures); TestHand rightHand = new TestHand(Handedness.Right); TestHand leftHand = new TestHand(Handedness.Left); TestContext.Out.WriteLine("Show both hands"); yield return(rightHand.Show(Vector3.zero)); yield return(leftHand.Show(Vector3.zero)); EnsurePointerStates(Handedness.Right, gazeOn); EnsurePointerStates(Handedness.Left, gazeOn); TestContext.Out.WriteLine("Turn off gaze cursor"); PointerUtils.SetGazePointerBehavior(PointerBehavior.AlwaysOff); yield return(null); PointerStateContainer gazeOff = new PointerStateContainer() { GazePointerEnabled = false, GGVPointerEnabled = false, PokePointerEnabled = null, SpherePointerEnabled = null, LinePointerEnabled = null }; EnsurePointerStates(Handedness.Right, gazeOff); EnsurePointerStates(Handedness.Left, gazeOff); }
/// <summary> /// Scroll a slate using GGV and ensure that the slate scrolls /// expected amount. Assumes panZoom has already been created. /// </summary> /// <param name="expectedScroll">The amount panZoom is expected to scroll</param> private IEnumerator RunGGVScrollTest(float expectedScroll) { PlayModeTestUtilities.SetHandSimulationMode(HandSimulationMode.Gestures); Vector2 totalPanDelta = Vector2.zero; panZoom.PanUpdated.AddListener((hpd) => totalPanDelta += hpd.PanDelta); TestHand h = new TestHand(Handedness.Right); yield return(h.SetGesture(ArticulatedHandPose.GestureId.Pinch)); yield return(h.Show(Vector3.zero)); yield return(h.Move(new Vector3(0.0f, -0.1f, 0f))); Assert.AreEqual(expectedScroll, totalPanDelta.y, 0.05, "pan delta is not correct"); yield return(h.Hide()); }
/// <summary> /// Scroll a slate using GGV and ensure that the slate scrolls /// expected amount. Assumes panZoom has already been created. /// </summary> /// <param name="expectedScroll">The amount panZoom is expected to scroll</param> private IEnumerator RunGGVScrollTest(float expectedScroll) { PlayModeTestUtilities.SetHandSimulationMode(HandSimulationMode.Gestures); Vector2 totalPanDelta = Vector2.zero; panZoom.PanUpdated.AddListener((hpd) => totalPanDelta += hpd.PanDelta); TestHand handRight = new TestHand(Handedness.Right); yield return(handRight.SetGesture(ArticulatedHandPose.GestureId.Pinch)); yield return(handRight.Show(Vector3.zero)); // Move requires a slower action (i.e. higher numSteps) in order to // achieve a reliable pan. yield return(handRight.Move(new Vector3(0.0f, -0.1f, 0f), 30)); Assert.AreEqual(expectedScroll, totalPanDelta.y, 0.1, "pan delta is not correct"); yield return(handRight.Hide()); }
public IEnumerator TestToggleEvents() { PlayModeTestUtilities.PushHandSimulationProfile(); PlayModeTestUtilities.SetHandSimulationMode(HandSimulationMode.Gestures); var toggleReceiver = interactable.AddReceiver <InteractableOnToggleReceiver>(); interactable.transform.position = Vector3.forward * 2f; interactable.NumOfDimensions = 2; interactable.CanSelect = true; interactable.CanDeselect = true; bool didSelect = false; bool didUnselect = false; toggleReceiver.OnSelect.AddListener(() => didSelect = true); toggleReceiver.OnDeselect.AddListener(() => didUnselect = true); var testHand = new TestHand(Handedness.Right); yield return(testHand.Show(Vector3.forward)); CameraCache.Main.transform.LookAt(interactable.transform.position); yield return(testHand.SetGesture(ArticulatedHandPose.GestureId.Open)); yield return(testHand.Click()); yield return(testHand.Click()); yield return(testHand.Hide()); Assert.True(didSelect, "Toggle select did not fire"); Assert.True(didUnselect, "Toggle unselect did not fire"); PlayModeTestUtilities.PopHandSimulationProfile(); }