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 fallbackOnBackPressed action is invoked as expected. It tracks the number of times this event occurs.

Summary

Public constructors

Public methods

@NonNull NavigationEventDispatcher

The NavigationEventDispatcher instance managed by this owner.

final int

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

Public constructors

TestNavigationEventDispatcherOwner

Added in 1.0.0-alpha09
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. This is invoked after the internal invocation counter is incremented.

Public methods

getNavigationEventDispatcher

Added in 1.0.0-alpha09
public @NonNull NavigationEventDispatcher getNavigationEventDispatcher()

The NavigationEventDispatcher instance managed by this owner.

This dispatcher is created with the fallbackOnBackPressed lambda provided to the TestNavigationEventDispatcherOwner's constructor, which increments onBackCompletedFallback.

getOnBackCompletedFallbackInvocations

Added in 1.0.0-alpha09
public final int getOnBackCompletedFallbackInvocations()

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

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