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

Add support for render mode SHRINK for AccessibilityRenderExtension #1355

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

geoff-powell
Copy link
Collaborator

Fixes #1350

@geoff-powell geoff-powell force-pushed the gpowell/accessibility-render-extension-shrink branch 2 times, most recently from 39280d0 to 118bcf2 Compare March 22, 2024 18:21
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious: why move from the unit test to the plugin test? It'd be nice keeping the former, unless there's a good reason.

Basically, the commit prior: https://github.com/cashapp/paparazzi/compare/c3e10703ecd6daab2a6f30e8118c511680437481..39280d0a467518e4b36799cfc25ec6c8ea16ad19

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Cool, got a comment in slack about moving it. I reverted that change to make the change smaller and straight forward

@geoff-powell geoff-powell force-pushed the gpowell/accessibility-render-extension-shrink branch from 118bcf2 to c3e1070 Compare March 25, 2024 14:07
@geoff-powell geoff-powell force-pushed the gpowell/accessibility-render-extension-shrink branch from c3e1070 to a8f28bd Compare March 25, 2024 14:13
@VirtualParticle
Copy link

Thank you for working on this! One thing I'll note is that it seems like this still runs into an issue if the content description takes up more space than the actual content. Take this test, for example:

@Test
fun `verify long content description`() {
  paparazzi.snapshot {
    Text(
      text = "Text",
      modifier = Modifier
        .padding(10.dp)
        .semantics {
          contentDescription = "This is a very long content description"
        },
    )
  }
}

It produces this screenshot:
image
Ideally, the test would recognize that the accessibility info is bigger and the screenshot would expand to fit the content description. Might be out-of-scope for this though.

import java.io.File
import javax.imageio.ImageIO

class AccessibilityRenderExtensionShrinkTest {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: can we combine this with AccessibilityRenderExtensionTest + TestParameterInjector? Looks like renderingMode is the only argument that differs between the two.

@geoff-powell
Copy link
Collaborator Author

Thank you for working on this! One thing I'll note is that it seems like this still runs into an issue if the content description takes up more space than the actual content. Take this test, for example:

@Test
fun `verify long content description`() {
  paparazzi.snapshot {
    Text(
      text = "Text",
      modifier = Modifier
        .padding(10.dp)
        .semantics {
          contentDescription = "This is a very long content description"
        },
    )
  }
}

It produces this screenshot: image Ideally, the test would recognize that the accessibility info is bigger and the screenshot would expand to fit the content description. Might be out-of-scope for this though.

Ya so that issue is due to the text having to be rendered after draw and not being part of the layout scope. Currently paparazzi render extensions execute on 1 layout pass. Unfortunately, we can only gather compose semantics after layout. Still thinking through other ways to fix this limitation

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.

AccessibilityRenderExtension doesn't work correctly with RenderingMode.SHRINK
3 participants