mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-02 19:17:10 +00:00
test(sidecar): use the tree the device really returns
This commit is contained in:
1 parent
3df8a3b3ba
commit
e67fffcab7
1 file changed
+27
-9
@@ -78,9 +78,17 @@ class EraseTextTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The erase targets the field the runner just tapped, so the length that
|
// The erase targets the field the runner just tapped, so the length that
|
||||||
// decides whether it worked is the focused editable node's, not some other
|
// decides whether it worked is that field's, not some other field that
|
||||||
// field that legitimately still holds text.
|
// legitimately still holds text.
|
||||||
@Test fun focusedEditableTextLengthReadsTheFocusedFieldOnly() {
|
//
|
||||||
|
// The tree these fixtures copy is the one the device really returns, and
|
||||||
|
// it holds the trap: an open keyboard puts a SECOND focused node in the
|
||||||
|
// tree, one of the IME's own keys, and it carries no text. Reading the
|
||||||
|
// first focused node would call a field that still holds 4096 characters
|
||||||
|
// empty, which is the one wrong answer that matters here. maestro's tree
|
||||||
|
// also carries no "editable" attribute at all, so the text field has to be
|
||||||
|
// recognised by its class.
|
||||||
|
@Test fun theFocusedFieldIsReadPastTheKeyboardsOwnFocusedKey() {
|
||||||
assertEquals(4096, focusedEditableTextLength(TREE_WITH_FULL_FIELD))
|
assertEquals(4096, focusedEditableTextLength(TREE_WITH_FULL_FIELD))
|
||||||
assertEquals(0, focusedEditableTextLength(TREE_WITH_EMPTY_FIELD))
|
assertEquals(0, focusedEditableTextLength(TREE_WITH_EMPTY_FIELD))
|
||||||
}
|
}
|
||||||
@@ -92,16 +100,26 @@ class EraseTextTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The keyboard's own focused key, exactly as the device reports it: focused,
|
||||||
|
// no text, and not a text field.
|
||||||
|
private val IME_FOCUSED_KEY =
|
||||||
|
"""
|
||||||
|
{"attributes":{"text":"","resource-id":
|
||||||
|
"com.google.android.inputmethod.latin:id/key_pos_header_access",
|
||||||
|
"focused":"true","class":"android.widget.FrameLayout"},"children":[]}
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
private fun tree(focusedText: String?, otherText: String): String {
|
private fun tree(focusedText: String?, otherText: String): String {
|
||||||
val focused = focusedText?.let {
|
val field = focusedText?.let {
|
||||||
"""{"attributes":{"resource-id":"AccountNameField",
|
""",{"attributes":{"resource-id":"AccountNameField","focused":"true",
|
||||||
"editable":"true","focused":"true","text":"$it"},"children":[]},"""
|
"class":"android.widget.EditText","text":"$it"},"children":[]}"""
|
||||||
} ?: ""
|
} ?: ""
|
||||||
return """
|
return """
|
||||||
{"attributes":{"resource-id":"AddAccountScreen"},"children":[
|
{"attributes":{"resource-id":"AddAccountScreen"},"children":[
|
||||||
$focused
|
$IME_FOCUSED_KEY $field,
|
||||||
{"attributes":{"resource-id":"OtherField","editable":"true",
|
{"attributes":{"resource-id":"OtherField","focused":"false",
|
||||||
"focused":"false","text":"$otherText"},"children":[]}]}
|
"class":"android.widget.EditText","text":"$otherText"},
|
||||||
|
"children":[]}]}
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user