use of com.android.speech.tts.MockableTextToSpeechService.IDelegate in project android_frameworks_base by ResurrectionRemix.
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");
}
use of com.android.speech.tts.MockableTextToSpeechService.IDelegate in project android_frameworks_base by crdroidandroid.
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 crdroidandroid.
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 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());
}
use of com.android.speech.tts.MockableTextToSpeechService.IDelegate 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());
}
Aggregations