mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 02:47:34 +00:00
Fixes #27498 Supersedes community PR #30297. Original contributor credit is preserved below. Co-authored-by: Wooseong Kim <innocarpe@gmail.com>
31 lines
1.7 KiB
Swift
31 lines
1.7 KiB
Swift
@main
|
|
struct RecordingInterruptionIntentTests {
|
|
static func main() {
|
|
var intent = RecordingInterruptionIntent()
|
|
// An idle audio interruption never starts a recording.
|
|
intent.began(wasRecording: false)
|
|
precondition(intent.ended(shouldResume: true, isRecording: false) == .blocked)
|
|
// A still-owned recording resumes once, not again on a duplicate end event.
|
|
intent.began(wasRecording: true)
|
|
precondition(intent.ended(shouldResume: true, isRecording: false) == .resume)
|
|
precondition(intent.ended(shouldResume: true, isRecording: false) == .blocked)
|
|
// A blocked or missing shouldResume bit consumes the old resume request.
|
|
intent.began(wasRecording: true)
|
|
precondition(intent.ended(shouldResume: false, isRecording: false) == .blocked)
|
|
precondition(intent.ended(shouldResume: true, isRecording: false) == .blocked)
|
|
// JavaScript cancels capture after began; ended must not turn its microphone back on.
|
|
intent.began(wasRecording: true)
|
|
intent.cancel()
|
|
precondition(intent.ended(shouldResume: true, isRecording: false) == .blocked)
|
|
// A newer explicit recording must not be cancelled by the old end notification.
|
|
intent.began(wasRecording: true)
|
|
intent.cancel()
|
|
precondition(intent.ended(shouldResume: true, isRecording: true) == .none)
|
|
// The most recent interruption, even one while idle, replaces old resume intent.
|
|
intent.began(wasRecording: true)
|
|
intent.began(wasRecording: false)
|
|
precondition(intent.ended(shouldResume: true, isRecording: false) == .blocked)
|
|
print("RecordingInterruptionIntent: 8 assertions passed")
|
|
}
|
|
}
|