Search in sources :

Example 71 with TextToSpeech

use of android.speech.tts.TextToSpeech in project robolectric by robolectric.

the class ShadowTextToSpeechTest method isShutdown_shouldReturnFalseBeforeShutdown.

@Test
public void isShutdown_shouldReturnFalseBeforeShutdown() {
    TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
    });
    assertThat(shadowOf(textToSpeech).isShutdown()).isFalse();
}
Also used : TextToSpeech(android.speech.tts.TextToSpeech) Test(org.junit.Test)

Example 72 with TextToSpeech

use of android.speech.tts.TextToSpeech in project robolectric by robolectric.

the class ShadowTextToSpeechTest method isShutdown_shouldReturnTrueAfterShutdown.

@Test
public void isShutdown_shouldReturnTrueAfterShutdown() {
    TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
    });
    textToSpeech.shutdown();
    assertThat(shadowOf(textToSpeech).isShutdown()).isTrue();
}
Also used : TextToSpeech(android.speech.tts.TextToSpeech) Test(org.junit.Test)

Example 73 with TextToSpeech

use of android.speech.tts.TextToSpeech in project robolectric by robolectric.

the class ShadowTextToSpeechTest method isLanguageAvailable_matchingCountry_returnsLangCountryAvailable.

@Test
public void isLanguageAvailable_matchingCountry_returnsLangCountryAvailable() {
    TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
    });
    ShadowTextToSpeech.addLanguageAvailability(new Locale.Builder().setLanguage("en").setRegion("us").setVariant("ONETW").build());
    assertThat(textToSpeech.isLanguageAvailable(new Locale.Builder().setLanguage("en").setRegion("us").setVariant("THREE").build())).isEqualTo(TextToSpeech.LANG_COUNTRY_AVAILABLE);
}
Also used : Locale(java.util.Locale) TextToSpeech(android.speech.tts.TextToSpeech) Test(org.junit.Test)

Example 74 with TextToSpeech

use of android.speech.tts.TextToSpeech in project robolectric by robolectric.

the class ShadowTextToSpeechTest method getSpokenTextList_neverSpoke_returnsEmpty.

@Test
public void getSpokenTextList_neverSpoke_returnsEmpty() {
    TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
    });
    assertThat(shadowOf(textToSpeech).getSpokenTextList()).isEmpty();
}
Also used : TextToSpeech(android.speech.tts.TextToSpeech) Test(org.junit.Test)

Example 75 with TextToSpeech

use of android.speech.tts.TextToSpeech in project robolectric by robolectric.

the class ShadowTextToSpeechTest method isLanguageAvailable_matchingVariant_returnsCountryVarAvailable.

@Test
public void isLanguageAvailable_matchingVariant_returnsCountryVarAvailable() {
    TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
    });
    ShadowTextToSpeech.addLanguageAvailability(new Locale.Builder().setLanguage("en").setRegion("us").setVariant("WOLTK").build());
    assertThat(textToSpeech.isLanguageAvailable(new Locale.Builder().setLanguage("en").setRegion("us").setVariant("WOLTK").build())).isEqualTo(TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE);
}
Also used : Locale(java.util.Locale) TextToSpeech(android.speech.tts.TextToSpeech) Test(org.junit.Test)

Aggregations

TextToSpeech (android.speech.tts.TextToSpeech)103 Test (org.junit.Test)34 Locale (java.util.Locale)18 TtsEngines (android.speech.tts.TtsEngines)15 ActivityNotFoundException (android.content.ActivityNotFoundException)12 Intent (android.content.Intent)12 ContentResolver (android.content.ContentResolver)10 MissingResourceException (java.util.MissingResourceException)10 IntentFilter (android.content.IntentFilter)8 TextView (android.widget.TextView)7 Config (org.robolectric.annotation.Config)7 BluetoothAdapter (android.bluetooth.BluetoothAdapter)6 Handler (android.os.Handler)6 UtteranceProgressListener (android.speech.tts.UtteranceProgressListener)6 ArrayAdapter (android.widget.ArrayAdapter)6 Context (android.content.Context)5 HashMap (java.util.HashMap)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 Bundle (android.os.Bundle)4 AtomicReference (java.util.concurrent.atomic.AtomicReference)3