Skip to content

Instantly share code, notes, and snippets.

View dylanmaryk's full-sized avatar

Dylan Maryk dylanmaryk

View GitHub Profile
var app: XCUIApplication!
var succulent: Succulent!
// The URL to the trace file for the current test when running tests
private var traceUrl: URL? {
let bundle = Bundle(for: type(of: self))
return bundle.url(forResource: self.traceName, withExtension: "trace", subdirectory: "Succulent")
}
// The URL to the trace file for the current test when recording
let baseUrlString = ProcessInfo.processInfo.environment["succulentBaseUrl"] ?? "{YOUR-REAL-BASE-URL}"
let baseUrl = URL(string: baseUrlString)
verify(view).expandTimeBubble(withSearchModeText: "Arrive: ",
andDateText: "Wed, 00:00",
animated: true)
view = MockPlannerMapView()
stub(view) { stub in
when(stub.setPolygons(with: any())).thenDoNothing()
when(stub.changeHintViewToOrigin()).thenDoNothing()
when(stub.makeTimeBubbleVisible()).thenDoNothing()
when(stub.makeTimeBubbleInvisible()).thenDoNothing()
when(stub.expandTimeBubble(withSearchModeText: anyString(),
andDateText: anyString(),
animated: any(Bool.self)))
.thenDoNothing()
describe("route to result card header component view model mapper test") {
context("when the route is a walking route") {
let route = Route.mockWalkingRoute
let departureDate = (route.segments?.first?.stops?.first?.scheduledDate)!
context("when the route is in less than 15 minutes") {
let currentDate = calendar.date(byAdding: .minute, value: -14, to: departureDate)!
let model = mapper.resultCardHeaderComponentViewModel(for: route, currentDate: currentDate)
it("returns a route type string for walking") {
expect(model.routeType).to(equal("Walk"))
}
if let previousCircle = previousCircle {
let circleLocation = CLLocation(latitude: circleCoordinate.latitude,
longitude: circleCoordinate.longitude)
let previousCircleLocation = CLLocation(latitude: previousCircle.position.latitude,
longitude: previousCircle.position.longitude)
if mapView.projection.points(forMeters: circleLocation.distance(from: previousCircleLocation),
at: mapView.camera.target) < intervalDistanceIncrement {
continue
}
}
for coordinateIndex in 0 ..< path.count() - 1 {
let startCoordinate = path.coordinate(at: coordinateIndex)
let endCoordinate = path.coordinate(at: coordinateIndex + 1)
let startLocation = CLLocation(latitude: startCoordinate.latitude, longitude: startCoordinate.longitude)
let endLocation = CLLocation(latitude: endCoordinate.latitude, longitude: endCoordinate.longitude)
let pathDistance = endLocation.distance(from: startLocation)
let intervalLatIncrement = (endLocation.coordinate.latitude - startLocation.coordinate.latitude) / pathDistance
let intervalLngIncrement = (endLocation.coordinate.longitude - startLocation.coordinate.longitude) / pathDistance
for intervalDistance in 0 ..< Int(pathDistance) {
let intervalLat = startLocation.coordinate.latitude + (intervalLatIncrement * Double(intervalDistance))
private let polyline = GMSPolyline(path: GMSPath(fromEncodedPath: "{dq_IowzpAzkAbhF"))
override func viewDidLoad() {
super.viewDidLoad()
mapView.delegate = self
set(polyline: polyline, on: mapView)
}
func mapView(_ mapView: GMSMapView, didChange position: GMSCameraPosition) {
set(polyline: polyline, on: mapView)
}
guard let path = polyline.path else {
return
}
mapView.clear()
let intervalDistanceIncrement: CGFloat = 10
let circleRadiusScale = 1 / mapView.projection.points(forMeters: 1, at: mapView.camera.target)
var previousCircle: GMSCircle?
for coordinateIndex in 0 ..< path.count() - 1 {
let startCoordinate = path.coordinate(at: coordinateIndex)
let endCoordinate = path.coordinate(at: coordinateIndex + 1)