Skip to content

Commit

Permalink
resolving merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
hactar committed Jul 24, 2024
2 parents 1e41063 + 258a8c9 commit ec1b2eb
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 41 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: rymndhng/release-on-push-action@master
- uses: rymndhng/release-on-push-action@v0.28.0
with:
bump_version_scheme: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && 'patch' || inputs.bump_version_scheme }}
bump_version_scheme: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' && 'patch' || inputs.bump_version_scheme }}
8 changes: 4 additions & 4 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/maplibre/maplibre-gl-native-distribution.git",
"state" : {
"revision" : "039ef525064a685c291db5118f6b5f6e8b090bb0",
"version" : "6.5.2"
"revision" : "a40e82162772e53180a2e0b1052e454db43a297d",
"version" : "6.5.1"
}
},
{
Expand All @@ -23,8 +23,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/Kolos65/Mockable.git",
"state" : {
"branch" : "main",
"revision" : "ccec0efd3e4a48b85b5407f788916de265c986dc"
"revision" : "81ccaead99a3c038c09345caa2888ae74b644ee9",
"version" : "0.0.9"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ let package = Package(
.package(url: "https://github.com/maplibre/maplibre-gl-native-distribution.git", from: "6.4.0"),
.package(url: "https://github.com/stadiamaps/maplibre-swift-macros.git", from: "0.0.3"),
// Testing
.package(url: "https://github.com/Kolos65/Mockable.git", branch: "main"),
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.15.3"),
.package(url: "https://github.com/Kolos65/Mockable.git", exact: "0.0.9"),
.package(url: "https://github.com/pointfreeco/swift-snapshot-testing", from: "1.17.2"),
],
targets: [
.target(
Expand Down
3 changes: 2 additions & 1 deletion Sources/MapLibreSwiftUI/StaticLocationManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import MapLibre
///
/// You can provide a new location by setting the ``lastLocation`` property.
///
/// This class does not ever perform any authorization checks. That is the responsibility of the caller.
/// While this class is required to implement authorization status per the underlying protocol,
/// it does not ever actually check whether you have access to Core Location services.
public final class StaticLocationManager: NSObject, @unchecked Sendable {
public var delegate: (any MLNLocationManagerDelegate)?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ final class MapViewCoordinatorCameraTests: XCTestCase {
@MainActor func testUnchangedCamera() {
let camera: MapViewCamera = .default()

given(maplibreMapView)
.setCenter(.any,
zoomLevel: .any,
direction: .any,
animated: .any)
.willReturn()

coordinator.updateCamera(mapView: maplibreMapView, camera: camera, animated: false)
// Run a second update. We're testing that the snapshotCamera correctly exits the function
// when nothing changed.
Expand All @@ -32,173 +39,192 @@ final class MapViewCoordinatorCameraTests: XCTestCase {
// This verifies the comment above.
verify(maplibreMapView)
.userTrackingMode(newValue: .value(.none))
.setterCalled(count: 1)
.setCalled(1)

verify(maplibreMapView)
.setCenter(.value(MapViewCamera.Defaults.coordinate),
zoomLevel: .value(10),
direction: .value(0),
animated: .value(false))
.called(count: 1)
.called(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)
.setCalled(2)

verify(maplibreMapView)
.maximumPitch(newValue: .value(0))
.setterCalled(count: 1)
.setCalled(1)

verify(maplibreMapView)
.maximumPitch(newValue: .value(60))
.setterCalled(count: 1)
.setCalled(1)

verify(maplibreMapView)
.setZoomLevel(.any, animated: .any)
.called(count: 0)
.called(0)
}

@MainActor func testCenterCameraUpdate() {
let coordinate = CLLocationCoordinate2D(latitude: 12.3, longitude: 23.4)
let newCamera: MapViewCamera = .center(coordinate, zoom: 13)

given(maplibreMapView)
.setCenter(.any,
zoomLevel: .any,
direction: .any,
animated: .any)
.willReturn()

coordinator.updateCamera(mapView: maplibreMapView, camera: newCamera, animated: false)

verify(maplibreMapView)
.userTrackingMode(newValue: .value(.none))
.setterCalled(count: 1)
.setCalled(1)

verify(maplibreMapView)
.setCenter(.value(coordinate),
zoomLevel: .value(13),
direction: .value(0),
animated: .value(false))
.called(count: 1)
.called(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)
.setCalled(2)

verify(maplibreMapView)
.maximumPitch(newValue: .value(0))
.setterCalled(count: 1)
.setCalled(1)

verify(maplibreMapView)
.maximumPitch(newValue: .value(60))
.setterCalled(count: 1)
.setCalled(1)

verify(maplibreMapView)
.setZoomLevel(.any, animated: .any)
.called(count: 0)
.called(0)
}

@MainActor func testUserTrackingCameraUpdate() {
let newCamera: MapViewCamera = .trackUserLocation()

given(maplibreMapView)
.setZoomLevel(.any, animated: .any)
.willReturn()

coordinator.updateCamera(mapView: maplibreMapView, camera: newCamera, animated: false)

verify(maplibreMapView)
.userTrackingMode(newValue: .value(.follow))
.setterCalled(count: 1)
.setCalled(1)

verify(maplibreMapView)
.setCenter(.any,
zoomLevel: .any,
direction: .any,
animated: .any)
.called(count: 0)
.called(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)
.setCalled(2)

verify(maplibreMapView)
.maximumPitch(newValue: .value(0))
.setterCalled(count: 1)
.setCalled(1)

verify(maplibreMapView)
.maximumPitch(newValue: .value(60))
.setterCalled(count: 1)
.setCalled(1)

verify(maplibreMapView)
.setZoomLevel(.value(10), animated: .value(false))
.called(count: 1)
.called(1)
}

@MainActor func testUserTrackingWithCourseCameraUpdate() {
let newCamera: MapViewCamera = .trackUserLocationWithCourse()

given(maplibreMapView)
.setZoomLevel(.any, animated: .any)
.willReturn()

coordinator.updateCamera(mapView: maplibreMapView, camera: newCamera, animated: false)

verify(maplibreMapView)
.userTrackingMode(newValue: .value(.followWithCourse))
.setterCalled(count: 1)
.setCalled(1)

verify(maplibreMapView)
.setCenter(.any,
zoomLevel: .any,
direction: .any,
animated: .any)
.called(count: 0)
.called(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)
.setCalled(2)

verify(maplibreMapView)
.maximumPitch(newValue: .value(0))
.setterCalled(count: 1)
.setCalled(1)

verify(maplibreMapView)
.maximumPitch(newValue: .value(60))
.setterCalled(count: 1)
.setCalled(1)

verify(maplibreMapView)
.setZoomLevel(.value(10), animated: .value(false))
.called(count: 1)
.called(1)
}

@MainActor func testUserTrackingWithHeadingUpdate() {
let newCamera: MapViewCamera = .trackUserLocationWithHeading()

given(maplibreMapView)
.setZoomLevel(.any, animated: .any)
.willReturn()

coordinator.updateCamera(mapView: maplibreMapView, camera: newCamera, animated: false)

verify(maplibreMapView)
.userTrackingMode(newValue: .value(.followWithHeading))
.setterCalled(count: 1)
.setCalled(1)

verify(maplibreMapView)
.setCenter(.any,
zoomLevel: .any,
direction: .any,
animated: .any)
.called(count: 0)
.called(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)
.setCalled(2)

verify(maplibreMapView)
.maximumPitch(newValue: .value(0))
.setterCalled(count: 1)
.setCalled(1)

verify(maplibreMapView)
.maximumPitch(newValue: .value(60))
.setterCalled(count: 1)
.setCalled(1)

verify(maplibreMapView)
.setZoomLevel(.value(10), animated: .value(false))
.called(count: 1)
.called(1)
}

// TODO: Test Rect & Showcase once we build it!
Expand Down
3 changes: 1 addition & 2 deletions Tests/MapLibreSwiftUITests/Support/XCTestAssertView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import SnapshotTesting
import SwiftUI
import XCTest

// TODO: This is a WIP that needs some additional eyes
extension XCTestCase {
func assertView(
named name: String? = nil,
Expand All @@ -18,7 +17,7 @@ extension XCTestCase {
let view = content()
.frame(width: frame.width, height: frame.height)

assertSnapshot(matching: view,
assertSnapshot(of: view,
as: .image(precision: 0.9, perceptualPrecision: 0.95),
named: name,
record: record,
Expand Down

0 comments on commit ec1b2eb

Please sign in to comment.