public
class
MonitoringInstrumentation
extends Instrumentation
java.lang.Object | ||
↳ | android.app.Instrumentation | |
↳ | android.support.test.runner.MonitoringInstrumentation |
Known Direct Subclasses |
An instrumentation that enables several advanced features and makes some hard guarantees about the state of the application under instrumentation.
A short list of these capabilities:Nested classes | |
---|---|
class |
MonitoringInstrumentation.ActivityFinisher
Loops through all the activities that have not yet finished and explicitly calls finish on them. |
Inherited constants |
---|
From
class
android.app.Instrumentation
|
Public constructors | |
---|---|
MonitoringInstrumentation()
|
Public methods | |
---|---|
void
|
callActivityOnCreate(Activity activity, Bundle bundle)
|
void
|
callActivityOnDestroy(Activity activity)
|
void
|
callActivityOnPause(Activity activity)
|
void
|
callActivityOnRestart(Activity activity)
|
void
|
callActivityOnResume(Activity activity)
|
void
|
callActivityOnStart(Activity activity)
|
void
|
callActivityOnStop(Activity activity)
|
void
|
callApplicationOnCreate(Application app)
|
void
|
execStartActivities(Context who, IBinder contextThread, IBinder token, Activity target, Intent[] intents, Bundle options)
|
Instrumentation.ActivityResult
|
execStartActivity(Context who, IBinder contextThread, IBinder token, Activity target, Intent intent, int requestCode, Bundle options)
|
Instrumentation.ActivityResult
|
execStartActivity(Context who, IBinder contextThread, IBinder token, Activity target, Intent intent, int requestCode)
|
Instrumentation.ActivityResult
|
execStartActivity(Context who, IBinder contextThread, IBinder token, Fragment target, Intent intent, int requestCode, Bundle options)
|
void
|
finish(int resultCode, Bundle results)
Ensures all activities launched in this instrumentation are finished before the instrumentation exits. |
Activity
|
newActivity(Class<?> clazz, Context context, IBinder token, Application application, Intent intent, ActivityInfo info, CharSequence title, Activity parent, String id, Object lastNonConfigurationInstance)
|
void
|
onCreate(Bundle arguments)
Sets up lifecycle monitoring, and argument registry. |
void
|
onDestroy()
|
boolean
|
onException(Object obj, Throwable e)
|
void
|
onStart()
This implementation of onStart() will guarantee that the Application's onCreate method has completed when it returns. |
Activity
|
startActivitySync(Intent intent)
|
Protected methods | |
---|---|
void
|
dumpThreadStateToOutputs(String outputFileName)
|
String
|
getThreadState()
|
final
void
|
specifyDexMakerCacheProperty()
|
void
|
waitForActivitiesToComplete()
Ensures we've onStopped() all activities which were onStarted(). |
Inherited methods | |
---|---|
From
class
android.app.Instrumentation
| |
From
class
java.lang.Object
|
MonitoringInstrumentation ()
void callActivityOnCreate (Activity activity, Bundle bundle)
Parameters | |
---|---|
activity |
Activity
|
bundle |
Bundle
|
void callActivityOnDestroy (Activity activity)
Parameters | |
---|---|
activity |
Activity
|
void callActivityOnPause (Activity activity)
Parameters | |
---|---|
activity |
Activity
|
void callActivityOnRestart (Activity activity)
Parameters | |
---|---|
activity |
Activity
|
void callActivityOnResume (Activity activity)
Parameters | |
---|---|
activity |
Activity
|
void callActivityOnStart (Activity activity)
Parameters | |
---|---|
activity |
Activity
|
void callActivityOnStop (Activity activity)
Parameters | |
---|---|
activity |
Activity
|
void callApplicationOnCreate (Application app)
Parameters | |
---|---|
app |
Application
|
void execStartActivities (Context who, IBinder contextThread, IBinder token, Activity target, Intent[] intents, Bundle options)
Parameters | |
---|---|
who |
Context
|
contextThread |
IBinder
|
token |
IBinder
|
target |
Activity
|
intents |
Intent
|
options |
Bundle
|
Instrumentation.ActivityResult execStartActivity (Context who, IBinder contextThread, IBinder token, Activity target, Intent intent, int requestCode, Bundle options)
Parameters | |
---|---|
who |
Context
|
contextThread |
IBinder
|
token |
IBinder
|
target |
Activity
|
intent |
Intent
|
requestCode |
int
|
options |
Bundle
|
Returns | |
---|---|
Instrumentation.ActivityResult |
Instrumentation.ActivityResult execStartActivity (Context who, IBinder contextThread, IBinder token, Activity target, Intent intent, int requestCode)
Parameters | |
---|---|
who |
Context
|
contextThread |
IBinder
|
token |
IBinder
|
target |
Activity
|
intent |
Intent
|
requestCode |
int
|
Returns | |
---|---|
Instrumentation.ActivityResult |
Instrumentation.ActivityResult execStartActivity (Context who, IBinder contextThread, IBinder token, Fragment target, Intent intent, int requestCode, Bundle options)
Parameters | |
---|---|
who |
Context
|
contextThread |
IBinder
|
token |
IBinder
|
target |
Fragment
|
intent |
Intent
|
requestCode |
int
|
options |
Bundle
|
Returns | |
---|---|
Instrumentation.ActivityResult |
void finish (int resultCode, Bundle results)
Ensures all activities launched in this instrumentation are finished before the instrumentation exits.
Subclasses who override this method should do their finish processing and then call super.finish to invoke this logic. Not waiting for all activities to finish() before exiting can cause device wide instability.
Parameters | |
---|---|
resultCode |
int
|
results |
Bundle
|
Activity newActivity (Class<?> clazz, Context context, IBinder token, Application application, Intent intent, ActivityInfo info, CharSequence title, Activity parent, String id, Object lastNonConfigurationInstance)
Parameters | |
---|---|
clazz |
Class
|
context |
Context
|
token |
IBinder
|
application |
Application
|
intent |
Intent
|
info |
ActivityInfo
|
title |
CharSequence
|
parent |
Activity
|
id |
String
|
lastNonConfigurationInstance |
Object
|
Returns | |
---|---|
Activity |
Throws | |
---|---|
InstantiationException |
|
IllegalAccessException |
void onCreate (Bundle arguments)
Sets up lifecycle monitoring, and argument registry.
Subclasses must call up to onCreate(). This onCreate method does not call start() it is the subclasses responsibility to call start if it desires.
Parameters | |
---|---|
arguments |
Bundle
|
void onDestroy ()
boolean onException (Object obj, Throwable e)
Parameters | |
---|---|
obj |
Object
|
e |
Throwable
|
Returns | |
---|---|
boolean |
void onStart ()
This implementation of onStart() will guarantee that the Application's onCreate method has completed when it returns.
Subclasses should call super.onStart() before executing any code that touches the application and it's state.
Activity startActivitySync (Intent intent)
Parameters | |
---|---|
intent |
Intent
|
Returns | |
---|---|
Activity |
void dumpThreadStateToOutputs (String outputFileName)
Parameters | |
---|---|
outputFileName |
String
|
String getThreadState ()
Returns | |
---|---|
String |
void specifyDexMakerCacheProperty ()
void waitForActivitiesToComplete ()
Ensures we've onStopped() all activities which were onStarted().
According to Activity's contract, the process is not killable between onStart and onStop. Breaking this contract (which finish() will if you let it) can cause bad behaviour (including a full restart of system_server).
We give the app 2 seconds to stop all its activities, then we proceed.