Hi!
I’m trying to create UI (PlayMode) tests for a game that uses UniRx to handle user’s input. I’m using Unity Test Framework. The buttons utilize onPointerDownAsObservable() trigger from UniRx/R3, so button.onClick().Invoke() doesn’t do anything to those buttons:
//Has no effect
Button addButton = GameObject.Find(addButtonLocator).GetComponent<Button>();
addButton.onClick.Invoke();
I’ve also tried to get the button coordinates and and click those coordinates with the InputTestFixture:
//Has no effect
Button addButton = GameObject.Find(addButtonLocator).GetComponent<Button>();
var elementPosition = new Vector2(uiElement.transform.position.x, uiElement.transform.position.y);
Set(mouse.position, elementPosition);
yield return new WaitForSeconds(1f);
Click(mouse.leftButton);
yield return new WaitForSeconds(1f);
//Has no effect
Button addButton = GameObject.Find(addButtonLocator).GetComponent<Button>();
var elementPosition = new Vector2(uiElement.transform.position.x, uiElement.transform.position.y);
Move(Mouse.current.position, elementPosition, queueEventOnly: true);
yield return new WaitForSeconds(1f);
PressAndRelease(mouse.leftButton);
yield return new WaitForSeconds(1f);
Could you please help me with any suggestions on how to click these buttons in the correct and working way?