A test fixture for writing tests that use the input system. Can be derived from
or simply instantiated from another test fixture.
Inheritance
InputTestFixture
public class InputTestFixture
Properties
Get or set the current time used by the input system.
Declaration
public double currentTime { get; set; }
Property Value
Type |
Description |
Double |
Current time used by the input system.
|
Methods
Declaration
public static void AssertButtonPress<TState>(InputDevice device, TState state, params ButtonControl[] buttons)
where TState : struct, IInputStateTypeInfo
Parameters
Type Parameters
Declaration
public static void AssertStickValues(StickControl stick, Vector2 stickValue, float up, float down, float left, float right)
Parameters
Declaration
public void BeginTouch(int touchId, Vector2 position, bool queueEventOnly = false, Touchscreen screen = null, double time = -1, double timeOffset = 0, byte displayIndex = 0)
Parameters
Declaration
public void BeginTouch(int touchId, Vector2 position, float pressure, bool queueEventOnly = false, Touchscreen screen = null, double time = -1, double timeOffset = 0)
Parameters
Declaration
public InputTestFixture.ActionConstraint Canceled(InputAction action, InputControl control = null, double? time = null, double? duration = null, object value = null)
Parameters
Returns
Declaration
public InputTestFixture.ActionConstraint Canceled<TInteraction>(InputAction action, InputControl control = null, object value = null, double? time = null, double? duration = null)
where TInteraction : IInputInteraction
Parameters
Returns
Type Parameters
Name |
Description |
TInteraction |
|
Declaration
public InputTestFixture.ActionConstraint Canceled<TValue>(InputAction action, InputControl<TValue> control, TValue value, double? time = null, double? duration = null)
where TValue : struct
Parameters
Returns
Type Parameters
Declaration
public void CancelTouch(int touchId, Vector2 position, float pressure, Vector2 delta = default(Vector2), bool queueEventOnly = false, Touchscreen screen = null, double time = -1, double timeOffset = 0)
Parameters
Declaration
public void CancelTouch(int touchId, Vector2 position, Vector2 delta = default(Vector2), bool queueEventOnly = false, Touchscreen screen = null, double time = -1, double timeOffset = 0)
Parameters
Declaration
public void Click(ButtonControl button, double time = -1, double timeOffset = 0, bool queueEventOnly = false)
Parameters
Declaration
public void EndTouch(int touchId, Vector2 position, float pressure, Vector2 delta = default(Vector2), bool queueEventOnly = false, Touchscreen screen = null, double time = -1, double timeOffset = 0)
Parameters
Declaration
public void EndTouch(int touchId, Vector2 position, Vector2 delta = default(Vector2), bool queueEventOnly = false, Touchscreen screen = null, double time = -1, double timeOffset = 0, byte displayIndex = 0)
Parameters
Declaration
public void Move(InputControl<Vector2> positionControl, Vector2 position, Vector2? delta = null, double time = -1, double timeOffset = 0, bool queueEventOnly = false)
Parameters
Declaration
public void MoveTouch(int touchId, Vector2 position, float pressure, Vector2 delta = default(Vector2), bool queueEventOnly = false, Touchscreen screen = null, double time = -1, double timeOffset = 0)
Parameters
Declaration
public void MoveTouch(int touchId, Vector2 position, Vector2 delta = default(Vector2), bool queueEventOnly = false, Touchscreen screen = null, double time = -1, double timeOffset = 0)
Parameters
Declaration
public InputTestFixture.ActionConstraint Performed(InputAction action, InputControl control = null, double? time = null, double? duration = null, object value = null)
Parameters
Returns
Declaration
public InputTestFixture.ActionConstraint Performed<TInteraction>(InputAction action, InputControl control = null, object value = null, double? time = null, double? duration = null)
where TInteraction : IInputInteraction
Parameters
Returns
Type Parameters
Name |
Description |
TInteraction |
|
Declaration
public InputTestFixture.ActionConstraint Performed<TValue>(InputAction action, InputControl<TValue> control, TValue value, double? time = null, double? duration = null)
where TValue : struct
Parameters
Returns
Type Parameters
Declaration
public void Press(ButtonControl button, double time = -1, double timeOffset = 0, bool queueEventOnly = false)
Parameters
Declaration
public void PressAndRelease(ButtonControl button, double time = -1, double timeOffset = 0, bool queueEventOnly = false)
Parameters
Declaration
public void Release(ButtonControl button, double time = -1, double timeOffset = 0, bool queueEventOnly = false)
Parameters
Set the control to the given value by sending a state event with the value to the
control's device.
Declaration
public void Set<TValue>(InputControl<TValue> control, TValue state, double time = -1, double timeOffset = 0, bool queueEventOnly = false)
where TValue : struct
Parameters
Type |
Name |
Description |
InputControl<TValue> |
control |
An input control on a device that has been added to the system.
|
TValue |
state |
New value for the input control.
|
Double |
time |
Timestamp to use for the state event. If -1 (default), current time is used (see currentTime).
|
Double |
timeOffset |
Offset to apply to the current time. This is an alternative to time . By default, no offset is applied.
|
Boolean |
queueEventOnly |
If true, no Update() will be performed after queueing the event. This will only put
the state event on the event queue and not do anything else. The default is to call Update() after queuing the event.
Note that not issuing an update means the state of the device will not change yet. This may affect subsequent Set/Press/Release/etc calls
as they will not yet see the state change.
Note that this parameter will be ignored if the test is a [UnityTest] . Multi-frame
playmode tests will automatically process input as part of the Unity player loop.
|
Type Parameters
Name |
Description |
TValue |
Value type of the given control.
|
var gamepad = InputSystem.AddDevice<Gamepad>();
Set(gamepad.leftButton, 1);
Set the control with the given path
on device
to the given state
by sending a state event with the value to the device.
Declaration
public void Set<TValue>(InputDevice device, string path, TValue state, double time = -1, double timeOffset = 0, bool queueEventOnly = false)
where TValue : struct
Parameters
Type |
Name |
Description |
InputDevice |
device |
Device on which to find a control.
|
String |
path |
Path of the control on the device.
|
TValue |
state |
New state for the control.
|
Double |
time |
Timestamp to use for the state event. If -1 (default), current time is used (see currentTime).
|
Double |
timeOffset |
Offset to apply to the current time. This is an alternative to time . By default, no offset is applied.
|
Boolean |
queueEventOnly |
If true, no Update() will be performed after queueing the event. This will only put
the state event on the event queue and not do anything else. The default is to call Update() after queuing the event.
Note that not issuing an update means the state of the device will not change yet. This may affect subsequent Set/Press/Release/etc calls
as they will not yet see the state change.
Note that this parameter will be ignored if the test is a [UnityTest] . Multi-frame
playmode tests will automatically process input as part of the Unity player loop.
|
Type Parameters
Name |
Description |
TValue |
Value type of the control.
|
var device = InputSystem.AddDevice("TestDevice");
Set<ButtonControl>(device, "button", 1);
Set<AxisControl>(device, "{Primary2DMotion}/x", 123.456f);
Declaration
public void SetKeyboardLayout(string name, Keyboard keyboard = null)
Parameters
Type |
Name |
Description |
String |
name |
Name of the keyboard layout to switch to.
|
Keyboard |
keyboard |
Keyboard to switch layout on. If null , current is used.
|
Exceptions
Declaration
public void SetKeyInfo(Key key, string displayName, int scanCode = 0)
Parameters
Type |
Name |
Description |
Key |
key |
Key to set the display name for.
|
String |
displayName |
Display name for the key.
|
Int32 |
scanCode |
Optional scanCode to report for the key.
|
Declaration
public void SetTouch(int touchId, TouchPhase phase, Vector2 position, float pressure, Vector2 delta = default(Vector2), bool queueEventOnly = true, Touchscreen screen = null, double time = -1, double timeOffset = 0, byte displayIndex = 0)
Parameters
Declaration
public void SetTouch(int touchId, TouchPhase phase, Vector2 position, Vector2 delta = default(Vector2), bool queueEventOnly = true, Touchscreen screen = null, double time = -1, double timeOffset = 0)
Parameters
Put InputSystem into a known state where it only has a basic set of
layouts and does not have any input devices.
Declaration
public virtual void Setup()
Declaration
public InputTestFixture.ActionConstraint Started(InputAction action, InputControl control = null, double? time = null, object value = null)
Parameters
Returns
Declaration
public InputTestFixture.ActionConstraint Started<TInteraction>(InputAction action, InputControl control = null, object value = null, double? time = null)
where TInteraction : IInputInteraction
Parameters
Returns
Type Parameters
Name |
Description |
TInteraction |
|
Declaration
public InputTestFixture.ActionConstraint Started<TValue>(InputAction action, InputControl<TValue> control, TValue value, double? time = null)
where TValue : struct
Parameters
Returns
Type Parameters
Restore the state of the input system it had when the test was started.
Declaration
public virtual void TearDown()
Perform the input action without having to know what it is bound to.
Declaration
public void Trigger(InputAction action)
Parameters
Type |
Name |
Description |
InputAction |
action |
An input action that is currently enabled and has controls it is bound to.
|
Declaration
public void Trigger<TValue>(InputAction action, InputControl<TValue> control, TValue value)
where TValue : struct
Parameters
Type Parameters