# TestNavigationEventDispatcherOwner

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

*** ** * ** ***

Common/All
- Cmn

  ```
  class TestNavigationEventDispatcherOwner : NavigationEventDispatcherOwner
  ```

*** ** * ** ***

A test implementation of `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcherOwner` for verifying `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcher` interactions.

Use this class in tests to confirm that the `onBackCompletedFallback` and `onForwardCompletedFallback` actions are invoked as expected. It tracks the number of times these events occur.

## Summary

| ### Public constructors |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner#TestNavigationEventDispatcherOwner(kotlin.Function1)(onBackCompletedFallback: https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner#TestNavigationEventDispatcherOwner(kotlin.Function1,kotlin.Function1)( onForwardCompletedFallback: https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html, onBackCompletedFallback: https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html )` Creates a `https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner` with both forward and back fallbacks. | Cmn |

| ### Public properties |
|---|---|---|
| `open https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcher` | `https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner#navigationEventDispatcher()` The `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcher` instance managed by this owner. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/navigationevent/DirectNavigationEventInput` | `https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner#navigationEventInput()` The `https://developer.android.com/reference/kotlin/androidx/navigationevent/DirectNavigationEventInput` instance managed by this owner. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner#onBackCompletedFallbackInvocations()` The number of times the dispatcher's `https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner#onBackCompletedFallback()` lambda has been invoked. | Cmn |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner#onForwardCompletedFallbackInvocations()` The number of times the dispatcher's `https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner#onForwardCompletedFallback()` lambda has been invoked. | Cmn |

## Public constructors

### TestNavigationEventDispatcherOwner

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigationevent#1.0.0)

```
TestNavigationEventDispatcherOwner(
    onBackCompletedFallback: TestNavigationEventDispatcherOwner.() -> Unit = {}
)
```

| Parameters |
|---|---|
| `onBackCompletedFallback: https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html = {}` | An optional lambda to execute when the `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcher` back fallback is triggered. |

### TestNavigationEventDispatcherOwner

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/navigationevent#1.2.0)

```
TestNavigationEventDispatcherOwner(
    onForwardCompletedFallback: TestNavigationEventDispatcherOwner.() -> Unit,
    onBackCompletedFallback: TestNavigationEventDispatcherOwner.() -> Unit
)
```

Creates a `https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner` with both forward and back fallbacks.

| Parameters |
|---|---|
| `onForwardCompletedFallback: https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | A lambda to execute when the `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcher` forward fallback is triggered. |
| `onBackCompletedFallback: https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner.() -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | An optional lambda to execute when the `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcher` back fallback is triggered. |

## Public properties

### navigationEventDispatcher

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigationevent#1.0.0)

```
open val navigationEventDispatcher: NavigationEventDispatcher
```

The `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventDispatcher` instance managed by this owner.

This dispatcher is created with the `onBackCompletedFallback` and `onForwardCompletedFallback` lambdas provided to the `https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner`'s constructor, which increments `https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner#onBackCompletedFallbackInvocations()` and `https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner#onForwardCompletedFallbackInvocations()`.

### navigationEventInput

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/navigationevent#1.2.0)

```
val navigationEventInput: DirectNavigationEventInput
```

The `https://developer.android.com/reference/kotlin/androidx/navigationevent/DirectNavigationEventInput` instance managed by this owner.

This input is automatically added to the `https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner#navigationEventDispatcher()` during initialization, allowing for direct simulation of navigation events.

### onBackCompletedFallbackInvocations

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigationevent#1.0.0)

```
val onBackCompletedFallbackInvocations: Int
```

The number of times the dispatcher's `https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner#onBackCompletedFallback()` lambda has been invoked.

This counter is incremented when a back navigation event completes and no `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventHandler` handles it.

### onForwardCompletedFallbackInvocations

Cmn Added in [1.2.0](https://developer.android.com/jetpack/androidx/releases/navigationevent#1.2.0)

```
val onForwardCompletedFallbackInvocations: Int
```

The number of times the dispatcher's `https://developer.android.com/reference/kotlin/androidx/navigationevent/testing/TestNavigationEventDispatcherOwner#onForwardCompletedFallback()` lambda has been invoked.

This counter is incremented when a forward navigation event completes and no `https://developer.android.com/reference/kotlin/androidx/navigationevent/NavigationEventHandler` handles it.