Skip to content

Instantly share code, notes, and snippets.

@veena14cs
Last active August 17, 2022 18:48
Show Gist options
  • Save veena14cs/8b26545ffb7f16d0487fe473603e6046 to your computer and use it in GitHub Desktop.
Save veena14cs/8b26545ffb7f16d0487fe473603e6046 to your computer and use it in GitHub Desktop.
Create bitmap in test class
val displayLocale = createDisplayLocaleImpl(EGYPT_ARABIC_CONTEXT)
val width: Int = context.resources.displayMetrics.widthPixels
val height: Int = context.resources.displayMetrics.heightPixels
val conf = Bitmap.Config.ARGB_8888
val bmp = Bitmap.createBitmap(width, height, conf)
val canvas = Canvas(bmp)
val paint = Paint()
canvas.drawBitmap(bmp, Matrix(), paint);
val shadowCanvas = shadowOf(canvas)
shadowCanvas.setWidth(960)
val x = 960
val dir = -1
bulletSpan0.drawLeadingMargin(
canvas, paint, x, dir, 0, 0, 96, htmlResult,
htmlResult.getSpanStart(bulletSpan0),
htmlResult.getSpanEnd(bulletSpan0),
true,
mock(Layout::class.java)
)
assertThat(shadowCanvas.getDrawnCircle(0).centerX).isWithin(1e-5f).of(-73.0f)
assertThat(shadowCanvas.getDrawnCircle(0).centerY).isWithin(1e-5f).of(48.0f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment