Screenshot
public
final
class
Screenshot
extends Object
java.lang.Object | |
↳ | android.support.test.runner.screenshot.Screenshot |
The Screenshot instance provides methods to capture a ScreenCapture
during
instrumentation tests run on an android device.
The Screenshot instance keeps track of a set of ScreenCaptureProcessor
s that will be
passed to each ScreenCapture
object when they are created during any test. These ScreenCaptureProcessor
s are capable of processing the ScreenCapture
that was created.
This API is currently in beta.
Summary
Public constructors | |
---|---|
Screenshot()
|
Public methods | |
---|---|
static
void
|
addScreenCaptureProcessors(Set<ScreenCaptureProcessor> screenCaptureProcessors)
Adds the given set of |
static
ScreenCapture
|
capture(Activity activity)
Creates a |
static
ScreenCapture
|
capture()
Creates a |
static
ScreenCapture
|
capture(View view)
Creates a |
static
void
|
setScreenshotProcessors(Set<ScreenCaptureProcessor> screenCaptureProcessors)
Sets the current set of |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
Public constructors
Screenshot
Screenshot ()
Public methods
addScreenCaptureProcessors
void addScreenCaptureProcessors (Set<ScreenCaptureProcessor> screenCaptureProcessors)
Adds the given set of ScreenCaptureProcessor
s to the current set of ScreenCaptureProcessor
s.
The current set of ScreenCaptureProcessor
s will be passed to each ScreenCapture
that is created.
Parameters | |
---|---|
screenCaptureProcessors |
Set : the set of ScreenCaptureProcessor s to add
|
capture
ScreenCapture capture (Activity activity)
Creates a ScreenCapture
that contains a Bitmap
of the given activity's root
View
hierarchy content.
The ScreenCapture
that is returned will also contain the set of ScreenCaptureProcessor
s that have been set in this instance.
Parameters | |
---|---|
activity |
Activity : the Activity who's root View will be used to create a Bitmap |
Returns | |
---|---|
ScreenCapture |
a ScreenCapture that contains the bitmap of the given activity's root View . |
Throws | |
---|---|
NullPointerException |
if given activity is null |
|
If there was an error capturing the screenshot |
Screenshot.ScreenShotException |
capture
ScreenCapture capture ()
Creates a ScreenCapture
that contains a Bitmap
of the visible screen content
for Build.VERSION_CODES.JELLY_BEAN_MR2 and above.
The ScreenCapture
that is returned will also contain the set of ScreenCaptureProcessor
s that have been set in this instance.
Note: Only use this method if all your tests run on API versions
Build.VERSION_CODES.JELLY_BEAN_MR2 or above. If you need to take screenshots on lower API
levels, you need to use capture(Activity)
or capture(View)
for those
versions.
Returns | |
---|---|
ScreenCapture |
a ScreenCapture that contains the bitmap of the visible screen content. |
Throws | |
---|---|
IllegalStateException |
if used on API below Build.VERSION_CODES.JELLY_BEAN_MR2 |
|
If there was an error capturing the screenshot |
Screenshot.ScreenShotException |
capture
ScreenCapture capture (View view)
Creates a ScreenCapture
that contains a Bitmap
of the given view's hierarchy
content.
The ScreenCapture
that is returned will also contain the set of ScreenCaptureProcessor
s that have been set in this instance.
Parameters | |
---|---|
view |
View : the View to create a Bitmap of |
Returns | |
---|---|
ScreenCapture |
ScreenCapture that contains the bitmap of the given view's hierarchy content. |
Throws | |
---|---|
NullPointerException |
if given view is null |
|
If there was an error capturing the screenshot |
Screenshot.ScreenShotException |
setScreenshotProcessors
void setScreenshotProcessors (Set<ScreenCaptureProcessor> screenCaptureProcessors)
Sets the current set of ScreenCaptureProcessor
s to the given set of ScreenCaptureProcessor
s.
The current set of ScreenCaptureProcessor
s will be passed to each ScreenCapture
that is created.
Parameters | |
---|---|
screenCaptureProcessors |
Set : the set of ScreenCaptureProcessor s to use
|
Interfaces
Classes