Search Unity

Question Missing link between InputTestFixture and UIEvent system possibly?

Discussion in 'Testing & Automation' started by hereandtherestudio08, Sep 10, 2023.

  1. hereandtherestudio08

    hereandtherestudio08

    Joined:
    Jan 30, 2022
    Posts:
    2
    I am trying to test Gamepad input on my UIToolkit base UI's. I am also using the Unity Test Framework to automate as much testing as I can. I have read the documentation for the Unity Test Framework on how to do input testing using the built in helper methods Press() PressAndRelease() etc. In my mind if I have code setup similar to this:

    public class Test_B_NewGameMenu : InputTestFixture{

    Gamepad gamepad;

    [Test]
    public void A_InputTest() {
    gamepad = InputSystem.AddDevice<Gamepad>();

    Press(gamepad.buttonSouth);
    InputSystem.Update();
    Release(gamepad.buttonSouth);
    InputSystem.Update();
    }
    }

    The UTF should simulate pressing the UIButton that I have highlighted with the Focus() method in a previous script when the scene was loading. By the time this test code is execute, my scene has loaded and all of my scripts have initilized like I want them to. I have built smaller tests to proved the that UTF is simulating the button press properly, but the simulated press event does not seem to be going to UIDoc button.

    When I was researching I came across a post that said that because of the nature of how UTF loads, the InputSystem and I think EventSystem because disconnected somehow.

    Is there a way to restore or simulate this connection?
    Am I missing a small checkbox or setting somewhere to get this working?
    Is this not supported at the moment and I need to pursue simulating the button click events rather that simulating the input? At least while testing the UI? Any guidance or troubleshooting ideas would be greatly appreciated.