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

AccessibilityRenderExtension doesn't work correctly with RenderingMode.SHRINK #1350

Open
VirtualParticle opened this issue Mar 20, 2024 · 5 comments · May be fixed by #1355
Open

AccessibilityRenderExtension doesn't work correctly with RenderingMode.SHRINK #1350

VirtualParticle opened this issue Mar 20, 2024 · 5 comments · May be fixed by #1355
Assignees
Labels
bug Something isn't working
Milestone

Comments

@VirtualParticle
Copy link

Description
Using the AccessibilityRenderExtension is useful for analyzing accessibility information, but the information added to the side of the screenshot is cropped out when the SHRINK rendering mode is used.

Steps to Reproduce
Here is an example test:

class ExampleTest {

    @get:Rule
    val paparazzi = Paparazzi(
        renderingMode = RenderingMode.SHRINK,
        renderExtensions = setOf(AccessibilityRenderExtension()),
    )

    @Test
    fun exampleTest() {
        paparazzi.snapshot {
            Box(
                modifier = Modifier
                    .background(Color.White)
                    .padding(16.dp)
            ) {
                Text(text = "Hello, world!")
            }
        }
    }

}

Expected behavior
I would expect for the accessibility information on the side of the screenshot to be included in the cropped screenshot, that is to say that the crop would take into account the size of the accessibility information, even if it was taller than the actual content.

Additional information:

  • Paparazzi Version: 1.3.3
  • OS: MacOS
  • Compile SDK: 34
  • Gradle Version: 8.6
  • Android Gradle Plugin Version: 8.3.0

Screenshots
Screenshot using SHRINK:
image

Screenshot using NORMAL:
image

I've given fixing this a look and it seems like one of the challenges here is that the accessibility information is a canvas element which can't easily use things like WRAP_CONTENT.

@VirtualParticle VirtualParticle added the bug Something isn't working label Mar 20, 2024
@jrodbx jrodbx added this to the 1.3.4 milestone Mar 22, 2024
@MedetZhakupov
Copy link

Is it considered blocker for the release 1.3.4 @adamalyyan ?

@adamalyyan
Copy link
Collaborator

I don't think this would be considered a blocker but I'll defer to @geoff-powell as his PR will resolve this!

@geoff-powell
Copy link
Collaborator

Ya I think this might not make 1.3.4. Need to figure out a better way to render accessibility information in a layout so we can correctly measure the details view.

@colinmarsch
Copy link
Contributor

I've been investigating the possible resolutions to this issue and I wonder if the best path forward might be to simply disallow accessibility snapshots from being taken in the SHRINK rendering mode.

It seems to me there are two possible technical paths to resolve this issue, both with drawbacks:

  1. @geoff-powell 's PR (Add support for render mode SHRINK for AccessibilityRenderExtension #1355) can enable SHRINK support for accessibility snapshots, however some cases where the legend size is larger than the view under test will run into the legend text being cutoff
  2. We find a way to ensure that the legend size can be properly measured (likely requiring another layout pass) and then base the generated snapshot size off of that. In this case the SHRINK rendering mode feels not respected as the generated snapshot will no longer be directly constrained to the size of the view under test.

Because of this, I think the option to disable the SHRINK rendering mode when the AccessibilityRenderExtension is used (with clear error messaging stating this) is potentially the best path forward here. If there are situations where it is vital to use SHRINK with the AccessibilityRenderExtension that I might be missing I would love to learn more about them!

@VirtualParticle
Copy link
Author

The best use-case for SHRINK and accessibility is just testing smaller components that don't need a whole device-sized screenshot. Our solution has been to manually crop the size with screenHeight and screenWidth or just live with the larger screenshot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants