composing-semantics-matchers

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Composing Semantics Matchers — One Matcher, One Error

组合 SemanticsMatcher——一个匹配器,一个错误

A
SemanticsMatcher
is a description string plus a
(SemanticsNode) -> Boolean
predicate (
SemanticsMatcher.kt:26
). Compose ships with a rich filter library and three combinators (
and
,
or
,
not
) that produce a single matcher whose error message lists every clause. This skill picks the right factory, composes precise predicates, and replaces brittle assertion chains.
SemanticsMatcher
由一个描述字符串和一条
(SemanticsNode) -> Boolean
谓词组成(
SemanticsMatcher.kt:26
)。Compose 自带一套丰富的筛选器库和三个组合器(
and
、
or
、
not
),它们可生成单个匹配器,并在错误消息中列出所有子句。本 skill 会选择合适的工厂方法、组合精确谓词,并替换脆弱的断言链。

When to use this skill

何时使用此 skill

  • The developer wants to find "an enabled Button with text Submit" or any node matching multiple constraints.
  • The developer asks how to combine
    hasText
    and
    hasClickAction
    , or how to negate a matcher with
    not
    .
  • The developer needs to filter by a custom
    SemanticsPropertyKey
    (e.g. a domain-specific role) using
    expectValue
    /
    keyIsDefined
    .
  • The developer asks about hierarchical matchers like
    hasParent
    ,
    hasAnyAncestor
    ,
    hasAnyChild
    ,
    hasAnySibling
    ,
    hasAnyDescendant
    .
  • A test chains multiple
    assertIs*
    calls and the developer wants a single, declarative predicate.
  • 开发者希望查找“文本为 Submit 的已启用 Button”,或任何满足多个约束条件的节点。
  • 开发者询问如何组合
    hasText
    和
    hasClickAction
    ,或如何使用
    not
    对匹配器取反。
  • 开发者需要使用
    expectValue
    /
    keyIsDefined
    按自定义
    SemanticsPropertyKey
    (例如领域特定角色)进行筛选。
  • 开发者询问
    hasParent
    、
    hasAnyAncestor
    、
    hasAnyChild
    、
    hasAnySibling
    、
    hasAnyDescendant
    等层级匹配器。
  • 测试中链式调用了多个
    assertIs*
    ,而开发者希望改用单个声明式谓词。

When NOT to use this skill

何时不应使用此 skill

  • The query is "find by tag/text/content description only" — use
    ../finding-nodes-by-tag-text-content/SKILL.md
    .
  • The right node exists but only as a relative — use
    ../traversing-the-semantics-tree/SKILL.md
    .
  • The matcher is fine; only the assertions need rework — see
    ../../assertions/asserting-node-state-and-text/SKILL.md
    .
  • 查询仅按“标签/文本/内容描述”查找——请使用
    ../finding-nodes-by-tag-text-content/SKILL.md
    。
  • 目标节点存在,但只能通过相对关系找到——请使用
    ../traversing-the-semantics-tree/SKILL.md
    。
  • 匹配器本身没有问题,只需要重构断言——请参阅
    ../../assertions/asserting-node-state-and-text/SKILL.md
    。

Prerequisites

前置条件

  • androidx.compose.ui:ui-test
    on the test classpath. See
    ../../setup/configuring-test-dependencies/SKILL.md
    if unresolved.
  • Comfort with
    Modifier.semantics { … }
    in production code. Custom keys must be set via
    Modifier.semantics { customKey = value }
    to be matchable from tests.
  • 测试类路径中包含
    androidx.compose.ui:ui-test
    。如果无法解析,请参阅
    ../../setup/configuring-test-dependencies/SKILL.md
    。
  • 熟悉生产代码中的
    Modifier.semantics { … }
    。自定义键必须通过
    Modifier.semantics { customKey = value }
    设置,才能在测试中进行匹配。

Workflow

