Skip to content

Make NavigationService optional. #3223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/MapboxNavigation/CarPlayManagerDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public protocol CarPlayManagerDelegate: AnyObject, UnimplementedLogging {
- parameter desiredSimulationMode: The desired simulation mode to use.
- returns: A navigation service that manages location updates along `route`.
*/
func carPlayManager(_ carPlayManager: CarPlayManager, navigationServiceFor routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, desiredSimulationMode: SimulationMode) -> NavigationService
func carPlayManager(_ carPlayManager: CarPlayManager, navigationServiceFor routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, desiredSimulationMode: SimulationMode) -> NavigationService?

/**
Called when the CarPlay manager fails to fetch a route.
Expand Down
6 changes: 3 additions & 3 deletions Tests/MapboxNavigationTests/CarPlayManagerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -406,11 +406,11 @@ class CarPlayManagerSpec: QuickSpec {
var customTripPreviewTextConfiguration: CPTripPreviewTextConfiguration?
var customTrip: CPTrip?

func carPlayManager(_ carPlayManager: CarPlayManager, willPreview trip: CPTrip) -> (CPTrip) {
func carPlayManager(_ carPlayManager: CarPlayManager, willPreview trip: CPTrip) -> CPTrip {
return customTrip ?? trip
}

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

Expand All @@ -423,7 +423,7 @@ class CarPlayManagerSpec: QuickSpec {
}

//TODO: ADD OPTIONS TO THIS DELEGATE METHOD
func carPlayManager(_ carPlayManager: CarPlayManager, navigationServiceFor routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, desiredSimulationMode: SimulationMode) -> NavigationService {
func carPlayManager(_ carPlayManager: CarPlayManager, navigationServiceFor routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, desiredSimulationMode: SimulationMode) -> NavigationService? {
let directionsFake = Directions(credentials: Fixture.credentials)
return MapboxNavigationService(routeResponse: routeResponse, routeIndex: routeIndex, routeOptions: routeOptions, directions: directionsFake, simulating: desiredSimulationMode)
}
Expand Down
4 changes: 2 additions & 2 deletions Tests/MapboxNavigationTests/Support/CarPlayUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CarPlayManagerFailureDelegateSpy: CarPlayManagerDelegate {
return nil
}

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

Expand Down Expand Up @@ -63,7 +63,7 @@ class TestCarPlayManagerDelegate: CarPlayManagerDelegate {
public var trailingBarButtons: [CPBarButton]?
public var mapButtons: [CPMapButton]?

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