### Question:
OrientationUtils { public static int computeDisplayOrientation(int screenRotationDegrees, int cameraRotationDegrees, boolean cameraIsMirrored) { int degrees = OrientationUtils.toClosestRightAngle(screenRotationDegrees); if (cameraIsMirrored) { degrees = (cameraRotationDegrees + degrees) % 360; degrees = (360 - degrees) % 360; } else { degrees = (cameraRotationDegrees - degrees + 360) % 360; } return degrees; }  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 computeDisplayOrientation_Phone_Portrait_FrontCamera() throws Exception { int screenOrientation = 0; int cameraOrientation = 270; int result = OrientationUtils.computeDisplayOrientation( screenOrientation, cameraOrientation, true ); assertEquals(90, result); }
@Test public void computeDisplayOrientation_Phone_Landscape_FrontCamera() throws Exception { int screenOrientation = 270; int cameraOrientation = 270; int result = OrientationUtils.computeDisplayOrientation( screenOrientation, cameraOrientation, true ); assertEquals(180, result); }
@Test public void computeDisplayOrientation_Phone_Portrait_BackCamera() throws Exception { int screenOrientation = 0; int cameraOrientation = 90; int result = OrientationUtils.computeDisplayOrientation( screenOrientation, cameraOrientation, false ); assertEquals(90, result); }
@Test public void computeDisplayOrientation_Phone_Landscape_BackCamera() throws Exception { int screenOrientation = 270; int cameraOrientation = 90; int result = OrientationUtils.computeDisplayOrientation( screenOrientation, cameraOrientation, false ); assertEquals(180, result); }