Skip to content

Instantly share code, notes, and snippets.

@ashley-figueira
Last active March 9, 2024 16:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashley-figueira/7b1e8eb770766c0c87f0c96c65cf9e81 to your computer and use it in GitHub Desktop.
Save ashley-figueira/7b1e8eb770766c0c87f0c96c65cf9e81 to your computer and use it in GitHub Desktop.
Screenshot Rule
class ScreenshotRule(
private val screenshoter: Paparazzi,
) : TestRule {
val layoutInflater: LayoutInflater
get() = paparazzi.layoutInflater
val context: Context
get() = paparazzi.context
override fun apply(base: Statement, description: Description): Statement {
return RuleChain
.emptyRuleChain()
.around(MyCustomRule())
.around(paparazzi)
.apply(base, description)
}
fun snapshot(
content: @Composable () -> Unit,
) {
paparazzi.snapshot {
MyTheme {
content()
}
}
}
fun snapshot(view: View) {
paparazzi.snapshot(view)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment