Repository navigation
ADFA-7258: Wait for the editor's async layout in IDEEditorAccessibilityTest - #2301
davidschachterADFA wants to merge 2 commits into
Conversation
…tyTest "accessibility click requests soft keyboard when editable" failed since it was added in d0bdfa8. The editor is right; the test raced a background thread. IDEEditor's a11y click calls sora's CodeEditor.showSoftInput(), which only reaches InputMethodManager.showSoftInput() when isEditable() is true. isEditable() is false while layoutBusy: sora measures text on a background executor and clears the flag in a callback it posts to the main looper. Robolectric runs that callback only when the test idles the looper, and setUp() idled once, right after setText(), before the layout finished. The click then hit a busy editor and the IMM was never called. setUp() now waits until sora's layout executor is idle and the editor is editable, and the keyboard test asserts that precondition. A temporary 100-iteration stress test failed 99/100 with the old setUp and 0/100 with the new one. The wait reads sora's private static AbstractLayout.executor by reflection; if sora renames it, setUp fails loudly rather than flakily. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
From the independent review of #2301: - The KDoc said isEditable() stays false until the layout callback runs. In fact sora's layout task sets layoutBusy itself when it starts, so isEditable() can read true before then. That is why the helper also waits for the executor to be idle. The second settled poll makes a missed task unlikely, not impossible. - The timeout message now gives the executor's queue size and active count, isEditable and isFormatting, and names the limit once. - The isEditable assertion before the click now says what failed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.
Tip: disable this comment in your organization's Code Review settings.
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
ADFA-7258
Fixes
IDEEditorAccessibilityTest's "accessibility click requests soft keyboard when editable", which has failed since it was added in d0bdfa8 (ADFA-4605, PR #2171). The test was wrong; the editor is right. Test-only change, one file, (+36 / -1), in two commits; the second answers the independent review.Why it failed
IDEEditor's accessibility click calls sora'sCodeEditor.showSoftInput(). That reachesInputMethodManager.showSoftInput()only whenisEditable()is true.isEditable()iseditable && !layoutBusy && !isFormatting. AftersetText(), sora measures the text in a task on a background executor (AbstractLayout.executor). The task setslayoutBusywhen it starts (LineBreakLayout,WordwrapLayout) and clears it in a callback it posts to the main looper.setUp()idled once, right aftersetText(), usually before the background layout finished. So the click hit a busy editor, and the IMM was never called.A temporary print at click time showed
layoutBusytrue, and the IMM'sshowSoftInputnever ran. A temporary 100-run stress test failed 99/100 before this change and 0/100 after it. The test also fails at d0bdfa8 itself, so no later commit broke it.The change
setUp()calls a newawaitEditorLayout()in place of the singleidle(). It polls until sora's layout executor has no queued or running task andeditor.isEditableis true, twice in a row, idling the main looper each time. Checking onlyisEditableisn't enough: it can read true before the layout task starts and setslayoutBusy. The second poll makes it unlikely, though not impossible, to miss a task that has left the queue but not yet started. After 10 s it fails with a message giving the executor's queue size and active count,isEditableandisFormatting.editor.isEditablebefore the click, with a message, so a future failure points at the precondition rather than at the IMM.awaitEditorLayout()reads sora's private staticAbstractLayout.executorby reflection, because sora exposes no "layout finished" signal. If a sora upgrade renames that field,setUp()fails at once withNoSuchFieldExceptionin all 5 tests, rather than becoming flaky; a type change fails fast too. The one quiet case is sora keeping the field but no longer using it: the helper then rests onisEditablealone.Not in this PR
The same race can happen on a phone, though I've only found it by reading the code. A TalkBack double-tap (or an ordinary tap) that lands while the editor is re-laying out its text, such as when a file opens, the text size or word wrap changes, or the phone rotates, brings up no keyboard. A second tap works. Changing the editor to wait for the layout is a separate change, tracked in ADFA-7270.
Sibling tests checked. The only other unit test that builds a real sora editor is
StaleWordwrapRowsTest(ADFA-6543). It has the same singleidle()aftersetText(), and in the review's probe its layout was still running after that idle in 50/50 runs. Its pending word-wrap callback may then rebuildrowTableduring the test's last idle, so its final assertion might pass even without the fix's relayout step (rebuildLayout()). That isn't proven, and it's left alone here: ADFA-7271 tracks checking and fixing it.EditorCloseTabTestmocks its editors, and the instrumentedIDEEditorTestruns on a real looper.Testing
./gradlew :editor:testV8DebugUnitTest --tests '*IDEEditorAccessibilityTest*': 5/5 pass (4/5 before)../gradlew spotlessCheck: passes.:editorunit tests (ADFA-5328): PR CI doesn't run them, and the nightly Analyze run, which does, ignores their failures. So the run above is the check. The stress test isn't committed.idle().🤖 Generated with Claude Code
https://claude.ai/code/session_01Vh2DAXGyHbMzjSsi2zbrkw