Skip to content

Commit

Permalink
Add theme test
Browse files Browse the repository at this point in the history
  • Loading branch information
takahirom committed Dec 18, 2024
1 parent 85802d4 commit f4aa5be
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ fun ComposablePreview<AndroidPreviewInfo>.toRoborazziComposeOptions(): Roborazzi
uiMode(previewInfo.uiMode)
previewDevice(previewInfo.device)
fontScale(previewInfo.fontScale)

/*
We don't specify `inspectionMode` by default.
The default value for `inspectionMode` in Compose is `false`.
This is to maintain higher fidelity in tests.
If you encounter issues integrating the library, you can set `inspectionMode` to `true`.
inspectionMode(true)
*/
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.github.takahirom.roborazzi.RoborazziComposeOptions
import com.github.takahirom.roborazzi.captureRoboImage
import com.github.takahirom.roborazzi.fontScale
import com.github.takahirom.roborazzi.roborazziSystemPropertyOutputDirectory
import com.github.takahirom.roborazzi.theme
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.annotation.Config
Expand All @@ -39,6 +40,18 @@ class ComposeLambdaTest {
}
}

@OptIn(ExperimentalRoborazziApi::class)
@Test
fun whenNonTransparentThemeItShouldHaveNonTransparentBackground() {
captureRoboImage(
roborazziComposeOptions = RoborazziComposeOptions {
theme(android.R.style.Theme_Material_Light)
}
) {
Text("This composable function should not have transparent background!")
}
}

@OptIn(ExperimentalRoborazziApi::class)
@Test
fun captureComposeLambdaImageWithRoborazziComposeOptions() {
Expand All @@ -48,15 +61,6 @@ class ComposeLambdaTest {
// We have several options to configure the test environment.
fontScale(2f)

/*
We don't specify `inspectionMode` by default.
The default value for `inspectionMode` in Compose is `false`.
This is to maintain higher fidelity in tests.
If you encounter issues integrating the library, you can set `inspectionMode` to `true`.
inspectionMode(true)
*/

// We can also configure the activity scenario and the composable content.
addOption(
object : RoborazziComposeComposableOption,
Expand Down

0 comments on commit f4aa5be

Please sign in to comment.