Last active
March 9, 2024 16:21
-
-
Save ashley-figueira/7b1e8eb770766c0c87f0c96c65cf9e81 to your computer and use it in GitHub Desktop.
Screenshot Rule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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