Skip to content

Commit

Permalink
Updated version to latest
Browse files Browse the repository at this point in the history
  • Loading branch information
Archdoog committed Feb 8, 2024
1 parent 6187b1a commit d3d0ec8
Showing 1 changed file with 43 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,48 @@ import CoreLocation

final class MapViewCameraTests: XCTestCase {

// TODO: Write all the camera tests
// func testCenterCamera() {
// let expectedCoordinate = CLLocationCoordinate2D(latitude: 12.3, longitude: 23.4)
// let state: CameraState = .coordinate(onCenter: expectedCoordinate)
// XCTAssertEqual(state, .coordinate(onCenter: CLLocationCoordinate2D(latitude: 12.3, longitude: 23.4)))
// }
//
// func testTrackingUserLocation() {
// let state: CameraState = .trackingUserLocation
// XCTAssertEqual(state, .trackingUserLocation)
// }
//
// func testTrackingUserLocationWithHeading() {
// let state: CameraState = .trackingUserLocationWithHeading
// XCTAssertEqual(state, .trackingUserLocationWithHeading)
// }
//
// func testTrackingUserLocationWithCourse() {
// let state: CameraState = .trackingUserLocationWithCourse
// XCTAssertEqual(state, .trackingUserLocationWithCourse)
// }
//
// func testRect() {
// let northeast = CLLocationCoordinate2D(latitude: 12.3, longitude: 23.4)
// let southwest = CLLocationCoordinate2D(latitude: 34.5, longitude: 45.6)
//
// let state: CameraState = .rect(northeast: northeast, southwest: southwest)
// XCTAssertEqual(state, .rect(northeast: northeast, southwest: southwest))
// }
func testCenterCamera() {
let expectedCoordinate = CLLocationCoordinate2D(latitude: 12.3, longitude: 23.4)
let pitch: CameraPitch = .freeWithinRange(minimum: 12, maximum: 34)
let direction: CLLocationDirection = 23

let camera = MapViewCamera.center(expectedCoordinate, zoom: 12, pitch: pitch, direction: direction)

XCTAssertEqual(camera.state, .coordinate(onCenter: expectedCoordinate))
XCTAssertEqual(camera.zoom, 12)
XCTAssertEqual(camera.pitch, pitch)
XCTAssertEqual(camera.direction, direction)
}

func testTrackingUserLocation() {
let pitch: CameraPitch = .freeWithinRange(minimum: 12, maximum: 34)
let camera = MapViewCamera.trackUserLocation(pitch: pitch)

XCTAssertEqual(camera.state, .trackingUserLocation)
XCTAssertEqual(camera.zoom, 10)
XCTAssertEqual(camera.pitch, pitch)
XCTAssertEqual(camera.direction, 0)
}

func testTrackUserLocationWithCourse() {
let pitch: CameraPitch = .freeWithinRange(minimum: 12, maximum: 34)
let camera = MapViewCamera.trackUserLocationWithCourse(zoom: 18, pitch: pitch)

XCTAssertEqual(camera.state, .trackingUserLocationWithCourse)
XCTAssertEqual(camera.zoom, 18)
XCTAssertEqual(camera.pitch, pitch)
XCTAssertEqual(camera.direction, 0)
}

func testTrackUserLocationWithHeading() {
let camera = MapViewCamera.trackUserLocationWithHeading()

XCTAssertEqual(camera.state, .trackingUserLocationWithHeading)
XCTAssertEqual(camera.zoom, 10)
XCTAssertEqual(camera.pitch, .free)
XCTAssertEqual(camera.direction, 0)
}

// TODO: Add additional camera tests once behaviors are added (e.g. rect)

}

0 comments on commit d3d0ec8

Please sign in to comment.