use of android.speech.tts.TextToSpeech in project robolectric by robolectric.
the class ShadowTextToSpeechTest method threeArgumentSpeak_withoutUtteranceId_shouldDoesNotGetCallback.
@Test
public void threeArgumentSpeak_withoutUtteranceId_shouldDoesNotGetCallback() {
TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
});
UtteranceProgressListener mockListener = mock(UtteranceProgressListener.class);
textToSpeech.setOnUtteranceProgressListener(mockListener);
textToSpeech.speak("Hello", TextToSpeech.QUEUE_FLUSH, null);
shadowMainLooper().idle();
verify(mockListener, never()).onStart(null);
verify(mockListener, never()).onDone(null);
}
use of android.speech.tts.TextToSpeech in project robolectric by robolectric.
the class ShadowTextToSpeechTest method shouldNotBeNull.
@Test
public void shouldNotBeNull() {
TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
});
assertThat(textToSpeech).isNotNull();
assertThat(shadowOf(textToSpeech)).isNotNull();
}
use of android.speech.tts.TextToSpeech in project robolectric by robolectric.
the class ShadowTextToSpeechTest method isStopped_shouldReturnFalseAfterSpeak.
@Test
public void isStopped_shouldReturnFalseAfterSpeak() {
TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
});
textToSpeech.speak("Hello", TextToSpeech.QUEUE_FLUSH, null);
assertThat(shadowOf(textToSpeech).isStopped()).isFalse();
}
use of android.speech.tts.TextToSpeech in project robolectric by robolectric.
the class ShadowTextToSpeechTest method isLanguageAvailable_twoLanguageAvailabilities_returnsRequestedAvailability.
@Test
public void isLanguageAvailable_twoLanguageAvailabilities_returnsRequestedAvailability() {
TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
});
ShadowTextToSpeech.addLanguageAvailability(new Locale.Builder().setLanguage("pl").setRegion("pl").build());
ShadowTextToSpeech.addLanguageAvailability(new Locale.Builder().setLanguage("ja").setRegion("jp").build());
assertThat(textToSpeech.isLanguageAvailable(new Locale.Builder().setLanguage("pl").setRegion("pl").build())).isEqualTo(TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE);
}
use of android.speech.tts.TextToSpeech in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class TtsEnginePreferenceFragment method onUpdateEngine.
/**
* Step 3: We have now bound to the TTS engine the user requested. We will attempt to check
* voice data for the engine if we successfully bound to it, or revert to the previous engine if
* we didn't.
*/
public void onUpdateEngine(int status) {
if (status == TextToSpeech.SUCCESS) {
Log.d(TAG, "Updating engine: Successfully bound to the engine: " + mTts.getCurrentEngine());
android.provider.Settings.Secure.putString(getContentResolver(), TTS_DEFAULT_SYNTH, mTts.getCurrentEngine());
} else {
Log.d(TAG, "Updating engine: Failed to bind to engine, reverting.");
if (mPreviousEngine != null) {
// This is guaranteed to at least bind, since mPreviousEngine would be
// null if the previous bind to this engine failed.
mTts = new TextToSpeech(getActivity().getApplicationContext(), null, mPreviousEngine);
}
mPreviousEngine = null;
}
}
Aggregations