TestLooperManager! |
acquireLooperManager(looper: Looper!)
Takes control of the execution of messages on the specified looper until TestLooperManager.release is called.
|
Unit |
addMonitor(monitor: Instrumentation.ActivityMonitor!)
Add a new ActivityMonitor that will be checked whenever an activity is started. The monitor is added after any existing ones; the monitor will be hit only if none of the existing monitors can themselves handle the Intent.
|
Instrumentation.ActivityMonitor! |
addMonitor(filter: IntentFilter!, result: Instrumentation.ActivityResult!, block: Boolean)
A convenience wrapper for addMonitor(android.app.Instrumentation.ActivityMonitor) that creates an intent filter matching ActivityMonitor for you and returns it.
|
Instrumentation.ActivityMonitor! |
addMonitor(cls: String!, result: Instrumentation.ActivityResult!, block: Boolean)
A convenience wrapper for addMonitor(android.app.Instrumentation.ActivityMonitor) that creates a class matching ActivityMonitor for you and returns it.
|
Unit |
addResults(results: Bundle!)
Report some results in the middle of instrumentation execution. Later results (including those provided by finish ) will be combined with android.os.Bundle#putAll.
|
Unit |
callActivityOnCreate(activity: Activity!, icicle: Bundle!)
Perform calling of an activity's android.app.Activity#onCreate method. The default implementation simply calls through to that method.
|
Unit |
callActivityOnCreate(activity: Activity!, icicle: Bundle!, persistentState: PersistableBundle!)
Perform calling of an activity's android.app.Activity#onCreate method. The default implementation simply calls through to that method.
|
Unit |
callActivityOnDestroy(activity: Activity!)
|
Unit |
callActivityOnNewIntent(activity: Activity!, intent: Intent!)
Perform calling of an activity's android.app.Activity#onNewIntent method. The default implementation simply calls through to that method.
|
Unit |
callActivityOnNewIntent(activity: Activity, intent: Intent, caller: ComponentCaller)
Same as callActivityOnNewIntent(android.app.Activity,android.content.Intent) , but with an extra parameter for the ComponentCaller instance associated with the app that sent the intent.
|
Unit |
callActivityOnPause(activity: Activity!)
Perform calling of an activity's Activity.onPause method. The default implementation simply calls through to that method.
|
Unit |
callActivityOnPictureInPictureRequested(activity: Activity)
Perform calling of an activity's Activity.onPictureInPictureRequested method. The default implementation simply calls through to that method.
|
Unit |
callActivityOnPostCreate(activity: Activity, savedInstanceState: Bundle?)
Perform calling of an activity's android.app.Activity#onPostCreate method. The default implementation simply calls through to that method.
|
Unit |
callActivityOnPostCreate(activity: Activity, savedInstanceState: Bundle?, persistentState: PersistableBundle?)
Perform calling of an activity's android.app.Activity#onPostCreate method. The default implementation simply calls through to that method.
|
Unit |
callActivityOnRestart(activity: Activity!)
Perform calling of an activity's Activity.onRestart method. The default implementation simply calls through to that method.
|
Unit |
callActivityOnRestoreInstanceState(activity: Activity, savedInstanceState: Bundle)
Perform calling of an activity's android.app.Activity#onRestoreInstanceState method. The default implementation simply calls through to that method.
|
Unit |
callActivityOnRestoreInstanceState(activity: Activity, savedInstanceState: Bundle?, persistentState: PersistableBundle?)
Perform calling of an activity's android.app.Activity#onRestoreInstanceState method. The default implementation simply calls through to that method.
|
Unit |
callActivityOnResume(activity: Activity!)
Perform calling of an activity's Activity.onResume method. The default implementation simply calls through to that method.
|
Unit |
callActivityOnSaveInstanceState(activity: Activity, outState: Bundle)
Perform calling of an activity's android.app.Activity#onSaveInstanceState method. The default implementation simply calls through to that method.
|
Unit |
callActivityOnSaveInstanceState(activity: Activity, outState: Bundle, outPersistentState: PersistableBundle)
Perform calling of an activity's android.app.Activity#onSaveInstanceState method. The default implementation simply calls through to that method.
|
Unit |
callActivityOnStart(activity: Activity!)
Perform calling of an activity's Activity.onStart method. The default implementation simply calls through to that method.
|
Unit |
callActivityOnStop(activity: Activity!)
Perform calling of an activity's Activity.onStop method. The default implementation simply calls through to that method.
|
Unit |
callActivityOnUserLeaving(activity: Activity!)
Perform calling of an activity's Activity.onUserLeaveHint method. The default implementation simply calls through to that method.
|
Unit |
callApplicationOnCreate(app: Application!)
Perform calling of the application's Application.onCreate method. The default implementation simply calls through to that method.
Note: This method will be called immediately after onCreate(android.os.Bundle) . Often instrumentation tests start their test thread in onCreate(); you need to be careful of races between these. (Well between it and everything else, but let's start here.)
|
Boolean |
checkMonitorHit(monitor: Instrumentation.ActivityMonitor!, minHits: Int)
Test whether an existing ActivityMonitor has been hit. If the monitor has been hit at least minHits times, then it will be removed from the activity monitor list and true returned. Otherwise it is left as-is and false is returned.
|
Unit |
endPerformanceSnapshot()
|
Unit |
finish(resultCode: Int, results: Bundle!)
Terminate instrumentation of the application. This will cause the application process to exit, removing this instrumentation from the next time the application is started. If multiple processes are currently running for this instrumentation, all of those processes will be killed.
|
Bundle! |
getAllocCounts()
Returns a bundle with the current results from the allocation counting.
|
Bundle! |
getBinderCounts()
Returns a bundle with the counts for various binder counts for this process. Currently the only two that are reported are the number of send and the number of received transactions.
|
ComponentName! |
getComponentName()
Returns complete component name of this instrumentation.
|
Context! |
getContext()
Return the Context of this instrumentation's package. Note that this is often different than the Context of the application being instrumentated, since the instrumentation code often lives is a different package than that of the application it is running against. See getTargetContext to retrieve a Context for the target application.
|
String! |
getProcessName()
Return the name of the process this instrumentation is running in. Note this should only be used for testing and debugging. If you are thinking about using this to, for example, conditionalize what is initialized in an Application class, it is strongly recommended to instead use lazy initialization (such as a getter for the state that only creates it when requested). This can greatly reduce the work your process does when created for secondary things, such as to receive a broadcast.
|
Context! |
getTargetContext()
Return a Context for the target application being instrumented. Note that this is often different than the Context of the instrumentation code, since the instrumentation code often lives is a different package than that of the application it is running against. See getContext to retrieve a Context for the instrumentation code.
|
UiAutomation! |
getUiAutomation()
Gets the UiAutomation instance with no flags set.
Note: The APIs exposed via the returned UiAutomation work across application boundaries while the APIs exposed by the instrumentation do not. For example, Instrumentation.sendPointerSync(MotionEvent) will not allow you to inject the event in an app different from the instrumentation target, while UiAutomation.injectInputEvent(android.view.InputEvent, boolean) will work regardless of the current application.
A typical test case should be using either the UiAutomation or Instrumentation APIs. Using both APIs at the same time is not a mistake by itself but a client has to be aware of the APIs limitations.
Equivalent to getUiAutomation(0) . If a UiAutomation exists with different flags, the flags on that instance will be changed, and then it will be returned.
Compatibility mode: This method is infallible for apps targeted for Build.VERSION_CODES.R and earlier versions; for apps targeted for later versions, it will return null if UiAutomation fails to connect. The caller can check the return value and retry on error.
|
UiAutomation! |
getUiAutomation(flags: Int)
Gets the UiAutomation instance with flags set.
Note: The APIs exposed via the returned UiAutomation work across application boundaries while the APIs exposed by the instrumentation do not. For example, Instrumentation.sendPointerSync(MotionEvent) will not allow you to inject the event in an app different from the instrumentation target, while UiAutomation.injectInputEvent(android.view.InputEvent, boolean) will work regardless of the current application.
A typical test case should be using either the UiAutomation or Instrumentation APIs. Using both APIs at the same time is not a mistake by itself but a client has to be aware of the APIs limitations.
If a UiAutomation exists with different flags, the flags on that instance will be changed, and then it will be returned.
Compatibility mode: This method is infallible for apps targeted for Build.VERSION_CODES.R and earlier versions; for apps targeted for later versions, it will return null if UiAutomation fails to connect. The caller can check the return value and retry on error.
|
Boolean |
invokeContextMenuAction(targetActivity: Activity!, id: Int, flag: Int)
Show the context menu for the currently focused view and executes a particular context menu item.
|
Boolean |
invokeMenuActionSync(targetActivity: Activity!, id: Int, flag: Int)
Execute a particular menu item.
|
Boolean |
isProfiling()
Check whether this instrumentation was started with profiling enabled.
|
Activity! |
newActivity(clazz: Class<*>!, context: Context!, token: IBinder!, application: Application!, intent: Intent!, info: ActivityInfo!, title: CharSequence!, parent: Activity!, id: String!, lastNonConfigurationInstance: Any!)
Perform instantiation of an Activity object. This method is intended for use with unit tests, such as android.test.ActivityUnitTestCase. The activity will be useable locally but will be missing some of the linkages necessary for use within the system.
|
Activity! |
newActivity(cl: ClassLoader!, className: String!, intent: Intent!)
Perform instantiation of the process's Activity object. The default implementation provides the normal system behavior.
|
Application! |
newApplication(cl: ClassLoader!, className: String!, context: Context!)
Perform instantiation of the process's Application object. The default implementation provides the normal system behavior.
|
Application! |
newApplication(clazz: Class<*>!, context: Context!)
Perform instantiation of the process's Application object. The default implementation provides the normal system behavior.
|
Unit |
onDestroy()
Called when the instrumented application is stopping, after all of the normal application cleanup has occurred.
|
Boolean |
onException(obj: Any!, e: Throwable!)
This is called whenever the system captures an unhandled exception that was thrown by the application. The default implementation simply returns false, allowing normal system handling of the exception to take place.
|
Unit |
removeMonitor(monitor: Instrumentation.ActivityMonitor!)
Remove an ActivityMonitor that was previously added with #addMonitor.
|
Unit |
resetInTouchMode()
Resets the touch mode to the device default.
|
Unit |
runOnMainSync(runner: Runnable!)
Execute a call on the application's main thread, blocking until it is complete. Useful for doing things that are not thread-safe, such as looking at or modifying the view hierarchy.
|
Unit |
sendCharacterSync(keyCode: Int)
Sends up and down key events with the given key code to the currently focused window, and waits for it to be processed.
Equivalent to sendKeyDownUpSync(int) .
|
Unit |
sendKeyDownUpSync(keyCode: Int)
Sends up and down key events with the given key code to the currently focused window, and waits for it to be processed.
|
Unit |
sendKeySync(event: KeyEvent!)
Sends a key event to the currently focused window, and waits for it to be processed.
This method blocks until the recipient has finished handling the event. Note that the recipient may not have completely finished reacting from the event when this method returns. For example, it may still be in the process of updating its display or UI contents upon reacting to the injected event.
|
Unit |
sendPointerSync(event: MotionEvent!)
Dispatches a pointer event into a window owned by the instrumented application, and waits for it to be processed.
If the motion event being injected is targeted at a window that is not owned by the instrumented application, the input injection will fail. See getUiAutomation() for injecting events into all windows.
This method blocks until the recipient has finished handling the event. Note that the recipient may not have completely finished reacting from the event when this method returns. For example, it may still be in the process of updating its display or UI contents upon reacting to the injected event.
|
Unit |
sendStatus(resultCode: Int, results: Bundle!)
Provide a status report about the application.
|
Unit |
sendStringSync(text: String!)
Sends the key events that result in the given text being typed into the currently focused window, and waits for it to be processed.
|
Unit |
sendTrackballEventSync(event: MotionEvent!)
Dispatches a trackball event into the currently focused window, and waits for it to be processed.
This method blocks until the recipient has finished handling the event. Note that the recipient may not have completely finished reacting from the event when this method returns. For example, it may still be in the process of updating its display or UI contents upon reacting to the injected event.
|
Unit |
setAutomaticPerformanceSnapshots()
|
Unit |
setInTouchMode(inTouch: Boolean)
Force the global system in or out of touch mode. This can be used if your instrumentation relies on the UI being in one more or the other when it starts.
Note: Starting from Android Build.VERSION_CODES.TIRAMISU , this method will only take effect if the instrumentation was sourced from a process with MODIFY_TOUCH_MODE_STATE internal permission granted (shell already have it).
|
Unit |
start()
Create and start a new thread in which to run instrumentation. This new thread will call to onStart where you can implement the instrumentation.
|
Activity! |
startActivitySync(intent: Intent!)
Start a new activity and wait for it to begin running before returning. In addition to being synchronous, this method as some semantic differences from the standard android.content.Context#startActivity call: the activity component is resolved before talking with the activity manager (its class name is specified in the Intent that this method ultimately starts), and it does not allow you to start activities that run in a different process. In addition, if the given Intent resolves to multiple activities, instead of displaying a dialog for the user to select an activity, an exception will be thrown.
The function returns as soon as the activity goes idle following the call to its android.app.Activity#onCreate. Generally this means it has gone through the full initialization including Activity.onResume and drawn and displayed its initial window.
|
Activity |
startActivitySync(intent: Intent, options: Bundle?)
Start a new activity and wait for it to begin running before returning. In addition to being synchronous, this method as some semantic differences from the standard android.content.Context#startActivity call: the activity component is resolved before talking with the activity manager (its class name is specified in the Intent that this method ultimately starts), and it does not allow you to start activities that run in a different process. In addition, if the given Intent resolves to multiple activities, instead of displaying a dialog for the user to select an activity, an exception will be thrown.
The function returns as soon as the activity goes idle following the call to its android.app.Activity#onCreate. Generally this means it has gone through the full initialization including Activity.onResume and drawn and displayed its initial window.
|
Unit |
startAllocCounting()
|
Unit |
startPerformanceSnapshot()
|
Unit |
startProfiling()
This method will start profiling if isProfiling() returns true. You should only call this method if you set the handleProfiling attribute in the manifest file for this Instrumentation to true.
|
Unit |
stopAllocCounting()
|
Unit |
stopProfiling()
Stops profiling if isProfiling() returns true.
|
Unit |
waitForIdle(recipient: Runnable!)
Schedule a callback for when the application's main thread goes idle (has no more events to process).
|
Unit |
waitForIdleSync()
Synchronously wait for the application to be idle. Can not be called from the main application thread -- use start to execute instrumentation in its own thread.
|
Activity! |
waitForMonitor(monitor: Instrumentation.ActivityMonitor!)
Wait for an existing ActivityMonitor to be hit. Once the monitor has been hit, it is removed from the activity monitor list and the first created Activity object that matched it is returned.
|
Activity! |
waitForMonitorWithTimeout(monitor: Instrumentation.ActivityMonitor!, timeOut: Long)
Wait for an existing ActivityMonitor to be hit till the timeout expires. Once the monitor has been hit, it is removed from the activity monitor list and the first created Activity object that matched it is returned. If the timeout expires, a null object is returned.
|