Browse Source

TextToSpeechTest: always test getLanguage.

This changes the getLanguage helper to return the result from
getLanguage on all platform versions, disabling the deprecated
message on API 21 and above.
master
Reece H. Dunn 10 years ago
parent
commit
702f8be24f

+ 4
- 7
android/eSpeakTests/src/com/reecedunn/espeak/test/TextToSpeechTest.java View File

Locale initialLocale = getLanguage(getEngine()); Locale initialLocale = getLanguage(getEngine());
assertThat(getEngine().isLanguageAvailable(new Locale("cel")), isTtsLangCode(TextToSpeech.LANG_NOT_SUPPORTED)); assertThat(getEngine().isLanguageAvailable(new Locale("cel")), isTtsLangCode(TextToSpeech.LANG_NOT_SUPPORTED));
Locale language = getLanguage(getEngine()); Locale language = getLanguage(getEngine());
if (language != null) { assertThat(getLanguage(getEngine()).getLanguage(), is(initialLocale.getLanguage()));
assertThat(getLanguage(getEngine()).getLanguage(), is(initialLocale.getLanguage())); assertThat(getLanguage(getEngine()).getCountry(), is(initialLocale.getCountry()));
assertThat(getLanguage(getEngine()).getCountry(), is(initialLocale.getCountry())); assertThat(getLanguage(getEngine()).getVariant(), is(initialLocale.getVariant()));
assertThat(getLanguage(getEngine()).getVariant(), is(initialLocale.getVariant()));
} else {
assertThat(initialLocale, is(nullValue()));
}
} }


public void testLanguages() public void testLanguages()

+ 1
- 8
android/eSpeakTests/src/com/reecedunn/espeak/test/TextToSpeechTestCase.java View File

@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static Locale getLanguage(TextToSpeech engine) { public static Locale getLanguage(TextToSpeech engine) {
if (engine != null) { if (engine != null) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { return engine.getLanguage();
android.speech.tts.Voice voice = engine.getVoice();
if (voice != null) {
return voice.getLocale();
}
} else {
return engine.getLanguage();
}
} }
return null; return null;
} }

Loading…
Cancel
Save