@@ -993,26 +993,25 @@ class GatewayBootstrapAuthTest {
993993 }
994994
995995 @Test
996- @OptIn(ExperimentalCoroutinesApi ::class )
997- fun talkPttOnceRetryPreservesCaptureCleanupOwnership () =
996+ fun talkPttOnceRetryReturnsBusyWithoutPreparingCapture () =
998997 runBlocking {
999998 val app = RuntimeEnvironment .getApplication()
1000999 shadowOf(app).grantPermissions(Manifest .permission.RECORD_AUDIO )
10011000 val runtime = createTestRuntime(app)
10021001 val talkMode = readField<Lazy <TalkModeManager >>(runtime, " talkMode\$ delegate" ).value
10031002 writeField(talkMode, " activePttCaptureId" , " capture-1" )
10041003 val dispatcher = readField<InvokeDispatcher >(runtime, " invokeDispatcher" )
1005- Dispatchers .setMain(Dispatchers .Unconfined )
1004+ val preparationMutex = readField<Mutex >(runtime, " voiceCapturePreparationMutex" )
1005+ preparationMutex.lock()
10061006 try {
1007- val retry = dispatcher.handleInvoke(OpenClawTalkCommand .PttOnce .rawValue, null )
1007+ val retry =
1008+ withTimeout(1_000 ) { dispatcher.handleInvoke(OpenClawTalkCommand .PttOnce .rawValue, null ) }
10081009 assertNull(retry.error)
1009- assertTrue(readField<MutableStateFlow <Boolean >>(runtime, " externalAudioCaptureActive" ).value)
1010-
1011- val cancel = dispatcher.handleInvoke(OpenClawTalkCommand .PttCancel .rawValue, null )
1012- assertNull(cancel.error)
1010+ assertEquals(""" {"captureId":"capture-1","status":"busy"}""" , retry.payloadJson)
1011+ assertEquals(" capture-1" , talkMode.activePushToTalkCaptureId)
10131012 assertFalse(readField<MutableStateFlow <Boolean >>(runtime, " externalAudioCaptureActive" ).value)
10141013 } finally {
1015- Dispatchers .resetMain ()
1014+ preparationMutex.unlock ()
10161015 }
10171016 }
10181017
0 commit comments