Improved the Capturing protocol in the Recording package target to capture interruptions and pause any active capture process.
This commit is contained in:
@@ -342,6 +342,47 @@ struct RecordingViewModelTests {
|
||||
|
||||
}
|
||||
|
||||
// MARK: Interruptions
|
||||
|
||||
@MainActor
|
||||
@Suite("Interruptions")
|
||||
struct Interruptions {
|
||||
|
||||
@Test func `pauses an ongoing recording when the capture is interrupted`() async throws {
|
||||
let capturer = CapturingMock()
|
||||
let model = Model(capturer: capturer)
|
||||
|
||||
model.pressedMain()
|
||||
|
||||
try await Task.sleep(for: .seconds(0.1))
|
||||
|
||||
capturer.interrupt()
|
||||
|
||||
try await Task.sleep(for: .seconds(0.1))
|
||||
|
||||
#expect(model.state == .paused)
|
||||
#expect(capturer.calls == ["start", "pause"])
|
||||
}
|
||||
|
||||
@Test func `changes nothing when the capture is interrupted while paused`() async throws {
|
||||
let capturer = CapturingMock()
|
||||
let model = Model(capturer: capturer)
|
||||
|
||||
model.pressedMain()
|
||||
model.pressedMain()
|
||||
|
||||
try await Task.sleep(for: .seconds(0.1))
|
||||
|
||||
capturer.interrupt()
|
||||
|
||||
try await Task.sleep(for: .seconds(0.1))
|
||||
|
||||
#expect(model.state == .paused)
|
||||
#expect(capturer.calls == ["start", "pause"])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// MARK: Processing
|
||||
|
||||
@MainActor
|
||||
|
||||
Reference in New Issue
Block a user