TestAppManager

public class TestAppManager
extends AppManager

java.lang.Object
   ↳ androidx.car.app.AppManager
     ↳ androidx.car.app.testing.TestAppManager


The AppManager that is used for testing.

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

Summary

Public methods

SurfaceCallback getSurfaceCallback()

Returns the callback set via AppManager.setSurfaceCallback(SurfaceCallback), or null if not set.

List<Pair<ScreenTemplate>> getTemplatesReturned()

Returns all the Templates returned from Screen.onGetTemplate() due to a call to AppManager.invalidate(), and the respective Screen instance that returned it.

List<CharSequence> getToastsShown()

Returns all the toasts shown via AppManager.showToast(CharSequence, int).

void reset()

Resets the values tracked by this TestAppManager and all ScreenControllers.

void setSurfaceCallback(SurfaceCallback surfaceCallback)

Sets the SurfaceCallback to get changes and updates to the surface on which the app can draw custom content, or null to reset the listener.

void showToast(CharSequence text, int duration)

Shows a toast on the car screen.

Inherited methods

Public methods

getSurfaceCallback

public SurfaceCallback getSurfaceCallback ()

Returns the callback set via AppManager.setSurfaceCallback(SurfaceCallback), or null if not set.

Returns
SurfaceCallback

getTemplatesReturned

public List<Pair<ScreenTemplate>> getTemplatesReturned ()

Returns all the Templates returned from Screen.onGetTemplate() due to a call to AppManager.invalidate(), and the respective Screen instance that returned it. The results are stored in the order in which they were returned from Screen.onGetTemplate(), where the first template in the list, is the first template returned.

The results will be stored until reset() is called.

Returns
List<Pair<ScreenTemplate>>

getToastsShown

public List<CharSequence> getToastsShown ()

Returns all the toasts shown via AppManager.showToast(CharSequence, int).

The toasts are stored in the order in which they are sent via AppManager.showToast(CharSequence, int), where the first toast in the list is the first toast that was sent.

The toasts will be stored until reset() is called.

Returns
List<CharSequence>

reset

public void reset ()

Resets the values tracked by this TestAppManager and all ScreenControllers.

setSurfaceCallback

public void setSurfaceCallback (SurfaceCallback surfaceCallback)

Sets the SurfaceCallback to get changes and updates to the surface on which the app can draw custom content, or null to reset the listener.

This call requires the androidx.car.app.ACCESS_SURFACE permission to be declared.

The Surface can be used to draw custom content such as a navigation app's map.

Note that the listener relates to UI events and will be executed on the main thread using Looper.getMainLooper().

Parameters
surfaceCallback SurfaceCallback

showToast