### Question:
RouteProgress { public float fractionTraveled() { float fractionRemaining = 1; if (directionsRoute().distance() > 0) { fractionRemaining = (float) (distanceTraveled() / directionsRoute().distance()); } return fractionRemaining; }  abstract DirectionsRoute directionsRoute(); abstract int legIndex(); @NonNull RouteLeg currentLeg(); double distanceTraveled(); double durationRemaining(); float fractionTraveled(); abstract double distanceRemaining(); int remainingWaypoints(); abstract RouteLegProgress currentLegProgress(); abstract List<Point> currentStepPoints(); @Nullable abstract List<Point> upcomingStepPoints(); abstract RouteProgress.Builder toBuilder(); static Builder builder();  }### Answer:
@Test public void multiLeg_fractionTraveled_equalsZeroAtBeginning() throws Exception { DirectionsRoute multiLegRoute = buildMultipleLegRoute(); RouteProgress routeProgress = buildBeginningOfLegRouteProgress(multiLegRoute); assertEquals(0, routeProgress.fractionTraveled(), BaseTest.LARGE_DELTA); }
@Test public void multiLeg_getFractionTraveled_equalsOneAtEndOfRoute() throws Exception { RouteProgress routeProgress = buildEndOfMultiRouteProgress(); assertEquals(1.0, routeProgress.fractionTraveled(), DELTA); }
@Test public void fractionTraveled_equalsZeroAtBeginning() throws Exception { DirectionsRoute route = buildTestDirectionsRoute(); RouteProgress beginningRouteProgress = buildBeginningOfLegRouteProgress(route); assertEquals(0, beginningRouteProgress.fractionTraveled(), BaseTest.LARGE_DELTA); }
@Test public void fractionTraveled_equalsOneAtEndOfRoute() throws Exception { DirectionsRoute route = buildTestDirectionsRoute(); RouteLeg firstLeg = route.legs().get(0); RouteProgress lastRouteProgress = buildLastRouteProgress(route, firstLeg); assertEquals(1.0, lastRouteProgress.fractionTraveled(), DELTA); }