工作流

  • 1. Build matchers from the prebuilt filter library. Every prebuilt matcher lives in
    commonMain/.../Filters.kt
    . Group by signal:
    SignalMatchersFile:line
    Enabled / disabled
    isEnabled()
    ,
    isNotEnabled()
    Filters.kt:38-47
    Toggle (Switch, Checkbox)
    isToggleable()
    ,
    isOn()
    ,
    isOff()
    Filters.kt:54-70
    Selection (Tab, RadioButton)
    isSelectable()
    ,
    isSelected()
    ,
    isNotSelected()
    Filters.kt:77-93
    Focus
    isFocusable()
    ,
    isNotFocusable()
    ,
    isFocused()
    ,
    isNotFocused()
    Filters.kt:100-122
    Click action
    hasClickAction()
    ,
    hasNoClickAction()
    Filters.kt:129-136
    Scroll action
    hasScrollAction()
    ,
    hasNoScrollAction()
    ,
    hasScrollToIndexAction()
    ,
    hasScrollToKeyAction()
    ,
    hasScrollToNodeAction()
    Filters.kt:143-425
    Text actions (TextField)
    hasSetTextAction()
    ,
    hasInsertTextAtCursorAction()
    ,
    hasPerformImeAction()
    ,
    hasImeAction(ImeAction)
    Filters.kt:365-392
    Focus action
    hasRequestFocusAction()
    Filters.kt:399
    Content description
    hasContentDescription(value, substring, ignoreCase)
    ,
    hasContentDescriptionExactly(vararg)
    Filters.kt:165-212
    Text
    hasText(text, substring, ignoreCase)
    ,
    hasTextExactly(vararg, includeEditableText=true)
    Filters.kt:229-293
    A11y / state metadata
    hasStateDescription
    ,
    hasProgressBarRangeInfo
    ,
    isHeading
    ,
    isDialog
    ,
    isPopup
    ,
    isHiddenFromAccessibility
    ,
    isEditable
    ,
    isRoot
    Filters.kt:301-439
    Test tag
    hasTestTag(testTag)
    Filters.kt:326-327
    Hierarchical
    hasParent(matcher)
    ,
    hasAnyChild(matcher)
    ,
    hasAnySibling(matcher)
    ,
    hasAnyAncestor(matcher)
    ,
    hasAnyDescendant(matcher)
    Filters.kt:446-530
    hasText
    searches
    SemanticsProperties.Text
    ,
    SemanticsProperties.EditableText
    , AND
    SemanticsProperties.InputText
    simultaneously (
    Filters.kt:229-258
    ).
    hasContentDescription
    matches against the merged list of descriptions (
    Filters.kt:165-188
    ).
  • 2. Compose with
    and
    /
    or
    /
    not
    .
    Combinators come from
    SemanticsMatcher.kt:60-74
    . Each produces a new matcher whose
    description
    reads
    (left) && (right)
    /
    (left) || (right)
    /
    NOT (inner)
    . The framework prints this description verbatim on assertion failure, so the failure message shows exactly which clause(s) failed.
  • 3. Use
    SemanticsMatcher.expectValue
    for custom keys.
    When the production code declares a custom
    SemanticsPropertyKey<T>
    and writes it via
    Modifier.semantics { customKey = value }
    , match it with
    SemanticsMatcher.expectValue(customKey, expectedValue)
    (
    SemanticsMatcher.kt:33-37
    ). For "this key is set at all", use
    SemanticsMatcher.keyIsDefined(customKey)
    (
    SemanticsMatcher.kt:40-42
    ); for "this key is NOT set", use
    keyNotDefined
    (
    SemanticsMatcher.kt:45-47
    ). Built-in matchers like
    isOn()
    are themselves thin wrappers over
    expectValue(SemanticsProperties.ToggleableState, On)
    (
    Filters.kt:61-62
    ).
  • 4. Pass the composed matcher to
    onNode
    /
    onAllNodes
    .
    onNode(matcher, useUnmergedTree=false)
    and
    onAllNodes(matcher, useUnmergedTree=false)
    are the canonical entry points (
    SemanticsNodeInteractionsProvider.kt
    ). Both
    onNodeWithTag
    and friends are convenience wrappers — drop them when the predicate gets richer.
  • 5. For hierarchical assertions, prefer
    hasAnyAncestor
    /
    hasAnyDescendant
    over multiple traversal steps.
    Example: "find the Text inside the dialog" →
    onNode(hasText("Discard?") and hasAnyAncestor(isDialog()))
    . Cleaner than
    onAllNodes(isDialog()).onFirst().onChildren().filter(hasText(...)).onFirst()
    .
  • 1. 从预置筛选器库构建匹配器。 每个预置匹配器都位于
    commonMain/.../Filters.kt
    中。可按信号对它们进行分组:
    信号匹配器文件:行
    启用/禁用
    isEnabled()
    、
    isNotEnabled()
    Filters.kt:38-47
    切换(Switch、Checkbox)
    isToggleable()
    、
    isOn()
    、
    isOff()
    Filters.kt:54-70
    选择(Tab、RadioButton)
    isSelectable()
    、
    isSelected()
    、
    isNotSelected()
    Filters.kt:77-93
    焦点
    isFocusable()
    、
    isNotFocusable()
    、
    isFocused()
    、
    isNotFocused()
    Filters.kt:100-122
    点击操作
    hasClickAction()
    、
    hasNoClickAction()
    Filters.kt:129-136
    滚动操作
    hasScrollAction()
    、
    hasNoScrollAction()
    、
    hasScrollToIndexAction()
    、
    hasScrollToKeyAction()
    、
    hasScrollToNodeAction()
    Filters.kt:143-425
    文本操作(TextField)
    hasSetTextAction()
    、
    hasInsertTextAtCursorAction()
    、
    hasPerformImeAction()
    、
    hasImeAction(ImeAction)
    Filters.kt:365-392
    焦点操作
    hasRequestFocusAction()
    Filters.kt:399
    内容描述
    hasContentDescription(value, substring, ignoreCase)
    、
    hasContentDescriptionExactly(vararg)
    Filters.kt:165-212
    文本
    hasText(text, substring, ignoreCase)
    、
    hasTextExactly(vararg, includeEditableText=true)
    Filters.kt:229-293
    无障碍/状态元数据
    hasStateDescription
    、
    hasProgressBarRangeInfo
    、
    isHeading
    、
    isDialog
    、
    isPopup
    、
    isHiddenFromAccessibility
    、
    isEditable
    、
    isRoot
    Filters.kt:301-439
    测试标签
    hasTestTag(testTag)
    Filters.kt:326-327
    层级关系
    hasParent(matcher)
    、
    hasAnyChild(matcher)
    、
    hasAnySibling(matcher)
    、
    hasAnyAncestor(matcher)
    、
    hasAnyDescendant(matcher)
    Filters.kt:446-530
    hasText
    会同时搜索
    SemanticsProperties.Text
    、
    SemanticsProperties.EditableText
    和
    SemanticsProperties.InputText
    (
    Filters.kt:229-258
    )。
    hasContentDescription
    会与合并后的描述列表进行匹配(
    Filters.kt:165-188
    )。
  • 2. 使用
    and
    /
    or
    /
    not
    进行组合。
    组合器来自
    SemanticsMatcher.kt:60-74
    。每个组合器都会生成一个新的匹配器,其
    description
    显示为
    (left) && (right)
    /
    (left) || (right)
    /
    NOT (inner)
    。框架在断言失败时原样打印此描述,因此失败消息会准确显示哪些子句失败。
  • 3. 使用
    SemanticsMatcher.expectValue
    处理自定义键。
    当生产代码声明自定义
    SemanticsPropertyKey<T>
    并通过
    Modifier.semantics { customKey = value }
    写入时,使用
    SemanticsMatcher.expectValue(customKey, expectedValue)
    进行匹配(
    SemanticsMatcher.kt:33-37
    )。如果要判断“这个键已设置”,使用
    SemanticsMatcher.keyIsDefined(customKey)
    (
    SemanticsMatcher.kt:40-42
    );如果要判断“这个键未设置”,使用
    keyNotDefined
    (
    SemanticsMatcher.kt:45-47
    )。
    isOn()
    等内置匹配器本质上是对
    expectValue(SemanticsProperties.ToggleableState, On)
    的轻量封装(
    Filters.kt:61-62
    )。
  • 4. 将组合后的匹配器传给
    onNode
    /
    onAllNodes
    。
    onNode(matcher, useUnmergedTree=false)
    和
    onAllNodes(matcher, useUnmergedTree=false)
    是标准入口(
    SemanticsNodeInteractionsProvider.kt
    )。
    onNodeWithTag
    等函数都是便捷包装器——当谓词变得更丰富时,应改用这些基础入口。
  • 5. 对于层级断言,如果关系是“位于上方或下方的任意位置”,优先使用
    hasAnyAncestor
    /
    hasAnyDescendant
    ,而不是执行多个遍历步骤。
    示例:“查找对话框内的 Text”→
    onNode(hasText("Discard?") and hasAnyAncestor(isDialog()))
    。这比
    onAllNodes(isDialog()).onFirst().onChildren().filter(hasText(...)).onFirst()
    更简洁。

