@Test
public void testWritesPng() {

	File file = new File(getContext().getCacheDir(), "test_file");
	Bitmap bitmap = Mockito.mock(Bitmap.class);
	Mockito.when(bitmap.hasAlpha()).thenReturn(true);
	Mockito.when(
			bitmap.compress((Bitmap.CompressFormat) Mockito.any(), Mockito.anyInt(),
					(OutputStream) Mockito.any())).
			thenReturn(true);
	Mockito.when(bitmap.getWidth()).thenReturn(400);
	Mockito.when(bitmap.getHeight()).thenReturn(400);
	// According to the docs, hasAlpha should return true for ARGB_8888
	// which i think it does on a real device. Use Mockito to get around this
	// on Robolectric
/		Bitmap bitmap = Bitmap.createBitmap(400, 400, Bitmap.Config.ARGB_8888);
	BitmapWriter writer = new BitmapWriter(bitmap);
	boolean result = writer.write(file);
	Assert.assertTrue(result);
	ShadowBitmapFactory.provideWidthAndHeightHints(file.getAbsolutePath(), 400, 400);
	Bitmap writtenBitmap = BitmapFactory.decodeFile(file.getAbsolutePath());
	Assert.assertNotNull(writtenBitmap);
	Assert.assertEquals(bitmap.getWidth(), writtenBitmap.getWidth());
	Assert.assertEquals(bitmap.getHeight(), writtenBitmap.getHeight());
	// ShadowBitmapFactory doesn't save the state of the bitmap.
	// Can't test this with robolectric it seems
/		Assert.assertTrue(writtenBitmap.hasAlpha());
}