Skip to content

Conversation

@K-Tone
Copy link
Collaborator

@K-Tone K-Tone commented Oct 29, 2025

Description

There was a problem reported that if you invoke InputTestFixture.Trigger with anything other than a Button or an Axis, there would be a NotImplementedException thrown.

Here, we address it by logically extending the approach originally taken by the Axis implementation (change the value slightly as an effect from Trigger) to all other possible InputControl variations that we have. We only have two outliers here -- the integer control just gets its value incremented by one instead of the regular small change. Also the TouchState thing gets the next state in the list as well.

Testing status & QA

Local testing

Overall Product Risks

  • Complexity: Low
  • Halo Effect: Low

Checklist

Before review:

  • Changelog entry added.
    • Explains the change in Changed, Fixed, Added sections.
    • For API change contains an example snippet and/or migration example.
    • JIRA ticket linked, example (case %%). If it is a private issue, just add the case ID without a link.
    • Jira port for the next release set as "Resolved".
  • Tests added/changed, if applicable.
    • Functional tests Area_CanDoX, Area_CanDoX_EvenIfYIsTheCase, Area_WhenIDoX_AndYHappens_ThisIsTheResult.
    • Performance tests.
    • Integration tests.
  • Docs for new/changed API's.
    • Xmldoc cross references are set correctly.
    • Added explanation how the API works.
    • Usage code examples added.
    • The manual is updated, if needed.

During merge:

  • Commit message for squash-merge is prefixed with one of the list:
    • NEW: ___.
    • FIX: ___.
    • DOCS: ___.
    • CHANGE: ___.
    • RELEASE: 1.1.0-preview.3.

After merge:

  • Create forward/backward port if needed. If you are blocked from creating a forward port now please add a task to ISX-1444.

@K-Tone K-Tone changed the title Anthony/isxb 1716 inputtestfixture not implemented FIX: [ISXB-1716] Add support for all existing InputControl types in InputTestFixture.Trigger Oct 29, 2025
@K-Tone K-Tone requested a review from ekcoh October 29, 2025 13:56
@K-Tone K-Tone marked this pull request as ready for review October 29, 2025 15:07
@u-pr-agent
Copy link
Contributor

u-pr-agent bot commented Oct 29, 2025

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪

The PR modifies a single method to support multiple control types, which requires checking each new case, but the logic is simple and self-contained.
🏅 Score: 75

The PR successfully adds support for many new control types as intended, but it introduces a bug in the `TouchPhaseControl` handling.
🧪 No relevant tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Potential Bug

The logic for TouchPhaseControl calculates a newIndex for the next phase but then sets the control back to its original phase value on line 803. It should use the newIndex to set the control to the next phase from the values array.

if (control is TouchPhaseControl touchPhaseControl)
{
    var phase = touchPhaseControl.ReadValue();
    var values = Enum.GetValues(typeof(TouchPhase));
    var index = Array.IndexOf(values, phase);
    var newIndex = (index + 1) % values.Length;
    Set(touchPhaseControl, phase);

    return;
}

🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr-agent

