Skip to content

test: screenshot plain Android view in IsolatedTest#100

Open
EmilioBejasa wants to merge 4 commits intomainfrom
screenshot-isolated-test
Open

test: screenshot plain Android view in IsolatedTest#100
EmilioBejasa wants to merge 4 commits intomainfrom
screenshot-isolated-test

Conversation

@EmilioBejasa
Copy link
Copy Markdown
Collaborator

Summary

  • Adds a screenshotPlainView test to IsolatedTest that snapshots a plain Android View
  • Verifies the screenshot infrastructure works end-to-end without needing React Native rendering
  • Fixes the "view is not measured" error by calling measure() + layout() manually before snapping

Test plan

  • CI passes with screenshotPlainView test green
  • Screenshot artifact is recorded for plain_view

🤖 Generated with Claude Code

EmilioBejasa and others added 4 commits April 1, 2026 12:05
Verifies the screenshot infrastructure works without React Native.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Test

Replaces the plain Android view screenshot with an actual React Native
surface screenshot, which is the real goal of this isolated test.
Uses the same WindowManager + software layer approach as BaseStoryScreenshotTest
so Fabric can commit its render tree in a test process.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tSimpleTestComponent

- Use ContextThemeWrapper (matches BaseStoryScreenshotTest pattern)
- Poll childCount on main thread with 30s timeout to handle cold JS bundle load
- Set software layer recursively after Fabric mounts children (child views
  default to hardware acceleration which Screenshot.snap() can't capture)
- Call Screenshot.snap() on the main thread

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@EmilioBejasa EmilioBejasa requested review from tdrhq April 2, 2026 15:53
val view = surface.view
?: throw IllegalStateException("ReactSurface returned a null view")

val wm = context.getSystemService(android.content.Context.WINDOW_SERVICE) as WindowManager
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're going in circles, I think we specifically said we didn't want to do it using WindowManager.

PixelFormat.TRANSLUCENT
).apply { alpha = 0f }

instrumentation.runOnMainSync {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we also specifically said we wanted to do everything without inter-thread synchronization. There can be one runOnMainSync, but all the code needs to be in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants