Replace ViewHelpers with explicit measure/layout; childCountTest uses view.post polling#113
Open
EmilioBejasa wants to merge 1 commit into
Open
Replace ViewHelpers with explicit measure/layout; childCountTest uses view.post polling#113EmilioBejasa wants to merge 1 commit into
EmilioBejasa wants to merge 1 commit into
Conversation
…ith view.post check - Remove ViewHelpers from constructViewTest and childCountTest (IsolatedTest.kt) and testSimpleTextView (ScreenshotTest.kt); use explicit measure()/layout() calls - Replace 30s poll loop in childCountTest with a self-rescheduling Runnable posted via view.post(), driven by the main-thread Handler that WindowAttachment.dispatchAttach installs in AttachInfo; block test thread on CompletableFuture.get(5s) - Remove childCountScreenshotTest (duplicate of childCountTest + screenshot) - assertGoodTask now captures and awaits startTask so the bg executor is drained before the future is polled Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ViewHelpersfromIsolatedTest.kt(constructViewTest,childCountTest) andScreenshotTest.kt(testSimpleTextView); replace with explicitview.measure()/view.layout()callschildCountTestwith a self-reschedulingRunnableposted viaview.post().WindowAttachment.dispatchAttachinjects a realHandler(bound to the main Looper) intoAttachInfo, soview.post()routes to the mainMessageQueue. TheRunnablecheckschildCountevery 50ms on the main thread and completes aCompletableFuture<Int>when children appear; the test thread blocks onfuture.get(5s).childCountScreenshotTest— it was a duplicate ofchildCountTestplus a screenshot; the screenshot half will live in a follow-up PRstartTaskreturn value andassertGoodTaskit before waiting on the future, so the bg executor is fully drained before polling beginsWhy view.post works here
WindowAttachment.dispatchAttach(screenshot-tests-for-android) doesn't add the view to a real window — it uses reflection to inject a fakeAttachInfo. ThatAttachInfois constructed withnew Handler()on the main thread, soview.post(r)callsattachInfo.mHandler.post(r), which posts to the main Looper.OnGlobalLayoutListenerdoes not work here because there's no realViewRootImpldriving layout traversals.Test plan
simpleTestpassesconstructViewTestpasseschildCountTestpasses (no sleep, no CountDownLatch, one setuprunOnMainSync)recordDebugAndroidTestScreenshotTestsucceeds;addViewHookTestscreenshot shows "Hello" (not blank)verifyDebugAndroidTestScreenshotTestpasses🤖 Generated with Claude Code