Improved the Capturing protocol in the Recording package target to capture interruptions and pause any active capture process.
This commit is contained in:
@@ -6,6 +6,9 @@ import Recording
|
||||
@MainActor
|
||||
final class CapturingMock: Capturing {
|
||||
|
||||
/// The stream of events the service emits outside its method calls.
|
||||
let events: AsyncStream<CapturingEvent>
|
||||
|
||||
/// The duration every method takes before returning, simulating slow capture work.
|
||||
var delay: Duration = .zero
|
||||
|
||||
@@ -15,6 +18,18 @@ final class CapturingMock: Capturing {
|
||||
/// The names of the methods called on the service, in call order.
|
||||
private(set) var calls: [String] = []
|
||||
|
||||
/// The continuation that feeds ``events``.
|
||||
private let continuation: AsyncStream<CapturingEvent>.Continuation
|
||||
|
||||
init() {
|
||||
(events, continuation) = AsyncStream.makeStream(of: CapturingEvent.self)
|
||||
}
|
||||
|
||||
/// Emits an interruption of the ongoing capture through ``events``.
|
||||
func interrupt() {
|
||||
continuation.yield(.interrupted)
|
||||
}
|
||||
|
||||
func start() async throws {
|
||||
try await called("start")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user