Patterns

模式

Pattern: replace assertion chains with a single matcher

模式:用单个匹配器替换断言链

kotlin
// WRONG
@Test
fun submit_isEnabledClickable() {
    rule.setContent { CheckoutScreen() }
    rule.onNodeWithText("Submit")
        .assertHasClickAction()
        .assertIsEnabled()
}
// WRONG because: each assertion is a separate fetch + error path. Failure prints "no click
// action" without telling the developer the matched node is the *enabled-but-wrong* button on
// a different screen.
kotlin
// RIGHT
@Test
fun submit_isEnabledClickable() {
    rule.setContent { CheckoutScreen() }
    rule.onNode(hasText("Submit") and hasClickAction() and isEnabled())
        .assertExists()
}
The composed matcher's description prints
(Text + InputText + EditableText contains 'Submit' (ignoreCase: false)) && (OnClick is defined) && (is enabled)
on failure, naming every unsatisfied clause.
kotlin
// WRONG
@Test
fun submit_isEnabledClickable() {
    rule.setContent { CheckoutScreen() }
    rule.onNodeWithText("Submit")
        .assertHasClickAction()
        .assertIsEnabled()
}
// WRONG because: each assertion is a separate fetch + error path. Failure prints "no click
// action" without telling the developer the matched node is the *enabled-but-wrong* button on
// a different screen.
kotlin
// RIGHT
@Test
fun submit_isEnabledClickable() {
    rule.setContent { CheckoutScreen() }
    rule.onNode(hasText("Submit") and hasClickAction() and isEnabled())
        .assertExists()
}
组合后的匹配器描述会输出
(Text + InputText + EditableText contains 'Submit' (ignoreCase: false)) && (OnClick is defined) && (is enabled)
,失败时会列出每个未满足的子句。

