Search in sources :

Example 1 with FasterRoute

use of com.mapbox.services.android.navigation.v5.route.FasterRoute in project mapbox-navigation-android by mapbox.

the class FasterRouteDetectorTest method onFasterRouteResponse_isFasterRouteIsTrue.

@Test
public void onFasterRouteResponse_isFasterRouteIsTrue() throws Exception {
    FasterRoute fasterRouteEngine = navigation.getFasterRouteEngine();
    // Create current progress
    RouteProgress currentProgress = obtainDefaultRouteProgress();
    DirectionsRoute longerRoute = currentProgress.directionsRoute().toBuilder().duration(// Current route duration is very long
    10000000d).build();
    currentProgress = currentProgress.toBuilder().directionsRoute(longerRoute).build();
    // Create new direction response
    DirectionsResponse response = obtainADirectionsResponse();
    boolean isFasterRoute = fasterRouteEngine.isFasterRoute(response, currentProgress);
    assertTrue(isFasterRoute);
}
Also used : FasterRoute(com.mapbox.services.android.navigation.v5.route.FasterRoute) DirectionsRoute(com.mapbox.api.directions.v5.models.DirectionsRoute) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) DirectionsResponse(com.mapbox.api.directions.v5.models.DirectionsResponse) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 2 with FasterRoute

use of com.mapbox.services.android.navigation.v5.route.FasterRoute in project mapbox-navigation-android by mapbox.

the class FasterRouteDetectorTest method onNullLocationPassed_shouldCheckFasterRouteIsFalse.

@Test
public void onNullLocationPassed_shouldCheckFasterRouteIsFalse() throws Exception {
    FasterRoute fasterRouteEngine = navigation.getFasterRouteEngine();
    boolean checkFasterRoute = fasterRouteEngine.shouldCheckFasterRoute(null, obtainDefaultRouteProgress());
    assertFalse(checkFasterRoute);
}
Also used : FasterRoute(com.mapbox.services.android.navigation.v5.route.FasterRoute) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 3 with FasterRoute

use of com.mapbox.services.android.navigation.v5.route.FasterRoute in project mapbox-navigation-android by mapbox.

the class FasterRouteDetectorTest method addFasterRouteEngine_didGetAdded.

@Test
public void addFasterRouteEngine_didGetAdded() throws Exception {
    FasterRoute fasterRouteEngine = mock(FasterRoute.class);
    navigation.setFasterRouteEngine(fasterRouteEngine);
    assertEquals(navigation.getFasterRouteEngine(), fasterRouteEngine);
}
Also used : FasterRoute(com.mapbox.services.android.navigation.v5.route.FasterRoute) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 4 with FasterRoute

use of com.mapbox.services.android.navigation.v5.route.FasterRoute in project mapbox-navigation-android by mapbox.

the class FasterRouteDetectorTest method onSlowerRouteResponse_isFasterRouteIsFalse.

@Test
public void onSlowerRouteResponse_isFasterRouteIsFalse() throws Exception {
    FasterRoute fasterRouteEngine = navigation.getFasterRouteEngine();
    // Create current progress
    RouteProgress currentProgress = obtainDefaultRouteProgress();
    DirectionsRoute longerRoute = currentProgress.directionsRoute().toBuilder().duration(// Current route duration is very short
    1000d).build();
    currentProgress = currentProgress.toBuilder().directionsRoute(longerRoute).build();
    // Create new direction response
    DirectionsResponse response = obtainADirectionsResponse();
    boolean isFasterRoute = fasterRouteEngine.isFasterRoute(response, currentProgress);
    assertFalse(isFasterRoute);
}
Also used : FasterRoute(com.mapbox.services.android.navigation.v5.route.FasterRoute) DirectionsRoute(com.mapbox.api.directions.v5.models.DirectionsRoute) RouteProgress(com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress) DirectionsResponse(com.mapbox.api.directions.v5.models.DirectionsResponse) Test(org.junit.Test) BaseTest(com.mapbox.services.android.navigation.v5.BaseTest)

Example 5 with FasterRoute

use of com.mapbox.services.android.navigation.v5.route.FasterRoute in project mapbox-navigation-android by mapbox.

the class FasterRouteDetectorTest method onNullRouteProgressPassed_shouldCheckFasterRouteIsFalse.

@Test
public void onNullRouteProgressPassed_shouldCheckFasterRouteIsFalse() throws Exception {
    FasterRoute fasterRouteEngine = navigation.getFasterRouteEngine();
    boolean checkFasterRoute = fasterRouteEngine.shouldCheckFasterRoute(mock(Location.class), null);
    assertFalse(checkFasterRoute);
}
Also used : FasterRoute(com.mapbox.services.android.navigation.v5.route.FasterRoute) 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)5 FasterRoute (com.mapbox.services.android.navigation.v5.route.FasterRoute)5 Test (org.junit.Test)5 DirectionsResponse (com.mapbox.api.directions.v5.models.DirectionsResponse)2 DirectionsRoute (com.mapbox.api.directions.v5.models.DirectionsRoute)2 RouteProgress (com.mapbox.services.android.navigation.v5.routeprogress.RouteProgress)2 Location (android.location.Location)1