Comment on lines +780 to +785
if (control is IntegerControl integerControl)
{
Set(integerControl, integerControl.ReadValue() + 1);

return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Incrementing the IntegerControl value can lead to an integer overflow if the current value is int.MaxValue. This would wrap the value to int.MinValue, which might be an unexpectedly large change. To make the trigger more robust, check for int.MaxValue and decrement instead to ensure a small, predictable change. [general, importance: 6]

Suggested change
if (control is IntegerControl integerControl)
{
Set(integerControl, integerControl.ReadValue() + 1);
return;
}
if (control is IntegerControl integerControl)
{
var value = integerControl.ReadValue();
if (value == int.MaxValue)
Set(integerControl, value - 1);
else
Set(integerControl, value + 1);
return;
}

🤖 Helpful? Please react with 👍/👎 | Questions❓Please reach out in Slack #ask-u-pr-agent

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure we need to do that really, there's barely any contract that Trigger should produce a minimal change

@codecov-github-com
Copy link

codecov-github-com bot commented Oct 29, 2025

Codecov Report

Attention: Patch coverage is 0% with 54 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
....inputsystem/Tests/TestFixture/InputTestFixture.cs 0.00% 54 Missing ⚠️
@@             Coverage Diff             @@
##           develop    #2270      +/-   ##
===========================================
+ Coverage    76.70%   76.82%   +0.11%     
===========================================
  Files          465      476      +11     
  Lines        87919    88714     +795     
===========================================
+ Hits         67442    68153     +711     
- Misses       20477    20561      +84     
Flag Coverage Δ
inputsystem_MacOS_2022.3 5.39% <0.00%> (+0.01%) ⬆️
inputsystem_MacOS_2022.3_project 74.70% <0.00%> (+0.11%) ⬆️
inputsystem_MacOS_6000.0 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.0_project 76.61% <0.00%> (+0.10%) ⬆️
inputsystem_MacOS_6000.2 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.2_project 76.60% <0.00%> (+0.10%) ⬆️
inputsystem_MacOS_6000.3 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.3_project 76.60% <0.00%> (+0.10%) ⬆️
inputsystem_MacOS_6000.4 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_MacOS_6000.4_project 76.62% <0.00%> (+0.11%) ⬆️
inputsystem_MacOS_6000.5 5.18% <0.00%> (?)
inputsystem_MacOS_6000.5_project 76.61% <0.00%> (?)
inputsystem_Ubuntu_2022.3 5.39% <0.00%> (+0.01%) ⬆️
inputsystem_Ubuntu_2022.3_project 74.49% <0.00%> (+0.10%) ⬆️
inputsystem_Ubuntu_6000.0 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.0_project 76.41% <0.00%> (+0.09%) ⬆️
inputsystem_Ubuntu_6000.2 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.2_project 76.41% <0.00%> (+0.09%) ⬆️
inputsystem_Ubuntu_6000.3 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.3_project 76.41% <0.00%> (+0.09%) ⬆️
inputsystem_Ubuntu_6000.4 5.19% <0.00%> (-0.01%) ⬇️
inputsystem_Ubuntu_6000.4_project 76.42% <0.00%> (+0.09%) ⬆️
inputsystem_Ubuntu_6000.5 5.19% <0.00%> (?)
inputsystem_Ubuntu_6000.5_project 76.42% <0.00%> (?)
inputsystem_Windows_2022.3 5.39% <0.00%> (+0.01%) ⬆️
inputsystem_Windows_2022.3_project 74.82% <0.00%> (+0.10%) ⬆️
inputsystem_Windows_6000.0 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.0_project 76.73% <0.00%> (+0.08%) ⬆️
inputsystem_Windows_6000.2 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.2_project 76.73% <0.00%> (+0.08%) ⬆️
inputsystem_Windows_6000.3 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.3_project 76.73% <0.00%> (+0.08%) ⬆️
inputsystem_Windows_6000.4 5.18% <0.00%> (-0.01%) ⬇️
inputsystem_Windows_6000.4_project 76.73% <0.00%> (+0.09%) ⬆️
inputsystem_Windows_6000.5 5.18% <0.00%> (?)
inputsystem_Windows_6000.5_project 76.73% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
....inputsystem/Tests/TestFixture/InputTestFixture.cs 72.11% <0.00%> (-6.01%) ⬇️

... and 24 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@ekcoh ekcoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this @K-Tone and I think this fills the gap called out in the ticket.
However I also believe this makes it even more clear why this is incorrectly implemented to begin with which I think is outside of this PR but wanted to mention anyway for alignment. Since Input System claims to be an extendible system, and decided to expose this test fixture, it means that the number of InputControl or InputDevice types is not fixed. Hence, IMO, implementing something like Trigger here is not scalable. It would have been much better to not have such a function in the fixture at all, and instead add such support via extension methods. Then each plugin implementing the control could provide a test assembly with an extension method providing the needed Trigger implementation for that particular type only. The same goes for Press, Release and all "test extensions" defined in this file. Something to think about for when we do v.2.0 API of this. Maybe we should even file a ticket on it or what do you think? It would be a straightforward refactor. If InputTestFixture would not be public, this would be less important, but still better design IMO, or what do you think?

@K-Tone
Copy link
Collaborator Author

K-Tone commented Oct 31, 2025

Thanks for doing this @K-Tone and I think this fills the gap called out in the ticket. However I also believe this makes it even more clear why this is incorrectly implemented to begin with which I think is outside of this PR but wanted to mention anyway for alignment. Since Input System claims to be an extendible system, and decided to expose this test fixture, it means that the number of InputControl or InputDevice types is not fixed. Hence, IMO, implementing something like Trigger here is not scalable. It would have been much better to not have such a function in the fixture at all, and instead add such support via extension methods. Then each plugin implementing the control could provide a test assembly with an extension method providing the needed Trigger implementation for that particular type only. The same goes for Press, Release and all "test extensions" defined in this file. Something to think about for when we do v.2.0 API of this. Maybe we should even file a ticket on it or what do you think? It would be a straightforward refactor. If InputTestFixture would not be public, this would be less important, but still better design IMO, or what do you think?

Totally agreed, that's what I've been thinking about while working on the ticket.

@K-Tone
Copy link
Collaborator Author

K-Tone commented Oct 31, 2025

Probably not much to review here (no fix), but still CC for viz, so that you're aware this happened @Pauliusd01

@K-Tone K-Tone force-pushed the anthony/isxb-1716-inputtestfixture-not-implemented branch from fe296dc to 8be40a1 Compare October 31, 2025 13:43
@K-Tone K-Tone merged commit ff44a02 into develop Nov 1, 2025
127 checks passed
@K-Tone K-Tone deleted the anthony/isxb-1716-inputtestfixture-not-implemented branch November 1, 2025 10:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants