Implemented the resumed interrupted recordings and allowed processing discards on the RecordingViewModel view model in the Recording package target.

This commit is contained in:
2026-07-05 16:16:53 +02:00
parent 8576d6bac6
commit c2ac476257
14 changed files with 563 additions and 309 deletions
@@ -0,0 +1,61 @@
import Foundation
import Testing
@testable import Recording
@Suite("Capturing interruption events")
struct CapturingEventInterruptionTests {
@Test
func `a began interruption maps to the interrupted event`() {
let event = CapturingEvent(interruption: [
"AVAudioSessionInterruptionTypeKey": UInt(1)
])
#expect(event == .interrupted)
}
@Test
func `an ended interruption without options maps to a non-resuming end event`() {
let event = CapturingEvent(interruption: [
"AVAudioSessionInterruptionTypeKey": UInt(0)
])
#expect(event == .interruptionEnded(shouldResume: false))
}
@Test
func `an ended interruption with the resume option maps to a resuming end event`() {
let event = CapturingEvent(interruption: [
"AVAudioSessionInterruptionTypeKey": UInt(0),
"AVAudioSessionInterruptionOptionKey": UInt(1),
])
#expect(event == .interruptionEnded(shouldResume: true))
}
@Test
func `a missing interruption type maps to no event`() {
#expect(CapturingEvent(interruption: [:]) == nil)
#expect(CapturingEvent(interruption: nil) == nil)
}
@Test
func `an unknown interruption type maps to no event`() {
let event = CapturingEvent(interruption: [
"AVAudioSessionInterruptionTypeKey": UInt(99)
])
#expect(event == nil)
}
@Test
func `a mistyped interruption type maps to no event`() {
let event = CapturingEvent(interruption: [
"AVAudioSessionInterruptionTypeKey": "began"
])
#expect(event == nil)
}
}