TestNavigationEventDispatcherOwner


public final class TestNavigationEventDispatcherOwner implements NavigationEventDispatcherOwner


A test implementation of NavigationEventDispatcherOwner for verifying 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

TestNavigationEventDispatcherOwner(
    @NonNull Function1<@NonNull TestNavigationEventDispatcherOwnerUnit> onForwardCompletedFallback,
    @NonNull Function1<@NonNull TestNavigationEventDispatcherOwnerUnit> onBackCompletedFallback
)

Creates a TestNavigationEventDispatcherOwner with both forward and back fallbacks.

Public methods

@NonNull NavigationEventDispatcher

The NavigationEventDispatcher instance managed by this owner.

final @NonNull DirectNavigationEventInput

The DirectNavigationEventInput instance managed by this owner.

final int

The number of times the dispatcher's onBackCompletedFallback lambda has been invoked.

final int

The number of times the dispatcher's onForwardCompletedFallback lambda has been invoked.

Public constructors

TestNavigationEventDispatcherOwner

Added in 1.0.0
public TestNavigationEventDispatcherOwner(
    @NonNull Function1<@NonNull TestNavigationEventDispatcherOwnerUnit> onBackCompletedFallback
)
Parameters
@NonNull Function1<@NonNull TestNavigationEventDispatcherOwnerUnit> onBackCompletedFallback

An optional lambda to execute when the NavigationEventDispatcher back fallback is triggered.

TestNavigationEventDispatcherOwner

Added in 1.2.0-alpha01
public TestNavigationEventDispatcherOwner(
    @NonNull Function1<@NonNull TestNavigationEventDispatcherOwnerUnit> onForwardCompletedFallback,
    @NonNull Function1<@NonNull TestNavigationEventDispatcherOwnerUnit> onBackCompletedFallback
)

Creates a TestNavigationEventDispatcherOwner with both forward and back fallbacks.

Parameters
@NonNull Function1<@NonNull TestNavigationEventDispatcherOwnerUnit> onForwardCompletedFallback

A lambda to execute when the NavigationEventDispatcher forward fallback is triggered.

@NonNull Function1<@NonNull TestNavigationEventDispatcherOwnerUnit> onBackCompletedFallback

An optional lambda to execute when the NavigationEventDispatcher back fallback is triggered.

Public methods

getNavigationEventDispatcher

Added in 1.0.0
public @NonNull NavigationEventDispatcher getNavigationEventDispatcher()

The NavigationEventDispatcher instance managed by this owner.

This dispatcher is created with the onBackCompletedFallback and onForwardCompletedFallback lambdas provided to the TestNavigationEventDispatcherOwner's constructor, which increments onBackCompletedFallbackInvocations and onForwardCompletedFallbackInvocations.

getNavigationEventInput

Added in 1.2.0-alpha01
public final @NonNull DirectNavigationEventInput getNavigationEventInput()

The DirectNavigationEventInput instance managed by this owner.

This input is automatically added to the navigationEventDispatcher during initialization, allowing for direct simulation of navigation events.

getOnBackCompletedFallbackInvocations

Added in 1.0.0
public final int getOnBackCompletedFallbackInvocations()

The number of times the dispatcher's onBackCompletedFallback lambda has been invoked.

This counter is incremented when a back navigation event completes and no NavigationEventHandler handles it.

getOnForwardCompletedFallbackInvocations

Added in 1.2.0-alpha01
public final int getOnForwardCompletedFallbackInvocations()

The number of times the dispatcher's onForwardCompletedFallback lambda has been invoked.

This counter is incremented when a forward navigation event completes and no NavigationEventHandler handles it.