/
NativeNavigatorSpy.swift
84 lines (69 loc) · 3.72 KB
/
NativeNavigatorSpy.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import MapboxNavigationNative
@_implementationOnly import MapboxCommon_Private
@_implementationOnly import MapboxNavigationNative_Private
@testable import MapboxCoreNavigation
public class NativeNavigatorSpy: MapboxNavigationNative.Navigator {
public var passedTileStore: TileStore?
public var passedDescriptors: [TilesetDescriptor]?
public var passedCacheOptions: PredictiveCacheControllerOptions?
public var passedRerouteController: RerouteControllerInterface?
public var passedLeg: UInt32? = nil
public var returnedChangeLegResult = true
public var passedNavigationTrackerOptions: PredictiveLocationTrackerOptions?
public var passedDescriptorsTrackerOptions: PredictiveLocationTrackerOptions?
public var passedDatasetTrackerOptions: PredictiveLocationTrackerOptions?
public var passedRemovedRerouteObserver: RerouteObserver?
public var rerouteController: RerouteControllerInterface!
public var rerouteDetector: RerouteDetectorInterface!
public var startNavigationSessionCalled = false
public var stopNavigationSessionCalled = false
public init() {
let factory = NativeHandlersFactory(tileStorePath: "", credentials: DirectionsSpy.shared.credentials)
super.init(config: NativeHandlersFactory.configHandle(),
cache: factory.cacheHandle,
historyRecorder: nil,
router: nil)
}
public override func createPredictiveCacheController(for options: PredictiveLocationTrackerOptions) -> PredictiveCacheController {
passedNavigationTrackerOptions = options
return super.createPredictiveCacheController(for: options)
}
public override func createPredictiveCacheController(for tileStore: TileStore,
descriptors: [TilesetDescriptor],
locationTrackerOptions: PredictiveLocationTrackerOptions) -> PredictiveCacheController {
passedTileStore = tileStore
passedDescriptors = descriptors
passedDescriptorsTrackerOptions = locationTrackerOptions
return super.createPredictiveCacheController(for: locationTrackerOptions)
}
public override func createPredictiveCacheController(for tileStore: TileStore,
cacheOptions: PredictiveCacheControllerOptions,
locationTrackerOptions: PredictiveLocationTrackerOptions) -> PredictiveCacheController {
passedTileStore = tileStore
passedCacheOptions = cacheOptions
passedDatasetTrackerOptions = locationTrackerOptions
return super.createPredictiveCacheController(for: locationTrackerOptions)
}
public override func changeLeg(forLeg leg: UInt32, callback: @escaping ChangeLegCallback) {
passedLeg = leg
callback(returnedChangeLegResult)
}
public override func removeRerouteObserver(for observer: RerouteObserver) {
passedRemovedRerouteObserver = observer
}
@_implementationOnly public override func setRerouteControllerForController(_ controller: RerouteControllerInterface) {
passedRerouteController = controller
}
@_implementationOnly public override func getRerouteController() -> RerouteControllerInterface {
return rerouteController ?? super.getRerouteController()
}
@_implementationOnly public override func getRerouteDetector() -> RerouteDetectorInterface {
return rerouteDetector ?? RerouteDetectorSpy()
}
public override func startNavigationSession() {
startNavigationSessionCalled = true
}
public override func stopNavigationSession() {
stopNavigationSessionCalled = true
}
}