【发布时间】:2018-09-24 15:10:55
【问题描述】:
那里有人尝试以编程方式在地图上模拟 iOS UI 测试的位置(不使用编辑方案 > 允许位置模拟)吗?
【问题讨论】:
-
你不知道GPX文件吗?
标签: ios mocking xcuitest testautomationfx
那里有人尝试以编程方式在地图上模拟 iOS UI 测试的位置(不使用编辑方案 > 允许位置模拟)吗?
【问题讨论】:
标签: ios mocking xcuitest testautomationfx
创建协议和模拟位置管理器
import CoreLocation
protocol LocationManager: class {
var location: CLLocation? { get }
}
final class MockCLLocationManager: LocationManager {
var location: CLLocation? {
return CLLocation(latitude: CLLocationDegrees(exactly: 52.51657052665494)!,
longitude: CLLocationDegrees(exactly: 13.381044881575008)!)
}
}
extension CLLocationManager: LocationManager { }
然后在您的地图视图控制器中:
let locationManager: LocationManager = MockCLLocationManager()
我无法让地图视图以这种方式显示蓝色用户位置指示器。
【讨论】: