@@ -4,34 +4,48 @@ import CoreLocation
44
55final class MapViewCameraTests : XCTestCase {
66
7- // TODO: Write all the camera tests
8- // func testCenterCamera() {
9- // let expectedCoordinate = CLLocationCoordinate2D(latitude: 12.3, longitude: 23.4)
10- // let state: CameraState = .coordinate(onCenter: expectedCoordinate)
11- // XCTAssertEqual(state, .coordinate(onCenter: CLLocationCoordinate2D(latitude: 12.3, longitude: 23.4)))
12- // }
13- //
14- // func testTrackingUserLocation() {
15- // let state: CameraState = .trackingUserLocation
16- // XCTAssertEqual(state, .trackingUserLocation)
17- // }
18- //
19- // func testTrackingUserLocationWithHeading() {
20- // let state: CameraState = .trackingUserLocationWithHeading
21- // XCTAssertEqual(state, .trackingUserLocationWithHeading)
22- // }
23- //
24- // func testTrackingUserLocationWithCourse() {
25- // let state: CameraState = .trackingUserLocationWithCourse
26- // XCTAssertEqual(state, .trackingUserLocationWithCourse)
27- // }
28- //
29- // func testRect() {
30- // let northeast = CLLocationCoordinate2D(latitude: 12.3, longitude: 23.4)
31- // let southwest = CLLocationCoordinate2D(latitude: 34.5, longitude: 45.6)
32- //
33- // let state: CameraState = .rect(northeast: northeast, southwest: southwest)
34- // XCTAssertEqual(state, .rect(northeast: northeast, southwest: southwest))
35- // }
7+ func testCenterCamera( ) {
8+ let expectedCoordinate = CLLocationCoordinate2D ( latitude: 12.3 , longitude: 23.4 )
9+ let pitch : CameraPitch = . freeWithinRange( minimum: 12 , maximum: 34 )
10+ let direction : CLLocationDirection = 23
11+
12+ let camera = MapViewCamera . center ( expectedCoordinate, zoom: 12 , pitch: pitch, direction: direction)
13+
14+ XCTAssertEqual ( camera. state, . coordinate( onCenter: expectedCoordinate) )
15+ XCTAssertEqual ( camera. zoom, 12 )
16+ XCTAssertEqual ( camera. pitch, pitch)
17+ XCTAssertEqual ( camera. direction, direction)
18+ }
19+
20+ func testTrackingUserLocation( ) {
21+ let pitch : CameraPitch = . freeWithinRange( minimum: 12 , maximum: 34 )
22+ let camera = MapViewCamera . trackUserLocation ( pitch: pitch)
23+
24+ XCTAssertEqual ( camera. state, . trackingUserLocation)
25+ XCTAssertEqual ( camera. zoom, 10 )
26+ XCTAssertEqual ( camera. pitch, pitch)
27+ XCTAssertEqual ( camera. direction, 0 )
28+ }
29+
30+ func testTrackUserLocationWithCourse( ) {
31+ let pitch : CameraPitch = . freeWithinRange( minimum: 12 , maximum: 34 )
32+ let camera = MapViewCamera . trackUserLocationWithCourse ( zoom: 18 , pitch: pitch)
33+
34+ XCTAssertEqual ( camera. state, . trackingUserLocationWithCourse)
35+ XCTAssertEqual ( camera. zoom, 18 )
36+ XCTAssertEqual ( camera. pitch, pitch)
37+ XCTAssertEqual ( camera. direction, 0 )
38+ }
39+
40+ func testTrackUserLocationWithHeading( ) {
41+ let camera = MapViewCamera . trackUserLocationWithHeading ( )
42+
43+ XCTAssertEqual ( camera. state, . trackingUserLocationWithHeading)
44+ XCTAssertEqual ( camera. zoom, 10 )
45+ XCTAssertEqual ( camera. pitch, . free)
46+ XCTAssertEqual ( camera. direction, 0 )
47+ }
48+
49+ // TODO: Add additional camera tests once behaviors are added (e.g. rect)
3650
3751}
0 commit comments