Search in sources :

Example 6 with Milestone

use of com.mapbox.services.android.navigation.v5.milestone.Milestone 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());
}
Also used : Context(android.content.Context) LocationEngine(com.mapbox.services.android.telemetry.location.LocationEngine) StepMilestone(com.mapbox.services.android.navigation.v5.milestone.StepMilestone) Milestone(com.mapbox.services.android.navigation.v5.milestone.Milestone) StepMilestone(com.mapbox.services.android.navigation.v5.milestone.StepMilestone) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 7 with Milestone

use of com.mapbox.services.android.navigation.v5.milestone.Milestone in project mapbox-navigation-android by mapbox.

the class MapboxNavigationTest method addMilestone_milestoneDidGetAdded.

@Test
public void addMilestone_milestoneDidGetAdded() throws Exception {
    Milestone milestone = new StepMilestone.Builder().build();
    navigation.addMilestone(milestone);
    assertTrue(navigation.getMilestones().contains(milestone));
}
Also used : StepMilestone(com.mapbox.services.android.navigation.v5.milestone.StepMilestone) Milestone(com.mapbox.services.android.navigation.v5.milestone.Milestone) StepMilestone(com.mapbox.services.android.navigation.v5.milestone.StepMilestone) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 8 with Milestone

use of com.mapbox.services.android.navigation.v5.milestone.Milestone 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());
}
Also used : Context(android.content.Context) LocationEngine(com.mapbox.services.android.telemetry.location.LocationEngine) StepMilestone(com.mapbox.services.android.navigation.v5.milestone.StepMilestone) Milestone(com.mapbox.services.android.navigation.v5.milestone.Milestone) GsonBuilder(com.google.gson.GsonBuilder) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest) Test(org.junit.Test)

Aggregations

Milestone (com.mapbox.services.android.navigation.v5.milestone.Milestone)8 BaseTest (com.mapbox.services.android.navigation.v5.BaseTest)6 StepMilestone (com.mapbox.services.android.navigation.v5.milestone.StepMilestone)6 Test (org.junit.Test)6 Context (android.content.Context)5 LocationEngine (com.mapbox.services.android.telemetry.location.LocationEngine)5 RouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress)2 Location (android.location.Location)1 GsonBuilder (com.google.gson.GsonBuilder)1 NavigationHelper.buildInstructionString (com.mapbox.services.android.navigation.v5.navigation.NavigationHelper.buildInstructionString)1