BitmapUtils { public static void recycleBitmap(Bitmap bitmap){ if (bitmap != null && !bitmap.isRecycled()) bitmap.recycle(); } private  BitmapUtils(); static void recycleBitmapFromImageView(ImageView imageView); static void recycleBitmap(Bitmap bitmap); static byte[] bitmapToBytes(Bitmap bitmap);  }
@Test public void testWontFailRecyclingBitmapIfPassedNull(){ try{ Bitmap bitmap = null; BitmapUtils.recycleBitmap(bitmap); }catch(Exception e){ fail("no exception should be thrown"); } }
@Test public void testRecycleBitmap(){ Bitmap bitmap = createTestBitmap(); BitmapUtils.recycleBitmap(bitmap); assertTrue(bitmap.isRecycled()); }