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

Inconsistent screenshot-testing with paparazzi and GlideImage composable #5402

Open
hhpettersen opened this issue Apr 29, 2024 · 0 comments
Open

Comments

@hhpettersen
Copy link

hhpettersen commented Apr 29, 2024

Glide Version: 1.0.0-beta01

Integration libraries: Not relevant

Device/Android Version: Ran tests on multiple emulators.

Issue details / Repro steps / Use case background:
The issue involves inconsistent loading of images in a screenshot test with Paparazzi using the GlideImage composable. Sometimes the image from a URL loads successfully, other times the image is blank, and occasionally, only the loading placeholder is shown. This inconsistency is problematic for reliable UI testing and screenshot generation.

Composable

val adImageSize = 50.dp
val requestSize = with(LocalDensity.current) { adImageSize.toPx().toInt() }

Box {
    GlideImage(
        model = ad?.image.orEmpty(),
        contentDescription = stringResource(R.string.content_description_adimage),
        contentScale = ContentScale.FillBounds,
        loading = placeholder(painterResource(id = R.drawable.placeholder)),
        failure = placeholder(painterResource(id = R.drawable.ad_placeholder)),
        modifier = Modifier
            .size(adImageSize)
            .align(Alignment.Center)
            .clip(shapes.roundedCornerExtraSmall),
        requestBuilderTransform = {
            it.apply(RequestOptions().override(requestSize))
        },
    )
}

Test

@RunWith(TestParameterInjector::class)
class ChatScreenshotTest(
    @TestParameter
    nightMode: NightMode,
) {
    @get:Rule
    val paparazzi = Paparazzi(
        deviceConfig = DeviceConfig.PIXEL_6_PRO.copy(
            nightMode = nightMode,
        ),
        theme = "android:Theme.Material.ActionBar",
        snapshotHandler = if (PaparazziConfig.isVerifying) {
            SnapshotVerifier(
                maxPercentDifference = PaparazziConfig.maxPercentDifference,
                rootDirectory = PaparazziConfig.dir
            )
        } else {
            HtmlReportWriter(snapshotRootDirectory = PaparazziConfig.dir)
        }
    )

    @Test
    fun textMessages() {
        paparazzi.snapshot {
            CompositionLocalProvider(
                LocalInspectionMode provides true,
            ) {
                Theme {
                    ConversationPreview(createPreviewTextMessages())
                }
            }
        }
    }
}

I also reaised an issue on Paparazzi since I am uncertain where the bug recides at this point: cashapp/paparazzi#1396

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

1 participant