Search in sources :

Example 16 with IDelegate

use of com.android.speech.tts.MockableTextToSpeechService.IDelegate in project android_frameworks_base by crdroidandroid.

the class TextToSpeechTests method testSetLanguage_unavailableLanguage.

public void testSetLanguage_unavailableLanguage() throws Exception {
    IDelegate delegate = LittleMock.mock(IDelegate.class);
    MockableTextToSpeechService.setMocker(delegate);
    // ---------------------------------------------------------
    // TEST 3 : Tests that the language that is set does not change when the
    // engine reports it could not load the specified language.
    LittleMock.doReturn(TextToSpeech.LANG_NOT_SUPPORTED).when(delegate).onIsLanguageAvailable("fra", "FRA", "");
    LittleMock.doReturn(TextToSpeech.LANG_NOT_SUPPORTED).when(delegate).onLoadLanguage("fra", "FRA", "");
    mTts.setLanguage(Locale.FRANCE);
    blockingCallSpeak("le fou barre", delegate);
    ArgumentCaptor<SynthesisRequest> req2 = LittleMock.createCaptor();
    LittleMock.verify(delegate, LittleMock.times(1)).onSynthesizeText(req2.capture(), LittleMock.<SynthesisCallback>anyObject());
    // The params are basically unchanged.
    assertEquals("eng", req2.getValue().getLanguage());
    assertEquals("USA", req2.getValue().getCountry());
    assertEquals("", req2.getValue().getVariant());
    assertEquals("en-US", req2.getValue().getVoiceName());
}
Also used : SynthesisRequest(android.speech.tts.SynthesisRequest) IDelegate(com.android.speech.tts.MockableTextToSpeechService.IDelegate)

Example 17 with IDelegate

use of com.android.speech.tts.MockableTextToSpeechService.IDelegate in project android_frameworks_base by crdroidandroid.

the class TextToSpeechTests method testSetLanguage_delegation.

public void testSetLanguage_delegation() {
    IDelegate delegate = LittleMock.mock(IDelegate.class);
    MockableTextToSpeechService.setMocker(delegate);
    LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE).when(delegate).onIsLanguageAvailable("eng", "USA", "variant");
    LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE).when(delegate).onLoadLanguage("eng", "USA", "variant");
    // Test 1 :Tests that calls to onLoadLanguage( ) are delegated through to the
    // service without any caching or intermediate steps.
    assertEquals(TextToSpeech.LANG_COUNTRY_VAR_AVAILABLE, mTts.setLanguage(new Locale("eng", "USA", "variant")));
    LittleMock.verify(delegate, LittleMock.anyTimes()).onIsLanguageAvailable("eng", "USA", "variant");
    LittleMock.verify(delegate, LittleMock.anyTimes()).onLoadLanguage("eng", "USA", "variant");
}
Also used : Locale(java.util.Locale) IDelegate(com.android.speech.tts.MockableTextToSpeechService.IDelegate)

Example 18 with IDelegate

use of com.android.speech.tts.MockableTextToSpeechService.IDelegate in project android_frameworks_base by ParanoidAndroid.

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).onLoadLanguage("eng", "USA", "variant");
    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());
}
Also used : Locale(java.util.Locale) SynthesisRequest(android.speech.tts.SynthesisRequest) IDelegate(com.android.speech.tts.MockableTextToSpeechService.IDelegate)

Example 19 with IDelegate

use of com.android.speech.tts.MockableTextToSpeechService.IDelegate in project android_frameworks_base by ParanoidAndroid.

the class TextToSpeechTests method testSetLanguage_unavailableLanguage.

public void testSetLanguage_unavailableLanguage() throws Exception {
    IDelegate delegate = LittleMock.mock(IDelegate.class);
    MockableTextToSpeechService.setMocker(delegate);
    // ---------------------------------------------------------
    // TEST 3 : Tests that the language that is set does not change when the
    // engine reports it could not load the specified language.
    LittleMock.doReturn(TextToSpeech.LANG_NOT_SUPPORTED).when(delegate).onLoadLanguage("fra", "FRA", "");
    mTts.setLanguage(Locale.FRANCE);
    blockingCallSpeak("le fou barre", delegate);
    ArgumentCaptor<SynthesisRequest> req2 = LittleMock.createCaptor();
    LittleMock.verify(delegate, LittleMock.times(1)).onSynthesizeText(req2.capture(), LittleMock.<SynthesisCallback>anyObject());
    // The params are basically unchanged.
    assertEquals("eng", req2.getValue().getLanguage());
    assertEquals("USA", req2.getValue().getCountry());
    assertEquals("", req2.getValue().getVariant());
}
Also used : SynthesisRequest(android.speech.tts.SynthesisRequest) IDelegate(com.android.speech.tts.MockableTextToSpeechService.IDelegate)

Example 20 with IDelegate

use of com.android.speech.tts.MockableTextToSpeechService.IDelegate in project android_frameworks_base by ParanoidAndroid.

the class TextToSpeechTests method setUp.

@Override
public void setUp() throws Exception {
    IDelegate passThrough = LittleMock.mock(IDelegate.class);
    MockableTextToSpeechService.setMocker(passThrough);
    blockingInitAndVerify(MOCK_ENGINE, TextToSpeech.SUCCESS);
    assertEquals(MOCK_ENGINE, mTts.getCurrentEngine());
}
Also used : IDelegate(com.android.speech.tts.MockableTextToSpeechService.IDelegate)

Aggregations

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