Update the SDK and use media filename and caption internally. (#3375)

Doesn't render captions (other than in fallback places).
This commit is contained in:
Doug
2024-10-08 11:00:58 +01:00
committed by GitHub
parent 794d0eead1
commit 6e51969d27
42 changed files with 581 additions and 358 deletions
@@ -4710,16 +4710,16 @@ class ClientProxyMock: ClientProxyProtocol {
}
//MARK: - loadMediaFileForSource
var loadMediaFileForSourceBodyThrowableError: Error?
var loadMediaFileForSourceBodyUnderlyingCallsCount = 0
var loadMediaFileForSourceBodyCallsCount: Int {
var loadMediaFileForSourceFilenameThrowableError: Error?
var loadMediaFileForSourceFilenameUnderlyingCallsCount = 0
var loadMediaFileForSourceFilenameCallsCount: Int {
get {
if Thread.isMainThread {
return loadMediaFileForSourceBodyUnderlyingCallsCount
return loadMediaFileForSourceFilenameUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = loadMediaFileForSourceBodyUnderlyingCallsCount
returnValue = loadMediaFileForSourceFilenameUnderlyingCallsCount
}
return returnValue!
@@ -4727,29 +4727,29 @@ class ClientProxyMock: ClientProxyProtocol {
}
set {
if Thread.isMainThread {
loadMediaFileForSourceBodyUnderlyingCallsCount = newValue
loadMediaFileForSourceFilenameUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
loadMediaFileForSourceBodyUnderlyingCallsCount = newValue
loadMediaFileForSourceFilenameUnderlyingCallsCount = newValue
}
}
}
}
var loadMediaFileForSourceBodyCalled: Bool {
return loadMediaFileForSourceBodyCallsCount > 0
var loadMediaFileForSourceFilenameCalled: Bool {
return loadMediaFileForSourceFilenameCallsCount > 0
}
var loadMediaFileForSourceBodyReceivedArguments: (source: MediaSourceProxy, body: String?)?
var loadMediaFileForSourceBodyReceivedInvocations: [(source: MediaSourceProxy, body: String?)] = []
var loadMediaFileForSourceFilenameReceivedArguments: (source: MediaSourceProxy, filename: String?)?
var loadMediaFileForSourceFilenameReceivedInvocations: [(source: MediaSourceProxy, filename: String?)] = []
var loadMediaFileForSourceBodyUnderlyingReturnValue: MediaFileHandleProxy!
var loadMediaFileForSourceBodyReturnValue: MediaFileHandleProxy! {
var loadMediaFileForSourceFilenameUnderlyingReturnValue: MediaFileHandleProxy!
var loadMediaFileForSourceFilenameReturnValue: MediaFileHandleProxy! {
get {
if Thread.isMainThread {
return loadMediaFileForSourceBodyUnderlyingReturnValue
return loadMediaFileForSourceFilenameUnderlyingReturnValue
} else {
var returnValue: MediaFileHandleProxy? = nil
DispatchQueue.main.sync {
returnValue = loadMediaFileForSourceBodyUnderlyingReturnValue
returnValue = loadMediaFileForSourceFilenameUnderlyingReturnValue
}
return returnValue!
@@ -4757,29 +4757,29 @@ class ClientProxyMock: ClientProxyProtocol {
}
set {
if Thread.isMainThread {
loadMediaFileForSourceBodyUnderlyingReturnValue = newValue
loadMediaFileForSourceFilenameUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
loadMediaFileForSourceBodyUnderlyingReturnValue = newValue
loadMediaFileForSourceFilenameUnderlyingReturnValue = newValue
}
}
}
}
var loadMediaFileForSourceBodyClosure: ((MediaSourceProxy, String?) async throws -> MediaFileHandleProxy)?
var loadMediaFileForSourceFilenameClosure: ((MediaSourceProxy, String?) async throws -> MediaFileHandleProxy)?
func loadMediaFileForSource(_ source: MediaSourceProxy, body: String?) async throws -> MediaFileHandleProxy {
if let error = loadMediaFileForSourceBodyThrowableError {
func loadMediaFileForSource(_ source: MediaSourceProxy, filename: String?) async throws -> MediaFileHandleProxy {
if let error = loadMediaFileForSourceFilenameThrowableError {
throw error
}
loadMediaFileForSourceBodyCallsCount += 1
loadMediaFileForSourceBodyReceivedArguments = (source: source, body: body)
loadMediaFileForSourceFilenameCallsCount += 1
loadMediaFileForSourceFilenameReceivedArguments = (source: source, filename: filename)
DispatchQueue.main.async {
self.loadMediaFileForSourceBodyReceivedInvocations.append((source: source, body: body))
self.loadMediaFileForSourceFilenameReceivedInvocations.append((source: source, filename: filename))
}
if let loadMediaFileForSourceBodyClosure = loadMediaFileForSourceBodyClosure {
return try await loadMediaFileForSourceBodyClosure(source, body)
if let loadMediaFileForSourceFilenameClosure = loadMediaFileForSourceFilenameClosure {
return try await loadMediaFileForSourceFilenameClosure(source, filename)
} else {
return loadMediaFileForSourceBodyReturnValue
return loadMediaFileForSourceFilenameReturnValue
}
}
}
@@ -9693,16 +9693,16 @@ class MediaLoaderMock: MediaLoaderProtocol {
}
//MARK: - loadMediaFileForSource
var loadMediaFileForSourceBodyThrowableError: Error?
var loadMediaFileForSourceBodyUnderlyingCallsCount = 0
var loadMediaFileForSourceBodyCallsCount: Int {
var loadMediaFileForSourceFilenameThrowableError: Error?
var loadMediaFileForSourceFilenameUnderlyingCallsCount = 0
var loadMediaFileForSourceFilenameCallsCount: Int {
get {
if Thread.isMainThread {
return loadMediaFileForSourceBodyUnderlyingCallsCount
return loadMediaFileForSourceFilenameUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = loadMediaFileForSourceBodyUnderlyingCallsCount
returnValue = loadMediaFileForSourceFilenameUnderlyingCallsCount
}
return returnValue!
@@ -9710,29 +9710,29 @@ class MediaLoaderMock: MediaLoaderProtocol {
}
set {
if Thread.isMainThread {
loadMediaFileForSourceBodyUnderlyingCallsCount = newValue
loadMediaFileForSourceFilenameUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
loadMediaFileForSourceBodyUnderlyingCallsCount = newValue
loadMediaFileForSourceFilenameUnderlyingCallsCount = newValue
}
}
}
}
var loadMediaFileForSourceBodyCalled: Bool {
return loadMediaFileForSourceBodyCallsCount > 0
var loadMediaFileForSourceFilenameCalled: Bool {
return loadMediaFileForSourceFilenameCallsCount > 0
}
var loadMediaFileForSourceBodyReceivedArguments: (source: MediaSourceProxy, body: String?)?
var loadMediaFileForSourceBodyReceivedInvocations: [(source: MediaSourceProxy, body: String?)] = []
var loadMediaFileForSourceFilenameReceivedArguments: (source: MediaSourceProxy, filename: String?)?
var loadMediaFileForSourceFilenameReceivedInvocations: [(source: MediaSourceProxy, filename: String?)] = []
var loadMediaFileForSourceBodyUnderlyingReturnValue: MediaFileHandleProxy!
var loadMediaFileForSourceBodyReturnValue: MediaFileHandleProxy! {
var loadMediaFileForSourceFilenameUnderlyingReturnValue: MediaFileHandleProxy!
var loadMediaFileForSourceFilenameReturnValue: MediaFileHandleProxy! {
get {
if Thread.isMainThread {
return loadMediaFileForSourceBodyUnderlyingReturnValue
return loadMediaFileForSourceFilenameUnderlyingReturnValue
} else {
var returnValue: MediaFileHandleProxy? = nil
DispatchQueue.main.sync {
returnValue = loadMediaFileForSourceBodyUnderlyingReturnValue
returnValue = loadMediaFileForSourceFilenameUnderlyingReturnValue
}
return returnValue!
@@ -9740,29 +9740,29 @@ class MediaLoaderMock: MediaLoaderProtocol {
}
set {
if Thread.isMainThread {
loadMediaFileForSourceBodyUnderlyingReturnValue = newValue
loadMediaFileForSourceFilenameUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
loadMediaFileForSourceBodyUnderlyingReturnValue = newValue
loadMediaFileForSourceFilenameUnderlyingReturnValue = newValue
}
}
}
}
var loadMediaFileForSourceBodyClosure: ((MediaSourceProxy, String?) async throws -> MediaFileHandleProxy)?
var loadMediaFileForSourceFilenameClosure: ((MediaSourceProxy, String?) async throws -> MediaFileHandleProxy)?
func loadMediaFileForSource(_ source: MediaSourceProxy, body: String?) async throws -> MediaFileHandleProxy {
if let error = loadMediaFileForSourceBodyThrowableError {
func loadMediaFileForSource(_ source: MediaSourceProxy, filename: String?) async throws -> MediaFileHandleProxy {
if let error = loadMediaFileForSourceFilenameThrowableError {
throw error
}
loadMediaFileForSourceBodyCallsCount += 1
loadMediaFileForSourceBodyReceivedArguments = (source: source, body: body)
loadMediaFileForSourceFilenameCallsCount += 1
loadMediaFileForSourceFilenameReceivedArguments = (source: source, filename: filename)
DispatchQueue.main.async {
self.loadMediaFileForSourceBodyReceivedInvocations.append((source: source, body: body))
self.loadMediaFileForSourceFilenameReceivedInvocations.append((source: source, filename: filename))
}
if let loadMediaFileForSourceBodyClosure = loadMediaFileForSourceBodyClosure {
return try await loadMediaFileForSourceBodyClosure(source, body)
if let loadMediaFileForSourceFilenameClosure = loadMediaFileForSourceFilenameClosure {
return try await loadMediaFileForSourceFilenameClosure(source, filename)
} else {
return loadMediaFileForSourceBodyReturnValue
return loadMediaFileForSourceFilenameReturnValue
}
}
}
@@ -10628,15 +10628,15 @@ class MediaProviderMock: MediaProviderProtocol {
}
//MARK: - loadFileFromSource
var loadFileFromSourceBodyUnderlyingCallsCount = 0
var loadFileFromSourceBodyCallsCount: Int {
var loadFileFromSourceFilenameUnderlyingCallsCount = 0
var loadFileFromSourceFilenameCallsCount: Int {
get {
if Thread.isMainThread {
return loadFileFromSourceBodyUnderlyingCallsCount
return loadFileFromSourceFilenameUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = loadFileFromSourceBodyUnderlyingCallsCount
returnValue = loadFileFromSourceFilenameUnderlyingCallsCount
}
return returnValue!
@@ -10644,29 +10644,29 @@ class MediaProviderMock: MediaProviderProtocol {
}
set {
if Thread.isMainThread {
loadFileFromSourceBodyUnderlyingCallsCount = newValue
loadFileFromSourceFilenameUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
loadFileFromSourceBodyUnderlyingCallsCount = newValue
loadFileFromSourceFilenameUnderlyingCallsCount = newValue
}
}
}
}
var loadFileFromSourceBodyCalled: Bool {
return loadFileFromSourceBodyCallsCount > 0
var loadFileFromSourceFilenameCalled: Bool {
return loadFileFromSourceFilenameCallsCount > 0
}
var loadFileFromSourceBodyReceivedArguments: (source: MediaSourceProxy, body: String?)?
var loadFileFromSourceBodyReceivedInvocations: [(source: MediaSourceProxy, body: String?)] = []
var loadFileFromSourceFilenameReceivedArguments: (source: MediaSourceProxy, filename: String?)?
var loadFileFromSourceFilenameReceivedInvocations: [(source: MediaSourceProxy, filename: String?)] = []
var loadFileFromSourceBodyUnderlyingReturnValue: Result<MediaFileHandleProxy, MediaProviderError>!
var loadFileFromSourceBodyReturnValue: Result<MediaFileHandleProxy, MediaProviderError>! {
var loadFileFromSourceFilenameUnderlyingReturnValue: Result<MediaFileHandleProxy, MediaProviderError>!
var loadFileFromSourceFilenameReturnValue: Result<MediaFileHandleProxy, MediaProviderError>! {
get {
if Thread.isMainThread {
return loadFileFromSourceBodyUnderlyingReturnValue
return loadFileFromSourceFilenameUnderlyingReturnValue
} else {
var returnValue: Result<MediaFileHandleProxy, MediaProviderError>? = nil
DispatchQueue.main.sync {
returnValue = loadFileFromSourceBodyUnderlyingReturnValue
returnValue = loadFileFromSourceFilenameUnderlyingReturnValue
}
return returnValue!
@@ -10674,26 +10674,26 @@ class MediaProviderMock: MediaProviderProtocol {
}
set {
if Thread.isMainThread {
loadFileFromSourceBodyUnderlyingReturnValue = newValue
loadFileFromSourceFilenameUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
loadFileFromSourceBodyUnderlyingReturnValue = newValue
loadFileFromSourceFilenameUnderlyingReturnValue = newValue
}
}
}
}
var loadFileFromSourceBodyClosure: ((MediaSourceProxy, String?) async -> Result<MediaFileHandleProxy, MediaProviderError>)?
var loadFileFromSourceFilenameClosure: ((MediaSourceProxy, String?) async -> Result<MediaFileHandleProxy, MediaProviderError>)?
func loadFileFromSource(_ source: MediaSourceProxy, body: String?) async -> Result<MediaFileHandleProxy, MediaProviderError> {
loadFileFromSourceBodyCallsCount += 1
loadFileFromSourceBodyReceivedArguments = (source: source, body: body)
func loadFileFromSource(_ source: MediaSourceProxy, filename: String?) async -> Result<MediaFileHandleProxy, MediaProviderError> {
loadFileFromSourceFilenameCallsCount += 1
loadFileFromSourceFilenameReceivedArguments = (source: source, filename: filename)
DispatchQueue.main.async {
self.loadFileFromSourceBodyReceivedInvocations.append((source: source, body: body))
self.loadFileFromSourceFilenameReceivedInvocations.append((source: source, filename: filename))
}
if let loadFileFromSourceBodyClosure = loadFileFromSourceBodyClosure {
return await loadFileFromSourceBodyClosure(source, body)
if let loadFileFromSourceFilenameClosure = loadFileFromSourceFilenameClosure {
return await loadFileFromSourceFilenameClosure(source, filename)
} else {
return loadFileFromSourceBodyReturnValue
return loadFileFromSourceFilenameReturnValue
}
}
}
@@ -6139,6 +6139,81 @@ open class EncryptionSDKMock: MatrixRustSDK.Encryption {
}
}
//MARK: - getUserIdentity
open var getUserIdentityUserIdThrowableError: Error?
var getUserIdentityUserIdUnderlyingCallsCount = 0
open var getUserIdentityUserIdCallsCount: Int {
get {
if Thread.isMainThread {
return getUserIdentityUserIdUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = getUserIdentityUserIdUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
getUserIdentityUserIdUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
getUserIdentityUserIdUnderlyingCallsCount = newValue
}
}
}
}
open var getUserIdentityUserIdCalled: Bool {
return getUserIdentityUserIdCallsCount > 0
}
open var getUserIdentityUserIdReceivedUserId: String?
open var getUserIdentityUserIdReceivedInvocations: [String] = []
var getUserIdentityUserIdUnderlyingReturnValue: UserIdentity?
open var getUserIdentityUserIdReturnValue: UserIdentity? {
get {
if Thread.isMainThread {
return getUserIdentityUserIdUnderlyingReturnValue
} else {
var returnValue: UserIdentity?? = nil
DispatchQueue.main.sync {
returnValue = getUserIdentityUserIdUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
getUserIdentityUserIdUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
getUserIdentityUserIdUnderlyingReturnValue = newValue
}
}
}
}
open var getUserIdentityUserIdClosure: ((String) async throws -> UserIdentity?)?
open override func getUserIdentity(userId: String) async throws -> UserIdentity? {
if let error = getUserIdentityUserIdThrowableError {
throw error
}
getUserIdentityUserIdCallsCount += 1
getUserIdentityUserIdReceivedUserId = userId
DispatchQueue.main.async {
self.getUserIdentityUserIdReceivedInvocations.append(userId)
}
if let getUserIdentityUserIdClosure = getUserIdentityUserIdClosure {
return try await getUserIdentityUserIdClosure(userId)
} else {
return getUserIdentityUserIdReturnValue
}
}
//MARK: - isLastDevice
open var isLastDeviceThrowableError: Error?
@@ -20854,6 +20929,122 @@ open class UnreadNotificationsCountSDKMock: MatrixRustSDK.UnreadNotificationsCou
}
}
}
open class UserIdentitySDKMock: MatrixRustSDK.UserIdentity {
init() {
super.init(noPointer: .init())
}
public required init(unsafeFromRawPointer pointer: UnsafeMutableRawPointer) {
fatalError("init(unsafeFromRawPointer:) has not been implemented")
}
fileprivate var pointer: UnsafeMutableRawPointer!
//MARK: - masterKey
var masterKeyUnderlyingCallsCount = 0
open var masterKeyCallsCount: Int {
get {
if Thread.isMainThread {
return masterKeyUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = masterKeyUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
masterKeyUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
masterKeyUnderlyingCallsCount = newValue
}
}
}
}
open var masterKeyCalled: Bool {
return masterKeyCallsCount > 0
}
var masterKeyUnderlyingReturnValue: String?
open var masterKeyReturnValue: String? {
get {
if Thread.isMainThread {
return masterKeyUnderlyingReturnValue
} else {
var returnValue: String?? = nil
DispatchQueue.main.sync {
returnValue = masterKeyUnderlyingReturnValue
}
return returnValue!
}
}
set {
if Thread.isMainThread {
masterKeyUnderlyingReturnValue = newValue
} else {
DispatchQueue.main.sync {
masterKeyUnderlyingReturnValue = newValue
}
}
}
}
open var masterKeyClosure: (() -> String?)?
open override func masterKey() -> String? {
masterKeyCallsCount += 1
if let masterKeyClosure = masterKeyClosure {
return masterKeyClosure()
} else {
return masterKeyReturnValue
}
}
//MARK: - pin
open var pinThrowableError: Error?
var pinUnderlyingCallsCount = 0
open var pinCallsCount: Int {
get {
if Thread.isMainThread {
return pinUnderlyingCallsCount
} else {
var returnValue: Int? = nil
DispatchQueue.main.sync {
returnValue = pinUnderlyingCallsCount
}
return returnValue!
}
}
set {
if Thread.isMainThread {
pinUnderlyingCallsCount = newValue
} else {
DispatchQueue.main.sync {
pinUnderlyingCallsCount = newValue
}
}
}
}
open var pinCalled: Bool {
return pinCallsCount > 0
}
open var pinClosure: (() async throws -> Void)?
open override func pin() async throws {
if let error = pinThrowableError {
throw error
}
pinCallsCount += 1
try await pinClosure?()
}
}
open class WidgetDriverSDKMock: MatrixRustSDK.WidgetDriver {
init() {
super.init(noPointer: .init())