# TestNavigationEventHandler

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/TestNavigationEventHandler.kt+class:androidx.navigationevent.testing.TestNavigationEventHandler) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/navigationevent#1.0.0)

*** ** * ** ***


```
public final class TestNavigationEventHandler<T extends NavigationEventInfo> extends NavigationEventHandler<@NonNull T>
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.navigationevent.NavigationEventHandler](https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler)\<@[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) T\> ||
|   | ↳ | [androidx.navigationevent.testing.TestNavigationEventHandler](https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler) |

*** ** * ** ***

A test implementation of `https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler` that records received events and invocation counts.

This class is primarily used in tests to verify that specific navigation event callbacks are triggered as expected. It captures the `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent` objects and counts how many times each callback is fired.

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/androidx/navigationevent/NavigationEventInfo>` | The `https://developer.android.com/reference/androidx/navigationevent/NavigationEventInfo` type this callback handles. |

## Summary

| ### Public constructors |
|---|
| `<T extends https://developer.android.com/reference/androidx/navigationevent/NavigationEventInfo> https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#TestNavigationEventHandler(androidx.navigationevent.NavigationEventInfo,kotlin.collections.List,kotlin.collections.List,kotlin.Boolean,kotlin.Function2,kotlin.Function2,kotlin.Function1,kotlin.Function1,kotlin.Boolean,kotlin.Function2,kotlin.Function2,kotlin.Function1,kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull T currentInfo, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> backInfo, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> forwardInfo, boolean isForwardEnabled, @https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler<@https://developer.android.com/reference/androidx/annotation/NonNull T>, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onForwardStarted, @https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler<@https://developer.android.com/reference/androidx/annotation/NonNull T>, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onForwardProgressed, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler<@https://developer.android.com/reference/androidx/annotation/NonNull T>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onForwardCancelled, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler<@https://developer.android.com/reference/androidx/annotation/NonNull T>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onForwardCompleted, boolean isBackEnabled, @https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler<@https://developer.android.com/reference/androidx/annotation/NonNull T>, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onBackStarted, @https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler<@https://developer.android.com/reference/androidx/annotation/NonNull T>, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onBackProgressed, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler<@https://developer.android.com/reference/androidx/annotation/NonNull T>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onBackCancelled, @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler<@https://developer.android.com/reference/androidx/annotation/NonNull T>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onBackCompleted )` |

| ### Public methods |
|---|---|
| `final int` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#getOnBackCancelledInvocations()()` Number of times `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onBackCancelled()` has been invoked. |
| `final int` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#getOnBackCompletedInvocations()()` Number of times `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onBackCompleted()` has been invoked. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent>` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#getOnBackProgressedEvents()()` All events received by `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onBackProgressed(androidx.navigationevent.NavigationEvent)`. |
| `final int` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#getOnBackProgressedInvocations()()` Number of times `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onBackProgressed(androidx.navigationevent.NavigationEvent)` has been invoked. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent>` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#getOnBackStartedEvents()()` All events received by `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onBackStarted(androidx.navigationevent.NavigationEvent)`. |
| `final int` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#getOnBackStartedInvocations()()` Number of times `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onBackStarted(androidx.navigationevent.NavigationEvent)` has been invoked. |
| `final int` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#getOnForwardCancelledInvocations()()` Number of times `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onForwardCancelled()` has been invoked. |
| `final int` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#getOnForwardCompletedInvocations()()` Number of times `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onForwardCompleted()` has been invoked. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent>` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#getOnForwardProgressedEvents()()` All events received by `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onForwardProgressed(androidx.navigationevent.NavigationEvent)`. |
| `final int` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#getOnForwardProgressedInvocations()()` Number of times `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onForwardProgressed(androidx.navigationevent.NavigationEvent)` has been invoked. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent>` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#getOnForwardStartedEvents()()` All events received by `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onForwardStarted(androidx.navigationevent.NavigationEvent)`. |
| `final int` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#getOnForwardStartedInvocations()()` Number of times `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onForwardStarted(androidx.navigationevent.NavigationEvent)` has been invoked. |

| ### Protected methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onBackCancelled()()` Override this to handle the cancellation of a back navigation event. |
| `void` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onBackCompleted()()` Override this to handle the completion of a back navigation event. |
| `void` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onBackProgressed(androidx.navigationevent.NavigationEvent)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent event)` Override this to handle the progress of an ongoing back navigation event. |
| `void` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onBackStarted(androidx.navigationevent.NavigationEvent)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent event)` Override this to handle the beginning of a back navigation event. |
| `void` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onForwardCancelled()()` Override this to handle the cancellation of a forward navigation event. |
| `void` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onForwardCompleted()()` Override this to handle the completion of a forward navigation event. |
| `void` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onForwardProgressed(androidx.navigationevent.NavigationEvent)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent event)` Override this to handle the progress of an ongoing forward navigation event. |
| `void` | `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onForwardStarted(androidx.navigationevent.NavigationEvent)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent event)` Override this to handle the beginning of a forward navigation event. |

