Repository navigation
test: Verify TextBox KeyDown event fires when key is pressed - #23083
Conversation
There was a problem hiding this comment.
Pull request overview
Adds Skia runtime regression coverage for issue #13983 by validating that TextBox.KeyDown is raised when a focused TextBox receives keyboard input (regular key and Enter).
Changes:
- Add a Skia-only runtime test that injects an
Akey press and assertsTextBox.KeyDownfires. - Add a Skia-only runtime test that injects an
Enterkey press and assertsTextBox.KeyDownfires.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
|
This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or it will be closed in 10 days. |
|
This PR was closed because it has been stalled for 10 days with no activity. |
|
Claude finished @MartinZikmund's task in 2m 34s —— View job Review: 4 findings (1 blocking, 3 advisory)
Overall: The intent is good — regression coverage for issue #13983 is worthwhile, and the test logic is correct. One rule violation must be fixed before merge; three others are advisory. Findings: 1 blocking, 3 advisory
Cross-cutting note: The PR description accurately flags the IME limitation — |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23083/wasm-skia-net9/index.html |
|
|
9c27e06 to
374f071
Compare
|
Claude finished @MartinZikmund's task in 2m 49s —— View job Review: 5 findings (1 blocking, 4 advisory)
Overall: The intent is sound — regression coverage for #13983 is valuable and the test logic itself is correct. One rule violation must be fixed before merge; four others are advisory improvements.
Cross-cutting note: The PR description correctly flags the IME limitation — |
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23083/wasm-skia-net9/index.html |
Extract a shared TapKey helper, drop the fully-qualified type names in favor of usings/aliases, and assert focus landed on the TextBox before injecting keys so a focus failure is not reported as a routing failure. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01GKBgQoAmRmaFoXXZr93iLB
|
Claude finished @MartinZikmund's task in 2m 3s —— View job Review: 1 blocking finding
Overall: The latest commit (884c587) has addressed all three advisory findings from the previous round —
Cross-cutting note: The PR description correctly flags the IME limitation — |
🤖 Addressed PR comments up to this pointAll review threads on this PR were reviewed individually against the current code on
✅ Addressed in
|
| Concern | file:line | Reviewer point | What changed |
|---|---|---|---|
| Noisy fully-qualified type names | Given_TextBox.cs |
Windows.System.* / Windows.UI.Core.* are hard to scan (@copilot-pull-request-reviewer, @Xiaoy312, ultrareview) |
VirtualKey/VirtualKeyModifiers are now unqualified via the file's existing using Windows.System; (in scope inside #if __SKIA__); KeyEventArgs/CorePhysicalKeyStatus use Skia-gated aliases (as Given_UIElement.cs does) to avoid ambiguity a blanket using Windows.UI.Core; would introduce. |
| No focus assertion before key injection | Given_TextBox.cs:1290, 1317 |
Focus(...) can silently fail → misleading "KeyDown never fired" (@copilot-pull-request-reviewer, ultrareview) |
Both tests now assert Assert.AreEqual(tb, FocusManager.GetFocusedElement(WindowHelper.XamlRoot), …) before injecting keys, matching When_Clicked_In_Popup in the same file. |
| Key-press sequence duplicated | Given_TextBox.cs:1260 |
Extract a helper for the key-down/up sequence (@copilot-pull-request-reviewer, ultrareview) | Extracted TapKey(VirtualKey key), mirroring the identically-named helper in Given_UIElement.cs; both tests now call await TapKey(...). |
⏳ Needs @MartinZikmund input (3 threads — left unresolved)
#if __SKIA__ around [TestMethod] → [PlatformCondition(ConditionMode.Include, RuntimeTestPlatforms.Skia)] — Given_TextBox.cs:1259/1271, ultrareview, flagged [Blocking] (three separate threads raise this same concern).
The discovery argument is correct in principle — .claude/rules/runtime-tests.md does say "skip per platform with attributes, not #if on the method". But this is not a mechanical swap, and I will not guess it under an inspection-only pass:
- The body cannot compile off Skia —
InputManager.Keyboard.OnKeyTestingOnlyexists only inInputManager.Keyboard.skia.cs.[PlatformCondition]therefore still requires the body under#if __SKIA__with a non-Skia#elsearm to avoid CS1998 (asyncmethod with noawait) — which is warnings-as-errors on CI. - Precedent conflict:
Given_UIElement.cswraps sixOnKeyTestingOnly-based[TestMethod]s in exactly this#if __SKIA__pattern (verified: lines 395–853). Changing only this PR diverges the two conventions; changing it everywhere is a repo-wide call. - The change spans five platform heads and needs a real build to trust — outside this inspection-only pass.
So this is escalated for your call, Martin: either accept the #if __SKIA__ precedent here (matching Given_UIElement.cs) and dismiss the finding, or greenlight a repo-wide migration to [PlatformCondition] + body-gating that I'll do with a proper build. Happy to do either — just say which.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23083/wasm-skia-net9/index.html |
Closes #13983
Summary
Issue #13983 reports that
TextBox.KeyDownevent is not triggered on Android (Google Pixel 6) when pressing virtual keyboard keys.Two runtime tests added in
Given_TextBox.csthat verifyTextBox.KeyDownfires when pressing a regular key (A) and the Enter key on a focused TextBox.The reported issue appears to be potentially fixed — the test(s) pass on current master (Skia target).
Test(s) added
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.cs→When_TextBox_Focused_And_Key_Pressed_Then_KeyDown_Firessrc/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.cs→When_TextBox_Focused_And_Enter_Pressed_Then_KeyDown_FiresNotes
The issue was reported on Android (Google Pixel 6, Uno 4.10). Runtime tests run on Skia only — the fix should be verified on native Android as well. The tests use
OnKeyTestingOnlywhich bypasses the virtual keyboard layer, so they serve as regression coverage for the Xaml event routing pipeline, but do not exercise the Android input method (IME) path that may be the actual source of the bug.