Skip to main content
Version: 2.0.0-alpha01

Selecting an alternative capture method

Testify provides three bitmap capture method. Each method will capture slightly different results based primarily on API level.

The three capture methods available are:

(1) Canvas: Render the view (and all of its children) to a given Canvas, using View.draw (2) DrawingCache: Pulls the view's drawing cache bitmap using the deprecated View.getDrawingCache (3) PixelCopy: Use Android's recommended PixelCopy API to capture the full screen, including elevation.

For legacy compatibility reasons, DrawingCache mode is the default Testify capture method.

If you wish to select an alternative capture method, you can enable the experimental feature either in code, or in your manifest. Available features can be found in TestifyFeatures

Code:

    @ScreenshotInstrumentation
@Test
fun testDefault() {
rule
.withExperimentalFeatureEnabled(TestifyFeatures.CanvasCapture)
.assertSame()
}

Manifest:

<manifest package="dev.testify.sample"
xmlns:android="http://schemas.android.com/apk/res/android">

<application>
<meta-data android:name="testify-canvas-capture" android:value="true" />
</application>

</manifest>