### Inherited methods

From [androidx.navigationevent.NavigationEventHandler](https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler) `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull T>` `https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler#getBackInfo()()`

A test implementation of `https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler` that records received events and invocation counts.
`final @https://developer.android.com/reference/androidx/annotation/NonNull T` `https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler#getCurrentInfo()()`

A test implementation of `https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler` that records received events and invocation counts.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull T>` `https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler#getForwardInfo()()`

A test implementation of `https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler` that records received events and invocation counts.
`final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEventTransitionState` `https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler#getTransitionState()()`

The current transition state of this specific handler (e.g., `https://developer.android.com/reference/androidx/navigationevent/NavigationEventTransitionState.Idle` or `https://developer.android.com/reference/androidx/navigationevent/NavigationEventTransitionState.InProgress`).
`final boolean` `https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler#isBackEnabled()()`

Controls whether this handler is active and should be considered for back event dispatching.
`final boolean` `https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler#isForwardEnabled()()`

Controls whether this handler is active and should be considered for forward event dispatching.
`final void` `https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler#remove()()`

Removes this handler from the `https://developer.android.com/reference/androidx/navigationevent/NavigationEventDispatcher` it is registered with.
`final void` `https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler#setBackEnabled(kotlin.Boolean)(boolean value)`

Controls whether this handler is active and should be considered for back event dispatching.
`final void` `https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler#setForwardEnabled(kotlin.Boolean)(boolean value)`

Controls whether this handler is active and should be considered for forward event dispatching.
`final void` `https://developer.android.com/reference/androidx/navigationevent/NavigationEventHandler#setInfo(androidx.navigationevent.NavigationEventInfo,kotlin.collections.List,kotlin.collections.List)(
@https://developer.android.com/reference/androidx/annotation/NonNull T currentInfo,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> backInfo,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> forwardInfo
)`

Sets the directional navigation context for this handler.

## Public constructors

### TestNavigationEventHandler

```
public <T extends NavigationEventInfo> TestNavigationEventHandler(
    @NonNull T currentInfo,
    @NonNull List<@NonNull T> backInfo,
    @NonNull List<@NonNull T> forwardInfo,
    boolean isForwardEnabled,
    @NonNull Function2<@NonNull TestNavigationEventHandler<@NonNull T>, @NonNull NavigationEvent, Unit> onForwardStarted,
    @NonNull Function2<@NonNull TestNavigationEventHandler<@NonNull T>, @NonNull NavigationEvent, Unit> onForwardProgressed,
    @NonNull Function1<@NonNull TestNavigationEventHandler<@NonNull T>, Unit> onForwardCancelled,
    @NonNull Function1<@NonNull TestNavigationEventHandler<@NonNull T>, Unit> onForwardCompleted,
    boolean isBackEnabled,
    @NonNull Function2<@NonNull TestNavigationEventHandler<@NonNull T>, @NonNull NavigationEvent, Unit> onBackStarted,
    @NonNull Function2<@NonNull TestNavigationEventHandler<@NonNull T>, @NonNull NavigationEvent, Unit> onBackProgressed,
    @NonNull Function1<@NonNull TestNavigationEventHandler<@NonNull T>, Unit> onBackCancelled,
    @NonNull Function1<@NonNull TestNavigationEventHandler<@NonNull T>, Unit> onBackCompleted
)
```

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/androidx/navigationevent/NavigationEventInfo>` | The `https://developer.android.com/reference/androidx/navigationevent/NavigationEventInfo` type this callback handles. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull T currentInfo` | Initial current navigation info. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> backInfo` | Initial back stack info list. Defaults to empty. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull T> forwardInfo` | Initial forward stack info list. Defaults to empty. |
| `boolean isForwardEnabled` | Determines if forward callbacks should process events. Defaults to `true`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler<@https://developer.android.com/reference/androidx/annotation/NonNull T>, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onForwardStarted` | Optional lambda to execute when `onForwardStarted` is called. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler<@https://developer.android.com/reference/androidx/annotation/NonNull T>, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onForwardProgressed` | Optional lambda to execute when `onForwardProgressed` is called. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler<@https://developer.android.com/reference/androidx/annotation/NonNull T>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onForwardCancelled` | Optional lambda to execute when `onForwardCancelled` is called. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler<@https://developer.android.com/reference/androidx/annotation/NonNull T>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onForwardCompleted` | Optional lambda to execute when `onForwardCompleted` is called. |
| `boolean isBackEnabled` | Determines if back callbacks should process events. Defaults to `true`. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler<@https://developer.android.com/reference/androidx/annotation/NonNull T>, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onBackStarted` | Optional lambda to execute when `onBackStarted` is called. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function2<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler<@https://developer.android.com/reference/androidx/annotation/NonNull T>, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onBackProgressed` | Optional lambda to execute when `onBackProgressed` is called. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler<@https://developer.android.com/reference/androidx/annotation/NonNull T>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onBackCancelled` | Optional lambda to execute when `onBackCancelled` is called. |
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler<@https://developer.android.com/reference/androidx/annotation/NonNull T>, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> onBackCompleted` | Optional lambda to execute when `onBackCompleted` is called. |

