Search in sources :

Example 46 with RouteProgress

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);
}
Also used : Point(com.mapbox.geojson.Point) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) Point(com.mapbox.geojson.Point) Location(android.location.Location) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 47 with RouteProgress

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));
}
Also used : Point(com.mapbox.geojson.Point) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) Location(android.location.Location) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 48 with RouteProgress

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);
}
Also used : RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) Point(com.mapbox.geojson.Point) Location(android.location.Location) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 49 with RouteProgress

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));
}
Also used : Point(com.mapbox.geojson.Point) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) Location(android.location.Location) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 50 with RouteProgress

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());
}
Also used : RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) Location(android.location.Location) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Aggregations

BaseTest (com.mapbox.services.android.navigation.v5.BaseTest)44 Test (org.junit.Test)44 RouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress)39 Point (com.mapbox.geojson.Point)30 Location (android.location.Location)19 LineString (com.mapbox.geojson.LineString)12 DirectionsRoute (com.mapbox.api.directions.v5.models.DirectionsRoute)10 DirectionsResponse (com.mapbox.api.directions.v5.models.DirectionsResponse)3 LegStep (com.mapbox.api.directions.v5.models.LegStep)3 Milestone (com.mapbox.services.android.navigation.v5.milestone.Milestone)3 NavigationRoute (com.mapbox.services.android.navigation.v5.navigation.NavigationRoute)3 Context (android.content.Context)2 GsonBuilder (com.google.gson.GsonBuilder)2 RouteLeg (com.mapbox.api.directions.v5.models.RouteLeg)2 FasterRoute (com.mapbox.services.android.navigation.v5.route.FasterRoute)2 MetricsRouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.MetricsRouteProgress)2 RouteStepProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteStepProgress)2 DistanceUtils (com.mapbox.services.android.navigation.v5.utils.DistanceUtils)2 Date (java.util.Date)2 Ignore (org.junit.Ignore)2