summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorPrzemyslaw Szczepaniak <pszczepaniak@google.com>2013-07-29 16:30:32 +0100
committerPrzemyslaw Szczepaniak <pszczepaniak@google.com>2013-07-29 16:30:04 +0000
commit93d34a61dbdfd9ece9ac4a53d78e896638172895 (patch)
tree8af53586f2f28ce0ac353d45eeee55593e4ea2c8 /tests
parent9ba21fdc9ddf1d132215d29054b55af416561367 (diff)
downloadframeworks_base-93d34a61dbdfd9ece9ac4a53d78e896638172895.zip
frameworks_base-93d34a61dbdfd9ece9ac4a53d78e896638172895.tar.gz
frameworks_base-93d34a61dbdfd9ece9ac4a53d78e896638172895.tar.bz2
Fix TTS tests.
Fix breakages steaming from recent changes: - onGetLanguage is no longer called anywhere (it's used in API <= 17), tests for it no longer apply. - onLoadLanguage is called as item on synthesis thread queue. To return value to client asap, onIsLanguageAvailable is called as well - added missing expectations for mocks. Change-Id: I205bc406f085e2c2f7e98f8495ddb96ad3701b97
Diffstat (limited to 'tests')
-rw-r--r--tests/TtsTests/src/com/android/speech/tts/TextToSpeechTests.java38
1 files changed, 6 insertions, 32 deletions
diff --git a/tests/TtsTests/src/com/android/speech/tts/TextToSpeechTests.java b/tests/TtsTests/src/com/android/speech/tts/TextToSpeechTests.java
index b736e9f..9c2cf41 100644
--- a/tests/TtsTests/src/com/android/speech/tts/TextToSpeechTests.java
+++ b/tests/TtsTests/src/com/android/speech/tts/TextToSpeechTests.java
@@ -70,6 +70,8 @@ public class TextToSpeechTests extends InstrumentationTestCase {
// Test 1 :Tests that calls to onLoadLanguage( ) are delegated through to the
// service without any caching or intermediate steps.
mTts.setLanguage(new Locale("eng", "USA", "variant"));
+ LittleMock.verify(delegate, LittleMock.times(1)).onIsLanguageAvailable(
+ "eng", "USA", "variant");
LittleMock.verify(delegate, LittleMock.times(1)).onLoadLanguage(
"eng", "USA", "variant");
}
@@ -82,6 +84,8 @@ public class TextToSpeechTests extends InstrumentationTestCase {
// 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).onLoadLanguage(
"eng", "USA", "variant");
mTts.setLanguage(new Locale("eng", "USA", "variant"));
@@ -103,6 +107,8 @@ public class TextToSpeechTests extends InstrumentationTestCase {
// TEST 3 : Tests that the language that is set does not change when the
// engine reports it could not load the specified language.
LittleMock.doReturn(TextToSpeech.LANG_NOT_SUPPORTED).when(
+ delegate).onIsLanguageAvailable("fra", "FRA", "");
+ LittleMock.doReturn(TextToSpeech.LANG_NOT_SUPPORTED).when(
delegate).onLoadLanguage("fra", "FRA", "");
mTts.setLanguage(Locale.FRANCE);
blockingCallSpeak("le fou barre", delegate);
@@ -116,38 +122,6 @@ public class TextToSpeechTests extends InstrumentationTestCase {
assertEquals("", req2.getValue().getVariant());
}
-
- 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);
- }
-
- 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);
- }
-
public void testIsLanguageAvailable() {
IDelegate delegate = LittleMock.mock(IDelegate.class);
MockableTextToSpeechService.setMocker(delegate);