Skip to content

Instantly share code, notes, and snippets.

@alexmaryin
Created June 9, 2022 11:54
Show Gist options
  • Save alexmaryin/b36a9181641cfd53d5c967739469e9eb to your computer and use it in GitHub Desktop.
Save alexmaryin/b36a9181641cfd53d5c967739469e9eb to your computer and use it in GitHub Desktop.
Semantic matcher for Jetbtains Compose matching background color and shape
/**
* Thanks for https://stackoverflow.com/a/72529233/15257426
*/
fun hasBackground(expectedColor: Color, expectedShape: Shape = RectangleShape): SemanticsMatcher = SemanticsMatcher("background color") {
it.layoutInfo.getModifierInfo().forEach {info ->
println(info.modifier.toString())
}
it.layoutInfo.getModifierInfo().any { modifierInfo ->
modifierInfo.modifier == Modifier.background(expectedColor, expectedShape)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment