mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-03 16:10:20 +00:00
Fixed some issues with voice messages when sent from a bridge. (#2190)
This commit is contained in:
@@ -171,8 +171,9 @@ class AudioPlayerStateTests: XCTestCase {
|
||||
}
|
||||
|
||||
func testHandlingAudioPlayerActionDidFinishLoading() async throws {
|
||||
let originalStateProgress = 0.4
|
||||
await audioPlayerState.updateState(progress: originalStateProgress)
|
||||
audioPlayerMock.duration = 10.0
|
||||
|
||||
audioPlayerState = AudioPlayerState(id: .timelineItemIdentifier(.random), duration: 0)
|
||||
audioPlayerState.attachAudioPlayer(audioPlayerMock)
|
||||
|
||||
let deferred = deferFulfillment(audioPlayerState.$playbackState) { action in
|
||||
@@ -189,6 +190,8 @@ class AudioPlayerStateTests: XCTestCase {
|
||||
|
||||
// The state is expected to be .readyToPlay
|
||||
XCTAssertEqual(audioPlayerState.playbackState, .readyToPlay)
|
||||
// The duration should have been updated with the player's duration
|
||||
XCTAssertEqual(audioPlayerState.duration, audioPlayerMock.duration)
|
||||
}
|
||||
|
||||
func testHandlingAudioPlayerActionDidStartPlaying() async throws {
|
||||
|
||||
@@ -52,6 +52,29 @@ class VoiceMessageMediaManagerTests: XCTestCase {
|
||||
}
|
||||
}
|
||||
|
||||
func testLoadVoiceMessageFromSourceMimeTypeWithParameters() async throws {
|
||||
// URL representing the file loaded by the media provider
|
||||
let loadedFile = URL("/some/url/loaded_file.ogg")
|
||||
// URL representing the final cached file
|
||||
let cachedConvertedFileURL = URL("/some/url/cached_converted_file.m4a")
|
||||
|
||||
voiceMessageCache.fileURLForReturnValue = nil
|
||||
let mediaSource = MediaSourceProxy(url: someURL, mimeType: "audio/ogg; codecs=opus")
|
||||
mediaProvider.loadFileFromSourceReturnValue = MediaFileHandleProxy.unmanaged(url: loadedFile)
|
||||
voiceMessageCache.cacheMediaSourceUsingMoveReturnValue = .success(cachedConvertedFileURL)
|
||||
|
||||
voiceMessageMediaManager = VoiceMessageMediaManager(mediaProvider: mediaProvider,
|
||||
voiceMessageCache: voiceMessageCache,
|
||||
audioConverter: AudioConverterMock(),
|
||||
backgroundTaskService: MockBackgroundTaskService())
|
||||
|
||||
do {
|
||||
_ = try await voiceMessageMediaManager.loadVoiceMessageFromSource(mediaSource, body: nil)
|
||||
} catch {
|
||||
XCTFail("An unexpected error has occured: \(error)")
|
||||
}
|
||||
}
|
||||
|
||||
func testLoadVoiceMessageFromSourceAlreadyCached() async throws {
|
||||
// Check if the file is already present in cache
|
||||
voiceMessageCache.fileURLForReturnValue = URL("/converted_file/url")
|
||||
|
||||
Reference in New Issue
Block a user