TestNavigationEventCallback



A test implementation of NavigationEventCallback 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 NavigationEvent objects and counts how many times each callback is fired.

Summary

Public constructors

TestNavigationEventCallback(
    isEnabled: Boolean,
    isPassThrough: Boolean,
    onEventStarted: TestNavigationEventCallback.(event: NavigationEvent) -> Unit,
    onEventProgressed: TestNavigationEventCallback.(event: NavigationEvent) -> Unit,
    onEventCancelled: TestNavigationEventCallback.() -> Unit,
    onEventCompleted: TestNavigationEventCallback.() -> Unit
)
Cmn

Public functions

open Unit

Callback for handling NavigationEventDispatcher.dispatchOnCancelled.

Cmn
open Unit

Callback for handling NavigationEventDispatcher.dispatchOnCompleted.

Cmn
open Unit

Callback for handling NavigationEventDispatcher.dispatchOnProgressed.

Cmn
open Unit

Callback for handling NavigationEventDispatcher.dispatchOnStarted.

Cmn

Public properties

Int

The number of times cancelledInvocations has been invoked.

Cmn
Int

The number of times completedInvocations has been invoked.

Cmn
List<NavigationEvent>

A List of all events received by the onEventProgressed callback.

Cmn
Int

The number of times progressedInvocations has been invoked.

Cmn
List<NavigationEvent>

A List of all events received by the onEventStarted callback.

Cmn
Int

The number of times onEventStarted has been invoked.

Cmn

Inherited properties

From androidx.navigationevent.NavigationEventCallback
Boolean

Controls whether this callback is active and should be considered for event dispatching.

Cmn
Boolean

Whether this callback should consume the events from NavigationEventDispatcher or allow it to continue.

Cmn

Public constructors

TestNavigationEventCallback

TestNavigationEventCallback(
    isEnabled: Boolean = true,
    isPassThrough: Boolean = false,
    onEventStarted: TestNavigationEventCallback.(event: NavigationEvent) -> Unit = {},
    onEventProgressed: TestNavigationEventCallback.(event: NavigationEvent) -> Unit = {},
    onEventCancelled: TestNavigationEventCallback.() -> Unit = {},
    onEventCompleted: TestNavigationEventCallback.() -> Unit = {}
)
Parameters
isEnabled: Boolean = true

Determines if the callback should process events. Defaults to true.

isPassThrough: Boolean = false

If true, events are passed to the next callback in the chain. Defaults to false.

onEventStarted: TestNavigationEventCallback.(event: NavigationEvent) -> Unit = {}

An optional lambda to execute when onEventStarted is called.

onEventProgressed: TestNavigationEventCallback.(event: NavigationEvent) -> Unit = {}

An optional lambda to execute when onEventProgressed is called.

onEventCancelled: TestNavigationEventCallback.() -> Unit = {}

An optional lambda to execute when onEventCancelled is called.

onEventCompleted: TestNavigationEventCallback.() -> Unit = {}

An optional lambda to execute when onEventCompleted is called.

Public functions

onEventCancelled

open fun onEventCancelled(): Unit

Callback for handling NavigationEventDispatcher.dispatchOnCancelled.

onEventCompleted

open fun onEventCompleted(): Unit

Callback for handling NavigationEventDispatcher.dispatchOnCompleted.

onEventProgressed

open fun onEventProgressed(event: NavigationEvent): Unit

Callback for handling NavigationEventDispatcher.dispatchOnProgressed.

onEventStarted

open fun onEventStarted(event: NavigationEvent): Unit

Callback for handling NavigationEventDispatcher.dispatchOnStarted.

Public properties

cancelledInvocations

val cancelledInvocationsInt

The number of times cancelledInvocations has been invoked.

completedInvocations

val completedInvocationsInt

The number of times completedInvocations has been invoked.

progressedEvents

val progressedEventsList<NavigationEvent>

A List of all events received by the onEventProgressed callback.

progressedInvocations

val progressedInvocationsInt

The number of times progressedInvocations has been invoked.

startedEvents

val startedEventsList<NavigationEvent>

A List of all events received by the onEventStarted callback.

startedInvocations

val startedInvocationsInt

The number of times onEventStarted has been invoked.