implement APIs for LLS observation

This commit is contained in:
Mauro Romito
2026-04-14 12:45:10 +02:00
committed by Mauro
parent 78240ebdee
commit facba008e7
10 changed files with 237 additions and 0 deletions
@@ -10414,6 +10414,70 @@ class JoinedRoomProxyMock: JoinedRoomProxyProtocol, @unchecked Sendable {
return clearDraftThreadRootEventIDReturnValue
}
}
//MARK: - getLiveLocationSharesService
var getLiveLocationSharesServiceUnderlyingCallsCount = 0
var getLiveLocationSharesServiceCallsCount: Int {
get {
if Thread.isMainThread {
return getLiveLocationSharesServiceUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = getLiveLocationSharesServiceUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
getLiveLocationSharesServiceUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
getLiveLocationSharesServiceUnderlyingCallsCount = newValue
}
}
}
}
var getLiveLocationSharesServiceCalled: Bool {
return getLiveLocationSharesServiceCallsCount > 0
}
var getLiveLocationSharesServiceUnderlyingReturnValue: LiveLocationSharesServiceProtocol!
var getLiveLocationSharesServiceReturnValue: LiveLocationSharesServiceProtocol! {
get {
if Thread.isMainThread {
return getLiveLocationSharesServiceUnderlyingReturnValue
} else {
var returnValue: LiveLocationSharesServiceProtocol? = nil
DispatchQueue.main.sync {
returnValue = getLiveLocationSharesServiceUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
getLiveLocationSharesServiceUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
getLiveLocationSharesServiceUnderlyingReturnValue = newValue
}
}
}
}
var getLiveLocationSharesServiceClosure: (() async -> LiveLocationSharesServiceProtocol)?
func getLiveLocationSharesService() async -> LiveLocationSharesServiceProtocol {
getLiveLocationSharesServiceCallsCount += 1
if let getLiveLocationSharesServiceClosure = getLiveLocationSharesServiceClosure {
return await getLiveLocationSharesServiceClosure()
} else {
return getLiveLocationSharesServiceReturnValue
}
}
//MARK: - startLiveLocationShare
var startLiveLocationShareDurationUnderlyingCallsCount = 0
@@ -11904,6 +11968,14 @@ class LiveLocationManagerMock: LiveLocationManagerProtocol, @unchecked Sendable
await stopLiveLocationRoomIDClosure?(roomID)
}
}
class LiveLocationSharesServiceMock: LiveLocationSharesServiceProtocol, @unchecked Sendable {
var liveLocationSharesPublisher: AnyPublisher<[LiveLocationShareProxy], Never> {
get { return underlyingLiveLocationSharesPublisher }
set(value) { underlyingLiveLocationSharesPublisher = value }
}
var underlyingLiveLocationSharesPublisher: AnyPublisher<[LiveLocationShareProxy], Never>!
}
class MediaLoaderMock: MediaLoaderProtocol, @unchecked Sendable {
//MARK: - loadMediaContentForSource
@@ -68,6 +68,8 @@ extension JoinedRoomProxyMock {
typingMembersPublisher = CurrentValueSubject([]).asCurrentValuePublisher()
identityStatusChangesPublisher = CurrentValueSubject([]).asCurrentValuePublisher()
getLiveLocationSharesServiceReturnValue = LiveLocationSharesServiceMock(.init())
updateMembersClosure = { }
setNameClosure = { _ in .success(()) }
setTopicClosure = { _ in .success(()) }
@@ -0,0 +1,20 @@
//
// Copyright 2026 Element Creations Ltd.
//
// SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial.
// Please see LICENSE files in the repository root for full details.
//
import Combine
import Foundation
struct LiveLocationSharesServiceMockConfiguration {
var shares: [LiveLocationShareProxy] = []
}
extension LiveLocationSharesServiceMock {
convenience init(_ configuration: LiveLocationSharesServiceMockConfiguration = .init()) {
self.init()
liveLocationSharesPublisher = CurrentValueSubject(configuration.shares).eraseToAnyPublisher()
}
}