From 6653538918fb1ee687fc9f7fc1e5eac68f8a5a2d Mon Sep 17 00:00:00 2001 From: PW Date: Tue, 14 May 2024 13:11:53 +0200 Subject: [PATCH] fixing tests --- .../MapViewCoordinatorCameraTests.swift | 38 +++++++++++++++++-- .../testTrackingUserLocation.1.txt | 2 +- .../testTrackingUserLocationWithCourse.1.txt | 2 +- .../testTrackingUserLocationWithHeading.1.txt | 2 +- .../MapViewCameraTests/testCenterCamera.1.txt | 2 +- .../testTrackUserLocationWithCourse.1.txt | 2 +- .../testTrackUserLocationWithHeading.1.txt | 2 +- .../testTrackingUserLocation.1.txt | 2 +- 8 files changed, 41 insertions(+), 11 deletions(-) diff --git a/Tests/MapLibreSwiftUITests/MapViewCoordinator/MapViewCoordinatorCameraTests.swift b/Tests/MapLibreSwiftUITests/MapViewCoordinator/MapViewCoordinatorCameraTests.swift index fab70a6..4d4b21d 100644 --- a/Tests/MapLibreSwiftUITests/MapViewCoordinator/MapViewCoordinatorCameraTests.swift +++ b/Tests/MapLibreSwiftUITests/MapViewCoordinator/MapViewCoordinatorCameraTests.swift @@ -40,8 +40,14 @@ final class MapViewCoordinatorCameraTests: XCTestCase { animated: .value(false)) .called(count: 1) + // Due to the .frame == .zero workaround, min/max pitch setting is called twice, once to set the + // pitch, and then once to set the actual range. verify(maplibreMapView) .minimumPitch(newValue: .value(0)) + .setterCalled(count: 2) + + verify(maplibreMapView) + .maximumPitch(newValue: .value(0)) .setterCalled(count: 1) verify(maplibreMapView) @@ -70,10 +76,16 @@ final class MapViewCoordinatorCameraTests: XCTestCase { animated: .value(false)) .called(count: 1) + // Due to the .frame == .zero workaround, min/max pitch setting is called twice, once to set the + // pitch, and then once to set the actual range. verify(maplibreMapView) .minimumPitch(newValue: .value(0)) + .setterCalled(count: 2) + + verify(maplibreMapView) + .maximumPitch(newValue: .value(0)) .setterCalled(count: 1) - + verify(maplibreMapView) .maximumPitch(newValue: .value(60)) .setterCalled(count: 1) @@ -99,10 +111,16 @@ final class MapViewCoordinatorCameraTests: XCTestCase { animated: .any) .called(count: 0) + // Due to the .frame == .zero workaround, min/max pitch setting is called twice, once to set the + // pitch, and then once to set the actual range. verify(maplibreMapView) .minimumPitch(newValue: .value(0)) + .setterCalled(count: 2) + + verify(maplibreMapView) + .maximumPitch(newValue: .value(0)) .setterCalled(count: 1) - + verify(maplibreMapView) .maximumPitch(newValue: .value(60)) .setterCalled(count: 1) @@ -128,10 +146,16 @@ final class MapViewCoordinatorCameraTests: XCTestCase { animated: .any) .called(count: 0) + // Due to the .frame == .zero workaround, min/max pitch setting is called twice, once to set the + // pitch, and then once to set the actual range. verify(maplibreMapView) .minimumPitch(newValue: .value(0)) + .setterCalled(count: 2) + + verify(maplibreMapView) + .maximumPitch(newValue: .value(0)) .setterCalled(count: 1) - + verify(maplibreMapView) .maximumPitch(newValue: .value(60)) .setterCalled(count: 1) @@ -157,10 +181,16 @@ final class MapViewCoordinatorCameraTests: XCTestCase { animated: .any) .called(count: 0) + // Due to the .frame == .zero workaround, min/max pitch setting is called twice, once to set the + // pitch, and then once to set the actual range. verify(maplibreMapView) .minimumPitch(newValue: .value(0)) + .setterCalled(count: 2) + + verify(maplibreMapView) + .maximumPitch(newValue: .value(0)) .setterCalled(count: 1) - + verify(maplibreMapView) .maximumPitch(newValue: .value(60)) .setterCalled(count: 1) diff --git a/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/CameraStateTests/testTrackingUserLocation.1.txt b/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/CameraStateTests/testTrackingUserLocation.1.txt index a7ee04a..0955934 100644 --- a/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/CameraStateTests/testTrackingUserLocation.1.txt +++ b/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/CameraStateTests/testTrackingUserLocation.1.txt @@ -1 +1 @@ -CameraState.trackingUserLocation(zoom: (4.0, 0.0, MapLibreSwiftUI.CameraPitch.free, 12.0)) \ No newline at end of file +CameraState.trackingUserLocation(zoom: (4.0, 0.0, MapLibreSwiftUI.CameraPitchRange.free, 12.0)) \ No newline at end of file diff --git a/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/CameraStateTests/testTrackingUserLocationWithCourse.1.txt b/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/CameraStateTests/testTrackingUserLocationWithCourse.1.txt index a28a609..13eace7 100644 --- a/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/CameraStateTests/testTrackingUserLocationWithCourse.1.txt +++ b/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/CameraStateTests/testTrackingUserLocationWithCourse.1.txt @@ -1 +1 @@ -CameraState.trackingUserLocationWithCourse(zoom: (4.0, 0.0, MapLibreSwiftUI.CameraPitch.free)) \ No newline at end of file +CameraState.trackingUserLocationWithCourse(zoom: (4.0, 0.0, MapLibreSwiftUI.CameraPitchRange.free)) \ No newline at end of file diff --git a/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/CameraStateTests/testTrackingUserLocationWithHeading.1.txt b/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/CameraStateTests/testTrackingUserLocationWithHeading.1.txt index 6ff3f6d..a071639 100644 --- a/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/CameraStateTests/testTrackingUserLocationWithHeading.1.txt +++ b/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/CameraStateTests/testTrackingUserLocationWithHeading.1.txt @@ -1 +1 @@ -CameraState.trackingUserLocationWithHeading(zoom: (4.0, 0.0, MapLibreSwiftUI.CameraPitch.free)) \ No newline at end of file +CameraState.trackingUserLocationWithHeading(zoom: (4.0, 0.0, MapLibreSwiftUI.CameraPitchRange.free)) \ No newline at end of file diff --git a/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/MapViewCameraTests/testCenterCamera.1.txt b/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/MapViewCameraTests/testCenterCamera.1.txt index 671bb9e..318c577 100644 --- a/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/MapViewCameraTests/testCenterCamera.1.txt +++ b/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/MapViewCameraTests/testCenterCamera.1.txt @@ -7,5 +7,5 @@ - longitude: 23.4 - zoom: 5.0 - pitch: 12.0 - - pitchRange: CameraPitch.free + - pitchRange: CameraPitchRange.free - direction: 23.0 diff --git a/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/MapViewCameraTests/testTrackUserLocationWithCourse.1.txt b/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/MapViewCameraTests/testTrackUserLocationWithCourse.1.txt index 5b38944..f405f82 100644 --- a/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/MapViewCameraTests/testTrackUserLocationWithCourse.1.txt +++ b/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/MapViewCameraTests/testTrackUserLocationWithCourse.1.txt @@ -5,7 +5,7 @@ ▿ trackingUserLocationWithCourse: (3 elements) - zoom: 18.0 - pitch: 0.0 - ▿ pitchRange: CameraPitch + ▿ pitchRange: CameraPitchRange ▿ freeWithinRange: (2 elements) - minimum: 12.0 - maximum: 34.0 diff --git a/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/MapViewCameraTests/testTrackUserLocationWithHeading.1.txt b/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/MapViewCameraTests/testTrackUserLocationWithHeading.1.txt index f705417..cb5da4b 100644 --- a/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/MapViewCameraTests/testTrackUserLocationWithHeading.1.txt +++ b/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/MapViewCameraTests/testTrackUserLocationWithHeading.1.txt @@ -5,4 +5,4 @@ ▿ trackingUserLocationWithHeading: (3 elements) - zoom: 10.0 - pitch: 0.0 - - pitchRange: CameraPitch.free + - pitchRange: CameraPitchRange.free diff --git a/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/MapViewCameraTests/testTrackingUserLocation.1.txt b/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/MapViewCameraTests/testTrackingUserLocation.1.txt index cf0ca03..4252dc9 100644 --- a/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/MapViewCameraTests/testTrackingUserLocation.1.txt +++ b/Tests/MapLibreSwiftUITests/Models/MapCamera/__Snapshots__/MapViewCameraTests/testTrackingUserLocation.1.txt @@ -5,7 +5,7 @@ ▿ trackingUserLocation: (4 elements) - zoom: 10.0 - pitch: 0.0 - ▿ pitchRange: CameraPitch + ▿ pitchRange: CameraPitchRange ▿ freeWithinRange: (2 elements) - minimum: 12.0 - maximum: 34.0