Skip to content

Commit 319cb99

Browse files
authored
Remove usage of real GPS position when simulationMode == .always (#4394)
* Fix route simulation * Add test * Add changelog
1 parent 05c6f97 commit 319cb99

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@
6565
* Increased terminal offboard route request timeout from 4 to 15 seconds. ([#4367](https://github.com/mapbox/mapbox-navigation-ios/pull/4367))
6666
* Sped up onboard routing cancellation. ([#4367](https://github.com/mapbox/mapbox-navigation-ios/pull/4367))
6767
* Fixed an issue when a rerouting could cause a memory leak. ([#4380](https://github.com/mapbox/mapbox-navigation-ios/pull/4380))
68+
* Fixed usage of real GPS locations in simulated routes ([#4394](https://github.com/mapbox/mapbox-navigation-ios/pull/4394))
6869

6970
## v2.10.0
7071

Sources/MapboxCoreNavigation/NavigationService.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public class MapboxNavigationService: NSObject, NavigationService {
239239
public func start() {
240240
// Feed the first location to the router if router doesn't have a location yet. See #1790, #3237 for reference.
241241
if router.location == nil {
242-
if let currentLocation = locationManager.location {
242+
if let currentLocation = locationManager.location, simulationMode != .always {
243243
router.locationManager?(nativeLocationSource, didUpdateLocations: [
244244
currentLocation
245245
])

Tests/MapboxCoreNavigationTests/NavigationServiceTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,16 @@ class NavigationServiceTests: TestCase {
165165
XCTAssertEqual(routerSpy.passedLocations, [location])
166166
}
167167

168+
func testStartIgnoresManagerLocationWhenSimulationModeAlways() {
169+
locationManager.returnedLocation = location
170+
service.simulationMode = .always
171+
service.start()
172+
173+
XCTAssertTrue(routerSpy.didUpdateLocationsCalled)
174+
let expectedCoordinate = route.shape!.coordinates.first!
175+
XCTAssertEqual(routerSpy.passedLocations?.first?.coordinate, expectedCoordinate)
176+
}
177+
168178
func testStartIfNilRouterLocationAndSimulatedLocation() {
169179
let coordinate = route.shape!.coordinates.first!
170180
service.start()

0 commit comments

Comments
 (0)