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

WIP: Bugfix/i578 #587

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions addons/gut/input_sender.gd
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ func _send_event(event):
for r in _receivers:
if(r == Input):
Input.parse_input_event(event)
if(event is InputEventAction):
if(event.pressed):
Input.action_press(event.action)
else:
Input.action_release(event.action)
if(_auto_flush_input):
Input.flush_buffered_events()
else:
Expand Down
43 changes: 43 additions & 0 deletions test/unit/test_bugs/test_i578.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
extends GutTest

class InputSingletonTracker:
extends Node
var input_frames = []

var _frame_counter = 0

func _process(delta):
_frame_counter += 1
if Input.is_anything_pressed():
input_frames.append(_frame_counter)

class TestInputSingleton:
extends "res://addons/gut/test.gd"
var _sender = InputSender.new(Input)

func before_all():
InputMap.add_action("jump")

func after_all():
InputMap.erase_action("jump")

func after_each():
_sender.release_all()
_sender.clear()

func test_raw_input_press():
var r = add_child_autofree(InputSingletonTracker.new())

Input.action_press("jump")
await wait_frames(10)
Input.action_release("jump")

assert_gt(r.input_frames.size(), 1, 'input size')

func test_input_sender_press():
var r = add_child_autofree(InputSingletonTracker.new())

_sender.action_down("jump").hold_for('10f')
await wait_for_signal(_sender.idle, 5)

assert_gt(r.input_frames.size(), 1, 'input size')