diff --git a/Tests/MapLibreSwiftUITests/Examples/CameraPreviewTests.swift b/Tests/MapLibreSwiftUITests/Examples/CameraPreviewTests.swift index 505dbfb..5fff98a 100644 --- a/Tests/MapLibreSwiftUITests/Examples/CameraPreviewTests.swift +++ b/Tests/MapLibreSwiftUITests/Examples/CameraPreviewTests.swift @@ -4,7 +4,7 @@ import XCTest final class CameraPreviewTests: XCTestCase { func testCameraPreview() { - assertView(named: "CameraPreview") { + assertView { CameraDirectManipulationPreview( styleURL: URL(string: "https://demotiles.maplibre.org/style.json")! ) diff --git a/Tests/MapLibreSwiftUITests/Examples/MapControlsTests.swift b/Tests/MapLibreSwiftUITests/Examples/MapControlsTests.swift index 529dfec..a41dc5e 100644 --- a/Tests/MapLibreSwiftUITests/Examples/MapControlsTests.swift +++ b/Tests/MapLibreSwiftUITests/Examples/MapControlsTests.swift @@ -1,79 +1,104 @@ +import CoreLocation import MapLibreSwiftDSL import SnapshotTesting import XCTest @testable import MapLibreSwiftUI final class MapControlsTests: XCTestCase { + // NOTE: The map views in this test intentionally have a non-north orientation + // so that the compass will be rendered if present. + @MainActor func testEmptyControls() { assertView { - MapView(styleURL: demoTilesURL) - .mapControls { - // No controls - } + MapView( + styleURL: demoTilesURL, + camera: .constant(.center(CLLocationCoordinate2D(), zoom: 4, direction: 45)) + ) + .mapControls { + // No controls + } } } @MainActor func testLogoOnly() { assertView { - MapView(styleURL: demoTilesURL) - .mapControls { - LogoView() - } + MapView( + styleURL: demoTilesURL, + camera: .constant(.center(CLLocationCoordinate2D(), zoom: 4, direction: 45)) + ) + .mapControls { + LogoView() + } } } @MainActor func testLogoChangePosition() { assertView { - MapView(styleURL: demoTilesURL) - .mapControls { - LogoView() - .position(.topLeft) - } + MapView( + styleURL: demoTilesURL, + camera: .constant(.center(CLLocationCoordinate2D(), zoom: 4, direction: 45)) + ) + .mapControls { + LogoView() + .position(.topLeft) + } } } @MainActor func testCompassOnly() { assertView { - MapView(styleURL: demoTilesURL) - .mapControls { - CompassView() - } + MapView( + styleURL: demoTilesURL, + camera: .constant(.center(CLLocationCoordinate2D(), zoom: 4, direction: 45)) + ) + .mapControls { + CompassView() + } } } @MainActor func testCompassChangePosition() { assertView { - MapView(styleURL: demoTilesURL) - .mapControls { - CompassView() - .position(.topLeft) - } + MapView( + styleURL: demoTilesURL, + camera: .constant(.center(CLLocationCoordinate2D(), zoom: 4, direction: 45)) + ) + .mapControls { + CompassView() + .position(.topLeft) + } } } @MainActor func testAttributionOnly() { assertView { - MapView(styleURL: demoTilesURL) - .mapControls { - AttributionButton() - } + MapView( + styleURL: demoTilesURL, + camera: .constant(.center(CLLocationCoordinate2D(), zoom: 4, direction: 45)) + ) + .mapControls { + AttributionButton() + } } } @MainActor func testAttributionChangePosition() { assertView { - MapView(styleURL: demoTilesURL) - .mapControls { - AttributionButton() - .position(.topLeft) - } + MapView( + styleURL: demoTilesURL, + camera: .constant(.center(CLLocationCoordinate2D(), zoom: 4, direction: 45)) + ) + .mapControls { + AttributionButton() + .position(.topLeft) + } } } } diff --git a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/CameraPreviewTests/testCameraPreview.1.png b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/CameraPreviewTests/testCameraPreview.1.png new file mode 100644 index 0000000..73075c3 Binary files /dev/null and b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/CameraPreviewTests/testCameraPreview.1.png differ diff --git a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/CameraPreviewTests/testCameraPreview.CameraPreview.png b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/CameraPreviewTests/testCameraPreview.CameraPreview.png deleted file mode 100644 index 76aa78a..0000000 Binary files a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/CameraPreviewTests/testCameraPreview.CameraPreview.png and /dev/null differ diff --git a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testCirclesWithSymbols.1.png b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testCirclesWithSymbols.1.png index 22296ce..112c2e7 100644 Binary files a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testCirclesWithSymbols.1.png and b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testCirclesWithSymbols.1.png differ diff --git a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testRoseTint.1.png b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testRoseTint.1.png index 22296ce..112c2e7 100644 Binary files a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testRoseTint.1.png and b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testRoseTint.1.png differ diff --git a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testRotatedSymbolConst.1.png b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testRotatedSymbolConst.1.png index 22296ce..112c2e7 100644 Binary files a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testRotatedSymbolConst.1.png and b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testRotatedSymbolConst.1.png differ diff --git a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testRotatedSymboleDynamic.1.png b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testRotatedSymboleDynamic.1.png index 22296ce..112c2e7 100644 Binary files a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testRotatedSymboleDynamic.1.png and b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testRotatedSymboleDynamic.1.png differ diff --git a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testSimpleSymbol.1.png b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testSimpleSymbol.1.png index 22296ce..112c2e7 100644 Binary files a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testSimpleSymbol.1.png and b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/LayerPreviewTests/testSimpleSymbol.1.png differ diff --git a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testAttributionChangePosition.1.png b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testAttributionChangePosition.1.png index b2fd6e2..36d9e58 100644 Binary files a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testAttributionChangePosition.1.png and b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testAttributionChangePosition.1.png differ diff --git a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testAttributionOnly.1.png b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testAttributionOnly.1.png index 22296ce..6cfe334 100644 Binary files a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testAttributionOnly.1.png and b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testAttributionOnly.1.png differ diff --git a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testCompassChangePosition.1.png b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testCompassChangePosition.1.png index 22296ce..93f90c8 100644 Binary files a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testCompassChangePosition.1.png and b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testCompassChangePosition.1.png differ diff --git a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testCompassOnly.1.png b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testCompassOnly.1.png index 22296ce..0c7668d 100644 Binary files a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testCompassOnly.1.png and b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testCompassOnly.1.png differ diff --git a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testEmptyControls.1.png b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testEmptyControls.1.png index 80c0081..d400176 100644 Binary files a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testEmptyControls.1.png and b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testEmptyControls.1.png differ diff --git a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testLogoChangePosition.1.png b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testLogoChangePosition.1.png index 7bbb8f1..c0980d8 100644 Binary files a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testLogoChangePosition.1.png and b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testLogoChangePosition.1.png differ diff --git a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testLogoOnly.1.png b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testLogoOnly.1.png index 321b769..021585c 100644 Binary files a/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testLogoOnly.1.png and b/Tests/MapLibreSwiftUITests/Examples/__Snapshots__/MapControlsTests/testLogoOnly.1.png differ diff --git a/Tests/MapLibreSwiftUITests/Support/XCTestAssertView.swift b/Tests/MapLibreSwiftUITests/Support/XCTestAssertView.swift index 1f48166..5fcf06f 100644 --- a/Tests/MapLibreSwiftUITests/Support/XCTestAssertView.swift +++ b/Tests/MapLibreSwiftUITests/Support/XCTestAssertView.swift @@ -7,6 +7,7 @@ extension XCTestCase { func assertView( named name: String? = nil, record: Bool = false, + colorScheme: ColorScheme = .light, frame: CGSize = CGSize(width: 430, height: 932), expectation _: XCTestExpectation? = nil, @ViewBuilder content: () -> some View, @@ -15,7 +16,9 @@ extension XCTestCase { line: UInt = #line ) { let view = content() + .environment(\.colorScheme, colorScheme) .frame(width: frame.width, height: frame.height) + .background(Color(red: 130 / 255, green: 203 / 255, blue: 114 / 255)) assertSnapshot(of: view, as: .image(precision: 0.9, perceptualPrecision: 0.95),