handle reduced accuracy authorization case

This commit is contained in:
Mauro Romito
2026-04-20 23:23:04 +02:00
committed by Mauro
parent 9983e23a4c
commit dd7048d5c2
5 changed files with 147 additions and 13 deletions

View File

@@ -42,6 +42,8 @@ final class LiveLocationManagerTests {
#expect(roomProxy.startLiveLocationShareDurationCalled)
#expect(!roomProxy.stopLiveLocationShareCalled)
#expect(appSettings.liveLocationSharingTimeoutDatesByRoomID["!room:matrix.org"] != nil)
#expect(locationManagerMock.startUpdatingLocationCalled)
#expect(!locationManagerMock.startMonitoringSignificantLocationChangesCalled)
}
@Test
@@ -131,6 +133,10 @@ final class LiveLocationManagerTests {
#expect(roomProxy.stopLiveLocationShareCalled)
#expect(appSettings.liveLocationSharingTimeoutDatesByRoomID["!room:matrix.org"] == nil)
// Setting the timeout date above starts tracking; removing it stops tracking.
#expect(locationManagerMock.startUpdatingLocationCalled)
#expect(locationManagerMock.stopUpdatingLocationCalled)
#expect(!locationManagerMock.stopMonitoringSignificantLocationChangesCalled)
}
@Test
@@ -156,6 +162,26 @@ final class LiveLocationManagerTests {
#expect(appSettings.liveLocationSharingTimeoutDatesByRoomID["!room2:matrix.org"] != nil)
}
// MARK: - Reduced accuracy
@Test
func startLiveLocationInReducedAccuracyMode() async throws {
locationManagerMock.underlyingAccuracyAuthorization = .reducedAccuracy
let roomProxy = makeRoomProxy(roomID: "!room:matrix.org")
clientProxy.roomForIdentifierClosure = { _ in .joined(roomProxy) }
let result = await manager.startLiveLocation(roomID: "!room:matrix.org", duration: .seconds(300))
try result.get()
#expect(locationManagerMock.startMonitoringSignificantLocationChangesCalled)
#expect(!locationManagerMock.startUpdatingLocationCalled)
await manager.stopLiveLocation(roomID: "!room:matrix.org")
#expect(locationManagerMock.stopMonitoringSignificantLocationChangesCalled)
#expect(!locationManagerMock.stopUpdatingLocationCalled)
}
// MARK: - Private
private func makeRoomProxy(roomID: String) -> JoinedRoomProxyMock {