TestNavigationManager

class TestNavigationManager : NavigationManager


The NavigationManager that is used for testing.

This class will track the following usages of the NavigationManager throughout your test:

Summary

Public constructors

TestNavigationManager(
    testCarContext: TestCarContext,
    hostDispatcher: HostDispatcher
)

Public functions

Unit

Clears the callback for receiving navigation manager events.

Int

Returns the number of times that navigation was ended via navigationEnded since creation or the last call to reset.

NavigationManagerCallback?

Returns the callback set via setNavigationManagerCallback.

Int

Returns the number of times that navigation was started via navigationStarted since creation or the last call to reset.

(Mutable)List<Trip!>

Returns all the Trips sent via updateTrip.

Unit

Notifies the host that the app has ended active navigation.

Unit

Notifies the host that the app has started active navigation.

Unit

Resets the values tracked by this TestNavigationManager.

Unit
setNavigationManagerCallback(
    executor: Executor,
    callback: NavigationManagerCallback
)

Sets a callback to start receiving navigation manager events.

Unit

Sends the destinations, steps, and trip estimates to the host.

Inherited functions

From androidx.car.app.navigation.NavigationManager
Unit

Sets a callback to start receiving navigation manager events.

Public constructors

TestNavigationManager

Added in 1.1.0
TestNavigationManager(
    testCarContext: TestCarContext,
    hostDispatcher: HostDispatcher
)

Public functions

clearNavigationManagerCallback

Added in 1.4.0-rc02
fun clearNavigationManagerCallback(): Unit

Clears the callback for receiving navigation manager events.

Throws
java.lang.IllegalStateException

if navigation is started (see navigationStarted for more info), or if the current thread is not the main thread

getNavigationEndedCount

Added in 1.1.0
fun getNavigationEndedCount(): Int

Returns the number of times that navigation was ended via navigationEnded since creation or the last call to reset.

getNavigationManagerCallback

Added in 1.1.0
fun getNavigationManagerCallback(): NavigationManagerCallback?

Returns the callback set via setNavigationManagerCallback.

The listener will be null if one was never set, or if clearNavigationManagerCallback or reset was called.

getNavigationStartedCount

Added in 1.1.0
fun getNavigationStartedCount(): Int

Returns the number of times that navigation was started via navigationStarted since creation or the last call to reset.

getTripsSent

Added in 1.1.0
fun getTripsSent(): (Mutable)List<Trip!>

Returns all the Trips sent via updateTrip.

The trips are stored in the order in which they were sent, where the first trip in the list, is the first trip sent.

The trips will be stored until reset is called.

Added in 1.4.0-rc02
fun navigationEnded(): Unit

Notifies the host that the app has ended active navigation.

Only one app may be actively navigating in the car at any time and ownership is managed by the host. The app must call this method to inform the system that it has ended navigation, for example, in response to the user cancelling navigation or upon reaching the destination.

This method is idempotent.

Throws
java.lang.IllegalStateException

if the current thread is not the main thread

Added in 1.4.0-rc02
fun navigationStarted(): Unit

Notifies the host that the app has started active navigation.

Only one app may be actively navigating in the car at any time and ownership is managed by the host. The app must call this method to inform the system that it has started navigation in response to user action.

This function can only called if setNavigationManagerCallback has been called with a non-null value. The callback is required so that a signal to stop navigation from the host can be handled using onStopNavigation.

This method is idempotent.

Throws
java.lang.IllegalStateException

if no navigation manager callback has been set, or if the current thread is not the main thread

reset

Added in 1.1.0
fun reset(): Unit

Resets the values tracked by this TestNavigationManager.

setNavigationManagerCallback

Added in 1.4.0-rc02
fun setNavigationManagerCallback(
    executor: Executor,
    callback: NavigationManagerCallback
): Unit

Sets a callback to start receiving navigation manager events.

Parameters
executor: Executor

the executor which will be used for invoking the callback

callback: NavigationManagerCallback

the NavigationManagerCallback to use

Throws
java.lang.IllegalStateException

if the current thread is not the main thread

updateTrip

Added in 1.4.0-rc02
fun updateTrip(trip: Trip): Unit

Sends the destinations, steps, and trip estimates to the host.

The data may be rendered at different places in the car such as the instrument cluster screen or the heads-up display.

This method should only be invoked once the navigation app has called navigationStarted, or else the updates will be dropped by the host. Once the app has called navigationEnded or received onStopNavigation it should stop sending updates.

As the location changes, and in accordance with speed and rounded distance changes, the TravelEstimates in the provided Trip should be rebuilt and this method called again. For example, when the next step is greater than 10 kilometers away and the display unit is kilometers, updates should occur roughly every kilometer.

Data provided to the cluster display depends on the vehicle capabilities. In some instances the information may not be shown at all. On some vehicles s of unknown type may be skipped while on other displays the associated icon may be shown.

Parameters
trip: Trip

destination, steps, and trip estimates to be sent to the host

Throws
androidx.car.app.HostException

if the call is invoked by an app that is not declared as a navigation app in the manifest

java.lang.IllegalStateException

if the call occurs when navigation is not started (see navigationStarted for more info), or if the current thread is not the main thread

java.lang.IllegalArgumentException

if any of the destinations, steps, or trip position is not well formed