|
| 1 | +import CoreLocation |
1 | 2 | import MapLibreSwiftDSL
|
2 | 3 | import SnapshotTesting
|
3 | 4 | import XCTest
|
4 | 5 | @testable import MapLibreSwiftUI
|
5 | 6 |
|
6 | 7 | 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 | + |
7 | 11 | @MainActor
|
8 | 12 | func testEmptyControls() {
|
9 | 13 | 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 | + } |
14 | 21 | }
|
15 | 22 | }
|
16 | 23 |
|
17 | 24 | @MainActor
|
18 | 25 | func testLogoOnly() {
|
19 | 26 | 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 | + } |
24 | 34 | }
|
25 | 35 | }
|
26 | 36 |
|
27 | 37 | @MainActor
|
28 | 38 | func testLogoChangePosition() {
|
29 | 39 | 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 | + } |
35 | 48 | }
|
36 | 49 | }
|
37 | 50 |
|
38 | 51 | @MainActor
|
39 | 52 | func testCompassOnly() {
|
40 | 53 | 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 | + } |
45 | 61 | }
|
46 | 62 | }
|
47 | 63 |
|
48 | 64 | @MainActor
|
49 | 65 | func testCompassChangePosition() {
|
50 | 66 | 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 | + } |
56 | 75 | }
|
57 | 76 | }
|
58 | 77 |
|
59 | 78 | @MainActor
|
60 | 79 | func testAttributionOnly() {
|
61 | 80 | 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 | + } |
66 | 88 | }
|
67 | 89 | }
|
68 | 90 |
|
69 | 91 | @MainActor
|
70 | 92 | func testAttributionChangePosition() {
|
71 | 93 | 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 | + } |
77 | 102 | }
|
78 | 103 | }
|
79 | 104 | }
|
0 commit comments