Skip to content

Commit d1f496c

Browse files
committed
Make NavigationService optional to be able to skip implementation of delegate method on client side as CarPlayManager provides default MapboxNavigationService implementation anyway.
1 parent 5101cb2 commit d1f496c

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

Sources/MapboxNavigation/CarPlayManagerDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public protocol CarPlayManagerDelegate: AnyObject, UnimplementedLogging {
6363
- parameter desiredSimulationMode: The desired simulation mode to use.
6464
- returns: A navigation service that manages location updates along `route`.
6565
*/
66-
func carPlayManager(_ carPlayManager: CarPlayManager, navigationServiceFor routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, desiredSimulationMode: SimulationMode) -> NavigationService
66+
func carPlayManager(_ carPlayManager: CarPlayManager, navigationServiceFor routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, desiredSimulationMode: SimulationMode) -> NavigationService?
6767

6868
/**
6969
Called when the CarPlay manager fails to fetch a route.

Tests/MapboxNavigationTests/CarPlayManagerTests.swift

+3-3
Original file line numberDiff line numberDiff line change
@@ -406,11 +406,11 @@ class CarPlayManagerSpec: QuickSpec {
406406
var customTripPreviewTextConfiguration: CPTripPreviewTextConfiguration?
407407
var customTrip: CPTrip?
408408

409-
func carPlayManager(_ carPlayManager: CarPlayManager, willPreview trip: CPTrip) -> (CPTrip) {
409+
func carPlayManager(_ carPlayManager: CarPlayManager, willPreview trip: CPTrip) -> CPTrip {
410410
return customTrip ?? trip
411411
}
412412

413-
func carPlayManager(_ carPlayManager: CarPlayManager, willPreview trip: CPTrip, with previewTextConfiguration: CPTripPreviewTextConfiguration) -> (CPTripPreviewTextConfiguration) {
413+
func carPlayManager(_ carPlayManager: CarPlayManager, willPreview trip: CPTrip, with previewTextConfiguration: CPTripPreviewTextConfiguration) -> CPTripPreviewTextConfiguration {
414414
return customTripPreviewTextConfiguration ?? previewTextConfiguration
415415
}
416416

@@ -423,7 +423,7 @@ class CarPlayManagerSpec: QuickSpec {
423423
}
424424

425425
//TODO: ADD OPTIONS TO THIS DELEGATE METHOD
426-
func carPlayManager(_ carPlayManager: CarPlayManager, navigationServiceFor routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, desiredSimulationMode: SimulationMode) -> NavigationService {
426+
func carPlayManager(_ carPlayManager: CarPlayManager, navigationServiceFor routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, desiredSimulationMode: SimulationMode) -> NavigationService? {
427427
let directionsFake = Directions(credentials: Fixture.credentials)
428428
return MapboxNavigationService(routeResponse: routeResponse, routeIndex: routeIndex, routeOptions: routeOptions, directions: directionsFake, simulating: desiredSimulationMode)
429429
}

Tests/MapboxNavigationTests/Support/CarPlayUtils.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class CarPlayManagerFailureDelegateSpy: CarPlayManagerDelegate {
2828
return nil
2929
}
3030

31-
func carPlayManager(_ carPlayManager: CarPlayManager, navigationServiceFor routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, desiredSimulationMode: SimulationMode) -> NavigationService {
31+
func carPlayManager(_ carPlayManager: CarPlayManager, navigationServiceFor routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, desiredSimulationMode: SimulationMode) -> NavigationService? {
3232
fatalError("This is an empty stub.")
3333
}
3434

@@ -63,7 +63,7 @@ class TestCarPlayManagerDelegate: CarPlayManagerDelegate {
6363
public var trailingBarButtons: [CPBarButton]?
6464
public var mapButtons: [CPMapButton]?
6565

66-
func carPlayManager(_ carPlayManager: CarPlayManager, navigationServiceFor routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, desiredSimulationMode: SimulationMode) -> NavigationService {
66+
func carPlayManager(_ carPlayManager: CarPlayManager, navigationServiceFor routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, desiredSimulationMode: SimulationMode) -> NavigationService? {
6767
let response = Fixture.routeResponse(from: jsonFileName, options: routeOptions)
6868
let directionsClientSpy = DirectionsSpy()
6969
let service = MapboxNavigationService(routeResponse: response, routeIndex: 0, routeOptions: routeOptions, directions: directionsClientSpy, locationSource: NavigationLocationManager(), eventsManagerType: NavigationEventsManagerSpy.self, simulating: desiredSimulationMode)

0 commit comments

Comments
 (0)