Pattern: hierarchical match — "the Text inside the dialog"

模式:层级匹配——“对话框内的 Text”

kotlin
// WRONG
rule.onAllNodes(isDialog())
    .onFirst()
    .onChildren()
    .filterToOne(hasText("Discard?"))
    .assertIsDisplayed()
// WRONG because: it implicitly assumes the Text is a direct child of the dialog root.
// AlertDialog wraps its body in Column/Surface, so the Text is a descendant, not a child.
kotlin
// RIGHT
rule.onNode(hasText("Discard?") and hasAnyAncestor(isDialog()))
    .assertIsDisplayed()
kotlin
// WRONG
rule.onAllNodes(isDialog())
    .onFirst()
    .onChildren()
    .filterToOne(hasText("Discard?"))
    .assertIsDisplayed()
// WRONG because: it implicitly assumes the Text is a direct child of the dialog root.
// AlertDialog wraps its body in Column/Surface, so the Text is a descendant, not a child.
kotlin
// RIGHT
rule.onNode(hasText("Discard?") and hasAnyAncestor(isDialog()))
    .assertIsDisplayed()

Pattern: negation and "exactly one"

模式:取反与“恰好一个”

kotlin
// "An enabled, non-toggleable Button (so: not a Switch or Checkbox) with text Submit"
rule.onNode(hasText("Submit") and isEnabled() and !isToggleable())
    .assertHasClickAction()
!matcher
invokes
operator fun not()
(
SemanticsMatcher.kt:72-74
) — works on every matcher in the library.
kotlin
// "An enabled, non-toggleable Button (so: not a Switch or Checkbox) with text Submit"
rule.onNode(hasText("Submit") and isEnabled() and !isToggleable())
    .assertHasClickAction()
!matcher
会调用
operator fun not()
(
SemanticsMatcher.kt:72-74
),适用于库中的每个匹配器。

Pattern: custom semantics key

模式:自定义语义键

kotlin
// production:
val PriorityKey = SemanticsPropertyKey<Int>("Priority")
var SemanticsPropertyReceiver.priority by PriorityKey

@Composable
fun TaskRow(task: Task) {
    Row(modifier = Modifier
        .testTag(TaskRowTag)
        .semantics { priority = task.priority }
    ) { /* … */ }
}

