Search in sources :

Example 11 with SynthesisRequest

use of android.speech.tts.SynthesisRequest in project android_frameworks_base by DirtyUnicorns.

the class TextToSpeechTests method testDefaultLanguage_setsVoiceName.

public void testDefaultLanguage_setsVoiceName() throws Exception {
    IDelegate delegate = LittleMock.mock(IDelegate.class);
    MockableTextToSpeechService.setMocker(delegate);
    Locale defaultLocale = Locale.getDefault();
    // ---------------------------------------------------------
    // Test that default language also sets the default voice
    // name
    LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(delegate).onIsLanguageAvailable(defaultLocale.getISO3Language(), defaultLocale.getISO3Country().toUpperCase(), defaultLocale.getVariant());
    LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(delegate).onLoadLanguage(defaultLocale.getISO3Language(), defaultLocale.getISO3Country(), defaultLocale.getVariant());
    blockingCallSpeak("foo bar", delegate);
    ArgumentCaptor<SynthesisRequest> req = LittleMock.createCaptor();
    LittleMock.verify(delegate, LittleMock.times(1)).onSynthesizeText(req.capture(), LittleMock.<SynthesisCallback>anyObject());
    assertEquals(defaultLocale.getISO3Language(), req.getValue().getLanguage());
    assertEquals(defaultLocale.getISO3Country(), req.getValue().getCountry());
    assertEquals("", req.getValue().getVariant());
    assertEquals(defaultLocale.toLanguageTag(), req.getValue().getVoiceName());
}
Also used : Locale(java.util.Locale) SynthesisRequest(android.speech.tts.SynthesisRequest) IDelegate(com.android.speech.tts.MockableTextToSpeechService.IDelegate)

Example 12 with SynthesisRequest

use of android.speech.tts.SynthesisRequest in project android_frameworks_base by ResurrectionRemix.

the class TextToSpeechTests method testDefaultLanguage_setsVoiceName.

public void testDefaultLanguage_setsVoiceName() throws Exception {
    IDelegate delegate = LittleMock.mock(IDelegate.class);
    MockableTextToSpeechService.setMocker(delegate);
    Locale defaultLocale = Locale.getDefault();
    // ---------------------------------------------------------
    // Test that default language also sets the default voice
    // name
    LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(delegate).onIsLanguageAvailable(defaultLocale.getISO3Language(), defaultLocale.getISO3Country().toUpperCase(), defaultLocale.getVariant());
    LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(delegate).onLoadLanguage(defaultLocale.getISO3Language(), defaultLocale.getISO3Country(), defaultLocale.getVariant());
    blockingCallSpeak("foo bar", delegate);
    ArgumentCaptor<SynthesisRequest> req = LittleMock.createCaptor();
    LittleMock.verify(delegate, LittleMock.times(1)).onSynthesizeText(req.capture(), LittleMock.<SynthesisCallback>anyObject());
    assertEquals(defaultLocale.getISO3Language(), req.getValue().getLanguage());
    assertEquals(defaultLocale.getISO3Country(), req.getValue().getCountry());
    assertEquals("", req.getValue().getVariant());
    assertEquals(defaultLocale.toLanguageTag(), req.getValue().getVoiceName());
}
Also used : Locale(java.util.Locale) SynthesisRequest(android.speech.tts.SynthesisRequest) IDelegate(com.android.speech.tts.MockableTextToSpeechService.IDelegate)

Example 13 with SynthesisRequest

use of android.speech.tts.SynthesisRequest in project android_frameworks_base by crdroidandroid.

the class TextToSpeechTests method testSetLanguage_availableLanguage.

public void testSetLanguage_availableLanguage() throws Exception {
    IDelegate delegate = LittleMock.mock(IDelegate.class);
    MockableTextToSpeechService.setMocker(delegate);
    // ---------------------------------------------------------
    // Test 2 : Tests that when the language is successfully set
    // like above (returns LANG_COUNTRY_AVAILABLE). That the
    // request language changes from that point on.
    LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(delegate).onIsLanguageAvailable("eng", "USA", "variant");
    LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(delegate).onIsLanguageAvailable("eng", "USA", "");
    LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(delegate).onLoadLanguage("eng", "USA", "");
    mTts.setLanguage(new Locale("eng", "USA", "variant"));
    blockingCallSpeak("foo bar", delegate);
    ArgumentCaptor<SynthesisRequest> req = LittleMock.createCaptor();
    LittleMock.verify(delegate, LittleMock.times(1)).onSynthesizeText(req.capture(), LittleMock.<SynthesisCallback>anyObject());
    assertEquals("eng", req.getValue().getLanguage());
    assertEquals("USA", req.getValue().getCountry());
    assertEquals("", req.getValue().getVariant());
    assertEquals("en-US", req.getValue().getVoiceName());
}
Also used : Locale(java.util.Locale) SynthesisRequest(android.speech.tts.SynthesisRequest) IDelegate(com.android.speech.tts.MockableTextToSpeechService.IDelegate)

Example 14 with SynthesisRequest

use of android.speech.tts.SynthesisRequest in project platform_frameworks_base by android.

the class TextToSpeechTests method testSetLanguage_availableLanguage.

public void testSetLanguage_availableLanguage() throws Exception {
    IDelegate delegate = Mockito.mock(IDelegate.class);
    MockableTextToSpeechService.setMocker(delegate);
    // ---------------------------------------------------------
    // Test 2 : Tests that when the language is successfully set
    // like above (returns LANG_COUNTRY_AVAILABLE). That the
    // request language changes from that point on.
    Mockito.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(delegate).onIsLanguageAvailable("eng", "USA", "variant");
    Mockito.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(delegate).onIsLanguageAvailable("eng", "USA", "");
    Mockito.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(delegate).onLoadLanguage("eng", "USA", "");
    mTts.setLanguage(new Locale("eng", "USA", "variant"));
    blockingCallSpeak("foo bar", delegate);
    ArgumentCaptor<SynthesisRequest> req = ArgumentCaptor.forClass(SynthesisRequest.class);
    Mockito.verify(delegate, Mockito.times(1)).onSynthesizeText(req.capture(), Mockito.<SynthesisCallback>anyObject());
    assertEquals("eng", req.getValue().getLanguage());
    assertEquals("USA", req.getValue().getCountry());
    assertEquals("", req.getValue().getVariant());
    assertEquals("en-US", req.getValue().getVoiceName());
}
Also used : Locale(java.util.Locale) SynthesisRequest(android.speech.tts.SynthesisRequest) IDelegate(com.android.speech.tts.MockableTextToSpeechService.IDelegate)

Aggregations

SynthesisRequest (android.speech.tts.SynthesisRequest)14 IDelegate (com.android.speech.tts.MockableTextToSpeechService.IDelegate)14 Locale (java.util.Locale)9