Add unit tests for voice messages (#1869)

This commit is contained in:
Nicolas Mauri
2023-10-10 08:03:40 +02:00
committed by GitHub
parent f7bf4b6e20
commit cb9d35948e
7 changed files with 438 additions and 0 deletions
@@ -30,3 +30,6 @@ enum AudioPlayerAction {
protocol AudioPlayerProtocol: MediaPlayerProtocol {
var actions: AnyPublisher<AudioPlayerAction, Never> { get }
}
// sourcery: AutoMockable
extension AudioPlayerProtocol { }
@@ -40,6 +40,10 @@ class AudioPlayerState: ObservableObject {
var isAttached: Bool {
audioPlayer != nil
}
var isPublishingProgress: Bool {
cancellableTimer != nil
}
init(duration: Double, waveform: Waveform? = nil, progress: Double = 0.0) {
self.duration = duration
@@ -133,6 +137,7 @@ class AudioPlayerState: ObservableObject {
private func stopPublishProgress() {
cancellableTimer?.cancel()
cancellableTimer = nil
}
private func restoreAudioPlayerState(audioPlayer: AudioPlayerProtocol) async {
@@ -37,3 +37,6 @@ protocol MediaPlayerProtocol {
func stop()
func seek(to progress: Double) async
}
// sourcery: AutoMockable
extension MediaPlayerProtocol { }
@@ -19,3 +19,6 @@ import Foundation
protocol VoiceMessageMediaManagerProtocol {
func loadVoiceMessageFromSource(_ source: MediaSourceProxy, body: String?) async throws -> URL
}
// sourcery: AutoMockable
extension VoiceMessageMediaManagerProtocol { }