From 702f8be24f4524b2c1a247e990b7730a6edabd01 Mon Sep 17 00:00:00 2001 From: "Reece H. Dunn" Date: Wed, 29 Oct 2014 16:32:25 +0000 Subject: [PATCH] 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. --- .../com/reecedunn/espeak/test/TextToSpeechTest.java | 11 ++++------- .../reecedunn/espeak/test/TextToSpeechTestCase.java | 9 +-------- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/android/eSpeakTests/src/com/reecedunn/espeak/test/TextToSpeechTest.java b/android/eSpeakTests/src/com/reecedunn/espeak/test/TextToSpeechTest.java index 11821093..22522670 100644 --- a/android/eSpeakTests/src/com/reecedunn/espeak/test/TextToSpeechTest.java +++ b/android/eSpeakTests/src/com/reecedunn/espeak/test/TextToSpeechTest.java @@ -33,13 +33,10 @@ public class TextToSpeechTest extends TextToSpeechTestCase Locale initialLocale = getLanguage(getEngine()); assertThat(getEngine().isLanguageAvailable(new Locale("cel")), isTtsLangCode(TextToSpeech.LANG_NOT_SUPPORTED)); Locale language = getLanguage(getEngine()); - if (language != null) { - assertThat(getLanguage(getEngine()).getLanguage(), is(initialLocale.getLanguage())); - assertThat(getLanguage(getEngine()).getCountry(), is(initialLocale.getCountry())); - assertThat(getLanguage(getEngine()).getVariant(), is(initialLocale.getVariant())); - } else { - assertThat(initialLocale, is(nullValue())); - } + + assertThat(getLanguage(getEngine()).getLanguage(), is(initialLocale.getLanguage())); + assertThat(getLanguage(getEngine()).getCountry(), is(initialLocale.getCountry())); + assertThat(getLanguage(getEngine()).getVariant(), is(initialLocale.getVariant())); } public void testLanguages() diff --git a/android/eSpeakTests/src/com/reecedunn/espeak/test/TextToSpeechTestCase.java b/android/eSpeakTests/src/com/reecedunn/espeak/test/TextToSpeechTestCase.java index 615d38c1..d466b85e 100644 --- a/android/eSpeakTests/src/com/reecedunn/espeak/test/TextToSpeechTestCase.java +++ b/android/eSpeakTests/src/com/reecedunn/espeak/test/TextToSpeechTestCase.java @@ -98,14 +98,7 @@ public class TextToSpeechTestCase extends AndroidTestCase @SuppressWarnings("deprecation") public static Locale getLanguage(TextToSpeech engine) { if (engine != null) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - android.speech.tts.Voice voice = engine.getVoice(); - if (voice != null) { - return voice.getLocale(); - } - } else { - return engine.getLanguage(); - } + return engine.getLanguage(); } return null; }