Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GD-554: Adding support for touch screen input event testing to GdUnitSceneRunner #556

Merged
merged 6 commits into from
Aug 22, 2024

Conversation

MikeSchulze
Copy link
Owner

@MikeSchulze MikeSchulze commented Aug 14, 2024

Why

see #554

What

  • Stabilized the scene runner input buffer handling to avoid chaotic runtime errors
  • Added new simulate touch screen functions
## Simulates a screen touch is pressed.[br]
## [member index] : The touch index in the case of a multi-touch event.[br]
## [member position] : The position to touch the screen.[br]
## [member double_tap] : If true, the touch's state is a double tab.
@warning_ignore("unused_parameter")
func simulate_screen_touch_pressed(index :int, position :Vector2, double_tap := false) -> GdUnitSceneRunner:


## Simulates a screen touch is press.[br]
## [member index] : The touch index in the case of a multi-touch event.[br]
## [member position] : The position to touch the screen.[br]
## [member double_tap] : If true, the touch's state is a double tab.
@warning_ignore("unused_parameter")
func simulate_screen_touch_press(index :int, position :Vector2, double_tap := false) -> GdUnitSceneRunner:


## Simulates a screen touch is released.[br]
## [member index] : The touch index in the case of a multi-touch event.[br]
## [member double_tap] : If true, the touch's state is a double tab.
@warning_ignore("unused_parameter")
func simulate_screen_touch_release(index :int, double_tap := false) -> GdUnitSceneRunner:


## Simulates a touch screen drag&drop to the relative coordinates (offset).[br]
## [color=yellow]You must use [b]await[/b] to wait until the simulated drag&drop is complete.[/color][br]
## [br]
## [member index] : The touch index in the case of a multi-touch event.[br]
## [member relative] : The relative position, indicating the drag&drop position offset.[br]
## [member time] : The time to move to the relative position in seconds (default is 1 second).[br]
## [member trans_type] : Sets the type of transition used (default is TRANS_LINEAR).[br]
## [codeblock]
##    func test_touch_drag_drop():
##       var runner = scene_runner("res://scenes/simple_scene.tscn")
##       # start drag at position 50,50
##       runner.simulate_screen_touch_drag_begin(1, Vector2(50, 50))
##       # and drop it at final at 150,50  relative (50,50 + 100,0)
##       await runner.simulate_screen_touch_drag_relative(1, Vector2(100,0))
## [/codeblock]
@warning_ignore("unused_parameter")
func simulate_screen_touch_drag_relative(index :int, relative: Vector2, time: float = 1.0, trans_type: Tween.TransitionType = Tween.TRANS_LINEAR) -> GdUnitSceneRunner:


## Simulates a touch screen drop to the absolute coordinates (offset).[br]
## [color=yellow]You must use [b]await[/b] to wait until the simulated drop is complete.[/color][br]
## [br]
## [member index] : The touch index in the case of a multi-touch event.[br]
## [member position] : The final position, indicating the drop position.[br]
## [member time] : The time to move to the final position in seconds (default is 1 second).[br]
## [member trans_type] : Sets the type of transition used (default is TRANS_LINEAR).[br]
## [codeblock]
##    func test_touch_drag_drop():
##       var runner = scene_runner("res://scenes/simple_scene.tscn")
##       # start drag at position 50,50
##       runner.simulate_screen_touch_drag_begin(1, Vector2(50, 50))
##       # and drop it at 100,50
##       await runner.simulate_screen_touch_drag_absolute(1, Vector2(100,50))
## [/codeblock]
@warning_ignore("unused_parameter")
func simulate_screen_touch_drag_absolute(index :int, position: Vector2, time: float = 1.0, trans_type: Tween.TransitionType = Tween.TRANS_LINEAR) -> GdUnitSceneRunner:


## Simulates a touch screen drop&drop to the absolute coordinates (offset).[br]
## [color=yellow]You must use [b]await[/b] to wait until the simulated drop is complete.[/color][br]
## [br]
## [member index] : The touch index in the case of a multi-touch event.[br]
## [member position] : The drag start position, indicating the drag position.[br]
## [member drop_position] : The drop position, indicating the drop position.[br]
## [member time] : The time to move to the final position in seconds (default is 1 second).[br]
## [member trans_type] : Sets the type of transition used (default is TRANS_LINEAR).[br]
## [codeblock]
##    func test_touch_drag_drop():
##       var runner = scene_runner("res://scenes/simple_scene.tscn")
##       # start drag at position 50,50 and drop it at 100,50
##       await runner.simulate_screen_touch_drag_drop(1, Vector2(50, 50), Vector2(100,50))
## [/codeblock]
@warning_ignore("unused_parameter")
func simulate_screen_touch_drag_drop(index :int, position: Vector2, drop_position: Vector2, time: float = 1.0, trans_type: Tween.TransitionType = Tween.TRANS_LINEAR) -> GdUnitSceneRunner:


## Simulates a touch screen drag event to given position.[br]
## [member index] : The touch index in the case of a multi-touch event.[br]
## [member position] : The drag start position, indicating the drag position.[br]
@warning_ignore("unused_parameter")
func simulate_screen_touch_drag(index :int, position: Vector2) -> GdUnitSceneRunner:


## Returns the actual position of the touch drag postion by given index
## [member index] : The touch index in the case of a multi-touch event.[br]
@warning_ignore("unused_parameter")
func get_screen_touch_drag_position(index: int) -> Vector2:

@MikeSchulze MikeSchulze added the enhancement New feature or request label Aug 14, 2024
@MikeSchulze MikeSchulze added this to the v4.3.5 milestone Aug 14, 2024
@MikeSchulze MikeSchulze self-assigned this Aug 14, 2024
@MikeSchulze MikeSchulze force-pushed the GD-554 branch 3 times, most recently from b8e5d8b to 972decb Compare August 14, 2024 14:27
…Runner`

# Why
see #554

# What
- Stabilized the scene runner input buffer handling to avoid chaotic runtime errors
- Added new simulate touch screen functions
  - `simulate_screen_touch_pressed`
  - `simulate_screen_touch_press`
  - `simulate_screen_touch_release`
@MikeSchulze MikeSchulze force-pushed the GD-554 branch 3 times, most recently from 25ba1bb to d8a7e78 Compare August 16, 2024 11:30
@MikeSchulze MikeSchulze modified the milestones: v4.3.5, v4.4.0 Aug 16, 2024
@MikeSchulze MikeSchulze force-pushed the GD-554 branch 3 times, most recently from 8a4cc29 to 7c52644 Compare August 16, 2024 12:40
@MikeSchulze MikeSchulze changed the title GD-554: Adding support for touch screen event testing to GdUnitSceneRunner GD-554: Adding support for touch screen input event testing to GdUnitSceneRunner Aug 16, 2024
@MikeSchulze MikeSchulze merged commit e92ffbf into master Aug 22, 2024
@MikeSchulze MikeSchulze deleted the GD-554 branch August 22, 2024 05:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

GD-554: Add simulate touch support to SceneRunner to enable it for testing touch screen input events
1 participant