mirror of
https://github.com/priyanshujain/sanderling.git
synced 2026-10-04 20:17:09 +00:00
feat(sidecar): match idPrefix in the tap-by-selector path
This commit is contained in:
1 parent
a8444cc34f
commit
b1a0678bf9
2 files changed
+25
No files matched your search
@@ -958,6 +958,12 @@ internal fun findBoundsInTree(
|
|||||||
} ==
|
} ==
|
||||||
true
|
true
|
||||||
|
|
||||||
|
"idPrefix" -> attrs["resource-id"]?.let { id ->
|
||||||
|
val local = id.indexOf(":id/")
|
||||||
|
id.startsWith(value) ||
|
||||||
|
(local >= 0 && id.substring(local + 4).startsWith(value))
|
||||||
|
} == true
|
||||||
|
|
||||||
"text" -> attrs["text"] == value
|
"text" -> attrs["text"] == value
|
||||||
|
|
||||||
"desc" -> attrs["content-desc"] == value
|
"desc" -> attrs["content-desc"] == value
|
||||||
|
|||||||
@@ -111,6 +111,25 @@ class DeviceOutputParserTest {
|
|||||||
assertEquals(listOf(5, 6, 7, 8), findBoundsBySelector(tree, "descPrefix:AccountCard")?.toList())
|
assertEquals(listOf(5, 6, 7, 8), findBoundsBySelector(tree, "descPrefix:AccountCard")?.toList())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test fun findBoundsBySelectorMatchesIdPrefixWithoutThePackage() {
|
||||||
|
val tree = node(
|
||||||
|
"resource-id" to "root",
|
||||||
|
children = listOf(
|
||||||
|
node(
|
||||||
|
"resource-id" to "com.example:id/customer_row_abc",
|
||||||
|
"bounds" to "[1,2,3,4]",
|
||||||
|
),
|
||||||
|
node("resource-id" to "supplier_row_x", "bounds" to "[5,6,7,8]"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
val prefix = findBoundsBySelector(tree, "idPrefix:customer_row_")
|
||||||
|
assertEquals(listOf(1, 2, 3, 4), prefix?.toList())
|
||||||
|
val qualified =
|
||||||
|
findBoundsBySelector(tree, "idPrefix:com.example:id/customer_row")
|
||||||
|
assertEquals(listOf(1, 2, 3, 4), qualified?.toList())
|
||||||
|
assertNull(findBoundsBySelector(tree, "idPrefix:invoice_row_"))
|
||||||
|
}
|
||||||
|
|
||||||
@Test fun findBoundsBySelectorReturnsNullForBadSelectorOrNoMatch() {
|
@Test fun findBoundsBySelectorReturnsNullForBadSelectorOrNoMatch() {
|
||||||
val tree = node("resource-id" to "com.example:id/x", "bounds" to "[0,0,1,1]")
|
val tree = node("resource-id" to "com.example:id/x", "bounds" to "[0,0,1,1]")
|
||||||
assertNull(findBoundsBySelector(tree, "id"))
|
assertNull(findBoundsBySelector(tree, "id"))
|
||||||
|
|||||||
Reference in new issue
Block a user