62 lines
1.6 KiB
Swift
62 lines
1.6 KiB
Swift
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)
|
|
}
|
|
|
|
}
|