Created
June 9, 2022 11:54
-
-
Save alexmaryin/b36a9181641cfd53d5c967739469e9eb to your computer and use it in GitHub Desktop.
Semantic matcher for Jetbtains Compose matching background color and shape
This file contains hidden or 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
/** | |
* 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