Search in sources :

Example 11 with MapboxNavigation

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());
}
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 12 with MapboxNavigation

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());
}
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 13 with MapboxNavigation

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());
}
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 14 with MapboxNavigation

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());
}
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)

Example 15 with MapboxNavigation

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();
}
Also used : MapboxNavigation(com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation)

Aggregations

Test (org.junit.Test)7 Milestone (com.mapbox.services.android.navigation.v5.milestone.Milestone)6 Context (android.content.Context)5 BaseTest (com.mapbox.services.android.navigation.v5.BaseTest)5 StepMilestone (com.mapbox.services.android.navigation.v5.milestone.StepMilestone)5 MapboxNavigation (com.mapbox.services.android.navigation.v5.navigation.MapboxNavigation)5 LocationEngine (com.mapbox.services.android.telemetry.location.LocationEngine)5 MapboxNavigationOptions (com.mapbox.services.android.navigation.v5.navigation.MapboxNavigationOptions)2 FeedbackEvent (com.mapbox.services.android.navigation.v5.navigation.metrics.FeedbackEvent)2 ProgressChangeListener (com.mapbox.services.android.navigation.v5.routeprogress.ProgressChangeListener)2 RouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress)2 Notification (android.app.Notification)1 Location (android.location.Location)1 GsonBuilder (com.google.gson.GsonBuilder)1 CustomNavigationNotification (com.mapbox.services.android.navigation.testapp.activity.notification.CustomNavigationNotification)1 RouteMilestone (com.mapbox.services.android.navigation.v5.milestone.RouteMilestone)1 SessionState (com.mapbox.services.android.navigation.v5.navigation.metrics.SessionState)1 NavigationNotification (com.mapbox.services.android.navigation.v5.navigation.notification.NavigationNotification)1 Date (java.util.Date)1