Does anyone know the rationale behind not exposing...
# compose
m
Does anyone know the rationale behind not exposing any semantic properties for text styles? All i seem to be able to validate is the text string, but not the font size, font family, etc….
t
Because semantic properties are primarily meant for accessibility services
m
@tad That’s kind of the issue though. How else would you test things like that? There’s no actual view to access with discrete properties. Semantics are the only way to test anything conditions in compose. Im not directly looking to test things like color. But i do have custom properties to test. I have a button which has a “tone” property that when combined with a “variant” and “size” affect colors, padding, etc…. I don’t necessarily need to test the colors and fonts directly, but i did add semantic properties for these 3 attributes so i can ensure that a given UI is putting the right type of button in the right slot.
I’m just wishing that more things were exposed in the semantic properties to validate this sort of stuff.
To be honest, it’s a big miss in my opinion to be able to create a text field like this in your UI:
Copy code
Text(..., style=MaterialTheme.typography.body1)
And not be able to write a test case to make sure the proper style has been set on it.
t
You can set tags, and it's not hard to create semantics keys
But at some point you have to trust that the Composable did the right thing with the arguments you provided to it
Otherwise you're testing the framework, and not your app