## Public methods

### getOnBackCancelledInvocations

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

```
public final int getOnBackCancelledInvocations()
```

Number of times `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onBackCancelled()` has been invoked.

### getOnBackCompletedInvocations

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

```
public final int getOnBackCompletedInvocations()
```

Number of times `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onBackCompleted()` has been invoked.

### getOnBackProgressedEvents

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

```
public final @NonNull List<@NonNull NavigationEvent> getOnBackProgressedEvents()
```

All events received by `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onBackProgressed(androidx.navigationevent.NavigationEvent)`.

### getOnBackProgressedInvocations

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

```
public final int getOnBackProgressedInvocations()
```

Number of times `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onBackProgressed(androidx.navigationevent.NavigationEvent)` has been invoked.

### getOnBackStartedEvents

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

```
public final @NonNull List<@NonNull NavigationEvent> getOnBackStartedEvents()
```

All events received by `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onBackStarted(androidx.navigationevent.NavigationEvent)`.

### getOnBackStartedInvocations

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

```
public final int getOnBackStartedInvocations()
```

Number of times `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onBackStarted(androidx.navigationevent.NavigationEvent)` has been invoked.

### getOnForwardCancelledInvocations

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

```
public final int getOnForwardCancelledInvocations()
```

Number of times `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onForwardCancelled()` has been invoked.

### getOnForwardCompletedInvocations

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

```
public final int getOnForwardCompletedInvocations()
```

Number of times `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onForwardCompleted()` has been invoked.

### getOnForwardProgressedEvents

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

```
public final @NonNull List<@NonNull NavigationEvent> getOnForwardProgressedEvents()
```

All events received by `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onForwardProgressed(androidx.navigationevent.NavigationEvent)`.

### getOnForwardProgressedInvocations

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

```
public final int getOnForwardProgressedInvocations()
```

Number of times `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onForwardProgressed(androidx.navigationevent.NavigationEvent)` has been invoked.

### getOnForwardStartedEvents

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

```
public final @NonNull List<@NonNull NavigationEvent> getOnForwardStartedEvents()
```

All events received by `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onForwardStarted(androidx.navigationevent.NavigationEvent)`.

### getOnForwardStartedInvocations

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

```
public final int getOnForwardStartedInvocations()
```

Number of times `https://developer.android.com/reference/androidx/navigationevent/testing/TestNavigationEventHandler#onForwardStarted(androidx.navigationevent.NavigationEvent)` has been invoked.

## Protected methods

### onBackCancelled

```
protected void onBackCancelled()
```

Override this to handle the cancellation of a back navigation event.

This is called when the user cancels the navigation action, signaling that the UI should return to its original state.

### onBackCompleted

```
protected void onBackCompleted()
```

Override this to handle the completion of a back navigation event.

This is called when the user commits to the back navigation action, signaling that the navigation should be finalized.

The default implementation throws an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html`. Any handler that can be completed **must** override this method to handle the navigation.

### onBackProgressed

```
protected void onBackProgressed(@NonNull NavigationEvent event)
```

Override this to handle the progress of an ongoing back navigation event.

This is called repeatedly during a gesture-driven back navigation to update the UI in real-time based on the user's input.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent event` | The `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent` containing progress information. |

### onBackStarted

```
protected void onBackStarted(@NonNull NavigationEvent event)
```

Override this to handle the beginning of a back navigation event.

This is called when a user action initiates a back navigation. It's the ideal place to prepare UI elements for a transition.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent event` | The `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent` that triggered this handler. |

### onForwardCancelled

```
protected void onForwardCancelled()
```

Override this to handle the cancellation of a forward navigation event.

This is called when the user cancels the navigation action, signaling that the UI should return to its original state.

### onForwardCompleted

```
protected void onForwardCompleted()
```

Override this to handle the completion of a forward navigation event.

This is called when the user commits to the forward navigation action, signaling that the navigation should be finalized.

The default implementation throws an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html`. Any handler that can be completed **must** override this method to handle the navigation.

### onForwardProgressed

```
protected void onForwardProgressed(@NonNull NavigationEvent event)
```

Override this to handle the progress of an ongoing forward navigation event.

This is called repeatedly during a gesture-driven forward navigation to update the UI in real-time based on the user's input.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent event` | The `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent` containing progress information. |

### onForwardStarted

```
protected void onForwardStarted(@NonNull NavigationEvent event)
```

Override this to handle the beginning of a forward navigation event.

This is called when a user action initiates a forward navigation. It's the ideal place to prepare UI elements for a transition.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/navigationevent/NavigationEvent event` | The `https://developer.android.com/reference/androidx/navigationevent/NavigationEvent` that triggered this handler. |