From e05793c2f587da015d6c98ac1e069f47fbc007bc Mon Sep 17 00:00:00 2001 From: Alon Haiut Date: Tue, 25 May 2021 15:25:29 +0300 Subject: [PATCH] Aligned android element screenshot to the same functionality --- .../java/com/wix/detox/espresso/action/ViewScreenshot.kt | 8 +------- detox/test/e2e/26.element-screenshots.test.js | 7 ------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/detox/android/detox/src/main/java/com/wix/detox/espresso/action/ViewScreenshot.kt b/detox/android/detox/src/main/java/com/wix/detox/espresso/action/ViewScreenshot.kt index 34c3d7594e..63d471853c 100644 --- a/detox/android/detox/src/main/java/com/wix/detox/espresso/action/ViewScreenshot.kt +++ b/detox/android/detox/src/main/java/com/wix/detox/espresso/action/ViewScreenshot.kt @@ -21,15 +21,9 @@ class ScreenshotResult(private val bitmap: Bitmap) { class ViewScreenshot() { fun takeOf(view: View): ScreenshotResult { - val visibleRect = Rect() - if (!view.getLocalVisibleRect(visibleRect)) { - throw IllegalStateException("Cannot take screenshot of a view that's out of screen's bounds") - } - val bitmap = Bitmap.createBitmap(view.width, view.height, Bitmap.Config.ARGB_8888) view.draw(Canvas(bitmap)) - val clippedBitmap = Bitmap.createBitmap(bitmap, visibleRect.left, visibleRect.top, visibleRect.width(), visibleRect.height()) - return ScreenshotResult(clippedBitmap) + return ScreenshotResult(bitmap) } } diff --git a/detox/test/e2e/26.element-screenshots.test.js b/detox/test/e2e/26.element-screenshots.test.js index 13dbbd97ae..b64257dc36 100644 --- a/detox/test/e2e/26.element-screenshots.test.js +++ b/detox/test/e2e/26.element-screenshots.test.js @@ -24,13 +24,6 @@ describe('Element screenshots', () => { expectBitmapsToBeEqual(bitmapPath, screenshotAssetPath); }); - it(':android: should fail to take a screenshot of an off-screen element', async () => { - await expectToThrow( - () => element(by.id('offscreenElement')).takeScreenshot(), - `Cannot take screenshot of a view that's out of screen's bounds`, - ); - }); - function expectBitmapsToBeEqual(bitmapPath, expectedBitmapPath) { const bitmapBuffer = fs.readFileSync(bitmapPath); const expectedBitmapBuffer = fs.readFileSync(expectedBitmapPath);