Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make A11y Dump more generic via SnapshotTransformer #291

Open
yschimke opened this issue Apr 9, 2024 · 5 comments
Open

Make A11y Dump more generic via SnapshotTransformer #291

yschimke opened this issue Apr 9, 2024 · 5 comments

Comments

@yschimke
Copy link
Contributor

yschimke commented Apr 9, 2024

The A11y dump #55 doesn't suit my purpose. There isn't an easy way to supply an alternate strategy.

Ideally the existing A11y dump feature and other features could be implemented using a clean API.

Examples

  • Current Roborazzy a11y dump
  • My A11y screenshots
  • Highlighting / masking sections in a screenshot

I ended up using the RoboComponent.Screen class to grab a bitmap, then transforming it to show A11y info in a resized bitmap.

See here https://github.com/google/horologist/pull/2182/files#diff-7d20314095381dcb544af22f8ddd40d6dd3121bd95864b77eaa155d724afa678R124

    public fun captureScreenA11yRoboImage(
        filePath: String,
        roborazziOptions: RoborazziOptions,
    ) {
        Espresso.onIdle()

        val screenImage: Bitmap = captureScreenImageToBitmap(roborazziOptions) // uses RoboComponent.Screen

        val annotatedImage: Bitmap = A11ySnapshotTransformer().transform(composeRule.onRoot(), screenImage)

        annotatedImage.captureRoboImage(filePath, roborazziOptions)
    }
@yschimke
Copy link
Contributor Author

yschimke commented Apr 9, 2024

Example

image

@takahirom
Copy link
Owner

Thank you, as always. It seems that you would like to access the screen bitmap, is that correct? Or is there something else you want to do?

@yschimke
Copy link
Contributor Author

At minimum I guess a clean API to capture the bitmap.

But I'm hoping there is some interceptor style API to postprocess the bitmap with contextual info before comparison.

@takahirom
Copy link
Owner

takahirom commented May 3, 2024

I have a different use case for this. I want to focus on crucial screen elements, such as the visibility of a button. Therefore, I'd like to highlight that area with a square. We might need to develop more basic APIs rather than practical ones for this purpose.

captureRoboImage() { roboCanvas ->
  roboCanvas.drawRectWithText(onNodeWithTag('subscribe_button').toRoboComponent(), "Subscribe Button")
}

@yschimke
Copy link
Contributor Author

yschimke commented May 3, 2024

@takahirom That sounds great. I think I could rework the current A11y transformer I have to do those draw operations.

Although I hope it's possible to expand or reduce the result bitmap size.

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

No branches or pull requests

2 participants