Constructor and Description |
---|
BaseUiDevice() |
Modifier and Type | Method and Description |
---|---|
protected abstract DroidDriverContext<?,?> |
getContext() |
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
|
protected abstract android.graphics.Bitmap |
takeScreenshot() |
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
|
public boolean isScreenOn()
UiDevice
isScreenOn
in interface UiDevice
public void wakeUp()
UiDevice
public void sleep()
UiDevice
public void pressBack()
UiDevice
public boolean perform(Action action)
UiDevice
public boolean takeScreenshot(java.lang.String path)
UiDevice
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()
.
takeScreenshot
in interface UiDevice
path
- the path of file to save screenshotpublic boolean takeScreenshot(java.lang.String path, android.graphics.Bitmap.CompressFormat format, int quality)
UiDevice
path
. Note
some implementations may not capture everything on the screen, for example
InstrumentationDriver may not see the IME soft keyboard or system content.takeScreenshot
in interface UiDevice
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 settingprotected abstract android.graphics.Bitmap takeScreenshot()
protected abstract DroidDriverContext<?,?> getContext()