use of com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation in project mapbox-navigation-android by mapbox.
the class MapboxNavigationTest method addMilestone_milestoneOnlyGetsAddedOnce.
@Test
public void addMilestone_milestoneOnlyGetsAddedOnce() throws Exception {
MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
MapboxNavigation navigationWithOptions = new MapboxNavigation(mock(Context.class), ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
Milestone milestone = new StepMilestone.Builder().build();
navigationWithOptions.addMilestone(milestone);
navigationWithOptions.addMilestone(milestone);
assertEquals(1, navigationWithOptions.getMilestones().size());
}
use of com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation in project mapbox-navigation-android by mapbox.
the class MapboxNavigationTest method removeMilestone_milestoneDidGetRemoved.
@Test
public void removeMilestone_milestoneDidGetRemoved() throws Exception {
MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
MapboxNavigation navigationWithOptions = new MapboxNavigation(mock(Context.class), ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
Milestone milestone = new StepMilestone.Builder().build();
navigationWithOptions.addMilestone(milestone);
assertEquals(1, navigationWithOptions.getMilestones().size());
navigationWithOptions.removeMilestone(milestone);
assertEquals(0, navigationWithOptions.getMilestones().size());
}
use of com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation in project mapbox-navigation-android by mapbox.
the class MapboxNavigationTest method removeMilestone_milestoneDoesNotExist.
@Test
public void removeMilestone_milestoneDoesNotExist() throws Exception {
MapboxNavigationOptions options = MapboxNavigationOptions.builder().defaultMilestonesEnabled(false).build();
MapboxNavigation navigationWithOptions = new MapboxNavigation(mock(Context.class), ACCESS_TOKEN, options, mock(NavigationTelemetry.class), mock(LocationEngine.class));
Milestone milestone = new StepMilestone.Builder().build();
navigationWithOptions.addMilestone(new StepMilestone.Builder().build());
navigationWithOptions.removeMilestone(milestone);
assertEquals(1, navigationWithOptions.getMilestones().size());
}
use of com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation 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.navigation.MapboxNavigation in project mapbox-navigation-android by mapbox.
the class NavigationViewModel method initNavigation.
/**
* Initializes {@link MapboxNavigation} and adds all views that implement listeners.
*/
private void initNavigation(Context context, MapboxNavigationOptions options) {
navigation = new MapboxNavigation(context, Mapbox.getAccessToken(), options);
addNavigationListeners();
}
Aggregations