use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class RouteEngine method buildRouteRequestFromCurrentLocation.
@Nullable
public static NavigationRoute.Builder buildRouteRequestFromCurrentLocation(Point origin, Double bearing, RouteProgress progress) {
RouteOptions options = progress.directionsRoute().routeOptions();
NavigationRoute.Builder builder = NavigationRoute.builder().origin(origin, bearing, BEARING_TOLERANCE).routeOptions(options);
List<Point> remainingWaypoints = RouteUtils.calculateRemainingWaypoints(progress);
if (remainingWaypoints == null) {
Timber.e("An error occurred fetching a new route");
return null;
}
addDestination(remainingWaypoints, builder);
addWaypoints(remainingWaypoints, builder);
return builder;
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class MapboxNavigationNotificationTest method updateDefaultNotification_onlyUpdatesNameWhenNew.
@Ignore
@Test
public void updateDefaultNotification_onlyUpdatesNameWhenNew() throws Exception {
RouteProgress routeProgress = RouteProgress.builder().directionsRoute(route).stepIndex(0).legIndex(0).build();
MapboxNavigationNotification mapboxNavigationNotification = new MapboxNavigationNotification(Mockito.mock(Context.class), Mockito.mock(MapboxNavigation.class));
mapboxNavigationNotification.updateNotification(routeProgress);
// notificationManager.getActiveNotifications()[0].getNotification().contentView;
// verify(notificationManager, times(1)).getActiveNotifications()[0];
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class NavigationHelperTest method increaseIndex_increasesStepByOne.
@Test
public void increaseIndex_increasesStepByOne() throws Exception {
RouteProgress routeProgress = routeProgressBuilder.legIndex(0).stepIndex(0).build();
NavigationIndices previousIndices = NavigationIndices.create(0, 0);
NavigationIndices newIndices = NavigationHelper.increaseIndex(routeProgress, previousIndices);
assertEquals(0, newIndices.legIndex());
assertEquals(1, newIndices.stepIndex());
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class NavigationHelperTest method checkMilestones_onlyTriggeredMilestonesGetReturned.
@Test
public void checkMilestones_onlyTriggeredMilestonesGetReturned() throws Exception {
RouteProgress routeProgress = routeProgressBuilder.legIndex(0).stepIndex(0).build();
MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
MapboxNavigation mapboxNavigation = new MapboxNavigation(mock(Context.class), ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
mapboxNavigation.addMilestone(new StepMilestone.Builder().setTrigger(Trigger.eq(TriggerProperty.STEP_INDEX, 0)).setIdentifier(1001).build());
mapboxNavigation.addMilestone(new StepMilestone.Builder().setTrigger(Trigger.eq(TriggerProperty.STEP_INDEX, 4)).setIdentifier(1002).build());
List<Milestone> triggeredMilestones = checkMilestones(routeProgress, routeProgress, mapboxNavigation);
assertEquals(1, triggeredMilestones.size());
assertEquals(1001, triggeredMilestones.get(0).getIdentifier());
assertNotSame(1002, triggeredMilestones.get(0).getIdentifier());
}
use of com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress in project mapbox-navigation-android by mapbox.
the class NavigationRouteProcessorTest method onShouldIncreaseStepIndex_indexIsIncreased.
@Test
public void onShouldIncreaseStepIndex_indexIsIncreased() throws Exception {
RouteProgress progress = routeProcessor.buildNewRouteProgress(navigation, mock(Location.class));
int currentStepIndex = progress.currentLegProgress().stepIndex();
routeProcessor.onShouldIncreaseIndex();
routeProcessor.checkIncreaseIndex(navigation);
RouteProgress secondProgress = routeProcessor.buildNewRouteProgress(navigation, mock(Location.class));
int secondStepIndex = secondProgress.currentLegProgress().stepIndex();
assertTrue(currentStepIndex != secondStepIndex);
}
Aggregations