Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class MRTKBaseInteractable : XRBaseInteractable
{
#region Gaze

readonly List<IGazeInteractor> hoveringGazeInteractors = new List<IGazeInteractor>();
private readonly List<IGazeInteractor> hoveringGazeInteractors = new List<IGazeInteractor>();

/// <summary>
/// (Read Only) The list of <see cref="IGazeInteractor"/> components currently gazing this object.
Expand All @@ -28,14 +28,14 @@ public class MRTKBaseInteractable : XRBaseInteractable

#region GazePinch

readonly List<IGazePinchInteractor> hoveringGazePinchInteractors = new List<IGazePinchInteractor>();
private readonly List<IGazePinchInteractor> hoveringGazePinchInteractors = new List<IGazePinchInteractor>();

/// <summary>
/// (Read Only) The list of <see cref="IGazePinchInteractor"/> components currently hovering this object.
/// </summary>
public List<IGazePinchInteractor> HoveringGazePinchInteractors => hoveringGazePinchInteractors;

readonly List<IGazePinchInteractor> selectingGazePinchInteractors = new List<IGazePinchInteractor>();
private readonly List<IGazePinchInteractor> selectingGazePinchInteractors = new List<IGazePinchInteractor>();

/// <summary>
/// (Read Only) The list of <see cref="IGazePinchInteractor"/> components currently selecting this object.
Expand All @@ -46,7 +46,7 @@ public class MRTKBaseInteractable : XRBaseInteractable

#region Poke

readonly List<IPokeInteractor> hoveringPokeInteractors = new List<IPokeInteractor>();
private readonly List<IPokeInteractor> hoveringPokeInteractors = new List<IPokeInteractor>();

/// <summary>
/// (Read Only) The list of <see cref="IPokeInteractor"/> components currently hovering this object.
Expand All @@ -57,14 +57,14 @@ public class MRTKBaseInteractable : XRBaseInteractable

#region Grab

readonly List<IGrabInteractor> hoveringGrabInteractors = new List<IGrabInteractor>();
private readonly List<IGrabInteractor> hoveringGrabInteractors = new List<IGrabInteractor>();

/// <summary>
/// (Read Only) The list of <see cref="IGrabInteractor"/> components currently hovering this object.
/// </summary>]
public List<IGrabInteractor> HoveringGrabInteractors => hoveringGrabInteractors;

readonly List<IGrabInteractor> selectingGrabInteractors = new List<IGrabInteractor>();
private readonly List<IGrabInteractor> selectingGrabInteractors = new List<IGrabInteractor>();

/// <summary>
/// (Read Only) The list of <see cref="IGrabInteractor"/> components currently selecting this object.
Expand All @@ -75,7 +75,7 @@ public class MRTKBaseInteractable : XRBaseInteractable

#region Ray

readonly List<IRayInteractor> hoveringRayInteractors = new List<IRayInteractor>();
private readonly List<IRayInteractor> hoveringRayInteractors = new List<IRayInteractor>();

/// <summary>
/// (Read Only) The list of <see cref="IRayInteractor"/> components currently hovering this object.
Expand Down Expand Up @@ -199,7 +199,7 @@ public void DisableInteractorType(SystemInterfaceType type)
}
}
/// <summary>
/// Removes the specified type to the set of interactors which cannot select this interactable
/// Removes the specified type from the set of interactors which cannot select this interactable
/// </summary>
public void EnableInteractorType(SystemInterfaceType type)
{
Expand Down
57 changes: 31 additions & 26 deletions org.mixedrealitytoolkit.input/Tests/Runtime/BasicInputTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@
#pragma warning disable CS1591

using MixedReality.Toolkit.Core.Tests;
using MixedReality.Toolkit.Input.Simulation;
using MixedReality.Toolkit.Subsystems;
using NUnit.Framework;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.TestTools;
using UnityEngine.XR;
using UnityEngine.XR.Interaction.Toolkit;
using MixedReality.Toolkit.Input;
using MixedReality.Toolkit.Input.Simulation;
using MixedReality.Toolkit;
using MixedReality.Toolkit.Subsystems;

using HandshapeId = MixedReality.Toolkit.Input.HandshapeTypes.HandshapeId;

namespace MixedReality.Toolkit.Input.Tests
Expand All @@ -31,7 +27,7 @@ public class BasicInputTests : BaseRuntimeInputTests
/// Ensure the simulated input devices are registered and present.
/// </summary>
[UnityTest]
public IEnumerator InputDeviceSmoketest()
public IEnumerator InputDeviceSmokeTest()
{
foreach (var device in InputSystem.devices)
{
Expand All @@ -45,9 +41,10 @@ public IEnumerator InputDeviceSmoketest()
/// Ensure the simulated input devices bind to the controllers on the rig.
/// </summary>
[UnityTest]
public IEnumerator InputBindingSmoketest()
public IEnumerator InputBindingSmokeTest()
{
var controllers = new[] {
XRBaseController[] controllers =
{
CachedLookup.LeftHandController,
CachedLookup.RightHandController,
CachedLookup.GazeController
Expand All @@ -69,7 +66,7 @@ public IEnumerator InputBindingSmoketest()
/// Ensure the simulated input device actually makes the rig's controllers move/actuate.
/// </summary>
[UnityTest]
public IEnumerator HandMovingSmoketest()
public IEnumerator HandMovingSmokeTest()
{
var controller = CachedLookup.RightHandController as ActionBasedController;

Expand Down Expand Up @@ -107,7 +104,7 @@ public IEnumerator GrabAnchorTest()
Vector3 cubePos = InputTestUtilities.InFrontOfUser();
cube.transform.position = cubePos;
cube.transform.localScale = Vector3.one * 1.0f;

var testHand = new TestHand(Handedness.Right);
InputTestUtilities.SetHandAnchorPoint(Handedness.Right, ControllerAnchorPoint.Grab);

Expand Down Expand Up @@ -136,32 +133,28 @@ public IEnumerator GrabAnchorTest()
public IEnumerator StatefulInteractableSmokeTest()
{
GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube.AddComponent<StatefulInteractable>();
StatefulInteractable firstCubeInteractable = cube.AddComponent<StatefulInteractable>();
cube.transform.position = InputTestUtilities.InFrontOfUser(new Vector3(0.2f, 0.2f, 0.5f));
cube.transform.localScale = Vector3.one * 0.1f;

// For this test, we won't use poke selection.
cube.GetComponent<StatefulInteractable>().DisableInteractorType(typeof(PokeInteractor));
firstCubeInteractable.DisableInteractorType(typeof(PokeInteractor));

GameObject cube2 = GameObject.CreatePrimitive(PrimitiveType.Cube);
cube2.AddComponent<StatefulInteractable>();
StatefulInteractable secondCubeInteractable = cube2.AddComponent<StatefulInteractable>();
cube2.transform.position = InputTestUtilities.InFrontOfUser(new Vector3(-0.2f, -0.2f, 0.5f));
cube2.transform.localScale = Vector3.one * 0.1f;

// For this test, we won't use poke selection.
cube2.GetComponent<StatefulInteractable>().DisableInteractorType(typeof(PokeInteractor));
secondCubeInteractable.DisableInteractorType(typeof(PokeInteractor));

var rightHand = new TestHand(Handedness.Right);

yield return rightHand.Show(InputTestUtilities.InFrontOfUser(0.5f));

yield return RuntimeTestUtilities.WaitForUpdates();

bool shouldTestToggle = false;

StatefulInteractable firstCubeInteractable = cube.GetComponent<StatefulInteractable>();
StatefulInteractable secondCubeInteractable = cube2.GetComponent<StatefulInteractable>();

for (int i = 0; i < 5; i++)
{
// Flip this back and forth to test both toggleability and un-toggleability
Expand All @@ -176,27 +169,33 @@ public IEnumerator StatefulInteractableSmokeTest()
firstCubeInteractable.TriggerOnRelease = (i % 2) == 0;

Assert.IsFalse(firstCubeInteractable.IsGrabHovered,
"StatefulInteractable was already GrabHovered.");
Assert.IsFalse(firstCubeInteractable.isHovered,
"StatefulInteractable was already hovered.");

yield return rightHand.MoveTo(cube.transform.position);
yield return RuntimeTestUtilities.WaitForUpdates();
Assert.IsTrue(firstCubeInteractable.IsGrabHovered,
"StatefulInteractable did not get GrabHovered.");
Assert.IsTrue(firstCubeInteractable.isHovered,
"StatefulInteractable did not get hovered.");

yield return rightHand.SetHandshape(HandshapeId.Pinch);
yield return RuntimeTestUtilities.WaitForUpdates();
Assert.IsTrue(firstCubeInteractable.IsGrabSelected,
"StatefulInteractable did not get GrabSelected.");
Assert.IsTrue(firstCubeInteractable.isSelected,
"StatefulInteractable did not get selected.");

if (shouldTestToggle)
{
if (secondCubeInteractable.TriggerOnRelease)
if (firstCubeInteractable.TriggerOnRelease)
{
Assert.IsFalse(secondCubeInteractable.IsToggled, "StatefulInteractable toggled on press, when it was set to be toggled on release.");
Assert.IsFalse(firstCubeInteractable.IsToggled, "StatefulInteractable toggled on press, when it was set to be toggled on release.");
}
else
{
Assert.IsFalse(secondCubeInteractable.IsToggled, "StatefulInteractable didn't toggled on press, when it was set to be toggled on press.");
Assert.IsFalse(firstCubeInteractable.IsToggled, "StatefulInteractable didn't toggled on press, when it was set to be toggled on press.");
}
}

Expand Down Expand Up @@ -225,17 +224,23 @@ public IEnumerator StatefulInteractableSmokeTest()
yield return RuntimeTestUtilities.WaitForUpdates();

Assert.IsFalse(secondCubeInteractable.IsGrabHovered,
"StatefulInteractable was already GrabHovered.");
Assert.IsFalse(secondCubeInteractable.isHovered,
"StatefulInteractable was already hovered.");

yield return rightHand.MoveTo(secondCubeInteractable.transform.position);
yield return RuntimeTestUtilities.WaitForUpdates();
Assert.IsTrue(secondCubeInteractable.IsGrabHovered,
"StatefulInteractable did not get GrabHovered.");
Assert.IsTrue(secondCubeInteractable.isHovered,
"StatefulInteractable did not get hovered.");

yield return rightHand.SetHandshape(HandshapeId.Pinch);
yield return RuntimeTestUtilities.WaitForUpdates();
Assert.IsTrue(secondCubeInteractable.IsGrabSelected,
"StatefulInteractable did not get GrabSelected.");
Assert.IsTrue(secondCubeInteractable.isSelected,
"StatefulInteractable did not get selected.");

if (shouldTestToggle)
{
Expand Down Expand Up @@ -303,7 +308,7 @@ public IEnumerator GazePinchSmokeTest()

yield return rightHand.SetHandshape(HandshapeId.Open);
yield return RuntimeTestUtilities.WaitForUpdates();

Assert.IsFalse(interactable.isSelected);
Assert.IsFalse(interactable.IsGazePinchSelected);
Assert.IsTrue(interactable.isHovered);
Expand Down Expand Up @@ -388,7 +393,7 @@ public IEnumerator ToggleHydrationTest()

didFireEvent = false;
interactable.ForceSetToggled(true, fireEvents: false);

Assert.IsTrue(interactable.IsToggled, "Interactable didn't get toggled.");
Assert.IsFalse(didFireEvent, "ForceSetToggled(true, fireEvents:false) should NOT have fired the event.");

Expand Down Expand Up @@ -493,7 +498,7 @@ public IEnumerator SpawnInteractableOnHand()

// Move hand far away.
yield return rightHand.MoveTo(new Vector3(2, 2, 2));
yield return RuntimeTestUtilities.WaitForUpdates(frameCount:240);
yield return RuntimeTestUtilities.WaitForUpdates(frameCount: 240);

Assert.IsFalse(AnyProximityDetectorsTriggered(), "Prox detectors should no longer be triggered.");

Expand Down Expand Up @@ -608,4 +613,4 @@ private bool AnyProximityDetectorsTriggered()
}
}
}
#pragma warning restore CS1591
#pragma warning restore CS1591
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public IEnumerator InteractionDetectorTest()
XRBaseController rightHandController = CachedLookup.RightHandController;
Assert.IsTrue(rightHandController != null, "No controllers found for right hand.");

// Moving the hand to a position where it's far ray is hovering over the cube
// Moving the hand to a position where its far ray is hovering over the cube
yield return rightHand.AimAt(cube.transform.position);
yield return RuntimeTestUtilities.WaitForUpdates();

Expand Down Expand Up @@ -127,7 +127,7 @@ public IEnumerator ModeMediationTest()
InputTestUtilities.SetHandAnchorPoint(Handedness.Right, ControllerAnchorPoint.Grab);
yield return RuntimeTestUtilities.WaitForUpdates();

// Moving the hand to a position where it's far ray is hovering over the cube
// Moving the hand to a position where its far ray is hovering over the cube
yield return rightHand.AimAt(cube.transform.position);
yield return RuntimeTestUtilities.WaitForUpdates();
InteractionMode farRayMode = rightHandController.GetComponentInChildren<MRTKRayInteractor>().GetComponent<InteractionDetector>().ModeOnHover;
Expand Down Expand Up @@ -165,7 +165,7 @@ public IEnumerator ModeMediationTest()

ValidateInteractionModeActive(rightHandController, nearMode);

// Moving the hand to a position where it's far ray is hovering over the cube
// Moving the hand to a position where its far ray is hovering over the cube
yield return rightHand.MoveTo(cube.transform.position + new Vector3(0.02f, -0.1f, -0.8f));
yield return RuntimeTestUtilities.WaitForUpdates(frameCount:120);

Expand All @@ -180,7 +180,7 @@ public IEnumerator ModeMediationTest()
private void ValidateInteractionModeActive(XRBaseController controller, InteractionMode currentMode)
{
// We construct the list of managed interactor types manually because we don't want to expose the internal controller mapping implementation to even internal use, since
// we don't want any other class to be able to modify those collections without going through the Mode Manager or it's in-editor inspector.
// we don't want any other class to be able to modify those collections without going through the Mode Manager or its in-editor inspector.
HashSet<System.Type> managedInteractorTypes = new HashSet<System.Type>(InteractionModeManager.Instance.PrioritizedInteractionModes.SelectMany(x => x.AssociatedTypes));
HashSet<System.Type> activeInteractorTypes = InteractionModeManager.Instance.PrioritizedInteractionModes.Find(x => x.ModeName == currentMode.Name).AssociatedTypes;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public static IEnumerator PointHandToTarget(Vector3 target, HandshapeId handshap
/// </summary>
/// <remarks>
/// <para>
/// This smooths the handshape based on the provided/ <paramref name="handshapeId"/> over the number of
/// This smooths the handshape based on the provided <paramref name="handshapeId"/> over the number of
/// steps provided by <paramref name="numSteps"/>.
/// </para>
/// <para>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class HandConstraintTests : BaseRuntimeInputTests
[UnityTest]
public IEnumerator HandConstraintEventsOneHanded()
{
// Disable gaze interactions for this unit test;
// Disable gaze interactions for this unit test
InputTestUtilities.DisableGazeInteractor();

// Set up GameObject with a SolverHandler
Expand Down
Loading