Skip to content

1.47.0

Choose a tag to compare

@takahirom takahirom released this 11 Aug 05:09
· 105 commits to main since this release
0f085a2

Compose Preview Tester Customization

Added Capturer interface to AndroidComposePreviewTester for customizing capture behavior (#716). This allows setting custom
comparison thresholds and other RoborazziOptions for generated Compose preview tests.

import com.dropbox.differ.SimpleImageComparator
import com.github.takahirom.roborazzi.*

@ExperimentalRoborazziApi
class MyCustomComposePreviewTester(
  private val defaultCapturer: AndroidComposePreviewTester.Capturer = AndroidComposePreviewTester.DefaultCapturer()
) : AndroidComposePreviewTester(
  capturer = { parameter ->
    val customOptions = parameter.roborazziOptions.copy(
      compareOptions = parameter.roborazziOptions.compareOptions.copy(
        // Set custom comparison threshold (0.0 = exact match, 1.0 = ignore differences)
        imageComparator = SimpleImageComparator(maxDistance = 0.01f)
      )
    )
    defaultCapturer.capture(
      parameter.copy(roborazziOptions = customOptions)
    )
  }
)

Fixes #703. Thanks @pavel163 for the issue report and @sergio-sastre for the review!

What's Changed

  • Minor tweak to documentation for Groovy DSL by @smugleafdev in #715
  • Add Capturer interface for customizing AndroidComposePreviewTester by @takahirom in #716

New Contributors

Full Changelog: 1.46.1...1.47.0