diff --git a/tools/chatgui-android/router-tests/src/test/kotlin/com/utun/chat/data/CallAudioRouterCleanupTest.kt b/tools/chatgui-android/router-tests/src/test/kotlin/com/utun/chat/data/CallAudioRouterCleanupTest.kt index 6cd992e5..edaf1c85 100644 --- a/tools/chatgui-android/router-tests/src/test/kotlin/com/utun/chat/data/CallAudioRouterCleanupTest.kt +++ b/tools/chatgui-android/router-tests/src/test/kotlin/com/utun/chat/data/CallAudioRouterCleanupTest.kt @@ -187,4 +187,31 @@ class CallAudioRouterCleanupTest { val clears = operation("clear") router.stop(); assertEquals(clears, operation("clear")); assertFalse(router.cleanupPending) } + + @Test fun communicationSelectionFailureAfterItsEffectRollsBackTheOwnedDevice() { + audio.failures = setOf("select after=1", "clear") + assertThrows(IllegalStateException::class.java) { router.start() } + assertNotNull(audio.communicationDevice); assertTrue(router.cleanupPending); assertTrue(audio.callbacks.isEmpty()) + audio.failures = emptySet(); router.stop() + assertNull(audio.communicationDevice); assertFalse(router.cleanupPending) + } + + @Test fun communicationReleaseAfterEffectStillNeedsASuccessfulAcknowledgment() { + router.start(); adapter.connect(0) + audio.failures = setOf("clear after"); stopRejected() + assertNull(audio.communicationDevice); assertTrue(router.cleanupPending) + audio.failures = emptySet(); router.stop() + assertFalse(router.cleanupPending); assertEquals(2, operation("clear")) + } + + @Test fun legacyScoEffectsAndIndependentAcknowledgmentsSurviveAfterEffectFailures() { + Build.VERSION.SDK_INT = 30 + router.start(); adapter.connect(0) + audio.failures = setOf("start sco after"); router.setRoute(AudioRoute.HEADSET) + assertTrue(audio.legacyScoStarted) + audio.failures = setOf("stop sco after", "sco after=false"); stopRejected() + assertFalse(audio.legacyScoStarted); assertFalse(audio.isBluetoothScoOn); assertTrue(router.cleanupPending) + audio.failures = emptySet(); router.stop() + assertFalse(router.cleanupPending); assertEquals(2, operation("stop sco")); assertEquals(2, operation("sco=false")) + } }