-
Notifications
You must be signed in to change notification settings - Fork 327
FIX: UISelectable's OnSubmit and OnCancel are not triggered when using InputTestFixture with mock keyboard [ISXB-1561] #2228
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
base: develop
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅ @@ Coverage Diff @@
## develop #2228 +/- ##
===========================================
- Coverage 68.14% 68.13% -0.02%
===========================================
Files 367 367
Lines 53662 53679 +17
===========================================
+ Hits 36570 36576 +6
- Misses 17092 17103 +11
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
Packages/com.unity.inputsystem/InputSystem/Plugins/UI/InputSystemUIInputModule.cs
Show resolved
Hide resolved
@@ -2318,6 +2317,26 @@ private void OnTrackedDevicePositionCallback(InputAction.CallbackContext context | |||
#endif | |||
} | |||
|
|||
private void OnSubmit(InputAction.CallbackContext context) | |||
{ | |||
m_SubmitCancelState.device = context.control.device; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is from OnSubmitCancelCallback that got removed
{ | ||
m_SubmitCancelState.device = context.control.device; | ||
|
||
if (!context.ReadValueAsButton()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So the way this is expected to work is that if we got into the callback, then this button has been interacted with. If it's been interacted with, and it is not pressed, then it's been released. Does this sound correct? Any corner cases here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for looking into this, generally changes look good but I am still confused around why the code before the diff wasn't working as expected to I need to run this to give my final comments/feedback on the proposed fix. I'll get back to you.
base.TearDown(); | ||
} | ||
|
||
private static bool[] FrameWaitingOptions = { true, false }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great you added this to get coverage on both scenarios/flavours. Maybe even motivate this with an inline comment, e.g.
// Test scenarios for separating Press and Release into two separate frames or processing them in the same frame.
IMO it makes it easier to decipher the tests after that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another option would be to make this an integer, framesToWait and let the above represent { 1, 0 }, then we could also easily extend it to case 2 as well where there is a "null frame" in between.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, fair. I have this comment right below, where it gets used: We'd like to test both options to be safe with rapid actions that happened within a single frame
. Can totally do it here instead if you prefer. As to the integer wait frames - I don't know, can of course do that if you fancy but to me it looked there was no difference whether to wait for one frame or any other >0 amount of frames.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I gess it's fine as is, I cannot say if doing it in 2 non-consecutive frame impacts the logic or not.
@K-Tone looks like formatter needs to be run on the code |
Yes. The problem as I perceive it is that action.WasReleasedThisFrame actually relies on when an EventSystem.Update happened (which is just a regular MonoBehaviour, so it's really when we update all MonoBehaviours). Because of that it's really challenging to trigger a Release in code such that we do it before EventSystem.Update is called this frame. In the user example:
I believe it's not a problem for normal input that reads actual devices because it's assumably interacted with before scripts update. In these kinds of automations with mock keyboards we're just running off an unfortunate frequency/phase. |
@@ -9,7 +9,6 @@ Due to package verification, the latest version below is the unpublished version | |||
however, it has to be formatted properly to pass verification tests. | |||
|
|||
## [Unreleased] - yyyy-mm-dd | |||
- Fixed InputControl picker not updating correctly when the Input Actions Window was dirty. [ISXB-1221](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1221) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my brain left the building when I filled that up, it should have totally been in another section. Moving now.
… was impossible to do automatic testing with mocks
b204ba9
to
9ffb53a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this looks good. Great work @K-Tone
Seems like the bug still reproes in the user project, waiting for changes |
Description
Here we attempt to address an ancient regression that happened when we moved from using the cached button states obtained via
performed
callbacks to using InputAction.wasReleasedThisFrame. The problem with wasReleasedThisFrame is that it gets updated before we can get control in tests, so there's really no direct way to trigger it from tests. That said, we have a simple caching approach here that hopefully works well.Testing status & QA
Local testing, 4 new regression tests to cover for the cases where we trigger events from a mock keyboard, both with a frame delay as well as without a frame delay. QA pass pending.
Overall Product Risks
Checklist
Before review:
Changed
,Fixed
,Added
sections.Area_CanDoX
,Area_CanDoX_EvenIfYIsTheCase
,Area_WhenIDoX_AndYHappens_ThisIsTheResult
.During merge:
NEW: ___
.FIX: ___
.DOCS: ___
.CHANGE: ___
.RELEASE: 1.1.0-preview.3
.After merge: