Class InputTestFixture
  A test fixture for writing tests that use the input system. Can be derived from
or simply instantiated from another test fixture.
 
  
  
    Inheritance
    
    InputTestFixture
   
  
  Assembly: Unity.InputSystem.TestFramework.dll
  
  
    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. 
 | 
      
    
  
  
  
  
  
  Declaration
  
    protected IReadOnlyList<InputTestFixture.AnalyticsRegistrationEventData> registeredAnalytics { get; }
   
  Property Value
  
  
  
  
  
  Declaration
  
    protected IReadOnlyList<InputTestFixture.AnalyticsEventData> sentAnalyticsEvents { 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 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 void CancelTouch(int touchId, Vector2 position, float pressure, Vector2 delta = default, bool queueEventOnly = false, Touchscreen screen = null, double time = -1, double timeOffset = 0)
   
  Parameters
  
  
  
  
  
  Declaration
  
    public void CancelTouch(int touchId, Vector2 position, Vector2 delta = default, 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 Click(ButtonControl button, double time = -1, double timeOffset = 0, bool queueEventOnly = false)
   
  Parameters
  
  
  
  Set up the test fixture to collect ALL analytics registrations and events.
 
  
  Declaration
  
    protected void CollectAnalytics()
   
  
  
  Set up the test fixture to collect analytics registrations and events
 
  
  Declaration
  
    protected void CollectAnalytics(Predicate<string> analyticsNameFilter)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | Predicate<string> | 
        analyticsNameFilter | 
        A filter predicate evaluating whether the given analytics name should be accepted to be stored in test fixture. 
 | 
      
    
  
  
  
  Set up the test fixture to collect filtered analytics registrations and events.
 
  
  Declaration
  
    protected void CollectAnalytics(string acceptedName)
   
  Parameters
  
    
      
        | Type | 
        Name | 
        Description | 
      
    
    
      
        | string | 
        acceptedName | 
        The analytics name to be accepted, all other registrations and data
will be discarded. 
 | 
      
    
  
  
  
  
  
  Declaration
  
    public void EndTouch(int touchId, Vector2 position, float pressure, Vector2 delta = default, bool queueEventOnly = false, Touchscreen screen = null, double time = -1, double timeOffset = 0)
   
  Parameters
  
  
  
  
  
  Declaration
  
    public void EndTouch(int touchId, Vector2 position, Vector2 delta = default, 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, bool queueEventOnly = false, Touchscreen screen = null, double time = -1, double timeOffset = 0)
   
  Parameters
  
  
  
  
  
  Declaration
  
    public void MoveTouch(int touchId, Vector2 position, Vector2 delta = default, 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
  
  
  
  
  
  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. 
 | 
      
      
        | int | 
        scanCode | 
        Optional scanCode to report for the key. 
 | 
      
    
  
  
  
  
  
  
  
  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 SetTouch(int touchId, TouchPhase phase, Vector2 position, float pressure, Vector2 delta = default, 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, bool queueEventOnly = true, Touchscreen screen = null, double time = -1, double timeOffset = 0)
   
  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. 
 | 
      
      
        | bool | 
        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 <code>[UnityTest]</code>. 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. 
 | 
      
      
        | bool | 
        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 <code>[UnityTest]</code>. 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);
  
  
  Put InputSystem into a known state where it only has a basic set of
layouts and does not have any input devices.
 
  
  Declaration
  
    [SetUp]
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
  
    [TearDown]
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