Add support for showing the native OS incoming call screen when starting new Element Calls

This commit is contained in:
Stefan Ceriu
2024-05-17 15:13:57 +03:00
committed by Stefan Ceriu
parent 5860317fea
commit 8bfd802793
19 changed files with 460 additions and 66 deletions
@@ -4230,6 +4230,88 @@ class CompletionSuggestionServiceMock: CompletionSuggestionServiceProtocol {
setSuggestionTriggerClosure?(suggestionTrigger)
}
}
class ElementCallServiceMock: ElementCallServiceProtocol {
var actions: AnyPublisher<ElementCallServiceAction, Never> {
get { return underlyingActions }
set(value) { underlyingActions = value }
}
var underlyingActions: AnyPublisher<ElementCallServiceAction, Never>!
//MARK: - setupCallSession
var setupCallSessionTitleUnderlyingCallsCount = 0
var setupCallSessionTitleCallsCount: Int {
get {
if Thread.isMainThread {
return setupCallSessionTitleUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = setupCallSessionTitleUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
setupCallSessionTitleUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
setupCallSessionTitleUnderlyingCallsCount = newValue
}
}
}
}
var setupCallSessionTitleCalled: Bool {
return setupCallSessionTitleCallsCount > 0
}
var setupCallSessionTitleReceivedTitle: String?
var setupCallSessionTitleReceivedInvocations: [String] = []
var setupCallSessionTitleClosure: ((String) async -> Void)?
func setupCallSession(title: String) async {
setupCallSessionTitleCallsCount += 1
setupCallSessionTitleReceivedTitle = title
setupCallSessionTitleReceivedInvocations.append(title)
await setupCallSessionTitleClosure?(title)
}
//MARK: - tearDownCallSession
var tearDownCallSessionUnderlyingCallsCount = 0
var tearDownCallSessionCallsCount: Int {
get {
if Thread.isMainThread {
return tearDownCallSessionUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = tearDownCallSessionUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
tearDownCallSessionUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
tearDownCallSessionUnderlyingCallsCount = newValue
}
}
}
}
var tearDownCallSessionCalled: Bool {
return tearDownCallSessionCallsCount > 0
}
var tearDownCallSessionClosure: (() -> Void)?
func tearDownCallSession() {
tearDownCallSessionCallsCount += 1
tearDownCallSessionClosure?()
}
}
class ElementCallWidgetDriverMock: ElementCallWidgetDriverProtocol {
var messagePublisher: PassthroughSubject<String, Never> {
get { return underlyingMessagePublisher }
@@ -9780,6 +9862,70 @@ class RoomProxyMock: RoomProxyProtocol {
return elementCallWidgetDriverReturnValue
}
}
//MARK: - sendCallNotificationIfNeeeded
var sendCallNotificationIfNeeededUnderlyingCallsCount = 0
var sendCallNotificationIfNeeededCallsCount: Int {
get {
if Thread.isMainThread {
return sendCallNotificationIfNeeededUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = sendCallNotificationIfNeeededUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
sendCallNotificationIfNeeededUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
sendCallNotificationIfNeeededUnderlyingCallsCount = newValue
}
}
}
}
var sendCallNotificationIfNeeededCalled: Bool {
return sendCallNotificationIfNeeededCallsCount > 0
}
var sendCallNotificationIfNeeededUnderlyingReturnValue: Result<Void, RoomProxyError>!
var sendCallNotificationIfNeeededReturnValue: Result<Void, RoomProxyError>! {
get {
if Thread.isMainThread {
return sendCallNotificationIfNeeededUnderlyingReturnValue
} else {
var returnValue: Result<Void, RoomProxyError>? = nil
DispatchQueue.main.sync {
returnValue = sendCallNotificationIfNeeededUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
sendCallNotificationIfNeeededUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
sendCallNotificationIfNeeededUnderlyingReturnValue = newValue
}
}
}
}
var sendCallNotificationIfNeeededClosure: (() async -> Result<Void, RoomProxyError>)?
func sendCallNotificationIfNeeeded() async -> Result<Void, RoomProxyError> {
sendCallNotificationIfNeeededCallsCount += 1
if let sendCallNotificationIfNeeededClosure = sendCallNotificationIfNeeededClosure {
return await sendCallNotificationIfNeeededClosure()
} else {
return sendCallNotificationIfNeeededReturnValue
}
}
//MARK: - matrixToPermalink
var matrixToPermalinkUnderlyingCallsCount = 0