1111using UnityEditor ;
1212using UnityEngine ;
1313using UnityEngine . TestTools ;
14+ using UnityEngine . XR . Interaction . Toolkit ;
1415
1516using HandshapeId = MixedReality . Toolkit . Input . HandshapeTypes . HandshapeId ;
1617
@@ -38,7 +39,6 @@ public override IEnumerator Setup()
3839 [ UnityTest ]
3940 public IEnumerator TestAddInteractableAtRuntime ( )
4041 {
41-
4242 // This should not throw exception
4343 AssembleSlider ( InputTestUtilities . InFrontOfUser ( Vector3 . forward ) , Vector3 . zero , out GameObject sliderObject , out Slider slider , out SliderVisuals sliderVisuals ) ;
4444 yield return DirectPinchAndMoveSlider ( slider , 1.0f ) ;
@@ -470,105 +470,104 @@ public IEnumerator TestVisualsOrientation()
470470 yield return null ;
471471 }
472472
473- // Disabled as we adopt Unity's multi-selection implementation
474- // /// <summary>
475- // /// Tests that the slider will only use the first valid grab interactor, and reject others.
476- // /// </summary>
477- // [UnityTest]
478- // public IEnumerator TestMultipleGrabBehavior()
479- // {
480- // // This should not throw exception
481- // AssembleSlider(Vector3.forward, Vector3.zero, out GameObject sliderObject, out Slider slider, out SliderVisuals sliderVisuals);
473+ /// <summary>
474+ /// Tests that the slider will only use the first valid grab interactor, and reject others.
475+ /// </summary>
476+ [ UnityTest , Ignore ( "Disabled as we adopt Unity's multi-selection implementation." ) ]
477+ public IEnumerator TestMultipleGrabBehavior ( )
478+ {
479+ // This should not throw exception
480+ AssembleSlider ( Vector3 . forward , Vector3 . zero , out GameObject sliderObject , out Slider slider , out SliderVisuals sliderVisuals ) ;
482481
483- // Debug.Assert(slider.Value == 0.5, "Slider should have value 0.5 at start");
482+ Debug . Assert ( slider . Value == 0.5 , "Slider should have value 0.5 at start" ) ;
484483
485- // // Single mode needed to reject incoming interactors once we are already selected.
486- // Debug.Assert(slider.selectMode == InteractableSelectMode.Single, "Slider should be in single select mode");
484+ // Single mode needed to reject incoming interactors once we are already selected.
485+ Debug . Assert ( slider . selectMode == InteractableSelectMode . Single , "Slider should be in single select mode" ) ;
487486
488- // var rightHand = new TestHand(Handedness.Right);
489- // Vector3 initialPos = sliderVisuals.Handle.position;
490- // yield return rightHand.Show(initialPos);
491- // yield return rightHand.SetGesture(GestureId .Pinch);
487+ var rightHand = new TestHand ( Handedness . Right ) ;
488+ Vector3 initialPos = sliderVisuals . Handle . position ;
489+ yield return rightHand . Show ( initialPos ) ;
490+ yield return rightHand . SetHandshape ( HandshapeId . Pinch ) ;
492491
493- // yield return RuntimeTestUtilities.WaitForUpdates();
494- // Debug.Assert(slider.isSelected == true, "Slider was not originally selected");
495- // Debug.Assert(slider.IsGrabSelected == true, "Slider should specifically be grab selected");
492+ yield return RuntimeTestUtilities . WaitForUpdates ( ) ;
493+ Debug . Assert ( slider . isSelected == true , "Slider was not originally selected" ) ;
494+ Debug . Assert ( slider . IsGrabSelected == true , "Slider should specifically be grab selected" ) ;
496495
497- // var leftHand = new TestHand(Handedness.Left);
498- // yield return leftHand.Show(initialPos);
499- // yield return leftHand.SetGesture(GestureId .Pinch);
496+ var leftHand = new TestHand ( Handedness . Left ) ;
497+ yield return leftHand . Show ( initialPos ) ;
498+ yield return leftHand . SetHandshape ( HandshapeId . Pinch ) ;
500499
501- // yield return RuntimeTestUtilities.WaitForUpdates();
502- // Debug.Assert(slider.interactorsSelecting.Count == 1, "Single mode should enforce single selection");
500+ yield return RuntimeTestUtilities . WaitForUpdates ( ) ;
501+ Debug . Assert ( slider . interactorsSelecting . Count == 1 , "Single mode should enforce single selection" ) ;
503502
504- // // Now we move the right hand to the left, but the slider should not move.
505- // yield return rightHand.MoveTo(new Vector3(-0.1f, 0, 1.0f));
503+ // Now we move the right hand to the left, but the slider should not move.
504+ yield return rightHand . MoveTo ( new Vector3 ( - 0.1f , 0 , 1.0f ) ) ;
506505
507- // yield return RuntimeTestUtilities.WaitForUpdates();
508- // Debug.Assert(Mathf.Abs(slider.Value - 0.5f) < 0.01f, "Slider should not have moved");
506+ yield return RuntimeTestUtilities . WaitForUpdates ( ) ;
507+ Debug . Assert ( Mathf . Abs ( slider . Value - 0.5f ) < 0.01f , "Slider should not have moved" ) ;
509508
510- // // Now we move the left (new) hand to the right, and the slider should now move.
511- // yield return leftHand.MoveTo(new Vector3(0.1f, 0, 1.0f));
509+ // Now we move the left (new) hand to the right, and the slider should now move.
510+ yield return leftHand . MoveTo ( new Vector3 ( 0.1f , 0 , 1.0f ) ) ;
512511
513- // yield return RuntimeTestUtilities.WaitForUpdates();
514- // Assert.That(slider.Value, Is.GreaterThan(0.5), "Slider didn't move after moving new grab");
512+ yield return RuntimeTestUtilities . WaitForUpdates ( ) ;
513+ Assert . That ( slider . Value , Is . GreaterThan ( 0.5 ) , "Slider didn't move after moving new grab" ) ;
515514
516- // // clean up
517- // Object.Destroy(sliderObject);
518- // }
515+ // clean up
516+ Object . Destroy ( sliderObject ) ;
517+ }
519518
520- // // / <summary>
521- // // / Tests that the slider will only use the first valid GazePinch interactor, and reject others.
522- // // / </summary>
523- // [UnityTest]
524- // public IEnumerator TestMultipleGazePinchBehavior()
525- // {
526- // // This should not throw exception
527- // AssembleSlider(Vector3.forward, Vector3.zero, out GameObject sliderObject, out Slider slider, out _);
519+ /// <summary>
520+ /// Tests that the slider will only use the first valid GazePinch interactor, and reject others.
521+ /// </summary>
522+ [ UnityTest , Ignore ( "Disabled as we adopt Unity's multi-selection implementation." ) ]
523+ public IEnumerator TestMultipleGazePinchBehavior ( )
524+ {
525+ // This should not throw exception
526+ AssembleSlider ( Vector3 . forward , Vector3 . zero , out GameObject sliderObject , out Slider slider , out _ ) ;
528527
529- // Debug.Assert(slider.Value == 0.5, "Slider should have value 0.5 at start");
528+ Debug . Assert ( slider . Value == 0.5 , "Slider should have value 0.5 at start" ) ;
530529
531- // // Single mode needed to reject incoming interactors once we are already selected.
532- // Debug.Assert(slider.selectMode == InteractableSelectMode.Single, "Slider should be in single select mode");
530+ // Single mode needed to reject incoming interactors once we are already selected.
531+ Debug . Assert ( slider . selectMode == InteractableSelectMode . Single , "Slider should be in single select mode" ) ;
533532
534- // var rightHand = new TestHand(Handedness.Right);
535- // Vector3 initialPos = new Vector3(0.0f, 0, 0.5f);
536- // yield return rightHand.Show(initialPos);
533+ var rightHand = new TestHand ( Handedness . Right ) ;
534+ Vector3 initialPos = new Vector3 ( 0.0f , 0 , 0.5f ) ;
535+ yield return rightHand . Show ( initialPos ) ;
537536
538- // // Use more frames for better gaze-pinch reliability
539- // yield return rightHand.SetGesture(GestureId .Pinch, 10);
537+ // Use more frames for better gaze-pinch reliability
538+ yield return rightHand . SetHandshape ( HandshapeId . Pinch , 10 ) ;
540539
541- // yield return RuntimeTestUtilities.WaitForUpdates();
542- // Debug.Assert(slider.isSelected == true, "Slider was not originally selected");
543- // Debug.Assert(slider.IsGazePinchSelected == true, "Slider should specifically be gaze-pinch selected");
544- // Debug.Assert(slider.interactorsSelecting.Count == 1, "Only one interactor should be selecting so far.");
540+ yield return RuntimeTestUtilities . WaitForUpdates ( ) ;
541+ Debug . Assert ( slider . isSelected == true , "Slider was not originally selected" ) ;
542+ Debug . Assert ( slider . IsGazePinchSelected == true , "Slider should specifically be gaze-pinch selected" ) ;
543+ Debug . Assert ( slider . interactorsSelecting . Count == 1 , "Only one interactor should be selecting so far." ) ;
545544
546- // float initialSliderValue = slider.Value;
545+ float initialSliderValue = slider . Value ;
547546
548- // var leftHand = new TestHand(Handedness.Left);
549- // yield return leftHand.Show(initialPos);
547+ var leftHand = new TestHand ( Handedness . Left ) ;
548+ yield return leftHand . Show ( initialPos ) ;
550549
551- // // Use more frames for better gaze-pinch reliability
552- // yield return leftHand.SetGesture(GestureId .Pinch, 10);
550+ // Use more frames for better gaze-pinch reliability
551+ yield return leftHand . SetHandshape ( HandshapeId . Pinch , 10 ) ;
553552
554- // yield return RuntimeTestUtilities.WaitForUpdates();
555- // Debug.Assert(slider.interactorsSelecting.Count == 1, "Single mode should not allow multiple interactors to select");
553+ yield return RuntimeTestUtilities . WaitForUpdates ( ) ;
554+ Debug . Assert ( slider . interactorsSelecting . Count == 1 , "Single mode should not allow multiple interactors to select" ) ;
556555
557- // // Now we move the right (original) hand to the left, but the slider should not move.
558- // yield return rightHand.MoveTo(new Vector3(-0.1f, 0, 1.0f));
556+ // Now we move the right (original) hand to the left, but the slider should not move.
557+ yield return rightHand . MoveTo ( new Vector3 ( - 0.1f , 0 , 1.0f ) ) ;
559558
560- // yield return RuntimeTestUtilities.WaitForUpdates();
561- // Debug.Assert(Mathf.Abs(slider.Value - initialSliderValue) < 0.01f, "Slider should have detached from the first interactor");
559+ yield return RuntimeTestUtilities . WaitForUpdates ( ) ;
560+ Debug . Assert ( Mathf . Abs ( slider . Value - initialSliderValue ) < 0.01f , "Slider should have detached from the first interactor" ) ;
562561
563- // // Now we move the left (new) hand to the right, and the slider should now move.
564- // yield return leftHand.MoveTo(new Vector3(0.1f, 0, 1.0f));
562+ // Now we move the left (new) hand to the right, and the slider should now move.
563+ yield return leftHand . MoveTo ( new Vector3 ( 0.1f , 0 , 1.0f ) ) ;
565564
566- // yield return RuntimeTestUtilities.WaitForUpdates();
567- // Assert.That(slider.Value, Is.GreaterThan(initialSliderValue), "Slider didn't move after moving the new interactor");
565+ yield return RuntimeTestUtilities . WaitForUpdates ( ) ;
566+ Assert . That ( slider . Value , Is . GreaterThan ( initialSliderValue ) , "Slider didn't move after moving the new interactor" ) ;
568567
569- // // clean up
570- // Object.Destroy(sliderObject);
571- // }
568+ // clean up
569+ Object . Destroy ( sliderObject ) ;
570+ }
572571
573572 #endregion Tests
574573
@@ -579,7 +578,7 @@ private IEnumerator DirectPinchAndMoveSlider(Slider slider, float toSliderValue)
579578 InputTestUtilities . SetHandAnchorPoint ( Handedness . Left , Input . Simulation . ControllerAnchorPoint . Grab ) ;
580579 InputTestUtilities . SetHandAnchorPoint ( Handedness . Right , Input . Simulation . ControllerAnchorPoint . Grab ) ;
581580
582- Debug . Log ( $ "moving hand to value { toSliderValue } ") ;
581+ Debug . Log ( $ "Moving hand to value { toSliderValue } ") ;
583582 var rightHand = new TestHand ( Handedness . Right ) ;
584583 Vector3 initialPos = InputTestUtilities . InFrontOfUser ( new Vector3 ( 0.05f , 0 , 1.0f ) ) ;
585584 yield return rightHand . Show ( initialPos ) ;
@@ -593,7 +592,7 @@ private IEnumerator DirectPinchAndMoveSlider(Slider slider, float toSliderValue)
593592 yield return rightHand . SetHandshape ( HandshapeId . Pinch , 30 ) ;
594593 yield return RuntimeTestUtilities . WaitForUpdates ( ) ;
595594
596- if ( ! ( toSliderValue >= 0 && toSliderValue <= 1 ) )
595+ if ( toSliderValue < 0 || toSliderValue > 1 )
597596 {
598597 throw new System . ArgumentException ( "toSliderValue must be between 0 and 1" ) ;
599598 }
0 commit comments