From 751be7b3a77d841b7723522f976d7c82dd2dc9a5 Mon Sep 17 00:00:00 2001 From: Doug <6060466+pixlwave@users.noreply.github.com> Date: Thu, 28 Nov 2024 08:34:38 +0000 Subject: [PATCH] Update the SDK. (#3565) * Update the SDK. * Add mockMXC URLs to fix all the crashes during tests. * Refactor Voice Messages to not use a MediaSource for local files. --- ElementX.xcodeproj/project.pbxproj | 6 +- .../xcshareddata/swiftpm/Package.resolved | 4 +- .../Mocks/Generated/GeneratedMocks.swift | 361 ++---------------- .../Sources/Mocks/MediaProviderMock.swift | 3 +- .../Sources/Mocks/RoomMemberProxyMock.swift | 6 +- .../Mocks/RoomSummaryProviderMock.swift | 4 +- ElementX/Sources/Other/Extensions/URL.swift | 8 + .../SwiftUI/Views/AvatarHeaderView.swift | 2 +- .../Other/SwiftUI/Views/RoomAvatarImage.swift | 4 +- .../Other/SwiftUI/Views/RoomHeaderView.swift | 2 +- .../View/GlobalSearchScreenCell.swift | 2 +- .../View/HomeScreenInviteCell.swift | 2 +- .../View/HomeScreenKnockedCell.swift | 2 +- .../JoinRoomScreen/View/JoinRoomScreen.swift | 6 +- .../View/RoomDirectorySearchScreen.swift | 2 +- .../RoomMembersListScreenMemberCell.swift | 4 +- .../View/CompletionSuggestionView.swift | 2 +- .../View/ComposerToolbar.swift | 2 +- .../View/MentionSuggestionItemView.swift | 2 +- .../Timeline/TimelineInteractionHandler.swift | 9 +- .../View/ReadReceipts/ReadReceiptCell.swift | 2 +- .../Services/Audio/Player/AudioPlayer.swift | 16 +- .../Audio/Player/AudioPlayerProtocol.swift | 26 +- .../Audio/Player/AudioPlayerState.swift | 2 +- .../Services/Client/ClientProxyProtocol.swift | 2 +- .../Media/Provider/MediaSourceProxy.swift | 5 +- .../MediaPlayer/MediaPlayerProtocol.swift | 34 -- .../MediaPlayer/MediaPlayerProvider.swift | 16 +- .../MediaPlayerProviderProtocol.swift | 2 +- .../Services/Timeline/TimelineItemProxy.swift | 6 +- .../VoiceMessage/VoiceMessageRecorder.swift | 10 +- .../UITests/UITestsAppCoordinator.swift | 24 +- ...test_completionSuggestion-iPad-en-GB.1.png | 4 +- ...est_completionSuggestion-iPad-pseudo.1.png | 4 +- ...completionSuggestion-iPhone-16-en-GB.1.png | 4 +- ...ompletionSuggestion-iPhone-16-pseudo.1.png | 4 +- ...serToolbar-iPad-en-GB.With-Suggestions.png | 4 +- ...erToolbar-iPad-pseudo.With-Suggestions.png | 4 +- ...olbar-iPhone-16-en-GB.With-Suggestions.png | 4 +- ...lbar-iPhone-16-pseudo.With-Suggestions.png | 4 +- .../test_joinRoomScreen-iPad-en-GB.Invite.png | 4 +- .../test_joinRoomScreen-iPad-en-GB.Join.png | 4 +- .../test_joinRoomScreen-iPad-en-GB.Knock.png | 4 +- ...test_joinRoomScreen-iPad-en-GB.Knocked.png | 4 +- ...test_joinRoomScreen-iPad-pseudo.Invite.png | 4 +- .../test_joinRoomScreen-iPad-pseudo.Join.png | 4 +- .../test_joinRoomScreen-iPad-pseudo.Knock.png | 4 +- ...est_joinRoomScreen-iPad-pseudo.Knocked.png | 4 +- ..._joinRoomScreen-iPhone-16-en-GB.Invite.png | 4 +- ...st_joinRoomScreen-iPhone-16-en-GB.Join.png | 4 +- ...t_joinRoomScreen-iPhone-16-en-GB.Knock.png | 4 +- ...joinRoomScreen-iPhone-16-en-GB.Knocked.png | 4 +- ...joinRoomScreen-iPhone-16-pseudo.Invite.png | 4 +- ...t_joinRoomScreen-iPhone-16-pseudo.Join.png | 4 +- ..._joinRoomScreen-iPhone-16-pseudo.Knock.png | 4 +- ...oinRoomScreen-iPhone-16-pseudo.Knocked.png | 4 +- ...mentionSuggestionItemView-iPad-en-GB.1.png | 4 +- ...entionSuggestionItemView-iPad-pseudo.1.png | 4 +- ...onSuggestionItemView-iPhone-16-en-GB.1.png | 4 +- ...nSuggestionItemView-iPhone-16-pseudo.1.png | 4 +- ..._readReceiptCell-iPad-en-GB.With-Image.png | 4 +- ...readReceiptCell-iPad-pseudo.With-Image.png | 4 +- ...ReceiptCell-iPhone-16-en-GB.With-Image.png | 4 +- ...eceiptCell-iPhone-16-pseudo.With-Image.png | 4 +- .../ComposerToolbarViewModelTests.swift | 2 +- .../Sources/MediaPlayerProviderTests.swift | 41 +- .../MediaProvider/MediaLoaderTests.swift | 4 +- .../MediaProvider/MediaProviderTests.swift | 24 +- .../RoomDetailsEditScreenViewModelTests.swift | 4 +- .../Sources/RoomScreenViewModelTests.swift | 4 +- .../UserProfileScreenViewModelTests.swift | 4 +- .../Sources/VoiceMessageCacheTests.swift | 2 +- .../VoiceMessageMediaManagerTests.swift | 2 +- .../Sources/VoiceMessageRecorderTests.swift | 17 +- project.yml | 2 +- 75 files changed, 222 insertions(+), 590 deletions(-) delete mode 100644 ElementX/Sources/Services/MediaPlayer/MediaPlayerProtocol.swift diff --git a/ElementX.xcodeproj/project.pbxproj b/ElementX.xcodeproj/project.pbxproj index eddd1befb0..555db7e68a 100644 --- a/ElementX.xcodeproj/project.pbxproj +++ b/ElementX.xcodeproj/project.pbxproj @@ -983,7 +983,6 @@ D02AA6208C7ACB9BE6332394 /* UNNotificationContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = BE148A4FFEE853C5A281500C /* UNNotificationContent.swift */; }; D02DEB36D32A72A1B365E452 /* SessionVerificationScreenCoordinator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 796CBD0C56FA0D3AEDAB255B /* SessionVerificationScreenCoordinator.swift */; }; D050D7756E92CA061ED0ABF0 /* SecureBackupLogoutConfirmationScreenViewModelProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74E08B8A66948E9690F38B94 /* SecureBackupLogoutConfirmationScreenViewModelProtocol.swift */; }; - D0550B8E0AE2C0CDBE52C88F /* MediaPlayerProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE87C931165F5E201CACBB87 /* MediaPlayerProtocol.swift */; }; D0A965852D6C04138FA55181 /* SecureBackupLogoutConfirmationScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = DCF239C619971FDE48132550 /* SecureBackupLogoutConfirmationScreenModels.swift */; }; D10BA4F041DC58580A440A32 /* RoomRolesAndPermissionsScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = B2B1DC3B3FB40A7F4AE9B7BF /* RoomRolesAndPermissionsScreen.swift */; }; D12F440F7973F1489F61389D /* NotificationSettingsScreenModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0F64447FF544298A6A3BEF85 /* NotificationSettingsScreenModels.swift */; }; @@ -2414,7 +2413,6 @@ FDEDD4D2DE0646DA724985D5 /* QRCodeLoginScreenModels.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QRCodeLoginScreenModels.swift; sourceTree = ""; }; FDF73F49E6B6683F7E2D26F0 /* SecureBackupScreenCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureBackupScreenCoordinator.swift; sourceTree = ""; }; FE1E6FAA3719E9B7A2D5510B /* FormattingToolbar.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormattingToolbar.swift; sourceTree = ""; }; - FE87C931165F5E201CACBB87 /* MediaPlayerProtocol.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MediaPlayerProtocol.swift; sourceTree = ""; }; FF720BA68256297680980481 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/InfoPlist.strings"; sourceTree = ""; }; FFECCE59967018204876D0A5 /* LocationMarkerView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LocationMarkerView.swift; sourceTree = ""; }; /* End PBXFileReference section */ @@ -3785,7 +3783,6 @@ 6709362D60732DED2069AE0F /* MediaPlayer */ = { isa = PBXGroup; children = ( - FE87C931165F5E201CACBB87 /* MediaPlayerProtocol.swift */, E8A1F98AE670377B20679FF5 /* MediaPlayerProvider.swift */, F5E23D8EE6CBACF32F1EC874 /* MediaPlayerProviderProtocol.swift */, ); @@ -6894,7 +6891,6 @@ 208C19811613F9A10F8A7B75 /* MediaLoader.swift in Sources */, A2434D4DFB49A68E5CD0F53C /* MediaLoaderProtocol.swift in Sources */, 4E0D9E09B52CEC4C0E6211A8 /* MediaPickerScreenCoordinator.swift in Sources */, - D0550B8E0AE2C0CDBE52C88F /* MediaPlayerProtocol.swift in Sources */, F66BCCC825D6CA51724A94D0 /* MediaPlayerProvider.swift in Sources */, 762DAF94846C7AC8550F1CC1 /* MediaPlayerProviderProtocol.swift in Sources */, B6EC2148FA5443C9289BEEBA /* MediaProvider.swift in Sources */, @@ -8195,7 +8191,7 @@ repositoryURL = "https://github.com/element-hq/matrix-rust-components-swift"; requirement = { kind = exactVersion; - version = 1.0.75; + version = 1.0.76; }; }; 701C7BEF8F70F7A83E852DCC /* XCRemoteSwiftPackageReference "GZIP" */ = { diff --git a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index dca464ac2e..00f2e1f4d9 100644 --- a/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/ElementX.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -149,8 +149,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/element-hq/matrix-rust-components-swift", "state" : { - "revision" : "6b14c048543bac9effe5e44fa90333bfa7dd9435", - "version" : "1.0.75" + "revision" : "dfb54791b10d17c5e2604c716c8e939bed221435", + "version" : "1.0.76" } }, { diff --git a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift index 45e2fd5d50..b980c6dd65 100644 --- a/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift +++ b/ElementX/Sources/Mocks/Generated/GeneratedMocks.swift @@ -1200,12 +1200,7 @@ class AudioConverterMock: AudioConverterProtocol { } } class AudioPlayerMock: AudioPlayerProtocol { - var actions: AnyPublisher { - get { return underlyingActions } - set(value) { underlyingActions = value } - } - var underlyingActions: AnyPublisher! - var mediaSource: MediaSourceProxy? + var sourceURL: URL? var duration: TimeInterval { get { return underlyingDuration } set(value) { underlyingDuration = value } @@ -1216,24 +1211,29 @@ class AudioPlayerMock: AudioPlayerProtocol { set(value) { underlyingCurrentTime = value } } var underlyingCurrentTime: TimeInterval! - var url: URL? + var playbackURL: URL? var state: MediaPlayerState { get { return underlyingState } set(value) { underlyingState = value } } var underlyingState: MediaPlayerState! + var actions: AnyPublisher { + get { return underlyingActions } + set(value) { underlyingActions = value } + } + var underlyingActions: AnyPublisher! //MARK: - load - var loadMediaSourceUsingAutoplayUnderlyingCallsCount = 0 - var loadMediaSourceUsingAutoplayCallsCount: Int { + var loadSourceURLPlaybackURLAutoplayUnderlyingCallsCount = 0 + var loadSourceURLPlaybackURLAutoplayCallsCount: Int { get { if Thread.isMainThread { - return loadMediaSourceUsingAutoplayUnderlyingCallsCount + return loadSourceURLPlaybackURLAutoplayUnderlyingCallsCount } else { var returnValue: Int? = nil DispatchQueue.main.sync { - returnValue = loadMediaSourceUsingAutoplayUnderlyingCallsCount + returnValue = loadSourceURLPlaybackURLAutoplayUnderlyingCallsCount } return returnValue! @@ -1241,28 +1241,28 @@ class AudioPlayerMock: AudioPlayerProtocol { } set { if Thread.isMainThread { - loadMediaSourceUsingAutoplayUnderlyingCallsCount = newValue + loadSourceURLPlaybackURLAutoplayUnderlyingCallsCount = newValue } else { DispatchQueue.main.sync { - loadMediaSourceUsingAutoplayUnderlyingCallsCount = newValue + loadSourceURLPlaybackURLAutoplayUnderlyingCallsCount = newValue } } } } - var loadMediaSourceUsingAutoplayCalled: Bool { - return loadMediaSourceUsingAutoplayCallsCount > 0 + var loadSourceURLPlaybackURLAutoplayCalled: Bool { + return loadSourceURLPlaybackURLAutoplayCallsCount > 0 } - var loadMediaSourceUsingAutoplayReceivedArguments: (mediaSource: MediaSourceProxy, url: URL, autoplay: Bool)? - var loadMediaSourceUsingAutoplayReceivedInvocations: [(mediaSource: MediaSourceProxy, url: URL, autoplay: Bool)] = [] - var loadMediaSourceUsingAutoplayClosure: ((MediaSourceProxy, URL, Bool) -> Void)? + var loadSourceURLPlaybackURLAutoplayReceivedArguments: (sourceURL: URL, playbackURL: URL, autoplay: Bool)? + var loadSourceURLPlaybackURLAutoplayReceivedInvocations: [(sourceURL: URL, playbackURL: URL, autoplay: Bool)] = [] + var loadSourceURLPlaybackURLAutoplayClosure: ((URL, URL, Bool) -> Void)? - func load(mediaSource: MediaSourceProxy, using url: URL, autoplay: Bool) { - loadMediaSourceUsingAutoplayCallsCount += 1 - loadMediaSourceUsingAutoplayReceivedArguments = (mediaSource: mediaSource, url: url, autoplay: autoplay) + func load(sourceURL: URL, playbackURL: URL, autoplay: Bool) { + loadSourceURLPlaybackURLAutoplayCallsCount += 1 + loadSourceURLPlaybackURLAutoplayReceivedArguments = (sourceURL: sourceURL, playbackURL: playbackURL, autoplay: autoplay) DispatchQueue.main.async { - self.loadMediaSourceUsingAutoplayReceivedInvocations.append((mediaSource: mediaSource, url: url, autoplay: autoplay)) + self.loadSourceURLPlaybackURLAutoplayReceivedInvocations.append((sourceURL: sourceURL, playbackURL: playbackURL, autoplay: autoplay)) } - loadMediaSourceUsingAutoplayClosure?(mediaSource, url, autoplay) + loadSourceURLPlaybackURLAutoplayClosure?(sourceURL, playbackURL, autoplay) } //MARK: - reset @@ -9812,320 +9812,13 @@ class MediaLoaderMock: MediaLoaderProtocol { } } } -class MediaPlayerMock: MediaPlayerProtocol { - var mediaSource: MediaSourceProxy? - var duration: TimeInterval { - get { return underlyingDuration } - set(value) { underlyingDuration = value } - } - var underlyingDuration: TimeInterval! - var currentTime: TimeInterval { - get { return underlyingCurrentTime } - set(value) { underlyingCurrentTime = value } - } - var underlyingCurrentTime: TimeInterval! - var url: URL? - var state: MediaPlayerState { - get { return underlyingState } - set(value) { underlyingState = value } - } - var underlyingState: MediaPlayerState! - - //MARK: - load - - var loadMediaSourceUsingAutoplayUnderlyingCallsCount = 0 - var loadMediaSourceUsingAutoplayCallsCount: Int { - get { - if Thread.isMainThread { - return loadMediaSourceUsingAutoplayUnderlyingCallsCount - } else { - var returnValue: Int? = nil - DispatchQueue.main.sync { - returnValue = loadMediaSourceUsingAutoplayUnderlyingCallsCount - } - - return returnValue! - } - } - set { - if Thread.isMainThread { - loadMediaSourceUsingAutoplayUnderlyingCallsCount = newValue - } else { - DispatchQueue.main.sync { - loadMediaSourceUsingAutoplayUnderlyingCallsCount = newValue - } - } - } - } - var loadMediaSourceUsingAutoplayCalled: Bool { - return loadMediaSourceUsingAutoplayCallsCount > 0 - } - var loadMediaSourceUsingAutoplayReceivedArguments: (mediaSource: MediaSourceProxy, url: URL, autoplay: Bool)? - var loadMediaSourceUsingAutoplayReceivedInvocations: [(mediaSource: MediaSourceProxy, url: URL, autoplay: Bool)] = [] - var loadMediaSourceUsingAutoplayClosure: ((MediaSourceProxy, URL, Bool) -> Void)? - - func load(mediaSource: MediaSourceProxy, using url: URL, autoplay: Bool) { - loadMediaSourceUsingAutoplayCallsCount += 1 - loadMediaSourceUsingAutoplayReceivedArguments = (mediaSource: mediaSource, url: url, autoplay: autoplay) - DispatchQueue.main.async { - self.loadMediaSourceUsingAutoplayReceivedInvocations.append((mediaSource: mediaSource, url: url, autoplay: autoplay)) - } - loadMediaSourceUsingAutoplayClosure?(mediaSource, url, autoplay) - } - //MARK: - reset - - var resetUnderlyingCallsCount = 0 - var resetCallsCount: Int { - get { - if Thread.isMainThread { - return resetUnderlyingCallsCount - } else { - var returnValue: Int? = nil - DispatchQueue.main.sync { - returnValue = resetUnderlyingCallsCount - } - - return returnValue! - } - } - set { - if Thread.isMainThread { - resetUnderlyingCallsCount = newValue - } else { - DispatchQueue.main.sync { - resetUnderlyingCallsCount = newValue - } - } - } - } - var resetCalled: Bool { - return resetCallsCount > 0 - } - var resetClosure: (() -> Void)? - - func reset() { - resetCallsCount += 1 - resetClosure?() - } - //MARK: - play - - var playUnderlyingCallsCount = 0 - var playCallsCount: Int { - get { - if Thread.isMainThread { - return playUnderlyingCallsCount - } else { - var returnValue: Int? = nil - DispatchQueue.main.sync { - returnValue = playUnderlyingCallsCount - } - - return returnValue! - } - } - set { - if Thread.isMainThread { - playUnderlyingCallsCount = newValue - } else { - DispatchQueue.main.sync { - playUnderlyingCallsCount = newValue - } - } - } - } - var playCalled: Bool { - return playCallsCount > 0 - } - var playClosure: (() -> Void)? - - func play() { - playCallsCount += 1 - playClosure?() - } - //MARK: - pause - - var pauseUnderlyingCallsCount = 0 - var pauseCallsCount: Int { - get { - if Thread.isMainThread { - return pauseUnderlyingCallsCount - } else { - var returnValue: Int? = nil - DispatchQueue.main.sync { - returnValue = pauseUnderlyingCallsCount - } - - return returnValue! - } - } - set { - if Thread.isMainThread { - pauseUnderlyingCallsCount = newValue - } else { - DispatchQueue.main.sync { - pauseUnderlyingCallsCount = newValue - } - } - } - } - var pauseCalled: Bool { - return pauseCallsCount > 0 - } - var pauseClosure: (() -> Void)? - - func pause() { - pauseCallsCount += 1 - pauseClosure?() - } - //MARK: - stop - - var stopUnderlyingCallsCount = 0 - var stopCallsCount: Int { - get { - if Thread.isMainThread { - return stopUnderlyingCallsCount - } else { - var returnValue: Int? = nil - DispatchQueue.main.sync { - returnValue = stopUnderlyingCallsCount - } - - return returnValue! - } - } - set { - if Thread.isMainThread { - stopUnderlyingCallsCount = newValue - } else { - DispatchQueue.main.sync { - stopUnderlyingCallsCount = newValue - } - } - } - } - var stopCalled: Bool { - return stopCallsCount > 0 - } - var stopClosure: (() -> Void)? - - func stop() { - stopCallsCount += 1 - stopClosure?() - } - //MARK: - seek - - var seekToUnderlyingCallsCount = 0 - var seekToCallsCount: Int { - get { - if Thread.isMainThread { - return seekToUnderlyingCallsCount - } else { - var returnValue: Int? = nil - DispatchQueue.main.sync { - returnValue = seekToUnderlyingCallsCount - } - - return returnValue! - } - } - set { - if Thread.isMainThread { - seekToUnderlyingCallsCount = newValue - } else { - DispatchQueue.main.sync { - seekToUnderlyingCallsCount = newValue - } - } - } - } - var seekToCalled: Bool { - return seekToCallsCount > 0 - } - var seekToReceivedProgress: Double? - var seekToReceivedInvocations: [Double] = [] - var seekToClosure: ((Double) async -> Void)? - - func seek(to progress: Double) async { - seekToCallsCount += 1 - seekToReceivedProgress = progress - DispatchQueue.main.async { - self.seekToReceivedInvocations.append(progress) - } - await seekToClosure?(progress) - } -} class MediaPlayerProviderMock: MediaPlayerProviderProtocol { - - //MARK: - player - - var playerForUnderlyingCallsCount = 0 - var playerForCallsCount: Int { - get { - if Thread.isMainThread { - return playerForUnderlyingCallsCount - } else { - var returnValue: Int? = nil - DispatchQueue.main.sync { - returnValue = playerForUnderlyingCallsCount - } - - return returnValue! - } - } - set { - if Thread.isMainThread { - playerForUnderlyingCallsCount = newValue - } else { - DispatchQueue.main.sync { - playerForUnderlyingCallsCount = newValue - } - } - } - } - var playerForCalled: Bool { - return playerForCallsCount > 0 - } - var playerForReceivedMediaSource: MediaSourceProxy? - var playerForReceivedInvocations: [MediaSourceProxy] = [] - - var playerForUnderlyingReturnValue: Result! - var playerForReturnValue: Result! { - get { - if Thread.isMainThread { - return playerForUnderlyingReturnValue - } else { - var returnValue: Result? = nil - DispatchQueue.main.sync { - returnValue = playerForUnderlyingReturnValue - } - - return returnValue! - } - } - set { - if Thread.isMainThread { - playerForUnderlyingReturnValue = newValue - } else { - DispatchQueue.main.sync { - playerForUnderlyingReturnValue = newValue - } - } - } + var player: AudioPlayerProtocol { + get { return underlyingPlayer } + set(value) { underlyingPlayer = value } } - var playerForClosure: ((MediaSourceProxy) -> Result)? + var underlyingPlayer: AudioPlayerProtocol! - func player(for mediaSource: MediaSourceProxy) -> Result { - playerForCallsCount += 1 - playerForReceivedMediaSource = mediaSource - DispatchQueue.main.async { - self.playerForReceivedInvocations.append(mediaSource) - } - if let playerForClosure = playerForClosure { - return playerForClosure(mediaSource) - } else { - return playerForReturnValue - } - } //MARK: - playerState var playerStateForUnderlyingCallsCount = 0 diff --git a/ElementX/Sources/Mocks/MediaProviderMock.swift b/ElementX/Sources/Mocks/MediaProviderMock.swift index eb1929eff4..c2ae134960 100644 --- a/ElementX/Sources/Mocks/MediaProviderMock.swift +++ b/ElementX/Sources/Mocks/MediaProviderMock.swift @@ -18,7 +18,8 @@ extension MediaProviderMock { return nil } - if mediaSource?.url == .picturesDirectory { + // At some stage it would be nice to return different images, but for now they can be the same. + if mediaSource?.url == .mockMXCImage || mediaSource?.url == .mockMXCAvatar { return Asset.Images.appLogo.image } diff --git a/ElementX/Sources/Mocks/RoomMemberProxyMock.swift b/ElementX/Sources/Mocks/RoomMemberProxyMock.swift index 2074c014b1..8c81c727e1 100644 --- a/ElementX/Sources/Mocks/RoomMemberProxyMock.swift +++ b/ElementX/Sources/Mocks/RoomMemberProxyMock.swift @@ -43,14 +43,14 @@ extension RoomMemberProxyMock { static var mockMe: RoomMemberProxyMock { RoomMemberProxyMock(with: .init(userID: "@me:matrix.org", displayName: "Me", - avatarURL: URL.picturesDirectory, + avatarURL: .mockMXCAvatar, membership: .join)) } static var mockMeAdmin: RoomMemberProxyMock { RoomMemberProxyMock(with: .init(userID: "@me:matrix.org", displayName: "Me", - avatarURL: URL.picturesDirectory, + avatarURL: .mockMXCAvatar, membership: .join, powerLevel: 100, role: .administrator)) @@ -83,7 +83,7 @@ extension RoomMemberProxyMock { static var mockDan: RoomMemberProxyMock { RoomMemberProxyMock(with: .init(userID: "@dan:matrix.org", displayName: "Dan", - avatarURL: URL.picturesDirectory, + avatarURL: .mockMXCAvatar, membership: .join)) } diff --git a/ElementX/Sources/Mocks/RoomSummaryProviderMock.swift b/ElementX/Sources/Mocks/RoomSummaryProviderMock.swift index ed88e9efe2..7c71582868 100644 --- a/ElementX/Sources/Mocks/RoomSummaryProviderMock.swift +++ b/ElementX/Sources/Mocks/RoomSummaryProviderMock.swift @@ -91,7 +91,7 @@ extension Array where Element == RoomSummary { joinRequestType: nil, name: "Foundation and Empire", isDirect: false, - avatarURL: URL.picturesDirectory, + avatarURL: .mockMXCAvatar, heroes: [], lastMessage: AttributedString("How do you see the Emperor then? You think he keeps office hours?"), lastMessageFormattedTimestamp: "2:56 PM", @@ -226,7 +226,7 @@ extension Array where Element == RoomSummary { joinRequestType: .invite(inviter: RoomMemberProxyMock.mockCharlie), name: "First room", isDirect: false, - avatarURL: URL.picturesDirectory, + avatarURL: .mockMXCAvatar, heroes: [], lastMessage: nil, lastMessageFormattedTimestamp: nil, diff --git a/ElementX/Sources/Other/Extensions/URL.swift b/ElementX/Sources/Other/Extensions/URL.swift index fc26b266b5..0c026ef129 100644 --- a/ElementX/Sources/Other/Extensions/URL.swift +++ b/ElementX/Sources/Other/Extensions/URL.swift @@ -100,4 +100,12 @@ extension URL: @retroactive ExpressibleByStringLiteral { } return nil } + + // MARK: Mocks + + static var mockMXCAudio: URL { "mxc://matrix.org/1234567890FiLe" } + static var mockMXCFile: URL { "mxc://matrix.org/1234567890FiLe" } + static var mockMXCImage: URL { "mxc://matrix.org/1234567890ImAgE" } + static var mockMXCVideo: URL { "mxc://matrix.org/1234567890ViDeO" } + static var mockMXCAvatar: URL { "mxc://matrix.org/1234567890AvAtAr" } } diff --git a/ElementX/Sources/Other/SwiftUI/Views/AvatarHeaderView.swift b/ElementX/Sources/Other/SwiftUI/Views/AvatarHeaderView.swift index f78421bf94..1f8afbe19f 100644 --- a/ElementX/Sources/Other/SwiftUI/Views/AvatarHeaderView.swift +++ b/ElementX/Sources/Other/SwiftUI/Views/AvatarHeaderView.swift @@ -190,7 +190,7 @@ struct AvatarHeaderView_Previews: PreviewProvider, TestablePreview { name: "Test Room", avatar: .room(id: "@test:matrix.org", name: "Test Room", - avatarURL: .picturesDirectory), + avatarURL: .mockMXCAvatar), canonicalAlias: "#test:matrix.org", isEncrypted: true, isPublic: true), diff --git a/ElementX/Sources/Other/SwiftUI/Views/RoomAvatarImage.swift b/ElementX/Sources/Other/SwiftUI/Views/RoomAvatarImage.swift index f4b3d2bee1..6601cc5cac 100644 --- a/ElementX/Sources/Other/SwiftUI/Views/RoomAvatarImage.swift +++ b/ElementX/Sources/Other/SwiftUI/Views/RoomAvatarImage.swift @@ -97,7 +97,7 @@ struct RoomAvatarImage_Previews: PreviewProvider, TestablePreview { RoomAvatarImage(avatar: .room(id: "!2:server.com", name: "Room", - avatarURL: .picturesDirectory), + avatarURL: .mockMXCAvatar), avatarSize: .room(on: .home), mediaProvider: MediaProviderMock(configuration: .init())) @@ -109,7 +109,7 @@ struct RoomAvatarImage_Previews: PreviewProvider, TestablePreview { RoomAvatarImage(avatar: .heroes([.init(userID: "@user:server.com", displayName: "User", - avatarURL: .picturesDirectory)]), + avatarURL: .mockMXCAvatar)]), avatarSize: .room(on: .home), mediaProvider: MediaProviderMock(configuration: .init())) diff --git a/ElementX/Sources/Other/SwiftUI/Views/RoomHeaderView.swift b/ElementX/Sources/Other/SwiftUI/Views/RoomHeaderView.swift index c7291c4412..ff25c03dad 100644 --- a/ElementX/Sources/Other/SwiftUI/Views/RoomHeaderView.swift +++ b/ElementX/Sources/Other/SwiftUI/Views/RoomHeaderView.swift @@ -41,7 +41,7 @@ struct RoomHeaderView_Previews: PreviewProvider, TestablePreview { RoomHeaderView(roomName: "Some Room name", roomAvatar: .room(id: "1", name: "Some Room Name", - avatarURL: URL.picturesDirectory), + avatarURL: .mockMXCAvatar), mediaProvider: MediaProviderMock(configuration: .init())) .previewLayout(.sizeThatFits) .padding() diff --git a/ElementX/Sources/Screens/GlobalSearchScreen/View/GlobalSearchScreenCell.swift b/ElementX/Sources/Screens/GlobalSearchScreen/View/GlobalSearchScreenCell.swift index 354e1cef80..e16b0485dd 100644 --- a/ElementX/Sources/Screens/GlobalSearchScreen/View/GlobalSearchScreenCell.swift +++ b/ElementX/Sources/Screens/GlobalSearchScreen/View/GlobalSearchScreenCell.swift @@ -46,7 +46,7 @@ struct GlobalSearchScreenListRow_Previews: PreviewProvider, TestablePreview { description: "The best place in the whole wide world", avatar: .room(id: "123", name: "Tech central", - avatarURL: .picturesDirectory)), + avatarURL: .mockMXCAvatar)), context: viewModel.context) } } diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenInviteCell.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenInviteCell.swift index 4eb7606ff9..2f9f9f4ef0 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenInviteCell.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenInviteCell.swift @@ -145,7 +145,7 @@ struct HomeScreenInviteCell_Previews: PreviewProvider, TestablePreview { HomeScreenInviteCell(room: .roomInvite(), context: viewModel().context) - HomeScreenInviteCell(room: .roomInvite(alias: "#footest:somewhere.org", avatarURL: .picturesDirectory), + HomeScreenInviteCell(room: .roomInvite(alias: "#footest:somewhere.org", avatarURL: .mockMXCAvatar), context: viewModel().context) HomeScreenInviteCell(room: .roomInvite(alias: "#footest:somewhere.org"), diff --git a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenKnockedCell.swift b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenKnockedCell.swift index 0f0f64717e..2a79f62e18 100644 --- a/ElementX/Sources/Screens/HomeScreen/View/HomeScreenKnockedCell.swift +++ b/ElementX/Sources/Screens/HomeScreen/View/HomeScreenKnockedCell.swift @@ -119,7 +119,7 @@ struct HomeScreenKnockedCell_Previews: PreviewProvider, TestablePreview { HomeScreenKnockedCell(room: .roomKnocked(), context: viewModel().context) - HomeScreenKnockedCell(room: .roomKnocked(alias: "#footest:somewhere.org", avatarURL: .picturesDirectory), + HomeScreenKnockedCell(room: .roomKnocked(alias: "#footest:somewhere.org", avatarURL: .mockMXCAvatar), context: viewModel().context) HomeScreenKnockedCell(room: .roomKnocked(alias: "#footest:somewhere.org"), diff --git a/ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift b/ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift index f47e63c632..2c3bff5240 100644 --- a/ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift +++ b/ElementX/Sources/Screens/JoinRoomScreen/View/JoinRoomScreen.swift @@ -237,11 +237,11 @@ struct JoinRoomScreen_Previews: PreviewProvider, TestablePreview { switch mode { case .knocked: clientProxy.roomForIdentifierClosure = { _ in - .knocked(KnockedRoomProxyMock(.init(avatarURL: URL.homeDirectory))) + .knocked(KnockedRoomProxyMock(.init(avatarURL: .mockMXCAvatar))) } case .invited: clientProxy.roomForIdentifierClosure = { _ in - .invited(InvitedRoomProxyMock(.init(avatarURL: URL.homeDirectory))) + .invited(InvitedRoomProxyMock(.init(avatarURL: .mockMXCAvatar))) } default: break @@ -251,7 +251,7 @@ struct JoinRoomScreen_Previews: PreviewProvider, TestablePreview { canonicalAlias: "#3🌞problem:matrix.org", // swiftlint:disable:next line_length topic: "“Science and technology were the only keys to opening the door to the future, and people approached science with the faith and sincerity of elementary school students.”", - avatarURL: URL.homeDirectory, + avatarURL: .mockMXCAvatar, memberCount: UInt(100), isHistoryWorldReadable: false, isJoined: membership.isJoined, diff --git a/ElementX/Sources/Screens/RoomDirectorySearchScreen/View/RoomDirectorySearchScreen.swift b/ElementX/Sources/Screens/RoomDirectorySearchScreen/View/RoomDirectorySearchScreen.swift index 95a67e0305..81f9605e29 100644 --- a/ElementX/Sources/Screens/RoomDirectorySearchScreen/View/RoomDirectorySearchScreen.swift +++ b/ElementX/Sources/Screens/RoomDirectorySearchScreen/View/RoomDirectorySearchScreen.swift @@ -84,7 +84,7 @@ struct RoomDirectorySearchScreen_Previews: PreviewProvider, TestablePreview { topic: nil, avatar: .room(id: "test_2", name: "Test 2", - avatarURL: .documentsDirectory), + avatarURL: .mockMXCAvatar), canBeJoined: false)] let roomDirectorySearchProxy = RoomDirectorySearchProxyMock(configuration: .init(results: results)) diff --git a/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListScreenMemberCell.swift b/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListScreenMemberCell.swift index efd25c1706..7eb4efa2a5 100644 --- a/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListScreenMemberCell.swift +++ b/ElementX/Sources/Screens/RoomMemberListScreen/View/RoomMembersListScreenMemberCell.swift @@ -88,13 +88,13 @@ struct RoomMembersListMemberCell_Previews: PreviewProvider, TestablePreview { .mockAdmin, .mockModerator, .init(with: .init(userID: "@nodisplayname:matrix.org", membership: .join)), - .init(with: .init(userID: "@avatar:matrix.org", displayName: "Avatar", avatarURL: .picturesDirectory, membership: .join)) + .init(with: .init(userID: "@avatar:matrix.org", displayName: "Avatar", avatarURL: .mockMXCAvatar, membership: .join)) ] static let bannedMembers: [RoomMemberProxyMock] = [ .init(with: .init(userID: "@nodisplayname:matrix.org", membership: .ban)), .init(with: .init(userID: "@fake:matrix.org", displayName: "President", membership: .ban)), - .init(with: .init(userID: "@badavatar:matrix.org", avatarURL: .picturesDirectory, membership: .ban)) + .init(with: .init(userID: "@badavatar:matrix.org", avatarURL: .mockMXCAvatar, membership: .ban)) ] static let viewModel = RoomMembersListScreenViewModel(roomProxy: JoinedRoomProxyMock(.init(name: "Some room", diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/CompletionSuggestionView.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/CompletionSuggestionView.swift index 29b5ff4cc9..2599f522d1 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/CompletionSuggestionView.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/CompletionSuggestionView.swift @@ -118,7 +118,7 @@ struct CompletionSuggestion_Previews: PreviewProvider, TestablePreview { VStack(spacing: 8) { CompletionSuggestionView(mediaProvider: MediaProviderMock(configuration: .init()), items: [.user(item: MentionSuggestionItem(id: "@user_mention_1:matrix.org", displayName: "User 1", avatarURL: nil, range: .init())), - .user(item: MentionSuggestionItem(id: "@user_mention_2:matrix.org", displayName: "User 2", avatarURL: URL.documentsDirectory, range: .init()))]) { _ in } + .user(item: MentionSuggestionItem(id: "@user_mention_2:matrix.org", displayName: "User 2", avatarURL: .mockMXCAvatar, range: .init()))]) { _ in } } VStack(spacing: 8) { CompletionSuggestionView(mediaProvider: MediaProviderMock(configuration: .init()), diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/ComposerToolbar.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/ComposerToolbar.swift index aa6c14db2f..dc87b4c31d 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/ComposerToolbar.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/ComposerToolbar.swift @@ -304,7 +304,7 @@ struct ComposerToolbar_Previews: PreviewProvider, TestablePreview { analyticsService: ServiceLocator.shared.analytics, composerDraftService: ComposerDraftServiceMock()) static let suggestions: [SuggestionItem] = [.user(item: MentionSuggestionItem(id: "@user_mention_1:matrix.org", displayName: "User 1", avatarURL: nil, range: .init())), - .user(item: MentionSuggestionItem(id: "@user_mention_2:matrix.org", displayName: "User 2", avatarURL: URL.documentsDirectory, range: .init()))] + .user(item: MentionSuggestionItem(id: "@user_mention_2:matrix.org", displayName: "User 2", avatarURL: .mockMXCAvatar, range: .init()))] static var previews: some View { ComposerToolbar.mock(focused: true) diff --git a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/MentionSuggestionItemView.swift b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/MentionSuggestionItemView.swift index eea817a9e6..d8643ac603 100644 --- a/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/MentionSuggestionItemView.swift +++ b/ElementX/Sources/Screens/RoomScreen/ComposerToolbar/View/MentionSuggestionItemView.swift @@ -38,7 +38,7 @@ struct MentionSuggestionItemView_Previews: PreviewProvider, TestablePreview { static let mockMediaProvider = MediaProviderMock(configuration: .init()) static var previews: some View { - MentionSuggestionItemView(mediaProvider: mockMediaProvider, item: .init(id: "test", displayName: "Test", avatarURL: URL.documentsDirectory, range: .init())) + MentionSuggestionItemView(mediaProvider: mockMediaProvider, item: .init(id: "test", displayName: "Test", avatarURL: .mockMXCAvatar, range: .init())) MentionSuggestionItemView(mediaProvider: mockMediaProvider, item: .init(id: "test2", displayName: nil, avatarURL: nil, range: .init())) } } diff --git a/ElementX/Sources/Screens/Timeline/TimelineInteractionHandler.swift b/ElementX/Sources/Screens/Timeline/TimelineInteractionHandler.swift index 18e6ef0ee8..c7d004df1e 100644 --- a/ElementX/Sources/Screens/Timeline/TimelineInteractionHandler.swift +++ b/ElementX/Sources/Screens/Timeline/TimelineInteractionHandler.swift @@ -408,10 +408,7 @@ class TimelineInteractionHandler { return } - guard case .success(let mediaPlayer) = mediaPlayerProvider.player(for: source), let audioPlayer = mediaPlayer as? AudioPlayerProtocol else { - MXLog.error("Cannot play a voice message without an audio player") - return - } + let audioPlayer = mediaPlayerProvider.player // Stop any recording in progress if voiceMessageRecorder.isRecording { @@ -430,7 +427,7 @@ class TimelineInteractionHandler { // Detach all other states await mediaPlayerProvider.detachAllStates(except: audioPlayerState) - guard audioPlayer.mediaSource == source, audioPlayer.state != .error else { + guard audioPlayer.sourceURL == source.url, audioPlayer.state != .error else { // Load content do { MXLog.info("Loading voice message audio content from source for itemID \(itemID)") @@ -438,7 +435,7 @@ class TimelineInteractionHandler { // Make sure that the player is still attached, as it may have been detached while waiting for the voice message to be loaded. if audioPlayerState.isAttached { - audioPlayer.load(mediaSource: source, using: url, autoplay: true) + audioPlayer.load(sourceURL: source.url, playbackURL: url, autoplay: true) } } catch { MXLog.error("Failed to load voice message: \(error)") diff --git a/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptCell.swift b/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptCell.swift index e1328e605f..53ae91850f 100644 --- a/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptCell.swift +++ b/ElementX/Sources/Screens/Timeline/View/ReadReceipts/ReadReceiptCell.swift @@ -66,7 +66,7 @@ struct ReadReceiptCell_Previews: PreviewProvider, TestablePreview { ReadReceiptCell(readReceipt: .init(userID: "@test:matrix.org", formattedTimestamp: "10:00"), memberState: .init(displayName: "Test", - avatarURL: URL.documentsDirectory), + avatarURL: .mockMXCAvatar), mediaProvider: MediaProviderMock(configuration: .init())) .previewDisplayName("With Image") ReadReceiptCell(readReceipt: .init(userID: "@test:matrix.org", diff --git a/ElementX/Sources/Services/Audio/Player/AudioPlayer.swift b/ElementX/Sources/Services/Audio/Player/AudioPlayer.swift index 79a1a3a5a9..d7cd59c57d 100644 --- a/ElementX/Sources/Services/Audio/Player/AudioPlayer.swift +++ b/ElementX/Sources/Services/Audio/Player/AudioPlayer.swift @@ -22,7 +22,7 @@ private enum InternalAudioPlayerState { } class AudioPlayer: NSObject, AudioPlayerProtocol { - var mediaSource: MediaSourceProxy? + var sourceURL: URL? private var playerItem: AVPlayerItem? private var internalAudioPlayer: AVQueuePlayer? @@ -46,7 +46,7 @@ class AudioPlayer: NSObject, AudioPlayerProtocol { private let releaseAudioSessionTimeoutInterval = 5.0 - private(set) var url: URL? + private(set) var playbackURL: URL? private var deinitInProgress = false @@ -86,13 +86,13 @@ class AudioPlayer: NSObject, AudioPlayerProtocol { unloadContent() } - func load(mediaSource: MediaSourceProxy, using url: URL, autoplay: Bool) { + func load(sourceURL: URL, playbackURL: URL, autoplay: Bool) { unloadContent() setInternalState(.loading) - self.mediaSource = mediaSource - self.url = url + self.sourceURL = sourceURL + self.playbackURL = playbackURL self.autoplay = autoplay - playerItem = AVPlayerItem(url: url) + playerItem = AVPlayerItem(url: playbackURL) internalAudioPlayer = AVQueuePlayer(playerItem: playerItem) addObservers() } @@ -162,8 +162,8 @@ class AudioPlayer: NSObject, AudioPlayerProtocol { } private func unloadContent() { - mediaSource = nil - url = nil + sourceURL = nil + playbackURL = nil internalAudioPlayer?.replaceCurrentItem(with: nil) internalAudioPlayer = nil playerItem = nil diff --git a/ElementX/Sources/Services/Audio/Player/AudioPlayerProtocol.swift b/ElementX/Sources/Services/Audio/Player/AudioPlayerProtocol.swift index 7addac3f3a..257713cc76 100644 --- a/ElementX/Sources/Services/Audio/Player/AudioPlayerProtocol.swift +++ b/ElementX/Sources/Services/Audio/Player/AudioPlayerProtocol.swift @@ -12,6 +12,17 @@ enum AudioPlayerError: Error { case genericError } +// There used to be a MediaPlayerProtocol that AudioPlayerProtocol inherited from. +// This should be called something else but we already have an AudioPlayerState, +// AudioPlayerPlaybackState and InternalAudioPlayerState so who knows what to call this. +enum MediaPlayerState { + case loading + case playing + case paused + case stopped + case error +} + enum AudioPlayerAction { case didStartLoading case didFinishLoading @@ -22,8 +33,21 @@ enum AudioPlayerAction { case didFailWithError(error: Error) } -protocol AudioPlayerProtocol: MediaPlayerProtocol { +protocol AudioPlayerProtocol: AnyObject { + var sourceURL: URL? { get } + var duration: TimeInterval { get } + var currentTime: TimeInterval { get } + var playbackURL: URL? { get } + var state: MediaPlayerState { get } + var actions: AnyPublisher { get } + + func load(sourceURL: URL, playbackURL: URL, autoplay: Bool) + func reset() + func play() + func pause() + func stop() + func seek(to progress: Double) async } // sourcery: AutoMockable diff --git a/ElementX/Sources/Services/Audio/Player/AudioPlayerState.swift b/ElementX/Sources/Services/Audio/Player/AudioPlayerState.swift index b0ab2abc31..2b468e28de 100644 --- a/ElementX/Sources/Services/Audio/Player/AudioPlayerState.swift +++ b/ElementX/Sources/Services/Audio/Player/AudioPlayerState.swift @@ -134,7 +134,7 @@ class AudioPlayerState: ObservableObject, Identifiable { MXLog.info("updating duration: \(duration) -> \(audioPlayerDuration)") duration = audioPlayerDuration } - fileURL = audioPlayer?.url + fileURL = audioPlayer?.playbackURL playbackState = .readyToPlay case .didStartPlaying: if let audioPlayer { diff --git a/ElementX/Sources/Services/Client/ClientProxyProtocol.swift b/ElementX/Sources/Services/Client/ClientProxyProtocol.swift index 0feae1793e..d13b363093 100644 --- a/ElementX/Sources/Services/Client/ClientProxyProtocol.swift +++ b/ElementX/Sources/Services/Client/ClientProxyProtocol.swift @@ -68,7 +68,7 @@ struct RoomPreviewDetails { let topic: String? let avatarURL: URL? let memberCount: UInt - let isHistoryWorldReadable: Bool + let isHistoryWorldReadable: Bool? let isJoined: Bool let isInvited: Bool let isPublic: Bool diff --git a/ElementX/Sources/Services/Media/Provider/MediaSourceProxy.swift b/ElementX/Sources/Services/Media/Provider/MediaSourceProxy.swift index abfb3b2fee..50023b5626 100644 --- a/ElementX/Sources/Services/Media/Provider/MediaSourceProxy.swift +++ b/ElementX/Sources/Services/Media/Provider/MediaSourceProxy.swift @@ -24,7 +24,10 @@ struct MediaSourceProxy: Hashable { } init(url: URL, mimeType: String?) { - underlyingSource = mediaSourceFromUrl(url: url.absoluteString) + guard let mediaSource = try? MediaSource.fromUrl(url: url.absoluteString) else { + fatalError("Unable to create MediaSource from URL: \(url.absoluteString)") + } + underlyingSource = mediaSource self.url = URL(string: underlyingSource.url()) self.mimeType = mimeType } diff --git a/ElementX/Sources/Services/MediaPlayer/MediaPlayerProtocol.swift b/ElementX/Sources/Services/MediaPlayer/MediaPlayerProtocol.swift deleted file mode 100644 index e955061139..0000000000 --- a/ElementX/Sources/Services/MediaPlayer/MediaPlayerProtocol.swift +++ /dev/null @@ -1,34 +0,0 @@ -// -// Copyright 2023, 2024 New Vector Ltd. -// -// SPDX-License-Identifier: AGPL-3.0-only -// Please see LICENSE in the repository root for full details. -// - -import Foundation - -enum MediaPlayerState { - case loading - case playing - case paused - case stopped - case error -} - -protocol MediaPlayerProtocol: AnyObject { - var mediaSource: MediaSourceProxy? { get } - var duration: TimeInterval { get } - var currentTime: TimeInterval { get } - var url: URL? { get } - var state: MediaPlayerState { get } - - func load(mediaSource: MediaSourceProxy, using url: URL, autoplay: Bool) - func reset() - func play() - func pause() - func stop() - func seek(to progress: Double) async -} - -// sourcery: AutoMockable -extension MediaPlayerProtocol { } diff --git a/ElementX/Sources/Services/MediaPlayer/MediaPlayerProvider.swift b/ElementX/Sources/Services/MediaPlayer/MediaPlayerProvider.swift index 894269cc56..e6399259e2 100644 --- a/ElementX/Sources/Services/MediaPlayer/MediaPlayerProvider.swift +++ b/ElementX/Sources/Services/MediaPlayer/MediaPlayerProvider.swift @@ -11,24 +11,12 @@ class MediaPlayerProvider: MediaPlayerProviderProtocol { private lazy var audioPlayer = AudioPlayer() private var audioPlayerStates: [String: AudioPlayerState] = [:] + var player: AudioPlayerProtocol { audioPlayer } + deinit { audioPlayerStates = [:] } - func player(for mediaSource: MediaSourceProxy) -> Result { - guard let mimeType = mediaSource.mimeType else { - MXLog.error("Unknown mime type") - return .failure(.unsupportedMediaType) - } - - if mimeType.starts(with: "audio/") { - return .success(audioPlayer) - } else { - MXLog.error("Unsupported media type: \(mediaSource.mimeType ?? "unknown")") - return .failure(.unsupportedMediaType) - } - } - // MARK: - AudioPlayer func playerState(for id: AudioPlayerStateIdentifier) -> AudioPlayerState? { diff --git a/ElementX/Sources/Services/MediaPlayer/MediaPlayerProviderProtocol.swift b/ElementX/Sources/Services/MediaPlayer/MediaPlayerProviderProtocol.swift index c1cb2b74ee..479e3796af 100644 --- a/ElementX/Sources/Services/MediaPlayer/MediaPlayerProviderProtocol.swift +++ b/ElementX/Sources/Services/MediaPlayer/MediaPlayerProviderProtocol.swift @@ -13,7 +13,7 @@ enum MediaPlayerProviderError: Error { @MainActor protocol MediaPlayerProviderProtocol { - func player(for mediaSource: MediaSourceProxy) -> Result + var player: AudioPlayerProtocol { get } func playerState(for id: AudioPlayerStateIdentifier) -> AudioPlayerState? func register(audioPlayerState: AudioPlayerState) diff --git a/ElementX/Sources/Services/Timeline/TimelineItemProxy.swift b/ElementX/Sources/Services/Timeline/TimelineItemProxy.swift index 11177b93bf..776a6c5522 100644 --- a/ElementX/Sources/Services/Timeline/TimelineItemProxy.swift +++ b/ElementX/Sources/Services/Timeline/TimelineItemProxy.swift @@ -243,7 +243,7 @@ struct VideoInfoProxy: Hashable { } static var mockVideo: VideoInfoProxy { - .init(source: .init(url: .picturesDirectory, mimeType: nil), + .init(source: .init(url: .mockMXCVideo, mimeType: nil), duration: 100, size: .init(width: 1920, height: 1080), aspectRatio: 1.78, @@ -292,14 +292,14 @@ struct ImageInfoProxy: Hashable { } static var mockImage: ImageInfoProxy { - .init(source: .init(url: .picturesDirectory, mimeType: "image/png"), + .init(source: .init(url: .mockMXCImage, mimeType: "image/png"), size: .init(width: 100, height: 100), aspectRatio: 1, mimeType: "image/png") } static var mockThumbnail: ImageInfoProxy { - .init(source: .init(url: .picturesDirectory, mimeType: nil), + .init(source: .init(url: .mockMXCImage, mimeType: nil), size: nil, aspectRatio: nil, mimeType: nil) diff --git a/ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorder.swift b/ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorder.swift index e907aed2c0..55f5f8769b 100644 --- a/ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorder.swift +++ b/ElementX/Sources/Services/VoiceMessage/VoiceMessageRecorder.swift @@ -101,13 +101,12 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol { await previewAudioPlayerState.attachAudioPlayer(audioPlayer) } - if audioPlayer.url == url { + if audioPlayer.playbackURL == url { audioPlayer.play() return .success(()) } - let pendingMediaSource = MediaSourceProxy(url: url, mimeType: mp4accMimeType) - audioPlayer.load(mediaSource: pendingMediaSource, using: url, autoplay: true) + audioPlayer.load(sourceURL: url, playbackURL: url, autoplay: true) return .success(()) } @@ -242,10 +241,7 @@ class VoiceMessageRecorder: VoiceMessageRecorderProtocol { previewAudioPlayerState = await AudioPlayerState(id: .recorderPreview, title: L10n.commonVoiceMessage, duration: recordingDuration, waveform: EstimatedWaveform(data: [])) // Build the preview audio player - let mediaSource = MediaSourceProxy(url: url, mimeType: mp4accMimeType) - guard case .success(let mediaPlayer) = await mediaPlayerProvider.player(for: mediaSource), let audioPlayer = mediaPlayer as? AudioPlayerProtocol else { - return .failure(.previewNotAvailable) - } + let audioPlayer = await mediaPlayerProvider.player previewAudioPlayer = audioPlayer return .success(()) diff --git a/ElementX/Sources/UITests/UITestsAppCoordinator.swift b/ElementX/Sources/UITests/UITestsAppCoordinator.swift index 73c4910754..56669b93f3 100644 --- a/ElementX/Sources/UITests/UITestsAppCoordinator.swift +++ b/ElementX/Sources/UITests/UITestsAppCoordinator.swift @@ -253,7 +253,7 @@ class MockScreen: Identifiable { let timelineController = MockRoomTimelineController() timelineController.timelineItems = RoomTimelineItemFixtures.smallChunk let parameters = RoomScreenCoordinatorParameters(clientProxy: ClientProxyMock(), - roomProxy: JoinedRoomProxyMock(.init(name: "New room", avatarURL: URL.picturesDirectory)), + roomProxy: JoinedRoomProxyMock(.init(name: "New room", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaProvider: MediaProviderMock(configuration: .init()), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -272,7 +272,7 @@ class MockScreen: Identifiable { let timelineController = MockRoomTimelineController() timelineController.timelineItems = RoomTimelineItemFixtures.default let parameters = RoomScreenCoordinatorParameters(clientProxy: ClientProxyMock(), - roomProxy: JoinedRoomProxyMock(.init(name: "New room", avatarURL: URL.picturesDirectory)), + roomProxy: JoinedRoomProxyMock(.init(name: "New room", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaProvider: MediaProviderMock(configuration: .init()), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -291,7 +291,7 @@ class MockScreen: Identifiable { let timelineController = MockRoomTimelineController() timelineController.timelineItems = RoomTimelineItemFixtures.smallChunkWithReadReceipts let parameters = RoomScreenCoordinatorParameters(clientProxy: ClientProxyMock(), - roomProxy: JoinedRoomProxyMock(.init(name: "New room", avatarURL: URL.picturesDirectory)), + roomProxy: JoinedRoomProxyMock(.init(name: "New room", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaProvider: MediaProviderMock(configuration: .init()), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -313,7 +313,7 @@ class MockScreen: Identifiable { timelineController.backPaginationResponses = [RoomTimelineItemFixtures.singleMessageChunk] timelineController.incomingItems = [RoomTimelineItemFixtures.incomingMessage] let parameters = RoomScreenCoordinatorParameters(clientProxy: ClientProxyMock(), - roomProxy: JoinedRoomProxyMock(.init(name: "Small timeline", avatarURL: URL.picturesDirectory)), + roomProxy: JoinedRoomProxyMock(.init(name: "Small timeline", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaProvider: MediaProviderMock(configuration: .init()), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -335,7 +335,7 @@ class MockScreen: Identifiable { timelineController.timelineItems = RoomTimelineItemFixtures.smallChunk timelineController.backPaginationResponses = [RoomTimelineItemFixtures.largeChunk] let parameters = RoomScreenCoordinatorParameters(clientProxy: ClientProxyMock(), - roomProxy: JoinedRoomProxyMock(.init(name: "Small timeline, paginating", avatarURL: URL.picturesDirectory)), + roomProxy: JoinedRoomProxyMock(.init(name: "Small timeline, paginating", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaProvider: MediaProviderMock(configuration: .init()), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -357,7 +357,7 @@ class MockScreen: Identifiable { timelineController.timelineItems = RoomTimelineItemFixtures.largeChunk timelineController.backPaginationResponses = [RoomTimelineItemFixtures.largeChunk] let parameters = RoomScreenCoordinatorParameters(clientProxy: ClientProxyMock(), - roomProxy: JoinedRoomProxyMock(.init(name: "Large timeline", avatarURL: URL.picturesDirectory)), + roomProxy: JoinedRoomProxyMock(.init(name: "Large timeline", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaProvider: MediaProviderMock(configuration: .init()), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -380,7 +380,7 @@ class MockScreen: Identifiable { timelineController.backPaginationResponses = [RoomTimelineItemFixtures.largeChunk] timelineController.incomingItems = [RoomTimelineItemFixtures.incomingMessage] let parameters = RoomScreenCoordinatorParameters(clientProxy: ClientProxyMock(), - roomProxy: JoinedRoomProxyMock(.init(name: "Large timeline", avatarURL: URL.picturesDirectory)), + roomProxy: JoinedRoomProxyMock(.init(name: "Large timeline", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaProvider: MediaProviderMock(configuration: .init()), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -402,7 +402,7 @@ class MockScreen: Identifiable { timelineController.timelineItems = RoomTimelineItemFixtures.largeChunk timelineController.incomingItems = [RoomTimelineItemFixtures.incomingMessage] let parameters = RoomScreenCoordinatorParameters(clientProxy: ClientProxyMock(), - roomProxy: JoinedRoomProxyMock(.init(name: "Large timeline", avatarURL: URL.picturesDirectory)), + roomProxy: JoinedRoomProxyMock(.init(name: "Large timeline", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaProvider: MediaProviderMock(configuration: .init()), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -423,7 +423,7 @@ class MockScreen: Identifiable { let timelineController = MockRoomTimelineController() timelineController.timelineItems = RoomTimelineItemFixtures.permalinkChunk let parameters = RoomScreenCoordinatorParameters(clientProxy: ClientProxyMock(), - roomProxy: JoinedRoomProxyMock(.init(name: "Timeline highlight", avatarURL: URL.picturesDirectory)), + roomProxy: JoinedRoomProxyMock(.init(name: "Timeline highlight", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaProvider: MediaProviderMock(configuration: .init()), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -458,7 +458,7 @@ class MockScreen: Identifiable { timelineController.timelineItems = RoomTimelineItemFixtures.disclosedPolls timelineController.incomingItems = [] let parameters = RoomScreenCoordinatorParameters(clientProxy: ClientProxyMock(), - roomProxy: JoinedRoomProxyMock(.init(name: "Polls timeline", avatarURL: URL.picturesDirectory)), + roomProxy: JoinedRoomProxyMock(.init(name: "Polls timeline", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaProvider: MediaProviderMock(configuration: .init()), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -480,7 +480,7 @@ class MockScreen: Identifiable { timelineController.timelineItems = RoomTimelineItemFixtures.undisclosedPolls timelineController.incomingItems = [] let parameters = RoomScreenCoordinatorParameters(clientProxy: ClientProxyMock(), - roomProxy: JoinedRoomProxyMock(.init(name: "Polls timeline", avatarURL: URL.picturesDirectory)), + roomProxy: JoinedRoomProxyMock(.init(name: "Polls timeline", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaProvider: MediaProviderMock(configuration: .init()), mediaPlayerProvider: MediaPlayerProviderMock(), @@ -502,7 +502,7 @@ class MockScreen: Identifiable { timelineController.timelineItems = RoomTimelineItemFixtures.outgoingPolls timelineController.incomingItems = [] let parameters = RoomScreenCoordinatorParameters(clientProxy: ClientProxyMock(), - roomProxy: JoinedRoomProxyMock(.init(name: "Polls timeline", avatarURL: URL.picturesDirectory)), + roomProxy: JoinedRoomProxyMock(.init(name: "Polls timeline", avatarURL: .mockMXCAvatar)), timelineController: timelineController, mediaProvider: MediaProviderMock(configuration: .init()), mediaPlayerProvider: MediaPlayerProviderMock(), diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_completionSuggestion-iPad-en-GB.1.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_completionSuggestion-iPad-en-GB.1.png index da48f52364..3b5c200b5d 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_completionSuggestion-iPad-en-GB.1.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_completionSuggestion-iPad-en-GB.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4dcc4ffc59ec9fc2f68bdce87a7f3d7bff27b1a2f7113df0669d1170e7a68045 -size 88606 +oid sha256:f6e63d693948eb3139609c45c2511a6db5213ba6d312082deba2dcca31bb836d +size 92248 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_completionSuggestion-iPad-pseudo.1.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_completionSuggestion-iPad-pseudo.1.png index da48f52364..3b5c200b5d 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_completionSuggestion-iPad-pseudo.1.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_completionSuggestion-iPad-pseudo.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:4dcc4ffc59ec9fc2f68bdce87a7f3d7bff27b1a2f7113df0669d1170e7a68045 -size 88606 +oid sha256:f6e63d693948eb3139609c45c2511a6db5213ba6d312082deba2dcca31bb836d +size 92248 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_completionSuggestion-iPhone-16-en-GB.1.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_completionSuggestion-iPhone-16-en-GB.1.png index 31587cb5a6..2ad9f0eab3 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_completionSuggestion-iPhone-16-en-GB.1.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_completionSuggestion-iPhone-16-en-GB.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aceb415158105cb684244cc5d468ac24915aa4a2c1e0f03e4b95915dea604f44 -size 46009 +oid sha256:141cf3859c4b421be24e2409abc2d6bb4b53ff3c9878811cdbb6b67c901251a7 +size 49837 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_completionSuggestion-iPhone-16-pseudo.1.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_completionSuggestion-iPhone-16-pseudo.1.png index 31587cb5a6..2ad9f0eab3 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_completionSuggestion-iPhone-16-pseudo.1.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_completionSuggestion-iPhone-16-pseudo.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:aceb415158105cb684244cc5d468ac24915aa4a2c1e0f03e4b95915dea604f44 -size 46009 +oid sha256:141cf3859c4b421be24e2409abc2d6bb4b53ff3c9878811cdbb6b67c901251a7 +size 49837 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_composerToolbar-iPad-en-GB.With-Suggestions.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_composerToolbar-iPad-en-GB.With-Suggestions.png index e594e1dd0b..fce9df4b14 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_composerToolbar-iPad-en-GB.With-Suggestions.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_composerToolbar-iPad-en-GB.With-Suggestions.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:1b8ef13343f827c0dc3e9aaf74ce28f8a3e96bb0f4b9aa457e6a9ff40b3ad632 -size 98059 +oid sha256:ad795840c41305dbe8028cfea18b8fe25d3be2ab9524bc3322ed77726df25bcb +size 101810 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_composerToolbar-iPad-pseudo.With-Suggestions.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_composerToolbar-iPad-pseudo.With-Suggestions.png index 0deed32f47..1b2a6cd0d3 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_composerToolbar-iPad-pseudo.With-Suggestions.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_composerToolbar-iPad-pseudo.With-Suggestions.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:516b16553d506445d965c708a5f56e5b9c53b23488809a2513a56c2368a2d633 -size 98477 +oid sha256:70452fc6801a7a7778992bc40ef49c929744d76f0285e2f1aec33c09a5ae3242 +size 102228 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_composerToolbar-iPhone-16-en-GB.With-Suggestions.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_composerToolbar-iPhone-16-en-GB.With-Suggestions.png index b4ce7760f4..322efcd586 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_composerToolbar-iPhone-16-en-GB.With-Suggestions.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_composerToolbar-iPhone-16-en-GB.With-Suggestions.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b4bc7dbfbb1c7c58641f7d19bcb648e792220c19919b9001b09bdc8ccda0c86f -size 53599 +oid sha256:26b773b1dd1468c8298fc18062e9cc8749698536c19ca643acb1551f9293fb91 +size 57194 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_composerToolbar-iPhone-16-pseudo.With-Suggestions.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_composerToolbar-iPhone-16-pseudo.With-Suggestions.png index 0c9096622a..1e2990cb14 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_composerToolbar-iPhone-16-pseudo.With-Suggestions.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_composerToolbar-iPhone-16-pseudo.With-Suggestions.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:fd4bca95fba0ed2e11a1212c1ac3d1a638815274c370a1bdb4a3dd825c89de6d -size 54013 +oid sha256:6a952ed17097a7d8d6b16d3a330e1eaf3fdea80dac026618d456b561ff10c39a +size 57608 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Invite.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Invite.png index f190faed8f..f9236284a9 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Invite.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Invite.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d5b3a8bd64746aad774b15fc3e3500bbab4144d64ed4f8714f9b2527c70a494c -size 1990774 +oid sha256:8927edf5a98a3beae9d1dd2a61985b5402b72ab5688a2960a8c65b726b28e7a8 +size 2016923 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Join.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Join.png index a140b1c4b7..3218c7edd5 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Join.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Join.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:b6be25a2a046c3d1088ae6f87e4e1e0033062225c624095d679f1083ffe538b6 -size 1945746 +oid sha256:c9390f013722ba23d3b9ade888bc484e7b276e223f135d6641371d60da690397 +size 1971897 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Knock.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Knock.png index 80328b815e..477eae3b2c 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Knock.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Knock.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:46447c25230d95f04d122924d938f6f4b5eacd633140e586c3c276322f8e8b75 -size 1791354 +oid sha256:2347df221ddac84740cf5436620bb07bf3e7f24aea85e6dceec11f8d374a66d0 +size 1817511 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Knocked.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Knocked.png index be7b7aed9e..c7919792e2 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Knocked.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-en-GB.Knocked.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e0070dcdfe989211600c14fdb7b96af79cfb2b50ae8c3d560f7fe738b368be48 -size 1982637 +oid sha256:630995e1d62ff737c63bda878adec6756c0baa5a0136fb898f9cbf07ef52aa43 +size 1987392 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Invite.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Invite.png index 3691161625..d793b5ec09 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Invite.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Invite.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:41f91af2b20ff571cdf281d4dedaf1f6749a8fdaf33508a1b70511ef6e477af4 -size 1995837 +oid sha256:177f9b216f7716c511037ad044d08c499bc1d33b576d46dbda7d6c67bb513f1e +size 2022040 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Join.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Join.png index daf9980781..ae566af5c2 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Join.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Join.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:daf1b08dbe20c63aa66d1c16e3bc41fdc92a54ad4f143ccfcd9ca8382964a0fe -size 1946727 +oid sha256:a13076406c868e7b86d89782752c1fe70776151623c18d6fe47e59671120e0d7 +size 1972878 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Knock.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Knock.png index e0acdc11eb..2b13d28459 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Knock.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Knock.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:08e0296e33a657e0c42f95cb2e4963cb8f32c3a37979262cd76bc4c3ac3a7132 -size 1799819 +oid sha256:69ad1bad58cd73c5626fdf52923f6a0955221f5673b4485c131048d64b215c84 +size 1825976 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Knocked.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Knocked.png index 1a6c7a7702..2a844d9813 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Knocked.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPad-pseudo.Knocked.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8283d5d60db3b91caa096216e4dbb1d5e5342375080c81e5814acbb01b41c8c9 -size 2000079 +oid sha256:a81a307b980a5e1d950c98d2fe2981d0cf138da722d76007dd2f61693d85c208 +size 2004686 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Invite.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Invite.png index 30981c1a0a..8eb621c81f 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Invite.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Invite.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:616a8a5fe92ef87797d9a69bd5d7581e685edad21b002bf079d1a02fdb782987 -size 827638 +oid sha256:329b0b5fd32c1e395f969a006d2b56d399292abdee46d6e15df89bf3a8005d89 +size 851720 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Join.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Join.png index 4e9483a8df..f22223291a 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Join.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Join.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6d7390ef83a9fb7e8887aff95c03282d4fbcf3826cf3e254d523373a2c434df0 -size 798961 +oid sha256:9f6a60932fcba3f2bcd0127af134fd7005cc74a3ba02bfa1717466c35e92ad8c +size 823057 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Knock.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Knock.png index ce2bdf2f6b..eecc7badea 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Knock.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Knock.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3f9518a386e4c12c9e1527eb5f841fb0ca56fc8658529b58d6d459376caca39b -size 705027 +oid sha256:438018482d1792510fd3d07df8f9ba72ca7ddf3f1e69d7ab0b0adcdbe7a8b0f8 +size 729066 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Knocked.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Knocked.png index 8db4a97964..3f5ee33021 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Knocked.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-en-GB.Knocked.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:19d3b48e373ed4e263c9cb0f6e5a3566a9c6612f19da8468be420eca0a10cd92 -size 819795 +oid sha256:72ccc0e3a37d2f8728fc59240b0a11099594e8576a4d89b2ad462ba422a2d38f +size 824019 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Invite.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Invite.png index 1de1b350e5..422ad1cbd5 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Invite.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Invite.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6ecca9bbfa7a1d245a96fc27aacfb5d60931ba1437639ebd8e9ff1756bd705c6 -size 835366 +oid sha256:2fb7e4c00fd1d30189f80d8abcf05dd3048039ce61a387f98691bfb618c9218e +size 859617 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Join.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Join.png index 42fb8407bb..0920fc6c93 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Join.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Join.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:450d28a2af4b81f2db2e8a1fb28405d029439cabf5f48688b448391dd7e43b05 -size 800675 +oid sha256:bd08e040f1aff5e3ca2b50965a2bb368557134e8e3bc5bd6e390a1b4a328ae67 +size 824771 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Knock.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Knock.png index dfd17d6251..70405c8970 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Knock.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Knock.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:858759589a323ce04e894f398c230c0454f64a3c3148b183f9ecdbeb29955b89 -size 714177 +oid sha256:03f9fedddcc22df3d14c21cb5314cdd8fdf17592032f57bb762b7c1fe1bbf5ca +size 738216 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Knocked.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Knocked.png index 8407998f15..a1596ce245 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Knocked.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_joinRoomScreen-iPhone-16-pseudo.Knocked.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:eb3a1c2ac88a74a4f9c402a46a8512abc2596937b92c3d17fa30a7cdf10ce22a -size 835796 +oid sha256:d9482f0f3428f1826ef0e5d7e83d65aa895fc88c8db8a756c8c93c2767300f99 +size 840024 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_mentionSuggestionItemView-iPad-en-GB.1.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_mentionSuggestionItemView-iPad-en-GB.1.png index eaa1387802..1b3feed28c 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_mentionSuggestionItemView-iPad-en-GB.1.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_mentionSuggestionItemView-iPad-en-GB.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:189a2f7d717020e1fdc38c758446fe00ecc6279fc29295df48fee6b11e2c0e45 -size 72244 +oid sha256:d00776a5033ba2bf44c909bd5c41a422ba3f8675bab60cee885788440f38a34a +size 76078 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_mentionSuggestionItemView-iPad-pseudo.1.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_mentionSuggestionItemView-iPad-pseudo.1.png index eaa1387802..1b3feed28c 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_mentionSuggestionItemView-iPad-pseudo.1.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_mentionSuggestionItemView-iPad-pseudo.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:189a2f7d717020e1fdc38c758446fe00ecc6279fc29295df48fee6b11e2c0e45 -size 72244 +oid sha256:d00776a5033ba2bf44c909bd5c41a422ba3f8675bab60cee885788440f38a34a +size 76078 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_mentionSuggestionItemView-iPhone-16-en-GB.1.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_mentionSuggestionItemView-iPhone-16-en-GB.1.png index 9b2ae835eb..de20826930 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_mentionSuggestionItemView-iPhone-16-en-GB.1.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_mentionSuggestionItemView-iPhone-16-en-GB.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a707341b7229847083f074c637678863b24e8bab3da2be830313c33236e1006d -size 31580 +oid sha256:87252ee182a5c1c0c8827b9fbb4679fcac0ad6829d92702f37a94d42ff069e91 +size 35403 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_mentionSuggestionItemView-iPhone-16-pseudo.1.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_mentionSuggestionItemView-iPhone-16-pseudo.1.png index 9b2ae835eb..de20826930 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_mentionSuggestionItemView-iPhone-16-pseudo.1.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_mentionSuggestionItemView-iPhone-16-pseudo.1.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:a707341b7229847083f074c637678863b24e8bab3da2be830313c33236e1006d -size 31580 +oid sha256:87252ee182a5c1c0c8827b9fbb4679fcac0ad6829d92702f37a94d42ff069e91 +size 35403 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_readReceiptCell-iPad-en-GB.With-Image.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_readReceiptCell-iPad-en-GB.With-Image.png index 984cf823e5..9dfa406a12 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_readReceiptCell-iPad-en-GB.With-Image.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_readReceiptCell-iPad-en-GB.With-Image.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:290f71a4d1e5bab703e3a4483acdbd3605ff9df65c18bbfdc7cca3297e516584 -size 76118 +oid sha256:7b6f71e4c5caef9d16e44bb90c0e2051db32467c190479271e9e9f50f249bad4 +size 79950 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_readReceiptCell-iPad-pseudo.With-Image.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_readReceiptCell-iPad-pseudo.With-Image.png index 984cf823e5..9dfa406a12 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_readReceiptCell-iPad-pseudo.With-Image.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_readReceiptCell-iPad-pseudo.With-Image.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:290f71a4d1e5bab703e3a4483acdbd3605ff9df65c18bbfdc7cca3297e516584 -size 76118 +oid sha256:7b6f71e4c5caef9d16e44bb90c0e2051db32467c190479271e9e9f50f249bad4 +size 79950 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_readReceiptCell-iPhone-16-en-GB.With-Image.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_readReceiptCell-iPhone-16-en-GB.With-Image.png index e3caddf9a0..485685cc39 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_readReceiptCell-iPhone-16-en-GB.With-Image.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_readReceiptCell-iPhone-16-en-GB.With-Image.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:da24b677846f3088c15a2dc4a6d3de517bf499ce62bc0ad58586912179019286 -size 35184 +oid sha256:951bde2a3cc7a130218d8123e8d91469efdd14f66ff251154f0b803d9e378ffb +size 39094 diff --git a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_readReceiptCell-iPhone-16-pseudo.With-Image.png b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_readReceiptCell-iPhone-16-pseudo.With-Image.png index e3caddf9a0..485685cc39 100644 --- a/PreviewTests/Sources/__Snapshots__/PreviewTests/test_readReceiptCell-iPhone-16-pseudo.With-Image.png +++ b/PreviewTests/Sources/__Snapshots__/PreviewTests/test_readReceiptCell-iPhone-16-pseudo.With-Image.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:da24b677846f3088c15a2dc4a6d3de517bf499ce62bc0ad58586912179019286 -size 35184 +oid sha256:951bde2a3cc7a130218d8123e8d91469efdd14f66ff251154f0b803d9e378ffb +size 39094 diff --git a/UnitTests/Sources/ComposerToolbarViewModelTests.swift b/UnitTests/Sources/ComposerToolbarViewModelTests.swift index f1a1123282..fbecde99de 100644 --- a/UnitTests/Sources/ComposerToolbarViewModelTests.swift +++ b/UnitTests/Sources/ComposerToolbarViewModelTests.swift @@ -91,7 +91,7 @@ class ComposerToolbarViewModelTests: XCTestCase { func testSuggestions() { let suggestions: [SuggestionItem] = [.user(item: MentionSuggestionItem(id: "@user_mention_1:matrix.org", displayName: "User 1", avatarURL: nil, range: .init())), - .user(item: MentionSuggestionItem(id: "@user_mention_2:matrix.org", displayName: "User 2", avatarURL: URL.documentsDirectory, range: .init()))] + .user(item: MentionSuggestionItem(id: "@user_mention_2:matrix.org", displayName: "User 2", avatarURL: .mockMXCAvatar, range: .init()))] let mockCompletionSuggestionService = CompletionSuggestionServiceMock(configuration: .init(suggestions: suggestions)) viewModel = ComposerToolbarViewModel(wysiwygViewModel: wysiwygViewModel, completionSuggestionService: mockCompletionSuggestionService, diff --git a/UnitTests/Sources/MediaPlayerProviderTests.swift b/UnitTests/Sources/MediaPlayerProviderTests.swift index 92ef5997d5..d4837d4728 100644 --- a/UnitTests/Sources/MediaPlayerProviderTests.swift +++ b/UnitTests/Sources/MediaPlayerProviderTests.swift @@ -15,50 +15,13 @@ class MediaPlayerProviderTests: XCTestCase { private var mediaPlayerProvider: MediaPlayerProvider! private let oggMimeType = "audio/ogg" - private let someURL = URL("/some/url") - private let someOtherURL = URL("/some/other/url") + private let someURL = URL.mockMXCAudio + private let someOtherURL = URL.mockMXCFile override func setUp() async throws { mediaPlayerProvider = MediaPlayerProvider() } - func testPlayerForWrongMediaType() async throws { - let mediaSourceWithoutMimeType = MediaSourceProxy(url: someURL, mimeType: nil) - switch mediaPlayerProvider.player(for: mediaSourceWithoutMimeType) { - case .failure(.unsupportedMediaType): - // Ok - break - default: - XCTFail("An error is expected") - } - - let mediaSourceVideo = MediaSourceProxy(url: someURL, mimeType: "video/mp4") - switch mediaPlayerProvider.player(for: mediaSourceVideo) { - case .failure(.unsupportedMediaType): - // Ok - break - default: - XCTFail("An error is expected") - } - } - - func testPlayerFor() async throws { - let mediaSource = MediaSourceProxy(url: someURL, mimeType: oggMimeType) - guard case .success(let playerA) = mediaPlayerProvider.player(for: mediaSource) else { - XCTFail("A valid player is expected") - return - } - - // calling it again with another mediasource must returns the same player - let otherMediaSource = MediaSourceProxy(url: someOtherURL, mimeType: oggMimeType) - guard case .success(let playerB) = mediaPlayerProvider.player(for: otherMediaSource) else { - XCTFail("A valid player is expected") - return - } - - XCTAssert(playerA === playerB) - } - func testPlayerStates() async throws { let audioPlayerStateId = AudioPlayerStateIdentifier.timelineItemIdentifier(.randomEvent) // By default, there should be no player state diff --git a/UnitTests/Sources/MediaProvider/MediaLoaderTests.swift b/UnitTests/Sources/MediaProvider/MediaLoaderTests.swift index 09d024d381..2e2b6e7d87 100644 --- a/UnitTests/Sources/MediaProvider/MediaLoaderTests.swift +++ b/UnitTests/Sources/MediaProvider/MediaLoaderTests.swift @@ -15,7 +15,7 @@ final class MediaLoaderTests: XCTestCase { mediaLoadingClient.getMediaContentMediaSourceReturnValue = Data() let mediaLoader = MediaLoader(client: mediaLoadingClient) - let mediaSource = MediaSourceProxy(url: URL.documentsDirectory, mimeType: nil) + let mediaSource = MediaSourceProxy(url: .mockMXCFile, mimeType: nil) do { for _ in 1...10 { @@ -33,7 +33,7 @@ final class MediaLoaderTests: XCTestCase { mediaLoadingClient.getMediaThumbnailMediaSourceWidthHeightReturnValue = Data() let mediaLoader = MediaLoader(client: mediaLoadingClient) - let mediaSource = MediaSourceProxy(url: URL.documentsDirectory, mimeType: nil) + let mediaSource = MediaSourceProxy(url: .mockMXCImage, mimeType: nil) do { for _ in 1...10 { diff --git a/UnitTests/Sources/MediaProvider/MediaProviderTests.swift b/UnitTests/Sources/MediaProvider/MediaProviderTests.swift index 98712ba6c9..9e1dc87bd4 100644 --- a/UnitTests/Sources/MediaProvider/MediaProviderTests.swift +++ b/UnitTests/Sources/MediaProvider/MediaProviderTests.swift @@ -36,7 +36,7 @@ final class MediaProviderTests: XCTestCase { return } - let loadTask = mediaProvider.loadImageRetryingOnReconnection(MediaSourceProxy(url: URL.picturesDirectory, mimeType: "image/jpeg")) + let loadTask = mediaProvider.loadImageRetryingOnReconnection(MediaSourceProxy(url: .mockMXCImage, mimeType: "image/jpeg")) let connectivitySubject = CurrentValueSubject(.unreachable) @@ -59,7 +59,7 @@ final class MediaProviderTests: XCTestCase { } func testLoadingRetriedOnReconnectionCancelsAfterSecondFailure() async throws { - let loadTask = mediaProvider.loadImageRetryingOnReconnection(MediaSourceProxy(url: URL.picturesDirectory, mimeType: "image/jpeg")) + let loadTask = mediaProvider.loadImageRetryingOnReconnection(MediaSourceProxy(url: .mockMXCImage, mimeType: "image/jpeg")) let connectivitySubject = CurrentValueSubject(.reachable) @@ -79,7 +79,7 @@ final class MediaProviderTests: XCTestCase { func test_whenImageFromSourceWithSourceNotNilAndImageCacheContainsImage_ImageIsReturned() throws { let avatarSize = Avatars.Size.room(on: .timeline) - let url = URL.picturesDirectory + let url = URL.mockMXCImage let key = "\(url.absoluteString){\(avatarSize.scaledValue),\(avatarSize.scaledValue)}" let imageForKey = UIImage() imageCache.retrievedImagesInMemory[key] = imageForKey @@ -89,14 +89,14 @@ final class MediaProviderTests: XCTestCase { } func test_whenImageFromSourceWithSourceNotNilAndImageNotCached_nilReturned() throws { - let image = mediaProvider.imageFromSource(MediaSourceProxy(url: URL.picturesDirectory, mimeType: "image/jpeg"), + let image = mediaProvider.imageFromSource(MediaSourceProxy(url: .mockMXCImage, mimeType: "image/jpeg"), size: Avatars.Size.room(on: .timeline).scaledSize) XCTAssertNil(image) } func test_whenLoadImageFromSourceAndImageCacheContainsImage_successIsReturned() async throws { let avatarSize = Avatars.Size.room(on: .timeline) - let url = URL.picturesDirectory + let url = URL.mockMXCImage let key = "\(url.absoluteString){\(avatarSize.scaledValue),\(avatarSize.scaledValue)}" let imageForKey = UIImage() imageCache.retrievedImagesInMemory[key] = imageForKey @@ -107,7 +107,7 @@ final class MediaProviderTests: XCTestCase { func test_whenLoadImageFromSourceAndImageNotCachedAndRetrieveImageSucceeds_successIsReturned() async throws { let avatarSize = Avatars.Size.room(on: .timeline) - let url = URL.picturesDirectory + let url = URL.mockMXCImage let key = "\(url.absoluteString){\(avatarSize.scaledValue),\(avatarSize.scaledValue)}" let imageForKey = UIImage() imageCache.retrievedImages[key] = imageForKey @@ -122,7 +122,7 @@ final class MediaProviderTests: XCTestCase { mediaLoader.loadMediaThumbnailForSourceWidthHeightReturnValue = expectedImage.pngData() - let result = await mediaProvider.loadImageFromSource(MediaSourceProxy(url: URL.picturesDirectory, mimeType: "image/jpeg"), + let result = await mediaProvider.loadImageFromSource(MediaSourceProxy(url: .mockMXCImage, mimeType: "image/jpeg"), size: avatarSize.scaledSize) switch result { case .success(let image): @@ -134,7 +134,7 @@ final class MediaProviderTests: XCTestCase { func test_whenLoadImageFromSourceAndImageNotCachedAndRetrieveImageFails_imageIsStored() async throws { let avatarSize = Avatars.Size.room(on: .timeline) - let url = URL.picturesDirectory + let url = URL.mockMXCImage let key = "\(url.absoluteString){\(avatarSize.scaledValue),\(avatarSize.scaledValue)}" let expectedImage = try loadTestImage() @@ -151,7 +151,7 @@ final class MediaProviderTests: XCTestCase { mediaLoader.loadMediaContentForSourceReturnValue = expectedImage.pngData() - let result = await mediaProvider.loadImageFromSource(MediaSourceProxy(url: URL.picturesDirectory, mimeType: "image/jpeg"), + let result = await mediaProvider.loadImageFromSource(MediaSourceProxy(url: .mockMXCImage, mimeType: "image/jpeg"), size: nil) switch result { case .success(let image): @@ -164,7 +164,7 @@ final class MediaProviderTests: XCTestCase { func test_whenLoadImageFromSourceAndImageNotCachedAndRetrieveImageFailsAndLoadImageThumbnailFails_errorIsThrown() async throws { mediaLoader.loadMediaThumbnailForSourceWidthHeightThrowableError = MediaProviderTestsError.error - let result = await mediaProvider.loadImageFromSource(MediaSourceProxy(url: URL.picturesDirectory, mimeType: "image/jpeg"), + let result = await mediaProvider.loadImageFromSource(MediaSourceProxy(url: .mockMXCImage, mimeType: "image/jpeg"), size: Avatars.Size.room(on: .timeline).scaledSize) switch result { case .success: @@ -177,7 +177,7 @@ final class MediaProviderTests: XCTestCase { func test_whenLoadImageFromSourceAndImageNotCachedAndRetrieveImageFailsAndNoAvatarSizeAndLoadImageContentFails_errorIsThrown() async throws { mediaLoader.loadMediaContentForSourceThrowableError = MediaProviderTestsError.error - let result = await mediaProvider.loadImageFromSource(MediaSourceProxy(url: URL.picturesDirectory, mimeType: "image/jpeg"), + let result = await mediaProvider.loadImageFromSource(MediaSourceProxy(url: .mockMXCImage, mimeType: "image/jpeg"), size: nil) switch result { case .success: @@ -190,7 +190,7 @@ final class MediaProviderTests: XCTestCase { func test_whenLoadImageFromSourceAndImageNotCachedAndRetrieveImageFailsAndImageThumbnailIsLoadedWithCorruptedData_errorIsThrown() async throws { mediaLoader.loadMediaThumbnailForSourceWidthHeightReturnValue = Data() - let result = await mediaProvider.loadImageFromSource(MediaSourceProxy(url: URL.picturesDirectory, mimeType: "image/jpeg"), + let result = await mediaProvider.loadImageFromSource(MediaSourceProxy(url: .mockMXCImage, mimeType: "image/jpeg"), size: Avatars.Size.room(on: .timeline).scaledSize) switch result { case .success: diff --git a/UnitTests/Sources/RoomDetailsEditScreenViewModelTests.swift b/UnitTests/Sources/RoomDetailsEditScreenViewModelTests.swift index 2088df6e3e..4befd2efbc 100644 --- a/UnitTests/Sources/RoomDetailsEditScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomDetailsEditScreenViewModelTests.swift @@ -58,7 +58,7 @@ class RoomDetailsEditScreenViewModelTests: XCTestCase { } func testAvatarDidChange() { - setupViewModel(roomProxyConfiguration: .init(name: "Some room", avatarURL: .picturesDirectory, members: [.mockMeAdmin])) + setupViewModel(roomProxyConfiguration: .init(name: "Some room", avatarURL: .mockMXCAvatar, members: [.mockMeAdmin])) context.send(viewAction: .removeImage) XCTAssertTrue(context.viewState.avatarDidChange) XCTAssertTrue(context.viewState.canSave) @@ -100,7 +100,7 @@ class RoomDetailsEditScreenViewModelTests: XCTestCase { } func testDeleteAvatar() { - setupViewModel(roomProxyConfiguration: .init(name: "Some room", avatarURL: .picturesDirectory, members: [.mockMeAdmin])) + setupViewModel(roomProxyConfiguration: .init(name: "Some room", avatarURL: .mockMXCAvatar, members: [.mockMeAdmin])) XCTAssertNotNil(context.viewState.avatarURL) context.send(viewAction: .removeImage) XCTAssertNil(context.viewState.avatarURL) diff --git a/UnitTests/Sources/RoomScreenViewModelTests.swift b/UnitTests/Sources/RoomScreenViewModelTests.swift index 773c9af2c7..306abca905 100644 --- a/UnitTests/Sources/RoomScreenViewModelTests.swift +++ b/UnitTests/Sources/RoomScreenViewModelTests.swift @@ -184,13 +184,13 @@ class RoomScreenViewModelTests: XCTestCase { try await deferred.fulfill() configuration.name = "NewName" - configuration.avatarURL = .documentsDirectory + configuration.avatarURL = .mockMXCAvatar configuration.hasOngoingCall = true roomProxyMock.canUserJoinCallUserIDReturnValue = .success(true) deferred = deferFulfillment(viewModel.context.$viewState) { viewState in viewState.roomTitle == "NewName" && - viewState.roomAvatar == .room(id: "TestID", name: "NewName", avatarURL: .documentsDirectory) && + viewState.roomAvatar == .room(id: "TestID", name: "NewName", avatarURL: .mockMXCAvatar) && viewState.canJoinCall && viewState.hasOngoingCall } diff --git a/UnitTests/Sources/UserProfileScreenViewModelTests.swift b/UnitTests/Sources/UserProfileScreenViewModelTests.swift index f040de8c28..6706966438 100644 --- a/UnitTests/Sources/UserProfileScreenViewModelTests.swift +++ b/UnitTests/Sources/UserProfileScreenViewModelTests.swift @@ -15,7 +15,7 @@ class UserProfileScreenViewModelTests: XCTestCase { var context: UserProfileScreenViewModelType.Context { viewModel.context } func testInitialState() async throws { - let profile = UserProfileProxy(userID: "@alice:matrix.org", displayName: "Alice", avatarURL: .picturesDirectory) + let profile = UserProfileProxy(userID: "@alice:matrix.org", displayName: "Alice", avatarURL: .mockMXCAvatar) let clientProxy = ClientProxyMock(.init()) clientProxy.profileForReturnValue = .success(profile) @@ -35,7 +35,7 @@ class UserProfileScreenViewModelTests: XCTestCase { } func testInitialStateAccountOwner() async throws { - let profile = UserProfileProxy(userID: RoomMemberProxyMock.mockMe.userID, displayName: "Me", avatarURL: .picturesDirectory) + let profile = UserProfileProxy(userID: RoomMemberProxyMock.mockMe.userID, displayName: "Me", avatarURL: .mockMXCAvatar) let clientProxy = ClientProxyMock(.init()) clientProxy.profileForReturnValue = .success(profile) diff --git a/UnitTests/Sources/VoiceMessageCacheTests.swift b/UnitTests/Sources/VoiceMessageCacheTests.swift index 12f8681486..7520867766 100644 --- a/UnitTests/Sources/VoiceMessageCacheTests.swift +++ b/UnitTests/Sources/VoiceMessageCacheTests.swift @@ -16,7 +16,7 @@ class VoiceMessageCacheTests: XCTestCase { private var mediaSource: MediaSourceProxy! private var fileManager: FileManager! - private let someURL = URL("/some/url") + private let someURL = URL.mockMXCAudio private let testFilename = "test-file" private let mpeg4aacFileExtension = "m4a" private let testTemporaryDirectory = URL.temporaryDirectory.appendingPathComponent("test-voice-messsage-cache") diff --git a/UnitTests/Sources/VoiceMessageMediaManagerTests.swift b/UnitTests/Sources/VoiceMessageMediaManagerTests.swift index 7a85f15dc4..2aeecf0624 100644 --- a/UnitTests/Sources/VoiceMessageMediaManagerTests.swift +++ b/UnitTests/Sources/VoiceMessageMediaManagerTests.swift @@ -16,7 +16,7 @@ class VoiceMessageMediaManagerTests: XCTestCase { private var voiceMessageCache: VoiceMessageCacheMock! private var mediaProvider: MediaProviderMock! - private let someURL = URL("/some/url") + private let someURL = URL.mockMXCAudio private let audioOGGMimeType = "audio/ogg" override func setUp() async throws { diff --git a/UnitTests/Sources/VoiceMessageRecorderTests.swift b/UnitTests/Sources/VoiceMessageRecorderTests.swift index bba8e525fb..a3c675c88f 100644 --- a/UnitTests/Sources/VoiceMessageRecorderTests.swift +++ b/UnitTests/Sources/VoiceMessageRecorderTests.swift @@ -43,9 +43,7 @@ class VoiceMessageRecorderTests: XCTestCase { audioPlayer.state = .stopped mediaPlayerProvider = MediaPlayerProviderMock() - mediaPlayerProvider.playerForClosure = { _ in - .success(self.audioPlayer) - } + mediaPlayerProvider.player = audioPlayer audioConverter = AudioConverterMock() voiceMessageCache = VoiceMessageCacheMock() voiceMessageCache.urlForRecording = FileManager.default.temporaryDirectory.appendingPathComponent("test-voice-message").appendingPathExtension("m4a") @@ -121,11 +119,10 @@ class VoiceMessageRecorderTests: XCTestCase { return } XCTAssertEqual(voiceMessageRecorder.previewAudioPlayerState?.isAttached, true) - XCTAssert(audioPlayer.loadMediaSourceUsingAutoplayCalled) - XCTAssertEqual(audioPlayer.loadMediaSourceUsingAutoplayReceivedArguments?.url, recordingURL) - XCTAssertEqual(audioPlayer.loadMediaSourceUsingAutoplayReceivedArguments?.mediaSource.mimeType, "audio/m4a") - XCTAssertEqual(audioPlayer.loadMediaSourceUsingAutoplayReceivedArguments?.mediaSource.url, recordingURL) - XCTAssertEqual(audioPlayer.loadMediaSourceUsingAutoplayReceivedArguments?.autoplay, true) + XCTAssert(audioPlayer.loadSourceURLPlaybackURLAutoplayCalled) + XCTAssertEqual(audioPlayer.loadSourceURLPlaybackURLAutoplayReceivedArguments?.sourceURL, recordingURL) + XCTAssertEqual(audioPlayer.loadSourceURLPlaybackURLAutoplayReceivedArguments?.playbackURL, recordingURL) + XCTAssertEqual(audioPlayer.loadSourceURLPlaybackURLAutoplayReceivedArguments?.autoplay, true) XCTAssertFalse(audioPlayer.playCalled) } @@ -141,7 +138,7 @@ class VoiceMessageRecorderTests: XCTestCase { func testResumePlayback() async throws { try await setRecordingComplete() - audioPlayer.url = recordingURL + audioPlayer.playbackURL = recordingURL guard case .success = await voiceMessageRecorder.startPlayback() else { XCTFail("Playback should start") @@ -149,7 +146,7 @@ class VoiceMessageRecorderTests: XCTestCase { } XCTAssertEqual(voiceMessageRecorder.previewAudioPlayerState?.isAttached, true) // The media must not have been reloaded - XCTAssertFalse(audioPlayer.loadMediaSourceUsingAutoplayCalled) + XCTAssertFalse(audioPlayer.loadSourceURLPlaybackURLAutoplayCalled) XCTAssertTrue(audioPlayer.playCalled) } diff --git a/project.yml b/project.yml index ea2d55d7c3..df794b7e46 100644 --- a/project.yml +++ b/project.yml @@ -61,7 +61,7 @@ packages: # Element/Matrix dependencies MatrixRustSDK: url: https://github.com/element-hq/matrix-rust-components-swift - exactVersion: 1.0.75 + exactVersion: 1.0.76 # path: ../matrix-rust-sdk Compound: url: https://github.com/element-hq/compound-ios