Search in sources :

Example 1 with IDelegate

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

the class TextToSpeechTests method testGetLanguage_invalidReturnValues.

public void testGetLanguage_invalidReturnValues() {
    IDelegate delegate = LittleMock.mock(IDelegate.class);
    MockableTextToSpeechService.setMocker(delegate);
    // Test1: Simple end to end test. Ensure that bad return values
    // are dealt with appropriately.
    LittleMock.doReturn(null).when(delegate).onGetLanguage();
    Locale returnVal = mTts.getLanguage();
    assertNull(returnVal);
    // Bad value 2. An array of length < 3.
    LittleMock.doReturn(new String[] { "eng", "usa" }).when(delegate).onGetLanguage();
    returnVal = mTts.getLanguage();
    assertNull(returnVal);
}
Also used : Locale(java.util.Locale) IDelegate(com.android.speech.tts.MockableTextToSpeechService.IDelegate)

Example 2 with IDelegate

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

the class TextToSpeechTests method testIsLanguageAvailable.

public void testIsLanguageAvailable() {
    IDelegate delegate = LittleMock.mock(IDelegate.class);
    MockableTextToSpeechService.setMocker(delegate);
    // Test1: Simple end to end test.
    LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(delegate).onIsLanguageAvailable("eng", "USA", "");
    assertEquals(TextToSpeech.LANG_COUNTRY_AVAILABLE, mTts.isLanguageAvailable(Locale.US));
    LittleMock.verify(delegate, LittleMock.times(1)).onIsLanguageAvailable("eng", "USA", "");
}
Also used : IDelegate(com.android.speech.tts.MockableTextToSpeechService.IDelegate)

Example 3 with IDelegate

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

the class TextToSpeechTests method testGetLanguage_validReturnValues.

public void testGetLanguage_validReturnValues() {
    IDelegate delegate = LittleMock.mock(IDelegate.class);
    MockableTextToSpeechService.setMocker(delegate);
    // A correct value.
    LittleMock.doReturn(new String[] { "eng", "usa", "" }).when(delegate).onGetLanguage();
    Locale returnVal = mTts.getLanguage();
    // Note: This is not the same as Locale.US . Well tough luck for
    // being the only component of the entire framework that standardized
    // three letter country and language codes.
    assertEquals(new Locale("eng", "USA", ""), returnVal);
}
Also used : Locale(java.util.Locale) IDelegate(com.android.speech.tts.MockableTextToSpeechService.IDelegate)

Example 4 with IDelegate

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

the class TextToSpeechTests method setUp.

@Override
public void setUp() throws Exception {
    IDelegate passThrough = LittleMock.mock(IDelegate.class);
    MockableTextToSpeechService.setMocker(passThrough);
    // For the default voice selection
    LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(passThrough).onIsLanguageAvailable(LittleMock.anyString(), LittleMock.anyString(), LittleMock.anyString());
    LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(passThrough).onLoadLanguage(LittleMock.anyString(), LittleMock.anyString(), LittleMock.anyString());
    blockingInitAndVerify(MOCK_ENGINE, TextToSpeech.SUCCESS);
    assertEquals(MOCK_ENGINE, mTts.getCurrentEngine());
}
Also used : IDelegate(com.android.speech.tts.MockableTextToSpeechService.IDelegate)

Example 5 with IDelegate

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

the class TextToSpeechTests method testIsLanguageAvailable.

public void testIsLanguageAvailable() {
    IDelegate delegate = LittleMock.mock(IDelegate.class);
    MockableTextToSpeechService.setMocker(delegate);
    // Test1: Simple end to end test.
    LittleMock.doReturn(TextToSpeech.LANG_COUNTRY_AVAILABLE).when(delegate).onIsLanguageAvailable("eng", "USA", "");
    assertEquals(TextToSpeech.LANG_COUNTRY_AVAILABLE, mTts.isLanguageAvailable(Locale.US));
    LittleMock.verify(delegate, LittleMock.times(1)).onIsLanguageAvailable("eng", "USA", "");
}
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