Class PlayModeTestUtilities
Inheritance
PlayModeTestUtilities
Assembly: cs.temp.dll.dll
public class PlayModeTestUtilities
Fields
If true, the controller movement test steps will take a longer number of frames. This is especially
useful for seeing motion in play mode tests (where the default smaller number of frames tends
to make tests too fast to be understandable to the human eye). This is false by default
to ensure that tests will run quickly in general, and can be set to true manually in specific
test cases using the example below.
Declaration
public static bool UseSlowTestController
Field Value
[UnityTest]
public IEnumerator YourTestCase()
{
PlayModeTestUtilities.UseSlowTestController = true;
...
PlayModeTestUtilities.UseSlowTestController = false;
}
Properties
The number of frames that elapse for each test controller movement, taking into account if
slow test controller mode has been engaged.
Declaration
public static int ControllerMoveSteps { get; }
Property Value
The number of frames that elapse for each test controller movement, taking into account if
slow test controller mode has been engaged.
Declaration
[Obsolete("Use ControllerMoveSteps instead.")]
public static int HandMoveSteps { get; }
Property Value
If true, the controller movement test steps will take a longer number of frames. This is especially
useful for seeing motion in play mode tests (where the default smaller number of frames tends
to make tests too fast to be understandable to the human eye). This is false by default
to ensure that tests will run quickly in general, and can be set to true manually in specific
test cases using the example below.
Declaration
[Obsolete("Use UseSlowTestController instead.")]
public static bool UseSlowTestHand { get; set; }
Property Value
[UnityTest]
public IEnumerator YourTestCase()
{
PlayModeTestUtilities.UseSlowTestController = true;
...
PlayModeTestUtilities.UseSlowTestController = false;
}
Methods
Given a numSteps value, determines if the value is a 'sentinel' value of
ControllerMoveStepsSentinelValue, which should be converted to the current
default value of ControllerMoveSteps. If it's not the sentinel value,
this returns numSteps unchanged.
Declaration
public static int CalculateNumSteps(int numSteps)
Parameters
Type |
Name |
Description |
Int32 |
numSteps |
|
Returns
Make sure there is a MixedRealityInputModule on the main camera, which is needed for using Unity UI with MRTK.
Declaration
public static void EnsureInputModule()
Declaration
public static SimulatedHandData.HandJointDataGenerator GenerateHandPose(ArticulatedHandPose.GestureId gesture, Handedness handedness, Vector3 worldPosition, Quaternion rotation)
Parameters
Type |
Name |
Description |
ArticulatedHandPose.GestureId |
gesture |
|
Handedness |
handedness |
|
Vector3 |
worldPosition |
|
Quaternion |
rotation |
|
Returns
Type |
Description |
SimulatedHandData.HandJointDataGenerator |
|
Utility function to simplify code for getting access to the running InputSimulationService
Declaration
public static InputSimulationService GetInputSimulationService()
Returns
Type |
Description |
InputSimulationService |
Returns InputSimulationService registered for playmode test scene
|
Declaration
public static IMixedRealityInputSystem GetInputSystem()
Returns
Type |
Description |
IMixedRealityInputSystem |
|
Declaration
public static T GetPointer<T>(Handedness handedness)
where T : class, IMixedRealityPointer
Parameters
Type |
Name |
Description |
Handedness |
handedness |
|
Returns
Type Parameters
Declaration
public static IEnumerator HideController(Handedness handedness, InputSimulationService inputSimulationService)
Parameters
Type |
Name |
Description |
Handedness |
handedness |
|
InputSimulationService |
inputSimulationService |
|
Returns
Type |
Description |
IEnumerator |
|
Declaration
public static IEnumerator HideHand(Handedness handedness, InputSimulationService inputSimulationService)
Parameters
Type |
Name |
Description |
Handedness |
handedness |
|
InputSimulationService |
inputSimulationService |
|
Returns
Type |
Description |
IEnumerator |
|
InstallTextMeshProEssentials()
Declaration
public static void InstallTextMeshProEssentials()
Moves the hand from startPos to endPos.
Declaration
public static IEnumerator MoveHand(Vector3 startPos, Vector3 endPos, ArticulatedHandPose.GestureId gestureId, Handedness handedness, InputSimulationService inputSimulationService, int numSteps = -1)
Parameters
Type |
Name |
Description |
Vector3 |
startPos |
|
Vector3 |
endPos |
|
ArticulatedHandPose.GestureId |
gestureId |
|
Handedness |
handedness |
|
InputSimulationService |
inputSimulationService |
|
Int32 |
numSteps |
|
Returns
Type |
Description |
IEnumerator |
|
Moves the motion controller from startPos to endPos.
Declaration
public static IEnumerator MoveMotionController(Vector3 startPos, Vector3 endPos, SimulatedMotionControllerButtonState buttonState, Handedness handedness, InputSimulationService inputSimulationService, int numSteps = -1)
Parameters
Type |
Name |
Description |
Vector3 |
startPos |
|
Vector3 |
endPos |
|
SimulatedMotionControllerButtonState |
buttonState |
|
Handedness |
handedness |
|
InputSimulationService |
inputSimulationService |
|
Int32 |
numSteps |
|
Returns
Type |
Description |
IEnumerator |
|
Declaration
public static void PopControllerSimulationProfile()
Declaration
[Obsolete("Use PopControllerSimulationProfile instead.")]
public static void PopHandSimulationProfile()
Declaration
public static void PushControllerSimulationProfile()
Declaration
[Obsolete("Use PushControllerSimulationProfile instead.")]
public static void PushHandSimulationProfile()
Declaration
public static void SetControllerSimulationMode(ControllerSimulationMode mode)
Parameters
Type |
Name |
Description |
ControllerSimulationMode |
mode |
|
Declaration
public static IEnumerator SetHandRotation(Quaternion fromRotation, Quaternion toRotation, Vector3 handPos, ArticulatedHandPose.GestureId gestureId, Handedness handedness, int numSteps, InputSimulationService inputSimulationService)
Parameters
Type |
Name |
Description |
Quaternion |
fromRotation |
|
Quaternion |
toRotation |
|
Vector3 |
handPos |
|
ArticulatedHandPose.GestureId |
gestureId |
|
Handedness |
handedness |
|
Int32 |
numSteps |
|
InputSimulationService |
inputSimulationService |
|
Returns
Type |
Description |
IEnumerator |
|
Declaration
[Obsolete("Use SetControllerSimulationMode instead.")]
public static void SetHandSimulationMode(ControllerSimulationMode mode)
Parameters
Type |
Name |
Description |
ControllerSimulationMode |
mode |
|
Declaration
public static IEnumerator SetHandState(Vector3 handPos, ArticulatedHandPose.GestureId gestureId, Handedness handedness, InputSimulationService inputSimulationService)
Parameters
Type |
Name |
Description |
Vector3 |
handPos |
|
ArticulatedHandPose.GestureId |
gestureId |
|
Handedness |
handedness |
|
InputSimulationService |
inputSimulationService |
|
Returns
Type |
Description |
IEnumerator |
|
Declaration
public static IEnumerator SetMotionControllerRotation(Quaternion fromRotation, Quaternion toRotation, Vector3 motionControllerPos, SimulatedMotionControllerButtonState buttonState, Handedness handedness, int numSteps, InputSimulationService inputSimulationService)
Parameters
Type |
Name |
Description |
Quaternion |
fromRotation |
|
Quaternion |
toRotation |
|
Vector3 |
motionControllerPos |
|
SimulatedMotionControllerButtonState |
buttonState |
|
Handedness |
handedness |
|
Int32 |
numSteps |
|
InputSimulationService |
inputSimulationService |
|
Returns
Type |
Description |
IEnumerator |
|
Declaration
public static IEnumerator SetMotionControllerState(Vector3 motionControllerPos, SimulatedMotionControllerButtonState buttonState, Handedness handedness, InputSimulationService inputSimulationService)
Parameters
Type |
Name |
Description |
Vector3 |
motionControllerPos |
|
SimulatedMotionControllerButtonState |
buttonState |
|
Handedness |
handedness |
|
InputSimulationService |
inputSimulationService |
|
Returns
Type |
Description |
IEnumerator |
|
Creates a play mode test scene, creates an MRTK instance, initializes playspace.
Declaration
public static void Setup(MixedRealityToolkitConfigurationProfile profile = null)
Parameters
Initializes the MRTK such that there are no other input system listeners
(global or per-interface).
Declaration
public static IEnumerator SetupMrtkWithoutGlobalInputHandlers()
Returns
Type |
Description |
IEnumerator |
|
Shows the hand in the open state, at the origin
Declaration
public static IEnumerator ShowHand(Handedness handedness, InputSimulationService inputSimulationService)
Parameters
Type |
Name |
Description |
Handedness |
handedness |
|
InputSimulationService |
inputSimulationService |
|
Returns
Type |
Description |
IEnumerator |
|
Declaration
public static IEnumerator ShowHand(Handedness handedness, InputSimulationService inputSimulationService, ArticulatedHandPose.GestureId handPose, Vector3 handLocation)
Parameters
Type |
Name |
Description |
Handedness |
handedness |
|
InputSimulationService |
inputSimulationService |
|
ArticulatedHandPose.GestureId |
handPose |
|
Vector3 |
handLocation |
|
Returns
Type |
Description |
IEnumerator |
|
Shows the motion controller in the default state, at the origin
Declaration
public static IEnumerator ShowMontionController(Handedness handedness, InputSimulationService inputSimulationService)
Parameters
Type |
Name |
Description |
Handedness |
handedness |
|
InputSimulationService |
inputSimulationService |
|
Returns
Type |
Description |
IEnumerator |
|
Declaration
public static IEnumerator ShowMontionController(Handedness handedness, InputSimulationService inputSimulationService, SimulatedMotionControllerButtonState buttonState, Vector3 motionControllerLocation)
Parameters
Type |
Name |
Description |
Handedness |
handedness |
|
InputSimulationService |
inputSimulationService |
|
SimulatedMotionControllerButtonState |
buttonState |
|
Vector3 |
motionControllerLocation |
|
Returns
Type |
Description |
IEnumerator |
|
Destroys all objects in the play mode test scene, if it has been loaded, and shuts down MRTK instance.
Declaration
public static void TearDown()
Destroy the input module to ensure it gets initialized cleanly for the next test.
Declaration
public static void TeardownInputModule()
Declaration
public static SimulatedMotionControllerData.MotionControllerPoseUpdater UpdateMotionControllerPose(Handedness handedness, Vector3 worldPosition, Quaternion rotation)
Parameters
Type |
Name |
Description |
Handedness |
handedness |
|
Vector3 |
worldPosition |
|
Quaternion |
rotation |
|
Returns
Type |
Description |
SimulatedMotionControllerData.MotionControllerPoseUpdater |
|
Waits for the user to press the enter key before a test continues.
Not actually used by any test, but it is useful when debugging since you can
pause the state of the test and inspect the scene.
Declaration
public static IEnumerator WaitForEnterKey()
Returns
Type |
Description |
IEnumerator |
|
Sometimes it take a few frames for inputs raised via InputSystem.OnInput*
to actually get sent to input handlers. This method waits for enough frames
to pass so that any events raised actually have time to send to handlers.
We set it fairly conservatively to ensure that after waiting
all input events have been sent.
Declaration
public static IEnumerator WaitForInputSystemUpdate()
Returns
Type |
Description |
IEnumerator |
|