// test:
rule.onNode(hasTestTag(TaskRowTag) and SemanticsMatcher.expectValue(PriorityKey, 1))
    .assertIsDisplayed()

// "this row has a priority assigned at all":
rule.onNode(hasTestTag(TaskRowTag) and SemanticsMatcher.keyIsDefined(PriorityKey))
    .assertIsDisplayed()
kotlin
// production:
val PriorityKey = SemanticsPropertyKey<Int>("Priority")
var SemanticsPropertyReceiver.priority by PriorityKey

@Composable
fun TaskRow(task: Task) {
    Row(modifier = Modifier
        .testTag(TaskRowTag)
        .semantics { priority = task.priority }
    ) { /* … */ }
}

// test:
rule.onNode(hasTestTag(TaskRowTag) and SemanticsMatcher.expectValue(PriorityKey, 1))
    .assertIsDisplayed()

// "this row has a priority assigned at all":
rule.onNode(hasTestTag(TaskRowTag) and SemanticsMatcher.keyIsDefined(PriorityKey))
    .assertIsDisplayed()

Pattern: dropdown / IME-action / scroll-to-key — narrow a TextField query

模式:下拉列表 / IME 操作 / 滚动到键——收窄 TextField 查询

kotlin
// "the editable TextField that handles Done as IME action"
rule.onNode(hasSetTextAction() and hasImeAction(ImeAction.Done))
    .performTextInput("hello")

// "any LazyColumn child reachable by key — i.e. has IndexForKey on top of ScrollToIndex"
rule.onNode(hasScrollToKeyAction()).performScrollToKey(itemKey)
hasScrollToKeyAction
is the conjunction
hasKey(ScrollToIndex) and hasKey(IndexForKey)
(
Filters.kt:415-416
).
hasScrollToNodeAction
adds an axis-range check (
Filters.kt:419-425
).
kotlin
// "the editable TextField that handles Done as IME action"
rule.onNode(hasSetTextAction() and hasImeAction(ImeAction.Done))
    .performTextInput("hello")

// "any LazyColumn child reachable by key — i.e. has IndexForKey on top of ScrollToIndex"
rule.onNode(hasScrollToKeyAction()).performScrollToKey(itemKey)
hasScrollToKeyAction
是
hasKey(ScrollToIndex) and hasKey(IndexForKey)
的组合条件(
Filters.kt:415-416
)。
hasScrollToNodeAction
还会增加轴范围检查(
Filters.kt:419-425
)。

Pattern: matcher description appears in error messages

模式:匹配器描述会出现在错误消息中

kotlin
val matcher = hasText("Submit") and hasClickAction() and isEnabled()
println(matcher.description)
// (Text + InputText + EditableText contains 'Submit' (ignoreCase: false)) &&
// (OnClick is defined) && (is enabled)
The description is human-readable and used by
assert(matcher)
(
Assertions.kt:254-267
) when the matcher does not hold. Clauses MUST be readable in isolation — that is why named matchers are preferred over inline lambdas.
kotlin
val matcher = hasText("Submit") and hasClickAction() and isEnabled()
println(matcher.description)
// (Text + InputText + EditableText contains 'Submit' (ignoreCase: false)) &&
// (OnClick is defined) && (is enabled)
该描述是人类可读的,并会在匹配器不成立时由
assert(matcher)
(
Assertions.kt:254-267
)使用。每个子句都必须能够被单独阅读——因此应优先使用命名匹配器,而不是内联 lambda。

Mandatory rules

