use of android.speech.tts.TextToSpeech in project robolectric by robolectric.
the class ShadowTextToSpeechTest method getOnInitListener_shouldReturnListener.
@Test
public void getOnInitListener_shouldReturnListener() {
TextToSpeech.OnInitListener listener = result -> {
};
TextToSpeech textToSpeech = new TextToSpeech(activity, listener);
assertThat(shadowOf(textToSpeech).getOnInitListener()).isEqualTo(listener);
}
use of android.speech.tts.TextToSpeech in project robolectric by robolectric.
the class ShadowTextToSpeechTest method getSpokenTextList_spoke_returnsSpokenTexts.
@Test
public void getSpokenTextList_spoke_returnsSpokenTexts() {
TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
});
textToSpeech.speak("one", TextToSpeech.QUEUE_FLUSH, null);
textToSpeech.speak("two", TextToSpeech.QUEUE_FLUSH, null);
textToSpeech.speak("three", TextToSpeech.QUEUE_FLUSH, null);
assertThat(shadowOf(textToSpeech).getSpokenTextList()).containsExactly("one", "two", "three");
}
use of android.speech.tts.TextToSpeech in project robolectric by robolectric.
the class ShadowTextToSpeechTest method synthesizeToFile_neverCalled_lastSynthesizeToFileTextNull.
@Test
@Config(minSdk = LOLLIPOP)
public void synthesizeToFile_neverCalled_lastSynthesizeToFileTextNull() {
TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
});
assertThat(shadowOf(textToSpeech).getLastSynthesizeToFileText()).isNull();
}
use of android.speech.tts.TextToSpeech in project robolectric by robolectric.
the class ShadowTextToSpeechTest method onInitListener_error.
@Test
public void onInitListener_error() {
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.ERROR);
assertThat(onInitCalled.get()).isEqualTo(TextToSpeech.ERROR);
}
use of android.speech.tts.TextToSpeech in project robolectric by robolectric.
the class ShadowTextToSpeechTest method getLastSpokenText_shouldReturnSpokenText.
@Test
public void getLastSpokenText_shouldReturnSpokenText() {
TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
});
textToSpeech.speak("Hello", TextToSpeech.QUEUE_FLUSH, null);
assertThat(shadowOf(textToSpeech).getLastSpokenText()).isEqualTo("Hello");
}
Aggregations