# GlanceNodeMatcher

# GlanceNodeMatcher

Artifact:[androidx.glance:glance-testing](https://developer.android.com/jetpack/androidx/releases/glance)  
[View Source](https://cs.android.com/search?q=file:androidx/glance/testing/GlanceNodeMatcher.kt+class:androidx.glance.testing.GlanceNodeMatcher)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/glance#1.1.0)

<br />

```
class GlanceNodeMatcher<R : Any?>
```

<br />

*** ** * ** ***

Wrapper for matcher lambdas and related details

## Summary

|                                                                                                                                                                                                                                                                            ### Public constructors                                                                                                                                                                                                                                                                             |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `<R : `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?> `[GlanceNodeMatcher](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher#GlanceNodeMatcher(kotlin.String,kotlin.Function1))`(` ` description: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`,` ` matcher: (`[GlanceNode](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNode)`<R>) `->` `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) `)` |

|                                                     ### Public functions                                                      |
|-------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `infix `[GlanceNodeMatcher](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher)`<R>`    | [and](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher#and(androidx.glance.testing.GlanceNodeMatcher))`(other: `[GlanceNodeMatcher](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher)`<R>)` Returns whether the given node is matched by this and the[other](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher#and(androidx.glance.testing.GlanceNodeMatcher))matcher. |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                           | [matches](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher#matches(androidx.glance.testing.GlanceNode))`(node: `[GlanceNode](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNode)`<R>)` Returns whether the given node is matched by this matcher.                                                                                                                                                                      |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)                                           | [matchesAny](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher#matchesAny(kotlin.collections.Iterable))`(nodes: `[Iterable](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-iterable/index.html)`<`[GlanceNode](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNode)`<R>>)` Returns whether at least one of the given nodes is matched by this matcher.                                                |
| `operator `[GlanceNodeMatcher](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher)`<R>` | [not](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher#not())`()` Returns whether the given node does not match the matcher.                                                                                                                                                                                                                                                                                                                          |
| `infix `[GlanceNodeMatcher](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher)`<R>`    | [or](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher#or(androidx.glance.testing.GlanceNodeMatcher))`(other: `[GlanceNodeMatcher](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher)`<R>)` Returns whether the given node is matched by this or the[other](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher#or(androidx.glance.testing.GlanceNodeMatcher))matcher.     |

## Public constructors

### GlanceNodeMatcher

```
<R : Any?> GlanceNodeMatcher(
    description: String,
    matcher: (GlanceNode<R>) -> Boolean
)
```  

|                                                                                                 Parameters                                                                                                 |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------|
| `description: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)                                                                                                           | a string explaining to the developer what conditions were being tested. |
| `matcher: (`[GlanceNode](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNode)`<R>) `->` `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | a lambda performing the actual logic of matching on the GlanceNode      |

## Public functions

### and

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/glance#1.1.0)  

```
infix fun and(other: GlanceNodeMatcher<R>): GlanceNodeMatcher<R>
```

Returns whether the given node is matched by this and the[other](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher#and(androidx.glance.testing.GlanceNodeMatcher))matcher.  

|                                                         Parameters                                                          |
|-----------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
| `other: `[GlanceNodeMatcher](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher)`<R>` | matcher that should also match in addition to current matcher |

### matches

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/glance#1.1.0)  

```
fun matches(node: GlanceNode<R>): Boolean
```

Returns whether the given node is matched by this matcher.  

### matchesAny

```
fun matchesAny(nodes: Iterable<GlanceNode<R>>): Boolean
```

Returns whether at least one of the given nodes is matched by this matcher.  

### not

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/glance#1.1.0)  

```
operator fun not(): GlanceNodeMatcher<R>
```

Returns whether the given node does not match the matcher.  

### or

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/glance#1.1.0)  

```
infix fun or(other: GlanceNodeMatcher<R>): GlanceNodeMatcher<R>
```

Returns whether the given node is matched by this or the[other](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher#or(androidx.glance.testing.GlanceNodeMatcher))matcher.  

|                                                         Parameters                                                          |
|-----------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------|
| `other: `[GlanceNodeMatcher](https://developer.android.com/reference/kotlin/androidx/glance/testing/GlanceNodeMatcher)`<R>` | matcher that can be tested to match if the current matcher doesn't. |