Skip to content

Commit

Permalink
Fix platform support (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
0xLeif authored Dec 21, 2023
1 parent 4e93f97 commit 9428dc0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
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

0 comments on commit 9428dc0

Please sign in to comment.