TestNavigationManager

public class TestNavigationManager
extends NavigationManager

java.lang.Object
   ↳ androidx.car.app.navigation.NavigationManager
     ↳ androidx.car.app.testing.navigation.TestNavigationManager


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 methods

void clearNavigationManagerCallback()

Clears the callback for receiving navigation manager events.

int getNavigationEndedCount()

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

NavigationManagerCallback getNavigationManagerCallback()

Returns the callback set via NavigationManager.setNavigationManagerCallback(NavigationManagerCallback).

int getNavigationStartedCount()

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

List<Trip> getTripsSent()

Returns all the Trips sent via NavigationManager.updateTrip(Trip).

void navigationEnded()

Notifies the host that the app has ended active navigation.

void navigationStarted()

Notifies the host that the app has started active navigation.

void reset()

Resets the values tracked by this TestNavigationManager.

void setNavigationManagerCallback(Executor executor, NavigationManagerCallback callback)

Sets a callback to start receiving navigation manager events.

void updateTrip(Trip trip)

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

Inherited methods

Public constructors

TestNavigationManager

public TestNavigationManager (TestCarContext testCarContext, 
                HostDispatcher hostDispatcher)

Parameters
testCarContext TestCarContext

hostDispatcher HostDispatcher

Public methods

clearNavigationManagerCallback

public void clearNavigationManagerCallback ()

Clears the callback for receiving navigation manager events.

getNavigationEndedCount

public int getNavigationEndedCount ()

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

Returns
int

getNavigationManagerCallback

public NavigationManagerCallback getNavigationManagerCallback ()

Returns the callback set via NavigationManager.setNavigationManagerCallback(NavigationManagerCallback).

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

Returns
NavigationManagerCallback

getNavigationStartedCount

public int getNavigationStartedCount ()

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

Returns
int

getTripsSent

public List<Trip> getTripsSent ()

Returns all the Trips sent via NavigationManager.updateTrip(Trip).

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.

Returns
List<Trip>

public void navigationEnded ()

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.

public void navigationStarted ()

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(NavigationManagerCallback) 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 NavigationManagerCallback.onStopNavigation().

This method is idempotent.

reset

public void reset ()

Resets the values tracked by this TestNavigationManager.

setNavigationManagerCallback

public void setNavigationManagerCallback (Executor executor, 
                NavigationManagerCallback callback)

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

updateTrip

public void updateTrip (Trip trip)

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 NavigationManagerCallback.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 Maneuvers 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