### Question:
ImageUtil { @VisibleForTesting static int[] computeTargetSize(Bitmap bitmap, int maxWidth, int maxHeight) { int width = bitmap.getWidth(); int height = bitmap.getHeight(); float targetWidth = width; float targetHeight = height; if (width > maxWidth || height > maxHeight) { float scaleWidth = (width * 1.0f / maxWidth); float scaleHeight = (height * 1.0f / maxHeight); float scale = Math.max(scaleWidth, scaleHeight); targetWidth = width / scale; targetHeight = height / scale; } return new int[]{(int) targetWidth, (int) targetHeight}; }  static String convertToBase64(Bitmap bitmap, int maxWidth, int maxHeight);  }### Answer:
@Test public void computeTargetSizeWidth1Height0() { Bitmap bitmap = ShadowBitmapFactory.create("AndroidGodEye", null, new Point(100, 20)); int[] targetSize0 = ImageUtil.computeTargetSize(bitmap, 30, 30); Assert.assertEquals(30, targetSize0[0]); Assert.assertEquals(6, targetSize0[1]); }
@Test public void computeTargetSizeWidth1Height1() { Bitmap bitmap = ShadowBitmapFactory.create("AndroidGodEye", null, new Point(100, 50)); int[] targetSize0 = ImageUtil.computeTargetSize(bitmap, 30, 30); Assert.assertEquals(30, targetSize0[0]); Assert.assertEquals(15, targetSize0[1]); }
@Test public void computeTargetSizeWidth0Height1() { Bitmap bitmap = ShadowBitmapFactory.create("AndroidGodEye", null, new Point(25, 50)); int[] targetSize0 = ImageUtil.computeTargetSize(bitmap, 30, 30); Assert.assertEquals(15, targetSize0[0]); Assert.assertEquals(30, targetSize0[1]); }
@Test public void computeTargetSizeWidth0Height0() { Bitmap bitmap = ShadowBitmapFactory.create("AndroidGodEye", null, new Point(20, 10)); int[] targetSize0 = ImageUtil.computeTargetSize(bitmap, 30, 30); Assert.assertEquals(20, targetSize0[0]); Assert.assertEquals(10, targetSize0[1]); }