Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix platform support #11

Merged
merged 1 commit into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,25 @@ open class LocationApplication: LifecyleApplication, CLLocationManagerDelegate {

// MARK: - Open CLLocationManagerDelegate Functions

#if os(iOS) || os(macOS)
open func locationManager(_ manager: CLLocationManager, didVisit visit: CLVisit) { }
open func locationManager(_ manager: CLLocationManager, didExitRegion region: CLRegion) { }
open func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) { }
open func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading) { }
open func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { }
open func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { }
open func locationManager(_ manager: CLLocationManager, didRange beacons: [CLBeacon], satisfying beaconConstraint: CLBeaconIdentityConstraint) { }
open func locationManager(_ manager: CLLocationManager, didStartMonitoringFor region: CLRegion) { }
open func locationManager(_ manager: CLLocationManager, didDetermineState state: CLRegionState, for region: CLRegion) { }
open func locationManager(_ manager: CLLocationManager, didFailRangingFor beaconConstraint: CLBeaconIdentityConstraint, error: Error) { }
open func locationManager(_ manager: CLLocationManager, didFinishDeferredUpdatesWithError error: Error?) { }
open func locationManager(_ manager: CLLocationManager, monitoringDidFailFor region: CLRegion?, withError error: Error) { }
open func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { }
open func locationManagerDidPauseLocationUpdates(_ manager: CLLocationManager) { }
open func locationManagerDidResumeLocationUpdates(_ manager: CLLocationManager) { }
#endif

#if !os(tvOS)
open func locationManagerShouldDisplayHeadingCalibration(_ manager: CLLocationManager) -> Bool { false }
#endif

open func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { }
open func locationManager(_ manager: CLLocationManager, didFailWithError error: Error) { }
open func locationManagerDidChangeAuthorization(_ manager: CLLocationManager) { }
}
10 changes: 2 additions & 8 deletions Tests/ApplicationKitTests/LocationApplicationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,11 @@ import CoreLocation
@testable import ApplicationKit

class MockLocationManager: LocationManager {
func test() {
delegate?.locationManager?(.init(), didEnterRegion: .init())
}

}

class MyLocationApplication: LocationApplication {
override func locationManager(_ manager: CLLocationManager, didEnterRegion region: CLRegion) {
print("didEnterRegion: \(region)")
}

}

final class LocationApplicationTests: XCTestCase {
Expand All @@ -32,8 +28,6 @@ final class LocationApplicationTests: XCTestCase {
XCTAssertNotNil(locationManager.delegate)
XCTAssertTrue(locationManager.delegate is MyLocationApplication)

mockLocationManager?.test()

locationManagerOverride.cancel()

XCTAssertNotNil(locationManager.delegate)
Expand Down