Skip to content

Commit

Permalink
Fix flaky e2e test (#2380)
Browse files Browse the repository at this point in the history
We noticed that on CI the surface views can be excluded in snapshot tests
  • Loading branch information
wcandillon authored Apr 18, 2024
1 parent 54138ee commit 472cf8f
Showing 1 changed file with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,21 @@ private static void drawSurfaceView(Canvas canvas, SurfaceView sv, Paint paint,
latch.await(SURFACE_VIEW_READ_PIXELS_TIMEOUT, TimeUnit.SECONDS);
} catch (Exception e) {
Log.e(TAG, "Cannot PixelCopy for " + sv, e);
drawSurfaceViewFromCache(canvas, sv, paint, opacity);
}
} else {
Bitmap cache = sv.getDrawingCache();
if (cache != null) {
canvas.save();
applyTransformations(canvas, sv);
paint.setAlpha(Math.round(opacity * 255)); // Set paint alpha based on opacity
canvas.drawBitmap(cache, 0, 0, paint);
canvas.restore();
}
drawSurfaceViewFromCache(canvas, sv, paint, opacity);
}
}

private static void drawSurfaceViewFromCache(Canvas canvas, SurfaceView sv, Paint paint, float opacity) {
Bitmap cache = sv.getDrawingCache();
if (cache != null) {
canvas.save();
applyTransformations(canvas, sv);
paint.setAlpha(Math.round(opacity * 255)); // Set paint alpha based on opacity
canvas.drawBitmap(cache, 0, 0, paint);
canvas.restore();
}
}

Expand Down

0 comments on commit 472cf8f

Please sign in to comment.