package com.cottondb.messages.chatimport android.app.Applicationimport android.os.ParcelFileDescriptorimport android.speech.RecognizerIntentimport org.junit.Assert.assertEqualsimport org.junit.Assert.assertFalseimport org.junit.Assert.assertTrueimport org.junit.Testimport org.junit.runner.RunWithimport org.robolectric.RobolectricTestRunnerimport org.robolectric.annotation.Config/** * The emulator (22 Nov 2026): the phone held no model for the language, and the app's ask for it went with the listening * intent, whose recording pipe was already closed: "Bad file descriptor", no model, no words on any voice message. */@RunWith(RobolectricTestRunner::class)@Config(sdk = [35], application = Application::class)classVoiceModelAskTest { @Test fun the_ask_for_a_language_model_carries_no_recording() {val ask = VoiceTranscript.modelIntent("en-US") assertEquals(RecognizerIntent.ACTION_RECOGNIZE_SPEECH, ask.action) assertEquals("en-US", ask.getStringExtra(RecognizerIntent.EXTRA_LANGUAGE)) assertTrue(ask.getBooleanExtra(RecognizerIntent.EXTRA_PREFER_OFFLINE, false)) assertFalse("no pipe to close under it", ask.hasExtra(RecognizerIntent.EXTRA_AUDIO_SOURCE))// Each ask is its own: a listening intent built from it does not reach back into the next ask.val pipe = ParcelFileDescriptor.createPipe()VoiceTranscript.modelIntent("en-US").putExtra(RecognizerIntent.EXTRA_AUDIO_SOURCE, pipe[0]) assertFalse(VoiceTranscript.modelIntent("en-US").hasExtra(RecognizerIntent.EXTRA_AUDIO_SOURCE)) pipe.forEach { it.close() } }}