Search in sources :

Example 31 with TextToSpeech

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

the class ShadowTextToSpeechTest method getLastTextToSpeechInstance_constructed_returnsInstance.

@Test
public void getLastTextToSpeechInstance_constructed_returnsInstance() {
    TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
    });
    assertThat(ShadowTextToSpeech.getLastTextToSpeechInstance()).isEqualTo(textToSpeech);
}
Also used : TextToSpeech(android.speech.tts.TextToSpeech) Test(org.junit.Test)

Example 32 with TextToSpeech

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

the class ShadowTextToSpeechTest method getCurrentLanguage_languageSet_returnsLanguage.

@Test
public void getCurrentLanguage_languageSet_returnsLanguage() {
    TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
    });
    Locale language = Locale.forLanguageTag("pl-pl");
    textToSpeech.setLanguage(language);
    assertThat(shadowOf(textToSpeech).getCurrentLanguage()).isEqualTo(language);
}
Also used : Locale(java.util.Locale) TextToSpeech(android.speech.tts.TextToSpeech) Test(org.junit.Test)

Example 33 with TextToSpeech

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

the class ShadowTextToSpeechTest method getVoices_returnsAvailableVoices.

@Test
@Config(minSdk = LOLLIPOP)
public void getVoices_returnsAvailableVoices() {
    TextToSpeech textToSpeech = new TextToSpeech(activity, result -> {
    });
    Voice voice = new Voice("test voice", Locale.getDefault(), Voice.QUALITY_VERY_HIGH, Voice.LATENCY_LOW, false, /* requiresNetworkConnection */
    ImmutableSet.of());
    ShadowTextToSpeech.addVoice(voice);
    assertThat(shadowOf(textToSpeech).getVoices()).containsExactly(voice);
}
Also used : TextToSpeech(android.speech.tts.TextToSpeech) Voice(android.speech.tts.Voice) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 34 with TextToSpeech

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

the class ShadowTextToSpeechTest method getCurrentLanguage_languageNeverSet_returnsNull.

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

Example 35 with TextToSpeech

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

the class ShadowTextToSpeechTest method getLastTextToSpeechInstance_constructedTwice_returnsMostRecentInstance.

@Test
public void getLastTextToSpeechInstance_constructedTwice_returnsMostRecentInstance() {
    TextToSpeech textToSpeechOne = new TextToSpeech(activity, result -> {
    });
    TextToSpeech textToSpeechTwo = new TextToSpeech(activity, result -> {
    });
    assertThat(ShadowTextToSpeech.getLastTextToSpeechInstance()).isEqualTo(textToSpeechTwo);
    assertThat(ShadowTextToSpeech.getLastTextToSpeechInstance()).isNotEqualTo(textToSpeechOne);
}
Also used : 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