Skip to content

Conversation

@takahirom
Copy link
Owner

What

Add a Capturer interface to AndroidComposePreviewTester to enable customization of screenshot capture behavior.

Why

Addresses Issue #703 - Users requested the ability to set custom changeThreshold for generated Compose preview tests. The composition-based solution allows users to customize capture behavior while maintaining backward compatibility.

@takahirom
Copy link
Owner Author

@sergio-sastre Thanks as always! 🙏
This PR addresses #703 - adds a way to customize RoborazziOptions (like changeThreshold) in generated Compose Preview tests.
Since this builds on ComposablePreviewScanner, would love your feedback on the approach!

Key: Added a Capturer interface to AndroidComposePreviewTester for customizing capture behavior while maintaining backward compatibility

@sergio-sastre
Copy link
Contributor

Sure! I’ll take a look at this this weekend whenever I find time 😊

Copy link
Contributor

@sergio-sastre sergio-sastre left a comment

Choose a reason for hiding this comment

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

@takahirom
I think it might be more comfortable for the user to just set a general threshold via the roborazzi plugin (which would be overriden by the annotation value for those previews with it), so they would not have to deal with the tester.

Moreover, one could make it even more flexible by extending the RoboComposePreviewOptions to add a threshold parameter.

In doing so, the user could set a different threshold for each preview separately via the annotation. If not threshold set, the user would default to the "general threshold" set in the plugin option.

@takahirom
Copy link
Owner Author

@sergio-sastre
Thank you for your feedback! I agree that setting the threshold from the user's perspective would be more comfortable. However, I think that if we add a public API for threshold now, the next requests will probably be for APIs for hshift, file name, scale, and so on. If we keep adding more and more public APIs, it may become unmanageable. For now, I think introducing this change will help reduce the pain for users, so I would like to proceed with it as is.

@takahirom
Copy link
Owner Author

I think there might be a few more APIs we should expose on @RoboComposePreviewOptions. I’m thinking of opening an issue to gather ideas—would that work for you?

@sergio-sastre
Copy link
Contributor

I think there might be a few more APIs we should expose on @RoboComposePreviewOptions. I’m thinking of opening an issue to gather ideas—would that work for you?

Sure!
I think this solution looks fine to avoid that pain for now, and we can discuss further ideas in a separate issue 😊

@takahirom takahirom merged commit b08fd9c into main Aug 11, 2025
8 checks passed
@takahirom takahirom deleted the tm/add-compose-preview-tester-customization branch August 11, 2025 05:04
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.

3 participants