Open sergio-sastre opened 12 months ago
Hi @sergio-sastre
Thanks for the request. In theory, ComposableScreenshotRule
does support changing the orientation in the same was as the base ScreenshotTestRule
.
This code should work:
@ScreenshotInstrumentation
@Test
fun landscape() {
rule
.configure {
orientation = SCREEN_ORIENTATION_LANDSCAPE
}
.setCompose {
val orientation = "Landscape".takeIf { rule.activity.isLandscape } ?: "Portrait"
Text(
text = "Orientation is $orientation",
fontSize = 16.sp
)
}
.assertSame()
}
However, it appears that there is a lifecyle bug in the beforeScreenshot()
callback and it's not providing the correct Activity for Compose to draw its composables.
I'm going to change this ticket to a bug and try to get a fix in for this soon.
Is your feature request related to a problem? Please describe. I’d like to take screenshots of composables in portrait as well as in landscape orientation
This feedback relates to:
Describe the solution you'd like That ComposableScreenshotTestRule supports orientation, dame as ScreenshotTestRule
Describe alternatives you've considered I’ve considered using ScreenshotTestRule and inflating the Composable inside the activity, what actually might work but looks like sth that I should not do as user of the library.
Test
Error