Peter Mandeljc
02/06/2023, 10:37 AMMyTextField composable and I would like somehow send text directly to the root of it. Atm I'm getting Failed to assert the following: (SetText is defined) .Peter Mandeljc
02/06/2023, 10:38 AM@Composable
fun MyTextField(...) {
Box {
Column {
Row {
BasicTextField(...)
}
}
}
}
And use it like so:
@Composable
fun SomeScreen() {
MyTextField(modifier = Modifiler.testTag("myTextField"))
}
Is it possible to send text to root of it like this:
// instrumented unit test
composeRule.onNodeWithTag("myTextField").performTextInput("banana")Peter Mandeljc
02/06/2023, 10:41 AMMyTextField (BasicTextField )?Peter Mandeljc
02/06/2023, 12:47 PMperformTextInput is called on material TextField for example?Alex Vanyo
02/06/2023, 7:04 PM.semantics(mergeDescendants = true) and the overall documentation for semantics: https://developer.android.com/jetpack/compose/semantics
Even though you asked about testing, the test tools use the same semantic information that drives accessibility services. If you’re making a custom component, tweaking the semantics of it to work naturally with the test tools should go hand-in-hand to making sure the custom component works well with accessibility services too!Peter Mandeljc
02/06/2023, 7:32 PMLorenzo Neumann
07/07/2023, 2:38 PMPeter Mandeljc
07/07/2023, 2:46 PMmodifier.semantics(
mergeDescendanta = true,
properties = {
setText {
onTextChanged(it.text),
true
}
}
)Lorenzo Neumann
07/07/2023, 3:20 PMPeter Mandeljc
07/07/2023, 4:23 PMmergeDescendants = false?Lorenzo Neumann
07/10/2023, 7:36 AM