Implemented the resumed interrupted recordings and allowed processing discards on the RecordingViewModel view model in the Recording package target.
This commit is contained in:
@@ -5,6 +5,8 @@ import Recording
|
||||
/// configured to fail.
|
||||
@MainActor
|
||||
final class CapturingMock: Capturing {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// The stream of events the service emits outside its method calls.
|
||||
let events: AsyncStream<CapturingEvent>
|
||||
@@ -20,16 +22,29 @@ final class CapturingMock: Capturing {
|
||||
|
||||
/// The continuation that feeds ``events``.
|
||||
private let continuation: AsyncStream<CapturingEvent>.Continuation
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
init() {
|
||||
(events, continuation) = AsyncStream.makeStream(of: CapturingEvent.self)
|
||||
}
|
||||
|
||||
// MARK: Methods
|
||||
|
||||
/// Emits an interruption of the ongoing capture through ``events``.
|
||||
func interrupt() {
|
||||
continuation.yield(.interrupted)
|
||||
}
|
||||
|
||||
/// Emits the end of an interruption of the capture through ``events``.
|
||||
///
|
||||
/// - Parameter shouldResume: Whether the capture may resume right away.
|
||||
func endInterruption(
|
||||
shouldResume: Bool
|
||||
) {
|
||||
continuation.yield(.interruptionEnded(shouldResume: shouldResume))
|
||||
}
|
||||
|
||||
func start() async throws {
|
||||
try await called("start")
|
||||
}
|
||||
|
||||
@@ -1,53 +0,0 @@
|
||||
import Foundation
|
||||
import Recording
|
||||
|
||||
/// A preinstalling service that records its requests, resolves the supported locales from configurable tables, and emits events
|
||||
/// on demand.
|
||||
@MainActor
|
||||
final class PreinstallingMock: Preinstalling {
|
||||
|
||||
/// The stream of events the service emits while preinstalling.
|
||||
let events: AsyncStream<PreinstallingEvent>
|
||||
|
||||
/// The supported equivalents the service resolves, keyed by the requested locale.
|
||||
var equivalents: [Locale: Locale] = [:]
|
||||
|
||||
/// The locales the service reports as supported.
|
||||
var localesSupported: [Locale] = []
|
||||
|
||||
/// The locales a preinstallation was requested for, in request order.
|
||||
private(set) var localesPreinstalled: [Locale] = []
|
||||
|
||||
/// The continuation that feeds ``events``.
|
||||
private let continuation: AsyncStream<PreinstallingEvent>.Continuation
|
||||
|
||||
init() {
|
||||
(events, continuation) = AsyncStream.makeStream(of: PreinstallingEvent.self)
|
||||
}
|
||||
|
||||
/// Emits the given event through ``events``.
|
||||
///
|
||||
/// - Parameter event: The event to emit.
|
||||
func emit(
|
||||
_ event: PreinstallingEvent
|
||||
) {
|
||||
continuation.yield(event)
|
||||
}
|
||||
|
||||
func preinstall(
|
||||
for locale: Locale
|
||||
) async {
|
||||
localesPreinstalled.append(locale)
|
||||
}
|
||||
|
||||
func supportedLocale(
|
||||
equivalentTo locale: Locale
|
||||
) async -> Locale? {
|
||||
equivalents[locale]
|
||||
}
|
||||
|
||||
func supportedLocales() async -> [Locale] {
|
||||
localesSupported
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,6 +4,8 @@ import Recording
|
||||
/// A transcribing service with a configurable delay, output, and failure.
|
||||
@MainActor
|
||||
final class TranscribingMock: Transcribing {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// The duration of the simulated transcription work.
|
||||
var delay: Duration = .seconds(0.2)
|
||||
@@ -13,6 +15,8 @@ final class TranscribingMock: Transcribing {
|
||||
|
||||
/// The transcription the service returns.
|
||||
var transcription = "This is a mocked transcription."
|
||||
|
||||
// MARK: Methods
|
||||
|
||||
func callAsFunction(
|
||||
_ audio: URL,
|
||||
|
||||
Reference in New Issue
Block a user