Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
run: |
bash ./.github/scripts/patch_index_js.sh "export/web"
- name: "Initialize CodeQL"
uses: "github/codeql-action/init@v4.31.10"
uses: "github/codeql-action/init@v4.31.11"
with:
# yamllint disable rule:quoted-strings
languages: ${{ matrix.language }}
Expand All @@ -69,10 +69,10 @@ jobs:
debug: "false"

- name: "Autobuild (optional for JS but included for completeness)"
uses: "github/codeql-action/autobuild@v4.31.10"
uses: "github/codeql-action/autobuild@v4.31.11"

- name: "Perform CodeQL Analysis"
uses: "github/codeql-action/analyze@v4.31.10"
uses: "github/codeql-action/analyze@v4.31.11"

- name: "Post-scan summary (optional)"
if: "always()" # Run even if previous steps fail
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
tag_name: "${{ steps.drafter.outputs.tag_name }}" # Expose from step
steps:
# yamllint disable-line rule:line-length
- uses: "release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5" # Pinned to v6.1.0 commit SHA
- uses: "release-drafter/release-drafter@6db134d15f3909ccc9eefd369f02bd1e9cffdf97" # Pinned to v6.2.0 commit SHA
id: drafter # Add ID to access outputs
with:
config-name: "release-drafter.yml" # Explicitly point to your config
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release_drafter_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
# yamllint disable-line rule:line-length
- uses: "release-drafter/release-drafter@b1476f6e6eb133afa41ed8589daba6dc69b4d3f5" # v6.1.0
- uses: "release-drafter/release-drafter@6db134d15f3909ccc9eefd369f02bd1e9cffdf97" # v6.2.0
with:
config-name: "release-drafter.yml" # Your existing config
env:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/snyk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
continue-on-error: true

- name: "Upload Snyk Code SARIF to GitHub"
uses: "github/codeql-action/upload-sarif@v4.31.10"
uses: "github/codeql-action/upload-sarif@19b2f06db2b6f5108140aeb04014ef02b648f789"
if: "always() && hashFiles('snyk-code.sarif') != ''"
with:
sarif_file: "snyk-code.sarif"
Expand All @@ -54,7 +54,7 @@ jobs:
continue-on-error: true

- name: "Upload Snyk Open Source SARIF to GitHub"
uses: "github/codeql-action/upload-sarif@v4.31.10"
uses: "github/codeql-action/upload-sarif@19b2f06db2b6f5108140aeb04014ef02b648f789"
if: "always() && hashFiles('snyk-os.sarif') != ''"
with:
sarif_file: "snyk-os.sarif"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/trivy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
ignore-unfixed: true # Ignore vulns without fixes available

- name: "Upload Trivy scan results to GitHub Security tab"
uses: "github/codeql-action/upload-sarif@fb650c22f965a3eff7e20c5535e51a256dd16bf1" # Pinned to SHA for v3.31.0 (latest stable as of 2025-10-28; fixes the invalid SHA error)
uses: "github/codeql-action/upload-sarif@55252c7a3a47fea1e0fdd923b269f4be8a5ad9a0" # Pinned to SHA for v3.31.0 (latest stable as of 2025-10-28; fixes the invalid SHA error)
if: always() # Upload even if scan fails
with:
sarif_file: 'trivy-results.sarif'
1 change: 1 addition & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,6 @@ ai_assistant_hub/preferences/always_scroll_to_bottom=false

[rendering]

textures/canvas_textures/default_texture_filter=0
renderer/rendering_method="gl_compatibility"
renderer/rendering_method.mobile="gl_compatibility"
181 changes: 181 additions & 0 deletions test/gut/test_input_remap_button.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
## 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"

const InputRemapButton = preload("res://scripts/input_remap_button.gd")

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.pressed.emit()
assert_true(button.listening)
# Simulate input
var new_key: InputEventKey = InputEventKey.new()
new_key.physical_keycode = KEY_B
new_key.pressed = true
Input.parse_input_event(new_key)
await get_tree().process_frame
# 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, button.get_event_label(new_key))
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.pressed.emit()
assert_true(button.listening)
# Simulate input
var new_gamepad: InputEventJoypadButton = InputEventJoypadButton.new()
new_gamepad.button_index = JOY_BUTTON_B
new_gamepad.pressed = true
Input.parse_input_event(new_gamepad)
await get_tree().process_frame
# 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, button.get_event_label(new_gamepad))
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.pressed.emit()
assert_true(button.listening)
var listening_text: String = button.text
# Simulate wrong input
var gamepad_event: InputEventJoypadButton = InputEventJoypadButton.new()
gamepad_event.button_index = JOY_BUTTON_A
gamepad_event.pressed = true
Input.parse_input_event(gamepad_event)
await get_tree().process_frame
# 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, listening_text)
assert_true(button.listening)


## IRB-05 | Get matching event for device | Action has mixed keyboard, and gamepad events | Call get_matching_event(DeviceType.KEYBOARD) | Correct keyboard event returned; null if none exist.
## :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.pressed.emit()
var new_key: InputEventKey = InputEventKey.new()
new_key.physical_keycode = KEY_C
new_key.pressed = true
Input.parse_input_event(new_key)
await get_tree().process_frame
# 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.pressed.emit()
assert_true(button.listening)
# Simulate input
var new_key: InputEventKey = InputEventKey.new()
new_key.physical_keycode = KEY_D
new_key.pressed = true
Input.parse_input_event(new_key)
await get_tree().process_frame
# 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, button.get_event_label(new_key))
assert_false(button.listening)
Loading