# LayoutElementAssertionsProvider

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

*** ** * ** ***


```
public final class LayoutElementAssertionsProvider
```

<br />

*** ** * ** ***

Provides the main entry point into testing by exposing methods to find a layout element.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementAssertionsProvider#LayoutElementAssertionsProvider(androidx.wear.protolayout.LayoutElementBuilders.Layout)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.Layout layout )` |
| `https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementAssertionsProvider#LayoutElementAssertionsProvider(androidx.wear.protolayout.LayoutElementBuilders.LayoutElement)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/LayoutElementBuilders.LayoutElement layoutRoot )` |

| ### Public methods |
|---|---|
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementAssertion` | `https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementAssertionsProvider#onElement(androidx.wear.protolayout.testing.LayoutElementMatcher)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementMatcher matcher)` Finds an element that matches the given condition. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementAssertion` | `https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementAssertionsProvider#onRoot()()` Finds the top level element of the element tree added to this `https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementAssertionsProvider`. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementAssertionsProvider` | `https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementAssertionsProvider#withDynamicData(kotlin.Array)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/wear/protolayout/expression/DynamicDataPair<@https://developer.android.com/reference/androidx/annotation/NonNull ?>... dynamicDataPairs )` Injects the app state and/or platform data for evaluating the dynamic data applied on the layout element under testing. |

## Public constructors

### LayoutElementAssertionsProvider

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public LayoutElementAssertionsProvider(
    @NonNull LayoutElementBuilders.Layout layout
)
```

### LayoutElementAssertionsProvider

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public LayoutElementAssertionsProvider(
    @NonNull LayoutElementBuilders.LayoutElement layoutRoot
)
```

## Public methods

### onElement

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final @NonNull LayoutElementAssertion onElement(@NonNull LayoutElementMatcher matcher)
```

Finds an element that matches the given condition.

### onRoot

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final @NonNull LayoutElementAssertion onRoot()
```

Finds the top level element of the element tree added to this `https://developer.android.com/reference/androidx/wear/protolayout/testing/LayoutElementAssertionsProvider`.

### withDynamicData

Added in [1.3.0](https://developer.android.com/jetpack/androidx/releases/wear-protolayout#1.3.0)

```
public final @NonNull LayoutElementAssertionsProvider withDynamicData(
    @NonNull DynamicDataPair<@NonNull ?>... dynamicDataPairs
)
```

Injects the app state and/or platform data for evaluating the dynamic data applied on the layout element under testing.