强制规则

  • MUST use
    infix and
    /
    infix or
    /
    operator not
    to compose matchers; MUST NOT chain
    assertIs*
    calls when a single composed matcher captures the same intent.
  • MUST wrap custom semantics keys with
    SemanticsMatcher.expectValue(...)
    or
    SemanticsMatcher.keyIsDefined(...)
    ; MUST NOT access
    node.config[CustomKey]
    from inside an ad-hoc lambda. The factory methods produce readable error descriptions.
  • MUST prefer
    hasAnyAncestor(isDialog())
    /
    hasAnyDescendant(...)
    over multi-step traversal when the relationship is "somewhere above/below". Cross-reference:
    ../traversing-the-semantics-tree/SKILL.md
    .
  • MUST keep the
    useUnmergedTree
    flag at its default
    false
    unless the matcher targets an inner element collapsed by merge. Skydoves hot take #2.
  • MUST NOT redefine an existing prebuilt matcher (e.g. writing a custom
    SemanticsMatcher("is enabled") { … }
    ) — use
    isEnabled()
    . Custom matchers are reserved for keys that don't have a prebuilt filter.
  • PREFERRED: prefer tag-anchored matchers —
    hasTestTag(SubmitTag) and isEnabled()
    — over text-anchored. Skydoves hot take #1.
  • 必须使用
    infix and
    /
    infix or
    /
    operator not
    组合匹配器;当单个组合匹配器可以表达相同意图时,不得链式调用
    assertIs*
    。
  • 必须使用
    SemanticsMatcher.expectValue(...)
    或
    SemanticsMatcher.keyIsDefined(...)
    包装自定义语义键;不得在临时 lambda 中直接访问
    node.config[CustomKey]
    。工厂方法能够生成可读的错误描述。
  • 当关系是“位于上方或下方的任意位置”时,必须优先使用
    hasAnyAncestor(isDialog())
    /
    hasAnyDescendant(...)
    ,而不是执行多步遍历。交叉参考:
    ../traversing-the-semantics-tree/SKILL.md
    。
  • 除非匹配器针对的是被 merge 折叠的内部元素,否则必须保持
    useUnmergedTree
    标志的默认值
    false
    。Skydoves 热门观点 #2。
  • 不得重新定义已有的预置匹配器(例如编写自定义
    SemanticsMatcher("is enabled") { … }
    )——请使用
    isEnabled()
    。自定义匹配器仅用于没有预置筛选器的键。
  • **首选:**优先使用以标签为锚点的匹配器,例如
    hasTestTag(SubmitTag) and isEnabled()
    ,而不是以文本为锚点的匹配器。Skydoves 热门观点 #1。

Verification

验证

  • Every multi-condition query uses one
    onNode(matcher)
    rather than chained finders + assertions.
  • Custom key checks use
    SemanticsMatcher.expectValue
    /
    keyIsDefined
    —
    node.config[...]
    does not appear in matcher predicates.
  • ./gradlew :app:connectedDebugAndroidTest
    or
    :app:testDebugUnitTest
    passes.
  • Failure messages from intentionally-broken matchers print the composed
    description
    so the failing clause is identifiable.
  • No matcher is silently shadowed by a re-declared local lambda with the same name.
  • 每个多条件查询都使用单个
    onNode(matcher)
    ,而不是链式查找器加断言。
  • 自定义键检查使用
    SemanticsMatcher.expectValue
    /
    keyIsDefined
    ,匹配器谓词中未出现
    node.config[...]
    。
  • ./gradlew :app:connectedDebugAndroidTest
    或
    :app:testDebugUnitTest
    通过。
  • 故意破坏的匹配器所产生的失败消息会打印组合后的
    description
    ,从而能够识别失败子句。
  • 没有匹配器被重新声明的同名局部 lambda 静默遮蔽。

References

参考资料

  • Compose 测试概览:https://developer.android.com/develop/ui/compose/testing
  • Compose 测试速查表:https://developer.android.com/develop/ui/compose/testing-cheatsheet
  • Compose 中的 Semantics:https://developer.android.com/develop/ui/compose/accessibility/semantics
  • compose/ui/ui-test/src/commonMain/kotlin/androidx/compose/ui/test/SemanticsMatcher.kt
    ——
    class SemanticsMatcher
    、
    expectValue
    /
    keyIsDefined
    /
    keyNotDefined
    、
    infix and
    、
    infix or
    、
    operator not
    。
  • compose/ui/ui-test/src/commonMain/kotlin/androidx/compose/ui/test/Filters.kt
    ——所有预置匹配器(状态、操作、文本、层级关系)。
  • compose/ui/ui-test/src/commonMain/kotlin/androidx/compose/ui/test/Assertions.kt
    ——
    fun assert(matcher, messagePrefixOnError)
    ,以及匹配器描述如何显示在错误中。
  • compose/ui/ui-test/src/commonMain/kotlin/androidx/compose/ui/test/SemanticsNodeInteractionsProvider.kt
    ——
    onNode(matcher, useUnmergedTree)
    /
    onAllNodes(matcher, useUnmergedTree)
    。