handle reduced accuracy authorization case

This commit is contained in:
Mauro Romito
2026-04-20 23:23:04 +02:00
committed by Mauro
parent 1ac9c96171
commit 2250087cfe
5 changed files with 147 additions and 13 deletions
@@ -10,11 +10,13 @@ import CoreLocation
extension CLLocationManagerMock {
struct Configuration {
var authorizationStatus: CLAuthorizationStatus = .authorizedAlways
var accuracyAuthorization: CLAccuracyAuthorization = .fullAccuracy
}
convenience init(_ configuration: Configuration) {
self.init()
underlyingAuthorizationStatus = configuration.authorizationStatus
underlyingAccuracyAuthorization = configuration.accuracyAuthorization
}
}
@@ -2214,6 +2214,11 @@ class CLLocationManagerMock: CLLocationManagerProtocol, @unchecked Sendable {
set(value) { underlyingAuthorizationStatus = value }
}
var underlyingAuthorizationStatus: CLAuthorizationStatus!
var accuracyAuthorization: CLAccuracyAuthorization {
get { return underlyingAccuracyAuthorization }
set(value) { underlyingAccuracyAuthorization = value }
}
var underlyingAccuracyAuthorization: CLAccuracyAuthorization!
//MARK: - requestAlwaysAuthorization
@@ -2320,6 +2325,76 @@ class CLLocationManagerMock: CLLocationManagerProtocol, @unchecked Sendable {
stopUpdatingLocationCallsCount += 1
stopUpdatingLocationClosure?()
}
//MARK: - startMonitoringSignificantLocationChanges
var startMonitoringSignificantLocationChangesUnderlyingCallsCount = 0
var startMonitoringSignificantLocationChangesCallsCount: Int {
get {
if Thread.isMainThread {
return startMonitoringSignificantLocationChangesUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = startMonitoringSignificantLocationChangesUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
startMonitoringSignificantLocationChangesUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
startMonitoringSignificantLocationChangesUnderlyingCallsCount = newValue
}
}
}
}
var startMonitoringSignificantLocationChangesCalled: Bool {
return startMonitoringSignificantLocationChangesCallsCount > 0
}
var startMonitoringSignificantLocationChangesClosure: (() -> Void)?
func startMonitoringSignificantLocationChanges() {
startMonitoringSignificantLocationChangesCallsCount += 1
startMonitoringSignificantLocationChangesClosure?()
}
//MARK: - stopMonitoringSignificantLocationChanges
var stopMonitoringSignificantLocationChangesUnderlyingCallsCount = 0
var stopMonitoringSignificantLocationChangesCallsCount: Int {
get {
if Thread.isMainThread {
return stopMonitoringSignificantLocationChangesUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = stopMonitoringSignificantLocationChangesUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
stopMonitoringSignificantLocationChangesUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
stopMonitoringSignificantLocationChangesUnderlyingCallsCount = newValue
}
}
}
}
var stopMonitoringSignificantLocationChangesCalled: Bool {
return stopMonitoringSignificantLocationChangesCallsCount > 0
}
var stopMonitoringSignificantLocationChangesClosure: (() -> Void)?
func stopMonitoringSignificantLocationChanges() {
stopMonitoringSignificantLocationChangesCallsCount += 1
stopMonitoringSignificantLocationChangesClosure?()
}
}
class CXProviderMock: CXProviderProtocol, @unchecked Sendable {