TestAppManager
class TestAppManager : AppManager
The AppManager that is used for testing.
This class will track the following usages of the AppManager throughout your test:
- All
SurfaceCallbacks set via callingsetSurfaceCallback. - The
Templates returned fromonGetTemplatedue to invalidate calls viainvalidate. - All toasts shown via calling
showToast.
Summary
Public functions |
|
|---|---|
SurfaceCallback? |
Returns the callback set via |
(Mutable)List<Pair<Screen!, Template!>!> |
Returns all the |
(Mutable)List<CharSequence!> |
Returns all the toasts shown via |
Unit |
reset()Resets the values tracked by this |
Unit |
setSurfaceCallback(surfaceCallback: SurfaceCallback?)Sets the |
Unit |
showToast(text: CharSequence, duration: Int)Shows a toast on the car screen. |
Inherited functions |
||||||
|---|---|---|---|---|---|---|
|
Public functions
getSurfaceCallback
fun getSurfaceCallback(): SurfaceCallback?
Returns the callback set via setSurfaceCallback, or null if not set.
getTemplatesReturned
fun getTemplatesReturned(): (Mutable)List<Pair<Screen!, Template!>!>
Returns all the Templates returned from onGetTemplate due to a call to invalidate, and the respective Screen instance that returned it. The results are stored in the order in which they were returned from onGetTemplate, where the first template in the list, is the first template returned.
The results will be stored until reset is called.
getToastsShown
fun getToastsShown(): (Mutable)List<CharSequence!>
Returns all the toasts shown via showToast.
The toasts are stored in the order in which they are sent via showToast, where the first toast in the list is the first toast that was sent.
The toasts will be stored until reset is called.
reset
fun reset(): Unit
Resets the values tracked by this TestAppManager and all ScreenControllers.
setSurfaceCallback
fun setSurfaceCallback(surfaceCallback: SurfaceCallback?): Unit
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 getMainLooper.
| Throws | |
|---|---|
java.lang.SecurityException |
if the app does not have the required permissions to access the surface |
androidx.car.app.HostException |
if the remote call fails |
showToast
fun showToast(text: CharSequence, duration: Int): Unit
Shows a toast on the car screen.
| Parameters | |
|---|---|
text: CharSequence |
the text to show |
duration: Int |
how long to display the message |
| Throws | |
|---|---|
androidx.car.app.HostException |
if the remote call fails |
java.lang.NullPointerException |
if |