Skip to content

Commit cd9c4e2

Browse files
committed
[Core] Integration tests in progress
1 parent 4e19e1e commit cd9c4e2

File tree

1 file changed

+14
-30
lines changed

1 file changed

+14
-30
lines changed

Tests/MapboxCoreNavigationIntegrationTests/RouteRefreshIntegrationTests.swift

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@ class RouteRefreshIntegrationTests: TestCase {
2828
}
2929

3030
func testRouteRefreshWithDefaultDrivingTrafficProfile() {
31-
simulateOnRoute(with: .automobileAvoidingTraffic, shouldRefresh: true)
31+
simulateAndTestOnRoute(with: .automobileAvoidingTraffic, shouldRefresh: true)
3232
}
3333

3434
func testRouteRefreshWithCustomDrivingTrafficProfile() {
35-
simulateOnRoute(with: .custom, shouldRefresh: true)
35+
simulateAndTestOnRoute(with: .custom, shouldRefresh: true)
3636
}
3737

3838
func testRouteRefreshWithWalkingProfile() {
39-
simulateOnRoute(with: .walking, shouldRefresh: false)
39+
simulateAndTestOnRoute(with: .walking, shouldRefresh: false)
4040
}
4141

4242
func testReRouteDefaultParametersDefaultDrivingTrafficProfile() {
43-
simulateOffRoute(
43+
simulateAndTestOffRoute(
4444
with: .mockedOptions(.automobileAvoidingTraffic),
4545
expectationKey: "RerouteDefaultParametersDefaultProfile") { options in
4646
XCTAssert(options.profileIdentifier == .automobileAvoidingTraffic)
4747
}
4848
}
4949

5050
func testReRouteCustomParametersCustomDrivingTrafficProfile() {
51-
simulateOffRoute(
51+
simulateAndTestOffRoute(
5252
with: .mockedCustomOptions(.custom),
5353
expectationKey: "RerouteCustomParametersDefaultProfile") { options in
5454
let customOptions = options as! CustomRouteOptions
@@ -58,7 +58,7 @@ class RouteRefreshIntegrationTests: TestCase {
5858
}
5959

6060
func testReRouteCustomParametersDefaultDrivingTrafficProfile() {
61-
simulateOffRoute(
61+
simulateAndTestOffRoute(
6262
with: .mockedCustomOptions(.automobileAvoidingTraffic),
6363
expectationKey: "RerouteCustomParametersCustomProfile") { options in
6464
let customOptions = options as! CustomRouteOptions
@@ -67,8 +67,13 @@ class RouteRefreshIntegrationTests: TestCase {
6767
}
6868
}
6969

70-
private func simulateOnRoute(with profile: ProfileIdentifier, shouldRefresh: Bool = true) {
71-
let (locationManager, navigation) = navigatorAndLocationManager(with: profile)
70+
private func simulateAndTestOnRoute(with profile: ProfileIdentifier, shouldRefresh: Bool = true) {
71+
let indexedRouteResponse = RouteResponse.mockedIndexRouteResponse(profile: profile)
72+
let simulationLocations = indexedRouteResponse.routeResponse.routes![0].simulationOnRouteLocations
73+
let (locationManager, navigation) = navigatorAndLocationManager(
74+
with: indexedRouteResponse,
75+
simulationLocations: simulationLocations
76+
)
7277
let refreshExpectation = expectation(
7378
forNotification: .routeControllerDidRefreshRoute,
7479
object: navigation.router
@@ -90,7 +95,7 @@ class RouteRefreshIntegrationTests: TestCase {
9095
waitForExpectations(timeout: .defaultDelay) { XCTAssertNil($0) }
9196
}
9297

93-
private func simulateOffRoute(
98+
private func simulateAndTestOffRoute(
9499
with options: NavigationRouteOptions,
95100
expectationKey: String,
96101
validation: @escaping (NavigationRouteOptions) -> Void
@@ -114,27 +119,6 @@ class RouteRefreshIntegrationTests: TestCase {
114119
waitForExpectations(timeout: .defaultDelay) { XCTAssertNil($0) }
115120
}
116121

117-
private func navigatorAndLocationManager(
118-
with profile: ProfileIdentifier,
119-
) -> (ReplayLocationManager, MapboxNavigationService) {
120-
RouteControllerProactiveReroutingInterval = 2
121-
122-
let indexedRouteResponse = RouteResponse.mockedIndexRouteResponse(profile: profile)
123-
let locationManager = ReplayLocationManager(
124-
locations: indexedRouteResponse.routeResponse.routes![0].simulationOnRouteLocations
125-
)
126-
127-
locationManager.speedMultiplier = 1
128-
let navigation = MapboxNavigationService(
129-
indexedRouteResponse: indexedRouteResponse,
130-
customRoutingProvider: MapboxRoutingProvider(.online),
131-
credentials: Fixture.credentials,
132-
locationSource: locationManager,
133-
simulating: .never
134-
)
135-
return (locationManager, navigation)
136-
}
137-
138122
private func navigatorAndLocationManager(
139123
with indexedRouteResponse: IndexedRouteResponse,
140124
simulationLocations: [CLLocation]

0 commit comments

Comments
 (0)