New voice message recording mode (#2051)

* Lock voice message recording

* Use the VoiceMessageCache to store the recording file

* Rework on some composer toolbar buttons

* Update accessibility labels for voice message recording button

* PreviewTests
This commit is contained in:
Nicolas Mauri
2023-11-10 16:32:22 +01:00
committed by GitHub
parent 5a0dab1ce8
commit da831f6725
34 changed files with 283 additions and 296 deletions
@@ -466,6 +466,18 @@ class AudioPlayerMock: AudioPlayerProtocol {
loadMediaSourceUsingAutoplayReceivedInvocations.append((mediaSource: mediaSource, url: url, autoplay: autoplay))
loadMediaSourceUsingAutoplayClosure?(mediaSource, url, autoplay)
}
//MARK: - reset
var resetCallsCount = 0
var resetCalled: Bool {
return resetCallsCount > 0
}
var resetClosure: (() -> Void)?
func reset() {
resetCallsCount += 1
resetClosure?()
}
//MARK: - play
var playCallsCount = 0
@@ -535,23 +547,23 @@ class AudioRecorderMock: AudioRecorderProtocol {
set(value) { underlyingIsRecording = value }
}
var underlyingIsRecording: Bool!
var audioFileUrl: URL?
var audioFileURL: URL?
//MARK: - record
var recordWithCallsCount = 0
var recordWithCalled: Bool {
return recordWithCallsCount > 0
var recordAudioFileURLCallsCount = 0
var recordAudioFileURLCalled: Bool {
return recordAudioFileURLCallsCount > 0
}
var recordWithReceivedRecordID: AudioRecordingIdentifier?
var recordWithReceivedInvocations: [AudioRecordingIdentifier] = []
var recordWithClosure: ((AudioRecordingIdentifier) async -> Void)?
var recordAudioFileURLReceivedAudioFileURL: URL?
var recordAudioFileURLReceivedInvocations: [URL] = []
var recordAudioFileURLClosure: ((URL) async -> Void)?
func record(with recordID: AudioRecordingIdentifier) async {
recordWithCallsCount += 1
recordWithReceivedRecordID = recordID
recordWithReceivedInvocations.append(recordID)
await recordWithClosure?(recordID)
func record(audioFileURL: URL) async {
recordAudioFileURLCallsCount += 1
recordAudioFileURLReceivedAudioFileURL = audioFileURL
recordAudioFileURLReceivedInvocations.append(audioFileURL)
await recordAudioFileURLClosure?(audioFileURL)
}
//MARK: - stopRecording
@@ -1098,6 +1110,18 @@ class MediaPlayerMock: MediaPlayerProtocol {
loadMediaSourceUsingAutoplayReceivedInvocations.append((mediaSource: mediaSource, url: url, autoplay: autoplay))
loadMediaSourceUsingAutoplayClosure?(mediaSource, url, autoplay)
}
//MARK: - reset
var resetCallsCount = 0
var resetCalled: Bool {
return resetCallsCount > 0
}
var resetClosure: (() -> Void)?
func reset() {
resetCallsCount += 1
resetClosure?()
}
//MARK: - play
var playCallsCount = 0
@@ -3143,6 +3167,11 @@ class UserNotificationCenterMock: UserNotificationCenterProtocol {
}
}
class VoiceMessageCacheMock: VoiceMessageCacheProtocol {
var urlForRecording: URL {
get { return underlyingUrlForRecording }
set(value) { underlyingUrlForRecording = value }
}
var underlyingUrlForRecording: URL!
//MARK: - fileURL
@@ -3234,6 +3263,11 @@ class VoiceMessageRecorderMock: VoiceMessageRecorderProtocol {
}
var underlyingAudioRecorder: AudioRecorderProtocol!
var previewAudioPlayerState: AudioPlayerState?
var isRecording: Bool {
get { return underlyingIsRecording }
set(value) { underlyingIsRecording = value }
}
var underlyingIsRecording: Bool!
var recordingURL: URL?
var recordingDuration: TimeInterval {
get { return underlyingRecordingDuration }