CircularDrawable extends Drawable { public void setBorder(float borderWidth, int borderColor) { useBorder = true; borderPaint.setColor(borderColor); borderPaint.setStrokeWidth(borderWidth); invalidateSelf(); } CircularDrawable(Bitmap bitmap);  CircularDrawable(Bitmap bitmap, float explicitDiameter); float getDiameter(); void setBorder(float borderWidth, int borderColor); void clearBorder(); @Override void draw(Canvas canvas); @Override int getOpacity(); @Override void setAlpha(int alpha); @Override void setColorFilter(ColorFilter cf); @Override int getIntrinsicHeight(); @Override int getIntrinsicWidth();  }
@Test public void testSetBorder() { Bitmap bitmap = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888); CircularDrawable drawable = new CircularDrawable(bitmap); drawable.setBorder(2.0f, Color.BLACK); Canvas canvas = Mockito.mock(Canvas.class); drawable.draw(canvas); Mockito.verify(canvas, Mockito.times(2)).drawCircle(Mockito.anyFloat(), Mockito.anyFloat(), Mockito.anyFloat(), (Paint) Mockito.any()); Assert.assertEquals(202, drawable.getIntrinsicWidth()); Assert.assertEquals(202, drawable.getIntrinsicHeight()); drawable.clearBorder(); Assert.assertEquals(200, drawable.getIntrinsicWidth()); Assert.assertEquals(200, drawable.getIntrinsicHeight()); }