### Question:
OrientationUtils { public static int computeImageOrientation(int screenRotationDegrees, int cameraRotationDegrees, boolean cameraIsMirrored) { int rotation; if (cameraIsMirrored) { rotation = -(screenRotationDegrees + cameraRotationDegrees); } else { rotation = screenRotationDegrees - cameraRotationDegrees; } return (rotation + 360 + 360) % 360; }  static int toClosestRightAngle(int degrees); static int computeDisplayOrientation(int screenRotationDegrees,
                                                int cameraRotationDegrees,
                                                boolean cameraIsMirrored); static int computeImageOrientation(int screenRotationDegrees,
                                              int cameraRotationDegrees,
                                              boolean cameraIsMirrored);  }### Answer:
@Test public void computeImageOrientation_Phone_Portrait_FrontCamera() throws Exception { int screenOrientation = 0; int cameraOrientation = 270; int result = OrientationUtils.computeImageOrientation( screenOrientation, cameraOrientation, true ); assertEquals(90, result); }
@Test public void computeImageOrientation_Phone_Landscape_FrontCamera() throws Exception { int screenOrientation = 270; int cameraOrientation = 270; int result = OrientationUtils.computeImageOrientation( screenOrientation, cameraOrientation, true ); assertEquals(180, result); }
@Test public void computeImageOrientation_Phone_Portrait_BackCamera() throws Exception { int screenOrientation = 0; int cameraOrientation = 90; int result = OrientationUtils.computeImageOrientation( screenOrientation, cameraOrientation, false ); assertEquals(270, result); }
@Test public void computeImageOrientation_Phone_Landscape_BackCamera() throws Exception { int screenOrientation = 270; int cameraOrientation = 90; int result = OrientationUtils.computeImageOrientation( screenOrientation, cameraOrientation, false ); assertEquals(180, result); }