Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move test doubles to TestHelper framework
- Loading branch information
Showing
16 changed files
with
266 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
MapboxCoreNavigationTests/Support/DummyURLSessionDataTask.swift
This file was deleted.
Oops, something went wrong.
60 changes: 0 additions & 60 deletions
60
MapboxCoreNavigationTests/Support/NavigationServiceTestDoubles.swift
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
...cbaselines/35CDA81821908F320072B675.xcbaseline/9C831563-2C49-4C7C-B2B5-A909580E1FC2.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>classNames</key> | ||
<dict> | ||
<key>BenchTests</key> | ||
<dict> | ||
<key>testControlRoute1()</key> | ||
<dict> | ||
<key>com.apple.XCTPerformanceMetric_WallClockTime</key> | ||
<dict> | ||
<key>baselineAverage</key> | ||
<real>0.736</real> | ||
<key>baselineIntegrationDisplayName</key> | ||
<string>Local Baseline</string> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Foundation | ||
|
||
public class DummyURLSessionDataTask: URLSessionDataTask { | ||
override public func resume() { | ||
// | ||
} | ||
|
||
override public func cancel() { | ||
// | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import Foundation | ||
import MapboxCoreNavigation | ||
import MapboxDirections | ||
|
||
class RouteControllerDataSourceFake: RouterDataSource { | ||
|
||
let manager = NavigationLocationManager() | ||
|
||
var location: CLLocation? { | ||
return manager.location | ||
} | ||
|
||
var locationProvider: NavigationLocationManager.Type { | ||
return type(of: manager) | ||
} | ||
} | ||
|
||
public class NavigationServiceDelegateSpy: NavigationServiceDelegate { | ||
private(set) var recentMessages: [String] = [] | ||
|
||
public func reset() { | ||
recentMessages.removeAll() | ||
} | ||
|
||
public func navigationService(_ service: NavigationService, shouldRerouteFrom location: CLLocation) -> Bool { | ||
recentMessages.append(#function) | ||
return true | ||
} | ||
|
||
public func navigationService(_ service: NavigationService, willRerouteFrom location: CLLocation) { | ||
recentMessages.append(#function) | ||
} | ||
|
||
public func navigationService(_ service: NavigationService, shouldDiscard location: CLLocation) -> Bool { | ||
recentMessages.append(#function) | ||
return true | ||
} | ||
|
||
public func navigationService(_ service: NavigationService, didRerouteAlong route: Route, at location: CLLocation?, proactive: Bool) { | ||
recentMessages.append(#function) | ||
} | ||
|
||
public func navigationService(_ service: NavigationService, didFailToRerouteWith error: Error) { | ||
recentMessages.append(#function) | ||
} | ||
|
||
public func navigationService(_ service: NavigationService, didUpdate progress: RouteProgress, with location: CLLocation, rawLocation: CLLocation) { | ||
recentMessages.append(#function) | ||
} | ||
|
||
public func navigationService(_ service: NavigationService, didArriveAt waypoint: Waypoint) -> Bool { | ||
recentMessages.append(#function) | ||
return true | ||
} | ||
|
||
public func navigationService(_ service: NavigationService, shouldPreventReroutesWhenArrivingAt waypoint: Waypoint) -> Bool { | ||
recentMessages.append(#function) | ||
return true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import Foundation | ||
import MapboxSpeech | ||
import AVKit | ||
@testable import MapboxNavigation | ||
/** | ||
* This class can be used as a substitute for SpeechSynthesizer under test, in order to verify whether expected calls were made. | ||
*/ | ||
|
||
|
||
public class SpeechAPISpy: SpeechSynthesizer { | ||
public struct AudioDataCall { | ||
static let sound = NSDataAsset(name: "reroute-sound", bundle: .mapboxNavigation)! | ||
|
||
let options: MapboxSpeech.SpeechOptions | ||
let completion: SpeechSynthesizer.CompletionHandler | ||
|
||
func fulfill() { | ||
completion(AudioDataCall.sound.data, nil) | ||
} | ||
} | ||
|
||
public var audioDataCalls: [AudioDataCall] = [] | ||
|
||
override public func audioData(with options: MapboxSpeech.SpeechOptions, completionHandler: @escaping MapboxSpeech.SpeechSynthesizer.CompletionHandler) -> URLSessionDataTask { | ||
let call = AudioDataCall(options: options, completion: completionHandler) | ||
audioDataCalls.append(call) | ||
return DummyURLSessionDataTask() | ||
} | ||
|
||
public func reset() { | ||
audioDataCalls.removeAll() | ||
} | ||
} | ||
|
||
public class AudioPlayerDummy: AVAudioPlayer { | ||
public let sound = NSDataAsset(name: "reroute-sound", bundle: .mapboxNavigation)! | ||
|
||
lazy var notifier: NotificationCenter = .default | ||
fileprivate typealias Note = Notification.Name.MapboxVoiceTests | ||
|
||
override public func prepareToPlay() -> Bool { | ||
notifier.post(name: Note.prepareToPlay, object: self) | ||
return true | ||
} | ||
|
||
override public func play() -> Bool { | ||
notifier.post(name: Note.play, object: self) | ||
return true | ||
} | ||
} | ||
|
||
extension Notification.Name { | ||
enum MapboxVoiceTests { | ||
static let prepareToPlay = NSNotification.Name("MapboxVoiceTests.prepareToPlay") | ||
static let play = NSNotification.Name("MapboxVoiceTests.play") | ||
} | ||
} |