A test fixture for writing tests that use the input system. Can be derived from
or simply instantiated from another test fixture.
Inheritance
System.Object
InputTestFixture
public class InputTestFixture
public class MyInputTests : InputTestFixture
{
public override void Setup()
{
base.Setup();
InputSystem.RegisterLayout<MyDevice>();
}
[Test]
public void CanCreateMyDevice()
{
InputSystem.AddDevice<MyDevice>();
Assert.That(InputSystem.devices, Has.Exactly(1).TypeOf<MyDevice>());
}
}
Properties
The input runtime used during testing.
Declaration
public InputTestRuntime runtime { get; }
Property Value
Methods
Declaration
public static void AssertButtonPress<TState>(InputDevice device, TState state, params ButtonControl[] buttons)
where TState : struct, IInputStateTypeInfo
Parameters
Type Parameters
Declaration
public InputTestFixture.ActionConstraint Canceled(InputAction action, InputControl control = null)
Parameters
Returns
Declaration
public InputTestFixture.ActionConstraint Canceled<TInteraction>(InputAction action, InputControl control = null)
where TInteraction : IInputInteraction
Parameters
Returns
Type Parameters
Name |
Description |
TInteraction |
|
Declaration
public InputTestFixture.ActionConstraint Performed(InputAction action, InputControl control = null)
Parameters
Returns
Declaration
public InputTestFixture.ActionConstraint Performed<TInteraction>(InputAction action, InputControl control = null)
where TInteraction : IInputInteraction
Parameters
Returns
Type Parameters
Name |
Description |
TInteraction |
|
Declaration
public void Press(ButtonControl button, double absoluteTime = -1, double timeOffset = 0)
Parameters
Type |
Name |
Description |
ButtonControl |
button |
|
System.Double |
absoluteTime |
|
System.Double |
timeOffset |
|
Declaration
public void PressAndRelease(ButtonControl button, double absoluteTime = -1, double timeOffset = 0)
Parameters
Type |
Name |
Description |
ButtonControl |
button |
|
System.Double |
absoluteTime |
|
System.Double |
timeOffset |
|
Declaration
public void Release(ButtonControl button, double absoluteTime = -1, double timeOffset = 0)
Parameters
Type |
Name |
Description |
ButtonControl |
button |
|
System.Double |
absoluteTime |
|
System.Double |
timeOffset |
|
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 absoluteTime = -1, double timeOffset = 0)
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.
|
System.Double |
absoluteTime |
|
System.Double |
timeOffset |
|
Type Parameters
Name |
Description |
TValue |
Value type of the given control.
|
var gamepad = InputSystem.AddDevice<Gamepad>();
Set(gamepad.leftButton, 1);
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)
Parameters
Returns
Declaration
public InputTestFixture.ActionConstraint Started<TInteraction>(InputAction action, InputControl control = null)
where TInteraction : IInputInteraction
Parameters
Returns
Type Parameters
Name |
Description |
TInteraction |
|
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