Repository navigation
Unit Test Plan: 1. Settings Logic — Default Mappings & Persistence, GitHub workflows maintenance #354
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
Merged
ikostan
merged 15 commits into
main
from
unit-test-plan-1-settings-logic-default-mappings-persistence
Jan 27, 2026
Merged
Unit Test Plan: 1. Settings Logic — Default Mappings & Persistence, GitHub workflows maintenance #354
Changes from 4 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5b61944
Unit Test Plan: 1. Settings Logic — Default Mappings & Persistence #347
ikostan 8a60b34
Update test_input_remap_button.gd
ikostan ef5410d
Update input remap button tests for key and gamepad events
ikostan 3171fff
Remove mouse button remap and label tests
ikostan 4278aaf
Bump release-drafter/release-drafter from 6.1.0 to 6.2.0
dependabot[bot] b6d700f
Bump github/codeql-action from 4.31.10 to 4.31.11
dependabot[bot] 0640b7d
Fix invalid typed preload syntax at line 9.
ikostan 68ce2ec
Update stale comment to reflect actual test coverage.
ikostan 7b24a64
Update test_input_remap_button.gd
ikostan fde8c9e
Update test_input_remap_button.gd
ikostan c61f109
Use get_event_label() instead of hardcoding OS.get_keycode_string() i…
ikostan 4e5d158
Merge pull request #357 from ikostan/dependabot/github_actions/github…
ikostan b93edfc
Merge pull request #358 from ikostan/dependabot/github_actions/releas…
ikostan a5ccca7
Update release_drafter.yml
ikostan 04c3e08
suggestion (security): Consider pinning github/codeql-action/upload-s…
ikostan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| ## test_input_remap_button.gd | ||
| ## GUT unit tests for input_remap_button.gd. | ||
| ## Covers IRB-01 to IRB-08 from test plan. | ||
| ## Test Plan: | ||
| ## https://github.com/ikostan/SkyLockAssault/issues/347 | ||
|
|
||
| extends "res://addons/gut/test.gd" | ||
|
|
||
| var InputRemapButton: = preload("res://scripts/input_remap_button.gd") # Adjust path as needed. | ||
|
|
||
| var button: InputRemapButton | ||
| const TEST_ACTION: String = "test_action" | ||
|
|
||
|
|
||
| ## Per-test setup: Reset InputMap for test action, instantiate button. | ||
| ## :rtype: void | ||
| func before_each() -> void: | ||
| if InputMap.has_action(TEST_ACTION): | ||
| InputMap.erase_action(TEST_ACTION) | ||
| InputMap.add_action(TEST_ACTION) | ||
| button = InputRemapButton.new() | ||
| button.action = TEST_ACTION | ||
| button.current_device = InputRemapButton.DeviceType.KEYBOARD | ||
| add_child_autofree(button) | ||
|
|
||
|
|
||
| ## Per-test cleanup: Erase test action. | ||
| ## :rtype: void | ||
| func after_each() -> void: | ||
| if InputMap.has_action(TEST_ACTION): | ||
| InputMap.erase_action(TEST_ACTION) | ||
| await get_tree().process_frame | ||
|
|
||
|
|
||
| ## IRB-01 | Remap keyboard event | current_device = KEYBOARD; action exists with prior events | Instantiate, simulate _input with Key, inspect InputMap | Only keyboard event added; old erased; button label updated; remap logged. | ||
| ## :rtype: void | ||
| func test_irb_01() -> void: | ||
| # Add prior events | ||
| var prior_key: InputEventKey = InputEventKey.new() | ||
| prior_key.physical_keycode = KEY_A | ||
| InputMap.action_add_event(TEST_ACTION, prior_key) | ||
| var prior_gamepad: InputEventJoypadButton = InputEventJoypadButton.new() | ||
| prior_gamepad.button_index = JOY_BUTTON_A | ||
| InputMap.action_add_event(TEST_ACTION, prior_gamepad) | ||
| # Start remapping | ||
| button.button_pressed = true | ||
| button._on_pressed() | ||
| assert_true(button.listening) | ||
| # Simulate input | ||
| var new_key: InputEventKey = InputEventKey.new() | ||
| new_key.physical_keycode = KEY_B | ||
| new_key.pressed = true | ||
| button._input(new_key) | ||
| # Assert | ||
| var events: Array = InputMap.action_get_events(TEST_ACTION) | ||
| assert_eq(events.size(), 2) | ||
| assert_true(events.any(func(ev: InputEvent) -> bool: return ev is InputEventKey and ev.physical_keycode == KEY_B)) | ||
| assert_true(events.any(func(ev: InputEvent) -> bool: return ev is InputEventJoypadButton and ev.button_index == JOY_BUTTON_A)) | ||
| assert_eq(button.text, OS.get_keycode_string(KEY_B)) | ||
| assert_false(button.listening) | ||
|
|
||
|
|
||
| ## IRB-02 | Remap gamepad event | current_device = GAMEPAD; action exists | Simulate _input with InputEventJoypadButton, inspect InputMap | Only gamepad event added; non-matching events ignored; label updated correctly. | ||
| ## :rtype: void | ||
| func test_irb_02() -> void: | ||
| button.current_device = InputRemapButton.DeviceType.GAMEPAD | ||
| # Add prior events | ||
| var prior_key: InputEventKey = InputEventKey.new() | ||
| prior_key.physical_keycode = KEY_A | ||
| InputMap.action_add_event(TEST_ACTION, prior_key) | ||
| # Start remapping | ||
| button.button_pressed = true | ||
| button._on_pressed() | ||
| assert_true(button.listening) | ||
| # Simulate input | ||
| var new_gamepad: InputEventJoypadButton = InputEventJoypadButton.new() | ||
| new_gamepad.button_index = JOY_BUTTON_B | ||
| new_gamepad.pressed = true | ||
| button._input(new_gamepad) | ||
| # Assert | ||
| var events: Array = InputMap.action_get_events(TEST_ACTION) | ||
| assert_eq(events.size(), 2) | ||
| assert_true(events.any(func(ev: InputEvent) -> bool: return ev is InputEventJoypadButton and ev.button_index == JOY_BUTTON_B)) | ||
| assert_true(events.any(func(ev: InputEvent) -> bool: return ev is InputEventKey and ev.physical_keycode == KEY_A)) | ||
| assert_eq(button.text, "B") | ||
| assert_false(button.listening) | ||
|
|
||
|
|
||
| ## IRB-04 | Ignore wrong-device event during remap | current_device = KEYBOARD | Simulate _input with InputEventJoypadButton | Event ignored; no change to InputMap; label unchanged. | ||
| ## :rtype: void | ||
| func test_irb_04() -> void: | ||
| # Add prior event | ||
| var prior_key: InputEventKey = InputEventKey.new() | ||
| prior_key.physical_keycode = KEY_A | ||
| InputMap.action_add_event(TEST_ACTION, prior_key) | ||
| # Start remapping | ||
| button.button_pressed = true | ||
| button._on_pressed() | ||
| assert_true(button.listening) | ||
| # Simulate wrong input | ||
| var gamepad_event: InputEventJoypadButton = InputEventJoypadButton.new() | ||
| gamepad_event.button_index = JOY_BUTTON_A | ||
| gamepad_event.pressed = true | ||
| button._input(gamepad_event) | ||
| # Assert | ||
| var events: Array = InputMap.action_get_events(TEST_ACTION) | ||
| assert_eq(events.size(), 1) | ||
| assert_true(events[0] is InputEventKey) | ||
| assert_eq(events[0].physical_keycode, KEY_A) | ||
| assert_eq(button.text, "Press a key or controller button/axis...") | ||
| assert_true(button.listening) | ||
|
|
||
|
|
||
| ## IRB-05 | Get matching event for device | Action has mixed keyboard, mouse, and gamepad events | Call get_matching_event(DeviceType.KEYBOARD) | Correct keyboard or mouse event returned; null if none exist. | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| ## :rtype: void | ||
| func test_irb_05() -> void: | ||
| # Add mixed events | ||
| var key_event: InputEventKey = InputEventKey.new() | ||
| key_event.physical_keycode = KEY_A | ||
| InputMap.action_add_event(TEST_ACTION, key_event) | ||
| var gamepad_event: InputEventJoypadButton = InputEventJoypadButton.new() | ||
| gamepad_event.button_index = JOY_BUTTON_A | ||
| InputMap.action_add_event(TEST_ACTION, gamepad_event) | ||
| # For keyboard | ||
| button.current_device = InputRemapButton.DeviceType.KEYBOARD | ||
| var matching: InputEvent = button.get_matching_event() | ||
| assert_true(matching is InputEventKey) | ||
| # For gamepad | ||
| button.current_device = InputRemapButton.DeviceType.GAMEPAD | ||
| matching = button.get_matching_event() | ||
| assert_true(matching is InputEventJoypadButton) | ||
| # None for keyboard after erase | ||
| InputMap.action_erase_events(TEST_ACTION) | ||
| button.current_device = InputRemapButton.DeviceType.KEYBOARD | ||
| matching = button.get_matching_event() | ||
| assert_null(matching) | ||
|
|
||
|
|
||
| ## IRB-07 | Handle remap logging | Logging enabled | Perform successful remap, inspect log output | Log entry includes device type and new event details. | ||
| ## :rtype: void | ||
| func test_irb_07() -> void: | ||
| # Note: Assuming Globals.log_info is called; use spy if available. | ||
| # For simplicity, perform remap (logging happens internally). | ||
| button.button_pressed = true | ||
| button._on_pressed() | ||
| var new_key: InputEventKey = InputEventKey.new() | ||
| new_key.physical_keycode = KEY_C | ||
| new_key.pressed = true | ||
| button._input(new_key) | ||
| # Assert remap happened, assume log is printed (no direct assert on print). | ||
| var events: Array = InputMap.action_get_events(TEST_ACTION) | ||
| assert_eq(events.size(), 1) | ||
| # If GUT supports output spying, add here. | ||
|
|
||
|
|
||
| ## IRB-08 | Edge case: No existing events | Action exists but has no mapped events | Clear action events, remap a new valid event | New event added correctly for active device; no errors thrown. | ||
| ## :rtype: void | ||
| func test_irb_08() -> void: | ||
| InputMap.action_erase_events(TEST_ACTION) | ||
| # Start remapping | ||
| button.button_pressed = true | ||
| button._on_pressed() | ||
| assert_true(button.listening) | ||
| # Simulate input | ||
| var new_key: InputEventKey = InputEventKey.new() | ||
| new_key.physical_keycode = KEY_D | ||
| new_key.pressed = true | ||
| button._input(new_key) | ||
| # Assert | ||
| var events: Array = InputMap.action_get_events(TEST_ACTION) | ||
| assert_eq(events.size(), 1) | ||
| assert_true(events[0] is InputEventKey) | ||
| assert_eq(events[0].physical_keycode, KEY_D) | ||
| assert_eq(button.text, OS.get_keycode_string(KEY_D)) | ||
| assert_false(button.listening) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.