@@ -23,6 +23,13 @@ final class MapViewCoordinatorCameraTests: XCTestCase {
23
23
@MainActor func testUnchangedCamera( ) {
24
24
let camera : MapViewCamera = . default( )
25
25
26
+ given ( maplibreMapView)
27
+ . setCenter ( . any,
28
+ zoomLevel: . any,
29
+ direction: . any,
30
+ animated: . any)
31
+ . willReturn ( )
32
+
26
33
coordinator. updateCamera ( mapView: maplibreMapView, camera: camera, animated: false )
27
34
// Run a second update. We're testing that the snapshotCamera correctly exits the function
28
35
// when nothing changed.
@@ -32,173 +39,192 @@ final class MapViewCoordinatorCameraTests: XCTestCase {
32
39
// This verifies the comment above.
33
40
verify ( maplibreMapView)
34
41
. userTrackingMode ( newValue: . value( . none) )
35
- . setterCalled ( count : 1 )
42
+ . setCalled ( 1 )
36
43
37
44
verify ( maplibreMapView)
38
45
. setCenter ( . value( MapViewCamera . Defaults. coordinate) ,
39
46
zoomLevel: . value( 10 ) ,
40
47
direction: . value( 0 ) ,
41
48
animated: . value( false ) )
42
- . called ( count : 1 )
49
+ . called ( 1 )
43
50
44
51
// Due to the .frame == .zero workaround, min/max pitch setting is called twice, once to set the
45
52
// pitch, and then once to set the actual range.
46
53
verify ( maplibreMapView)
47
54
. minimumPitch ( newValue: . value( 0 ) )
48
- . setterCalled ( count : 2 )
55
+ . setCalled ( 2 )
49
56
50
57
verify ( maplibreMapView)
51
58
. maximumPitch ( newValue: . value( 0 ) )
52
- . setterCalled ( count : 1 )
59
+ . setCalled ( 1 )
53
60
54
61
verify ( maplibreMapView)
55
62
. maximumPitch ( newValue: . value( 60 ) )
56
- . setterCalled ( count : 1 )
63
+ . setCalled ( 1 )
57
64
58
65
verify ( maplibreMapView)
59
66
. setZoomLevel ( . any, animated: . any)
60
- . called ( count : 0 )
67
+ . called ( 0 )
61
68
}
62
69
63
70
@MainActor func testCenterCameraUpdate( ) {
64
71
let coordinate = CLLocationCoordinate2D ( latitude: 12.3 , longitude: 23.4 )
65
72
let newCamera : MapViewCamera = . center( coordinate, zoom: 13 )
66
73
74
+ given ( maplibreMapView)
75
+ . setCenter ( . any,
76
+ zoomLevel: . any,
77
+ direction: . any,
78
+ animated: . any)
79
+ . willReturn ( )
80
+
67
81
coordinator. updateCamera ( mapView: maplibreMapView, camera: newCamera, animated: false )
68
82
69
83
verify ( maplibreMapView)
70
84
. userTrackingMode ( newValue: . value( . none) )
71
- . setterCalled ( count : 1 )
85
+ . setCalled ( 1 )
72
86
73
87
verify ( maplibreMapView)
74
88
. setCenter ( . value( coordinate) ,
75
89
zoomLevel: . value( 13 ) ,
76
90
direction: . value( 0 ) ,
77
91
animated: . value( false ) )
78
- . called ( count : 1 )
92
+ . called ( 1 )
79
93
80
94
// Due to the .frame == .zero workaround, min/max pitch setting is called twice, once to set the
81
95
// pitch, and then once to set the actual range.
82
96
verify ( maplibreMapView)
83
97
. minimumPitch ( newValue: . value( 0 ) )
84
- . setterCalled ( count : 2 )
98
+ . setCalled ( 2 )
85
99
86
100
verify ( maplibreMapView)
87
101
. maximumPitch ( newValue: . value( 0 ) )
88
- . setterCalled ( count : 1 )
102
+ . setCalled ( 1 )
89
103
90
104
verify ( maplibreMapView)
91
105
. maximumPitch ( newValue: . value( 60 ) )
92
- . setterCalled ( count : 1 )
106
+ . setCalled ( 1 )
93
107
94
108
verify ( maplibreMapView)
95
109
. setZoomLevel ( . any, animated: . any)
96
- . called ( count : 0 )
110
+ . called ( 0 )
97
111
}
98
112
99
113
@MainActor func testUserTrackingCameraUpdate( ) {
100
114
let newCamera : MapViewCamera = . trackUserLocation( )
101
115
116
+ given ( maplibreMapView)
117
+ . setZoomLevel ( . any, animated: . any)
118
+ . willReturn ( )
119
+
102
120
coordinator. updateCamera ( mapView: maplibreMapView, camera: newCamera, animated: false )
103
121
104
122
verify ( maplibreMapView)
105
123
. userTrackingMode ( newValue: . value( . follow) )
106
- . setterCalled ( count : 1 )
124
+ . setCalled ( 1 )
107
125
108
126
verify ( maplibreMapView)
109
127
. setCenter ( . any,
110
128
zoomLevel: . any,
111
129
direction: . any,
112
130
animated: . any)
113
- . called ( count : 0 )
131
+ . called ( 0 )
114
132
115
133
// Due to the .frame == .zero workaround, min/max pitch setting is called twice, once to set the
116
134
// pitch, and then once to set the actual range.
117
135
verify ( maplibreMapView)
118
136
. minimumPitch ( newValue: . value( 0 ) )
119
- . setterCalled ( count : 2 )
137
+ . setCalled ( 2 )
120
138
121
139
verify ( maplibreMapView)
122
140
. maximumPitch ( newValue: . value( 0 ) )
123
- . setterCalled ( count : 1 )
141
+ . setCalled ( 1 )
124
142
125
143
verify ( maplibreMapView)
126
144
. maximumPitch ( newValue: . value( 60 ) )
127
- . setterCalled ( count : 1 )
145
+ . setCalled ( 1 )
128
146
129
147
verify ( maplibreMapView)
130
148
. setZoomLevel ( . value( 10 ) , animated: . value( false ) )
131
- . called ( count : 1 )
149
+ . called ( 1 )
132
150
}
133
151
134
152
@MainActor func testUserTrackingWithCourseCameraUpdate( ) {
135
153
let newCamera : MapViewCamera = . trackUserLocationWithCourse( )
136
154
155
+ given ( maplibreMapView)
156
+ . setZoomLevel ( . any, animated: . any)
157
+ . willReturn ( )
158
+
137
159
coordinator. updateCamera ( mapView: maplibreMapView, camera: newCamera, animated: false )
138
160
139
161
verify ( maplibreMapView)
140
162
. userTrackingMode ( newValue: . value( . followWithCourse) )
141
- . setterCalled ( count : 1 )
163
+ . setCalled ( 1 )
142
164
143
165
verify ( maplibreMapView)
144
166
. setCenter ( . any,
145
167
zoomLevel: . any,
146
168
direction: . any,
147
169
animated: . any)
148
- . called ( count : 0 )
170
+ . called ( 0 )
149
171
150
172
// Due to the .frame == .zero workaround, min/max pitch setting is called twice, once to set the
151
173
// pitch, and then once to set the actual range.
152
174
verify ( maplibreMapView)
153
175
. minimumPitch ( newValue: . value( 0 ) )
154
- . setterCalled ( count : 2 )
176
+ . setCalled ( 2 )
155
177
156
178
verify ( maplibreMapView)
157
179
. maximumPitch ( newValue: . value( 0 ) )
158
- . setterCalled ( count : 1 )
180
+ . setCalled ( 1 )
159
181
160
182
verify ( maplibreMapView)
161
183
. maximumPitch ( newValue: . value( 60 ) )
162
- . setterCalled ( count : 1 )
184
+ . setCalled ( 1 )
163
185
164
186
verify ( maplibreMapView)
165
187
. setZoomLevel ( . value( 10 ) , animated: . value( false ) )
166
- . called ( count : 1 )
188
+ . called ( 1 )
167
189
}
168
190
169
191
@MainActor func testUserTrackingWithHeadingUpdate( ) {
170
192
let newCamera : MapViewCamera = . trackUserLocationWithHeading( )
171
193
194
+ given ( maplibreMapView)
195
+ . setZoomLevel ( . any, animated: . any)
196
+ . willReturn ( )
197
+
172
198
coordinator. updateCamera ( mapView: maplibreMapView, camera: newCamera, animated: false )
173
199
174
200
verify ( maplibreMapView)
175
201
. userTrackingMode ( newValue: . value( . followWithHeading) )
176
- . setterCalled ( count : 1 )
202
+ . setCalled ( 1 )
177
203
178
204
verify ( maplibreMapView)
179
205
. setCenter ( . any,
180
206
zoomLevel: . any,
181
207
direction: . any,
182
208
animated: . any)
183
- . called ( count : 0 )
209
+ . called ( 0 )
184
210
185
211
// Due to the .frame == .zero workaround, min/max pitch setting is called twice, once to set the
186
212
// pitch, and then once to set the actual range.
187
213
verify ( maplibreMapView)
188
214
. minimumPitch ( newValue: . value( 0 ) )
189
- . setterCalled ( count : 2 )
215
+ . setCalled ( 2 )
190
216
191
217
verify ( maplibreMapView)
192
218
. maximumPitch ( newValue: . value( 0 ) )
193
- . setterCalled ( count : 1 )
219
+ . setCalled ( 1 )
194
220
195
221
verify ( maplibreMapView)
196
222
. maximumPitch ( newValue: . value( 60 ) )
197
- . setterCalled ( count : 1 )
223
+ . setCalled ( 1 )
198
224
199
225
verify ( maplibreMapView)
200
226
. setZoomLevel ( . value( 10 ) , animated: . value( false ) )
201
- . called ( count : 1 )
227
+ . called ( 1 )
202
228
}
203
229
204
230
// TODO: Test Rect & Showcase once we build it!
0 commit comments