public interface UiDevice
Modifier and Type | Method and Description |
---|---|
boolean |
isScreenOn()
Returns whether the screen is on.
|
boolean |
perform(Action action)
Executes a global action without the context of a certain UiElement.
|
void |
pressBack()
Simulates pressing "back" button
|
void |
sleep()
Puts device to sleep if the screen is on
|
boolean |
takeScreenshot(java.lang.String path)
Takes a screenshot of current window and stores it in
path as PNG. |
boolean |
takeScreenshot(java.lang.String path,
android.graphics.Bitmap.CompressFormat format,
int quality)
Takes a screenshot of current window and stores it in
path . |
void |
wakeUp()
Wakes up device if the screen is off
|
boolean isScreenOn()
void wakeUp()
void sleep()
void pressBack()
boolean perform(Action action)
action
- The action to executeboolean takeScreenshot(java.lang.String path)
path
as PNG.
If this is used in a test which extends
ActivityInstrumentationTestCase2
, call this before
tearDown()
because tearDown()
finishes activities created
by ActivityInstrumentationTestCase2.getActivity()
.
path
- the path of file to save screenshotboolean takeScreenshot(java.lang.String path, android.graphics.Bitmap.CompressFormat format, int quality)
path
. Note
some implementations may not capture everything on the screen, for example
InstrumentationDriver may not see the IME soft keyboard or system content.path
- the path of file to save screenshotformat
- The format of the compressed imagequality
- Hint to the compressor, 0-100. 0 meaning compress for small
size, 100 meaning compress for max quality. Some formats, like PNG
which is lossless, will ignore the quality setting