I’m having a problem testing my input field in a r...
# compose
m
I’m having a problem testing my input field in a robolectric test. I have a custom phone number visual transformation, and i’m trying the following test code:
Copy code
composeRule.onNodeWithTag("input2")
                .performTextReplacement("5558675309")
And this causes the following error
Copy code
offset(14) should be less than line limit(0)
java.lang.IndexOutOfBoundsException: offset(14) should be less than line limit(0)
	at android.text.TextLine.measure(TextLine.java:383)
	at android.text.Layout.getHorizontal(Layout.java:1214)
	at android.text.Layout.getHorizontal(Layout.java:1191)
	at android.text.Layout.getPrimaryHorizontal(Layout.java:1161)
	at android.text.Layout.getPrimaryHorizontal(Layout.java:1150)
	at androidx.compose.ui.text.android.LayoutHelper.getDownstreamHorizontal(LayoutHelper.kt:344)
	at androidx.compose.ui.text.android.LayoutHelper.getHorizontalPosition(LayoutHelper.kt:226)
	at androidx.compose.ui.text.android.TextLayout.getPrimaryHorizontal(TextLayout.kt:330)
	at androidx.compose.ui.text.android.TextLayout.getPrimaryHorizontal$default(TextLayout.kt:329)
	at androidx.compose.ui.text.platform.AndroidParagraph.getCursorRect(AndroidParagraph.android.kt:328)
I’m guessing this is due to the use of the visual transformation. Anyone have any ideas?
Update. This is a robolectric issue that's fixed in 4.9.1 that was published 2 days ago
124 Views