Repository navigation
test(textbox): De-flake iOS single-tap caret assert - #23963
Conversation
When_Touch_SingleTap_Places_Caret_iOS asserted CaretMode exactly once after a bare WaitForIdle, but ThumblessCaretShowing/Hidden are the two halves of the caret blink cycle, flipped every 500ms by a DispatcherTimer that Select() restarts on each caret move. Any tap-to-assert gap longer than one blink period legitimately leaves the caret hidden, which is what failed the iOS Skia shard on an unusually slow simulator agent (all three in-process retries failed there). Wait for the expected mode instead, with an explicit 3000ms timeout since WaitFor defaults to 1000ms. The Android expectation is a thumbed mode that stops the timer, so it still matches on the first evaluation, and a genuine focus loss still fails after the timeout with the same symptom. Applies the same wait to AssertTouchGestureOnEmptyBoxOpensFlyout, the one remaining single-shot assert on a blinking mode; it is green today only because its callers are gated off Skia-UIKit. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
🟢 Ready to approve
The change is confined to runtime tests, uses an existing WindowHelper.WaitFor API correctly (including timeoutMS), and I did not find any correctness or maintainability issues in the updated assertions.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR hardens TextBox touch runtime tests on Skia to avoid flakiness caused by the iOS thumbless caret blinking (500ms cycle), by waiting for the expected CaretMode instead of sampling it once.
Changes:
- Replaces a single-shot
Assert.AreEqual(expectedCaret, SUT.CaretMode)withWindowHelper.WaitFor(() => SUT.CaretMode == expectedCaret, timeoutMS: 3000, ...)for the single-tap caret assertion. - Applies the same “wait for expected caret mode” approach to the empty-box gesture → flyout scenario to avoid mid-blink sampling failures.
File summaries
| File | Description |
|---|---|
src/Uno.UI.RuntimeTests/Tests/Windows_UI_Xaml_Controls/Given_TextBox.skia.cs |
Updates two caret-mode assertions to wait (with a 3000ms timeout) for the expected CaretMode, avoiding iOS blink-cycle timing flakiness. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
|
🤖 Your WebAssembly Skia Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-23963/wasm-skia-net9/index.html |
|
The build 225780 found UI Test snapshots differences: Details
|
|
@Mergifyio backport release/stable/6.7 |
✅ Backports have been createdDetails
|
…6.7/pr-23963 test(textbox): De-flake iOS single-tap caret assert (backport #23963)
GitHub Issue: #9080 (tracking epic — intentionally not auto-closed by this PR)
PR Type:
🏗️ Build or CI related changes
What changed? 🚀
Given_TextBox.When_Touch_SingleTap_Places_Caret_iOSfailed the Tests - iOS Skia Runtime Tests 3 shard:ThumblessCaretShowing/ThumblessCaretHiddenare the two halves of the caret blink cycle, not twodifferent outcomes. A 500 ms
DispatcherTimerflips between them (TextBox.skia.cs:79,TimerOnTickat:1504-1517), andSelect()restarts that timer on every caret move (:548-555). The test tapped, awaited abare
WaitForIdle(), then sampledCaretModeexactly once — so any tap→assert gap longer than one blinkperiod legitimately observes the hidden half and fails. It is the only runtime test that asserted a blinking
mode without a wait.
That gap only opens on the iOS simulator, where focus drives a full native keyboard/IME handshake that
WaitForIdlehas to drain (StartImeSession(); the device log shows a keyboard dismiss + show cycle per focus,UIKeyboardAnimationDuration = 0.25plus a 0.4 sBSAnimationSettings). Desktop and Android Skia have noper-focus keyboard cost, which is why the test is green there. On the failing run the shard's agent was
unusually slow — 1 h 4 m vs 29–52 m for the other three iOS shards — and all three in-process retries failed,
so it was reproducible on that agent rather than a one-off.
This waits for the expected mode instead of sampling it:
Assert.AreEqual("", SUT.SelectedText); - Assert.AreEqual(expectedCaret, SUT.CaretMode); + await WindowHelper.WaitFor( + () => SUT.CaretMode == expectedCaret, + timeoutMS: 3000, + message: $"tap should settle the caret in {expectedCaret}");Notes on the choices:
timeoutMS: 3000matters —WindowHelper.WaitFordefaults to 1000 ms(
TestServices.WindowHelper.cs:314), only two blink periods on the one platform that stalls. Line 5072 ofthe same file already passes 3000.
timer (
TextBox.skia.cs:113-117), so it still matches on the first evaluation with no added pumping._caretModeinitializes toThumblessCaretHidden(
TextBox.skia.cs:55), so that variant would pass vacuously if the tap never registered. Waiting forShowingrequires focus plus a running timer.Assert.AreEqual("", SUT.SelectedText)is kept ahead of the wait, so a tap ever mis-read as a double-tapstill fails there with a clear message instead of timing out.
[PlatformCondition]added. Gating this off Skia-UIKit would drop coverage on the very platform whoseconvention the test emulates — worse than the flake it would hide. A genuine focus loss also still fails
after the timeout with the same symptom (
TimerOnTickno-ops when unfocused), so this does not mask aregression.
The same wait is applied to
AssertTouchGestureOnEmptyBoxOpensFlyout, the one remaining single-shot assert ona blinking mode. It samples
CaretModeafter aTask.Delay(1200)and a flyout-open wait — well past one blinkperiod — and is green today only because its callers are gated to
SkiaDesktop | SkiaAndroid, not because theassert is safe. (The third
ThumblessCaretsite,AssertTouchTapOnEmptyBoxPlacesCaret, already usedWaitFor.)Test-only change — no product code touched. The caret is supposed to blink; the test had to tolerate it.
Validation: compile —
Uno.UI.RuntimeTests.Skianet10.0, 0 errors / 0 warnings. Runtime — not run locally;a Skia Desktop run cannot reproduce an iOS-simulator timing flake, so the iOS shards on this PR are the real
gate. Per the investigation this should not be called proven until those shards come back green.
PR Checklist ✅
Screenshots Compare Test Runresults. — N/A, no rendering change🤖 Generated with Claude Code