use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class NavigationRouteProcessorTest method onStepDistanceRemainingZeroAndNoBearingMatch_stepIndexForceIncreased.
@Test
public void onStepDistanceRemainingZeroAndNoBearingMatch_stepIndexForceIncreased() throws Exception {
RouteProgress firstProgress = routeProcessor.buildNewRouteProgress(navigation, mock(Location.class));
int firstProgressIndex = firstProgress.currentLegProgress().stepIndex();
List<Point> coordinates = createCoordinatesFromCurrentStep(firstProgress);
Point lastPointInCurrentStep = coordinates.remove(coordinates.size() - 1);
Location rawLocation = buildDefaultLocationUpdate(lastPointInCurrentStep.longitude(), lastPointInCurrentStep.latitude());
RouteProgress secondProgress = routeProcessor.buildNewRouteProgress(navigation, rawLocation);
int secondProgressIndex = secondProgress.currentLegProgress().stepIndex();
assertTrue(firstProgressIndex != secondProgressIndex);
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class NavigationRouteProcessorTest method onSnapToRouteEnabledAndUserOffRoute_rawLocationReturns.
@Test
public void onSnapToRouteEnabledAndUserOffRoute_rawLocationReturns() throws Exception {
RouteProgress progress = routeProcessor.buildNewRouteProgress(navigation, mock(Location.class));
boolean snapEnabled = false;
boolean userOffRoute = false;
List<Point> coordinates = createCoordinatesFromCurrentStep(progress);
Point lastPointInCurrentStep = coordinates.remove(coordinates.size() - 1);
Location rawLocation = buildDefaultLocationUpdate(lastPointInCurrentStep.longitude(), lastPointInCurrentStep.latitude());
Location snappedLocation = routeProcessor.buildSnappedLocation(navigation, snapEnabled, rawLocation, progress, userOffRoute);
assertTrue(rawLocation.equals(snappedLocation));
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class NavigationRouteProcessorTest method onInvalidNextStep_indexIsNotIncreased.
@Test
public void onInvalidNextStep_indexIsNotIncreased() throws Exception {
routeProcessor.buildNewRouteProgress(navigation, mock(Location.class));
int stepSize = navigation.getRoute().legs().get(0).steps().size();
for (int i = 0; i < stepSize; i++) {
routeProcessor.onShouldIncreaseIndex();
routeProcessor.checkIncreaseIndex(navigation);
}
RouteProgress progress = routeProcessor.buildNewRouteProgress(navigation, mock(Location.class));
assertTrue(progress.currentLegProgress().stepIndex() == stepSize - 1);
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class NavigationRouteProcessorTest method onSnapToRouteDisabledAndUserOnRoute_rawLocationReturns.
@Test
public void onSnapToRouteDisabledAndUserOnRoute_rawLocationReturns() throws Exception {
RouteProgress progress = routeProcessor.buildNewRouteProgress(navigation, mock(Location.class));
boolean snapEnabled = false;
boolean userOffRoute = false;
List<Point> coordinates = createCoordinatesFromCurrentStep(progress);
Point lastPointInCurrentStep = coordinates.remove(coordinates.size() - 1);
Location rawLocation = buildDefaultLocationUpdate(lastPointInCurrentStep.longitude(), lastPointInCurrentStep.latitude());
Location snappedLocation = routeProcessor.buildSnappedLocation(navigation, snapEnabled, rawLocation, progress, userOffRoute);
assertTrue(rawLocation.equals(snappedLocation));
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class NavigationRouteProcessorTest method onFirstRouteProgressBuilt_newRouteIsDecoded.
@Test
public void onFirstRouteProgressBuilt_newRouteIsDecoded() throws Exception {
RouteProgress progress = routeProcessor.buildNewRouteProgress(navigation, mock(Location.class));
assertEquals(0, progress.legIndex());
assertEquals(0, progress.currentLegProgress().stepIndex());
}
Aggregations