Skip to content

Commit a789bbe

Browse files
authored
Merge pull request maplibre#49 from stadiamaps/make-snapshot-tests-reproducible
Make snapshot helpers reproducible
2 parents cee1194 + 2c197b0 commit a789bbe

17 files changed

+60
-32
lines changed

Tests/MapLibreSwiftUITests/Examples/CameraPreviewTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import XCTest
44

55
final class CameraPreviewTests: XCTestCase {
66
func testCameraPreview() {
7-
assertView(named: "CameraPreview") {
7+
assertView {
88
CameraDirectManipulationPreview(
99
styleURL: URL(string: "https://demotiles.maplibre.org/style.json")!
1010
)
Lines changed: 56 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,104 @@
1+
import CoreLocation
12
import MapLibreSwiftDSL
23
import SnapshotTesting
34
import XCTest
45
@testable import MapLibreSwiftUI
56

67
final class MapControlsTests: XCTestCase {
8+
// NOTE: The map views in this test intentionally have a non-north orientation
9+
// so that the compass will be rendered if present.
10+
711
@MainActor
812
func testEmptyControls() {
913
assertView {
10-
MapView(styleURL: demoTilesURL)
11-
.mapControls {
12-
// No controls
13-
}
14+
MapView(
15+
styleURL: demoTilesURL,
16+
camera: .constant(.center(CLLocationCoordinate2D(), zoom: 4, direction: 45))
17+
)
18+
.mapControls {
19+
// No controls
20+
}
1421
}
1522
}
1623

1724
@MainActor
1825
func testLogoOnly() {
1926
assertView {
20-
MapView(styleURL: demoTilesURL)
21-
.mapControls {
22-
LogoView()
23-
}
27+
MapView(
28+
styleURL: demoTilesURL,
29+
camera: .constant(.center(CLLocationCoordinate2D(), zoom: 4, direction: 45))
30+
)
31+
.mapControls {
32+
LogoView()
33+
}
2434
}
2535
}
2636

2737
@MainActor
2838
func testLogoChangePosition() {
2939
assertView {
30-
MapView(styleURL: demoTilesURL)
31-
.mapControls {
32-
LogoView()
33-
.position(.topLeft)
34-
}
40+
MapView(
41+
styleURL: demoTilesURL,
42+
camera: .constant(.center(CLLocationCoordinate2D(), zoom: 4, direction: 45))
43+
)
44+
.mapControls {
45+
LogoView()
46+
.position(.topLeft)
47+
}
3548
}
3649
}
3750

3851
@MainActor
3952
func testCompassOnly() {
4053
assertView {
41-
MapView(styleURL: demoTilesURL)
42-
.mapControls {
43-
CompassView()
44-
}
54+
MapView(
55+
styleURL: demoTilesURL,
56+
camera: .constant(.center(CLLocationCoordinate2D(), zoom: 4, direction: 45))
57+
)
58+
.mapControls {
59+
CompassView()
60+
}
4561
}
4662
}
4763

4864
@MainActor
4965
func testCompassChangePosition() {
5066
assertView {
51-
MapView(styleURL: demoTilesURL)
52-
.mapControls {
53-
CompassView()
54-
.position(.topLeft)
55-
}
67+
MapView(
68+
styleURL: demoTilesURL,
69+
camera: .constant(.center(CLLocationCoordinate2D(), zoom: 4, direction: 45))
70+
)
71+
.mapControls {
72+
CompassView()
73+
.position(.topLeft)
74+
}
5675
}
5776
}
5877

5978
@MainActor
6079
func testAttributionOnly() {
6180
assertView {
62-
MapView(styleURL: demoTilesURL)
63-
.mapControls {
64-
AttributionButton()
65-
}
81+
MapView(
82+
styleURL: demoTilesURL,
83+
camera: .constant(.center(CLLocationCoordinate2D(), zoom: 4, direction: 45))
84+
)
85+
.mapControls {
86+
AttributionButton()
87+
}
6688
}
6789
}
6890

6991
@MainActor
7092
func testAttributionChangePosition() {
7193
assertView {
72-
MapView(styleURL: demoTilesURL)
73-
.mapControls {
74-
AttributionButton()
75-
.position(.topLeft)
76-
}
94+
MapView(
95+
styleURL: demoTilesURL,
96+
camera: .constant(.center(CLLocationCoordinate2D(), zoom: 4, direction: 45))
97+
)
98+
.mapControls {
99+
AttributionButton()
100+
.position(.topLeft)
101+
}
77102
}
78103
}
79104
}
153 KB
Loading
19.4 KB
Loading
19.4 KB
Loading
19.4 KB
Loading
19.4 KB
Loading
19.4 KB
Loading
8.18 KB
Loading

0 commit comments

Comments
 (0)