TestCarContext
public
class
TestCarContext
extends CarContext
java.lang.Object | ||||
↳ | android.content.Context | |||
↳ | android.content.ContextWrapper | |||
↳ | com.google.android.libraries.car.app.CarContext | |||
↳ | com.google.android.libraries.car.app.testing.TestCarContext |
The CarContext
that is used for testing.
This class will return the test version of car services for tracking calls during testing.
It also allows retrieving the car services already cast to the testing class by calling getCarService(Class
with the class name of the test services:
testCarContext.getCarService(TestAppManager.class)
testCarContext.getCarService(TestNavigationManager.class)
testCarContext.getCarService(TestScreenManager.class)
Allows retrieving all Intent
s sent via CarContext.startCarApp(Intent)
and
CarContext.startCarApp(Intent, Intent)
.
Summary
Inherited constants | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.google.android.libraries.car.app.CarContext
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
android.content.Context
|
Public methods | |
---|---|
static
TestCarContext
|
createCarContext(Context testContext)
Creates a |
void
|
finishCarApp()
Requests to finish the car app. |
<T>
T
|
getCarService(Class<T> serviceClass)
Returns the a car service, by class. |
Object
|
getCarService(String name)
Provides a car service by name. |
List<Intent>
|
getStartCarAppIntents()
Retrieves all |
boolean
|
hasCalledFinishCarApp()
Verifies if |
void
|
reset()
Resets the values tracked by this |
void
|
startCarApp(Intent intent)
Starts a car app on the car screen. |
Inherited methods | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
From class
com.google.android.libraries.car.app.CarContext
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
android.content.ContextWrapper
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
android.content.Context
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
From class
java.lang.Object
|
Public methods
createCarContext
public static TestCarContext createCarContext (Context testContext)
Creates a TestCarContext
to use for testing.
Parameters | |
---|---|
testContext |
Context |
Returns | |
---|---|
TestCarContext |
finishCarApp
public void finishCarApp ()
Requests to finish the car app.
Call this when your app is done and should be closed.
At some point after this call, CarAppService.onCarAppFinished()
will be called, and
eventually the OS will destroy your CarAppService
.
getCarService
public T getCarService (Class<T> serviceClass)
Returns the a car service, by class.
Currently supported classes are: AppManager
, NavigationManager
, ScreenManager
.
Parameters | |
---|---|
serviceClass |
Class : the class of the requested service. |
Returns | |
---|---|
T |
The car service instance. |
getCarService
public Object getCarService (String name)
Provides a car service by name.
The class of the returned object varies by the requested name.
Currently supported car services, and their respective classes, are:
APP_SERVICE
- An
AppManager
for communication between the app and the host. NAVIGATION_SERVICE
- A
NavigationManager
for management of navigation updates. SCREEN_MANAGER_SERVICE
- A
ScreenManager
for management ofScreen
s.
Parameters | |
---|---|
name |
String : The name of the car service requested. This should be one of CarContext.APP_SERVICE ,
CarContext.NAVIGATION_SERVICE or CarContext.SCREEN_MANAGER_SERVICE . |
Returns | |
---|---|
Object |
The car service instance. |
getStartCarAppIntents
public List<Intent> getStartCarAppIntents ()
Retrieves all Intent
s sent via CarContext.startCarApp(Intent)
.
The Intent
s are stored in order of calls.
The results will be stored until reset()
is called.
Returns | |
---|---|
List<Intent> |
hasCalledFinishCarApp
public boolean hasCalledFinishCarApp ()
Verifies if CarContext.finishCarApp()
has been called.
Returns | |
---|---|
boolean |
startCarApp
public void startCarApp (Intent intent)
Starts a car app on the car screen.
The target application will get the Intent
via CarAppService.onCreateScreen(Intent)
or CarAppService.onNewIntent(Intent)
.
Supported Intent
s:
- An
Intent
to navigate. - The action must be
ACTION_NAVIGATE
.- The data URI scheme must be either a latitude,longitude pair, or a + separated string query as follows:
- 1) "geo:12.345,14.8767" for a latitude, longitude pair.
- 2) "geo:0,0?q=123+Main+St,+Seattle,+WA+98101" for an address.
- 3) "geo:0,0?q=a+place+name" for a place to search for.
- The data URI scheme must be either a latitude,longitude pair, or a + separated string query as follows:
- An
Intent
to make a phone call. - The
Intent
must be created as defined here. - An
Intent
to start this app in the car. - The component name of the intent must be the one for the
CarAppService
that contains thisCarContext
. If the component name is for a different component, the method will throw aSecurityException
.
Parameters | |
---|---|
intent |
Intent : the Intent to send to the target application. |