paparazzi icon indicating copy to clipboard operation
paparazzi copied to clipboard

Hard to cleanly override SnapshotHandler

Open yschimke opened this issue 2 years ago • 2 comments

Attempting a temporary fix I tried to decorate the snapshot handler.

It seems awkward to do this currently, since determineHandler is private in Paparazzi.Companion.

    @get:Rule
    val paparazzi = Paparazzi(
        deviceConfig = GALAXY_WATCH4_CLASSIC_LARGE,
        theme = "android:ThemeOverlay.Material.Dark",
        maxPercentDifference = 0.1,
        snapshotHandler = WearSnapshotHandler(determineHandler(0.1))
    )

    private val isVerifying: Boolean =
        System.getProperty("paparazzi.test.verify")?.toBoolean() == true

    private fun determineHandler(maxPercentDifference: Double): SnapshotHandler =
        if (isVerifying) {
            SnapshotVerifier(maxPercentDifference)
        } else {
            HtmlReportWriter()
        }

yschimke avatar Apr 16 '22 11:04 yschimke

I won't need this after https://github.com/cashapp/paparazzi/pull/411, but I assume this is why it is there.

yschimke avatar Apr 16 '22 12:04 yschimke

If I want to use my own custom SnapshotHandler, a lot of the types you need to do similar are also internal.

ImageUtils, Snapshot.toFileName and so on.

Is a good way to take this forward to show examples of where I want to use these? Or they will remain internal, and I should put PRs up to add features I'd like (nothing critical, just nice to haves).

yschimke avatar Apr 17 '22 08:04 yschimke