### Question:
NavigationHelper { static NavigationIndices increaseIndex(RouteProgress routeProgress, NavigationIndices previousIndices) { DirectionsRoute route = routeProgress.directionsRoute(); int previousStepIndex = previousIndices.stepIndex(); int previousLegIndex = previousIndices.legIndex(); int routeLegSize = route.legs().size(); int legStepSize = route.legs().get(routeProgress.legIndex()).steps().size(); boolean isOnLastLeg = previousLegIndex == routeLegSize - 1; boolean isOnLastStep = previousStepIndex == legStepSize - 1; if (isOnLastStep && !isOnLastLeg) { return NavigationIndices.create((previousLegIndex + 1), 0); } if (isOnLastStep) { return previousIndices; } return NavigationIndices.create(previousLegIndex, (previousStepIndex + 1)); } private  NavigationHelper(); @NonNull static List<StepIntersection> createIntersectionsList(@NonNull LegStep currentStep, LegStep upcomingStep); @NonNull static List<Pair<StepIntersection, Double>> createDistancesToIntersections(List<Point> stepPoints,
                                                                             List<StepIntersection> intersections); static StepIntersection findCurrentIntersection(@NonNull List<StepIntersection> intersections,
                                                  @NonNull List<Pair<StepIntersection, Double>> measuredIntersections,
                                                  double stepDistanceTraveled); static StepIntersection findUpcomingIntersection(@NonNull List<StepIntersection> intersections,
                                                   @Nullable LegStep upcomingStep,
                                                   StepIntersection currentIntersection); @Nullable static CurrentLegAnnotation createCurrentAnnotation(CurrentLegAnnotation currentLegAnnotation,
                                                      RouteLeg leg, double legDistanceRemaining);  }### Answer:
@Test public void increaseIndex_increasesStepByOne() throws Exception { RouteProgress routeProgress = buildMultiLegRouteProgress(); NavigationIndices previousIndices = NavigationIndices.create(0, 0); NavigationIndices newIndices = NavigationHelper.increaseIndex(routeProgress, previousIndices); assertEquals(0, newIndices.legIndex()); assertEquals(1, newIndices.stepIndex()); }
@Test public void increaseIndex_increasesLegIndex() throws Exception { RouteProgress multiLegRouteProgress = buildMultiLegRouteProgress(); RouteProgress routeProgress = multiLegRouteProgress.toBuilder() .legIndex(0) .stepIndex(21) .build(); NavigationIndices previousIndices = NavigationIndices.create(0, 21); NavigationIndices newIndices = NavigationHelper.increaseIndex(routeProgress, previousIndices); assertEquals(1, newIndices.legIndex()); }
@Test public void increaseIndex_stepIndexResetsOnLegIndexIncrease() throws Exception { RouteProgress multiLegRouteProgress = buildMultiLegRouteProgress(); RouteProgress routeProgress = multiLegRouteProgress.toBuilder() .legIndex(0) .stepIndex(21) .build(); NavigationIndices previousIndices = NavigationIndices.create(0, 21); NavigationIndices newIndices = NavigationHelper.increaseIndex(routeProgress, previousIndices); assertEquals(0, newIndices.stepIndex()); }