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);
}
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", "");
}
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);
}
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());
}
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", "");
}
Aggregations