Testing
The testing packages are test-only. They run the same checks Camouflage runs on its own components against your screens.
- Kotlin
- Dart
// build.gradle.kts: testImplementation("com.srctool.camouflage:camouflage-skin-testing")
@OptIn(ExperimentalTestApi::class)
class SignUpAccessibilityTest {
@Test
fun signUpIsAccessible() = runComposeUiTest {
val problems = accessibilityProblems(
skin = MaterialSkin,
theme = materialTheme(),
fontScale = 2f, // 200% text
rtl = false,
) { SignUpScreen() }
assertTrue(problems.isEmpty(), problems.joinToString("\n"))
}
}
accessibilityProblems returns one line per problem: a missing name, a missing role or state, or a touch target under 44 dp.
Run it across skins and directions
Loop over what you support so a change in one place cannot break another:
- Kotlin
- Dart
for ((skin, theme) in listOf(MaterialSkin to materialTheme(), CupertinoSkin to cupertinoTheme())) {
for (rtl in listOf(false, true)) {
// accessibilityProblems(skin, theme, rtl = rtl) { SignUpScreen() }
}
}
Validate the theme too
Add one test that your brand colors pass theme.validate(); see Validating a theme.