MikeSchulze / gdUnit3

A Godot Unit Test Framework. Support for gdScript and c# unit testing
MIT License
312 stars 22 forks source link

GD-351: Scene runner's mouse simulation doesn't trigger drag & drop functions #351

Closed MonaCage closed 1 year ago

MonaCage commented 1 year ago

The used Godot version: 3.5.1

OS including version: Windows 10

Describe the bug We're trying to simulate UI-tests and have a drag and drop function implemented in our game which we are trying to test via scene runner and it seems like the functions for simulate_mouse_button_press() & simulate_mouse_move() are not doing anything while set_mouse_pos() is working as we assume.

  1. When simulating the mouse button press (hold) on a scene runner, it doesn't trigger the get_drag_data() (and also _gui_input() by the looks of it) function of a child even when moving the mouse manually. We assume this is because simulate_mouse_button_press() doesn't actually hold the mouse button down. When checking against Input.is_mouse_button_pressed(BUTTON_LEFT) it also returns false.
  2. When simulating the mouse movement on a scene runner the _gui_input function of the scene gets called but the mouse position doesn't update in the viewport.

Steps to Reproduce For this functionality the test must be started with "Debug Tests" and the window has to be not minimized otherwise the set_mouse_pos() function doesn't update the mouse in the viewport either.

Mouse Press

  1. Open project from below
  2. Start test test_mouse_press() of res://test/PanelContainerTest.gd with Debug Tests
  3. Move the mouse on top of a Panel or the Button
  4. See that the Game Node prints Left mouse button was pressed! but the Panel doesn't
  5. See that, when doing the same for the Button, it also doesn't register the simulated press

Mouse Movement

  1. Open project from below
  2. Start test test_simulate_mouse_move() of res://test/PanelContainerTest.gd with Debug Tests
  3. See that the expected mouse position (300, 300) doesn't match the actual mouse position (100, 100)

Minimal reproduction project: Uploaded project: https://github.com/MonaCage/gdunit-mouse-sim