Skip to content

Commit

Permalink
Merge pull request #673 from devapro/ISSUE-638-Screenshot-in-compose-…
Browse files Browse the repository at this point in the history
…project

ISSUE-638: Can't take screenshot in compose project tests
  • Loading branch information
CherchesovAzamat authored Oct 27, 2024
2 parents 98bc157 + af7e440 commit ee04033
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.app.Activity
import android.graphics.Bitmap
import android.graphics.Canvas
import android.os.Looper
import android.util.Log
import android.view.View
import com.kaspersky.kaspresso.device.activities.Activities
import com.kaspersky.kaspresso.params.ScreenshotParams
Expand Down Expand Up @@ -82,7 +83,7 @@ class InternalScreenshotMaker(
private fun drawBitmap(view: View): Bitmap {
view.layout(0, 0, view.measuredWidth, view.measuredHeight)
val bitmap = Bitmap.createBitmap(view.width, view.height, Bitmap.Config.ARGB_8888)
val bitmapHolder = Canvas(bitmap!!)
val bitmapHolder = Canvas(bitmap)
view.draw(bitmapHolder)
return bitmap
}
Expand All @@ -97,6 +98,8 @@ class InternalScreenshotMaker(
activity.runOnUiThread {
try {
activity.drawToBitmap(bitmap)
} catch (e: Exception) {
Log.e("InternalScreenshotMaker", "Unable to get screenshot ${file.absolutePath}")
} finally {
latch.countDown()
}
Expand Down

0 comments on commit ee04033

Please sign in to comment.