Has anyone had issues testing a BasicTextField wit...
# compose
Has anyone had issues testing a BasicTextField with a custom text style? It seems to cause issues. After i match the text field and call
I can no longer match any other elements on the tree. If i use a style from MaterialTheme like body2 it’s fine, but anything else, I get this error:
Copy code
offset(6) should be less than line limit(0)
java.lang.IndexOutOfBoundsException: offset(6) should be less than line limit(0)
	at android.text.TextLine.measure(TextLine.java:353)
	at android.text.Layout.getHorizontal(Layout.java:1213)
	at android.text.Layout.getHorizontal(Layout.java:1190)
	at android.text.Layout.getPrimaryHorizontal(Layout.java:1160)
Code is in thread
Copy code
@Config(sdk = [30])
class TextFieldIssue {
    val composeRule = createComposeRule()

    fun demonstrateIssue() {
        val value = mutableStateOf("")
        val onClick = mock<() -> Unit>()

        composeRule.setContent {
            MaterialTheme {
                Column {
                        modifier = Modifier.testTag("input"),
                        value = value.value,
                        onValueChange = { value.value = it },
                        readOnly = false,
                        textStyle = TextStyle(
                            fontFamily = FontFamily.Serif,
                            fontWeight = FontWeight.Normal,
                            fontSize = 16.sp,
                            lineHeight = 24.sp,
                            letterSpacing = 0.00000.em
                        modifier = Modifier.testTag("button"),
                        onClick = onClick

                    ) {

        println(composeRule.onRoot(useUnmergedTree = true).printToString())


It’s worth nothing this is a robolectric test, not an espresso test..
Hey, just ran into this as well! Have not found a solution yet, but will let you know if I do
@mattinger @Bryan Herbst did either of you ever find out a solution? I'm having the same issue
Not yet @Chuck Stein. I'm wondering if it's a robolectric bug or a compose bug. Maybe 1.2.0 will fix it. i'll give the beta a try again to see what happens.
Definitely NOT fixed with compose 1.2.0-rc02 and roboletric 4.8.1
But i have narrowed it down specifically to the
attribute. The second i add that in, it barfs
Thanks for the update! Definitely a bummer that 1.2.0 isn't fixing it. I wonder if Robolectric is tracking this issue and can make a fix or if it's more in Google's hands