use of android.speech.tts.TextToSpeech in project robolectric by robolectric.
the class ShadowTextToSpeechTest method getQueueMode_shouldReturnMostRecentQueueMode.
@Test
public void getQueueMode_shouldReturnMostRecentQueueMode() {
TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
});
textToSpeech.speak("Hello", TextToSpeech.QUEUE_ADD, null);
assertThat(shadowOf(textToSpeech).getQueueMode()).isEqualTo(TextToSpeech.QUEUE_ADD);
}
use of android.speech.tts.TextToSpeech in project robolectric by robolectric.
the class ShadowTextToSpeechTest method isLanguageAvailable_neverAdded_returnsUnsupported.
@Test
public void isLanguageAvailable_neverAdded_returnsUnsupported() {
TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
});
assertThat(textToSpeech.isLanguageAvailable(new Locale.Builder().setLanguage("pl").setRegion("pl").build())).isEqualTo(TextToSpeech.LANG_NOT_SUPPORTED);
}
use of android.speech.tts.TextToSpeech in project robolectric by robolectric.
the class ShadowTextToSpeechTest method onInitListener_success_getsCalledAsynchronously.
@Test
public void onInitListener_success_getsCalledAsynchronously() {
AtomicReference<Integer> onInitCalled = new AtomicReference<>();
TextToSpeech.OnInitListener listener = onInitCalled::set;
TextToSpeech textToSpeech = new TextToSpeech(activity, listener);
assertThat(textToSpeech).isNotNull();
Shadows.shadowOf(textToSpeech).getOnInitListener().onInit(TextToSpeech.SUCCESS);
assertThat(onInitCalled.get()).isEqualTo(TextToSpeech.SUCCESS);
}
use of android.speech.tts.TextToSpeech in project robolectric by robolectric.
the class ShadowTextToSpeechTest method onUtteranceProgressListener_shouldGetCallbackUtteranceId.
@Test
@Config(minSdk = LOLLIPOP)
public void onUtteranceProgressListener_shouldGetCallbackUtteranceId() {
TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
});
UtteranceProgressListener mockListener = mock(UtteranceProgressListener.class);
textToSpeech.setOnUtteranceProgressListener(mockListener);
textToSpeech.speak("Hello", TextToSpeech.QUEUE_FLUSH, null, "TTSEnable");
shadowMainLooper().idle();
verify(mockListener).onStart("TTSEnable");
verify(mockListener).onDone("TTSEnable");
}
use of android.speech.tts.TextToSpeech in project robolectric by robolectric.
the class ShadowTextToSpeechTest method synthesizeToFile_lastSynthesizeToFileTextStored.
@Test
@Config(minSdk = LOLLIPOP)
public void synthesizeToFile_lastSynthesizeToFileTextStored() {
TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
});
Bundle bundle = new Bundle();
File file = new File("example.txt");
int result = textToSpeech.synthesizeToFile("text", bundle, file, "id");
assertThat(result).isEqualTo(TextToSpeech.SUCCESS);
assertThat(shadowOf(textToSpeech).getLastSynthesizeToFileText()).isEqualTo("text");
}
Aggregations