diff options
Diffstat (limited to 'tests/src/com/android/inputmethod/latin')
4 files changed, 15 insertions, 68 deletions
diff --git a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java index e92831c48..e96c934cb 100644 --- a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java +++ b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java @@ -44,10 +44,6 @@ public class BinaryDictionaryTests extends AndroidTestCase { private static final String TEST_LOCALE = "test"; private static final String DICTIONARY_ID = "TestBinaryDictionary"; - private static boolean supportsNgram(final int formatVersion) { - return formatVersion >= FormatSpec.VERSION403; - } - private HashSet<File> mDictFilesToBeDeleted = new HashSet<>(); @Override diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java index f2885f5f2..02cd21c8d 100644 --- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java +++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java @@ -645,22 +645,6 @@ public class InputLogicTests extends InputTestsBase { mEditText.getText().toString()); } - public void testSwitchLanguages() { - final String WORD_TO_TYPE_FIRST_PART = "com"; - final String WORD_TO_TYPE_SECOND_PART = "md"; - final String EXPECTED_RESULT = "comme"; - changeLanguage("en"); - type(WORD_TO_TYPE_FIRST_PART); - changeLanguage("fr"); - runMessages(); - type(WORD_TO_TYPE_SECOND_PART); - sleep(DELAY_TO_WAIT_FOR_UNDERLINE_MILLIS); - runMessages(); - final SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest(); - assertEquals("Suggestions updated after switching languages", - EXPECTED_RESULT, suggestedWords.size() > 0 ? suggestedWords.getWord(1) : null); - } - public void testBasicGesture() { gesture("this"); assertEquals("this", mEditText.getText().toString()); @@ -743,18 +727,10 @@ public class InputLogicTests extends InputTestsBase { type(" "); typeWordAndPutCursorInside(WORD_TO_TYPE, cursorPos + 1 /* startPos */); type(Constants.CODE_DELETE); + sleep(DELAY_TO_WAIT_FOR_UNDERLINE_MILLIS); ensureComposingSpanPos("delete while in the middle of a word cancels composition", -1, -1); } - public void testAutoCorrectForFrench() { - final String STRING_TO_TYPE = "irq "; - final String EXPECTED_RESULT = "ir a "; - changeLanguage("es"); - type(STRING_TO_TYPE); - assertEquals("simple auto-correct for Spanish", EXPECTED_RESULT, - mEditText.getText().toString()); - } - public void testManualPickThenSeparatorForFrench() { final String WORD1_TO_TYPE = "test"; final String WORD2_TO_TYPE = "!"; @@ -780,13 +756,12 @@ public class InputLogicTests extends InputTestsBase { mEditText.getText().toString()); } - public void testWordThenSpaceThenPunctuationFromStripTwiceForFrench() { + public void testWordThenSpaceThenPunctuationFromStripTwice() { setBooleanPreference(Settings.PREF_BIGRAM_PREDICTIONS, false, true); final String WORD_TO_TYPE = "test "; final String PUNCTUATION_FROM_STRIP = "!"; - final String EXPECTED_RESULT = "test !!"; - changeLanguage("fr"); + final String EXPECTED_RESULT = "test!! "; type(WORD_TO_TYPE); sleep(DELAY_TO_WAIT_FOR_UNDERLINE_MILLIS); runMessages(); @@ -794,14 +769,12 @@ public class InputLogicTests extends InputTestsBase { mLatinIME.getSuggestedWordsForTest().isPunctuationSuggestions()); pickSuggestionManually(PUNCTUATION_FROM_STRIP); pickSuggestionManually(PUNCTUATION_FROM_STRIP); - assertEquals("type word then type space then punctuation from strip twice for French", - EXPECTED_RESULT, mEditText.getText().toString()); + assertEquals(EXPECTED_RESULT, mEditText.getText().toString()); } public void testWordThenSpaceDisplaysPredictions() { - final String WORD_TO_TYPE = "beaujolais "; - final String EXPECTED_RESULT = "nouveau"; - changeLanguage("fr"); + final String WORD_TO_TYPE = "Barack "; + final String EXPECTED_RESULT = "Obama"; type(WORD_TO_TYPE); sleep(DELAY_TO_WAIT_FOR_UNDERLINE_MILLIS); runMessages(); @@ -809,22 +782,4 @@ public class InputLogicTests extends InputTestsBase { assertEquals("type word then type space yields predictions for French", EXPECTED_RESULT, suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null); } - - public void testAutoCorrectForGerman() { - final String STRING_TO_TYPE = "unf "; - final String EXPECTED_RESULT = "und "; - changeLanguage("de"); - type(STRING_TO_TYPE); - assertEquals("simple auto-correct for German", EXPECTED_RESULT, - mEditText.getText().toString()); - } - - public void testAutoCorrectWithUmlautForGerman() { - final String STRING_TO_TYPE = "ueber "; - final String EXPECTED_RESULT = "über "; - changeLanguage("de"); - type(STRING_TO_TYPE); - assertEquals("auto-correct with umlaut for German", EXPECTED_RESULT, - mEditText.getText().toString()); - } } diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java index 0d9b36ac0..dead53da2 100644 --- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java +++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java @@ -66,7 +66,8 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { protected static final int DELAY_TO_WAIT_FOR_PREDICTIONS_MILLIS = 200; // We wait for gesture computation for this delay protected static final int DELAY_TO_WAIT_FOR_GESTURE_MILLIS = 200; - private final int TIMEOUT_TO_WAIT_FOR_LOADING_MAIN_DICTIONARY_IN_SECONDS = 60; + // If a dictionary takes longer to load, we could have serious problems. + private final int TIMEOUT_TO_WAIT_FOR_LOADING_MAIN_DICTIONARY_IN_SECONDS = 5; // Type for a test phony dictionary private static final String TYPE_TEST = "test"; @@ -106,12 +107,15 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { throw new RuntimeException("Expected one span, found " + spans.length); } } + public SuggestionSpan getSpan() { + return (SuggestionSpan) mSpan; + } public boolean isAutoCorrectionIndicator() { return (mSpan instanceof SuggestionSpan) && - 0 != (SuggestionSpan.FLAG_AUTO_CORRECTION & ((SuggestionSpan)mSpan).getFlags()); + 0 != (SuggestionSpan.FLAG_AUTO_CORRECTION & getSpan().getFlags()); } public String[] getSuggestions() { - return ((SuggestionSpan)mSpan).getSuggestions(); + return getSpan().getSuggestions(); } } @@ -152,8 +156,6 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { super(LatinIMEForTests.class); } - // TODO: Isn't there a way to make this generic somehow? We can take a <T> and return a <T> - // but we'd have to dispatch types on editor.put...() functions protected boolean setBooleanPreference(final String key, final boolean value, final boolean defaultValue) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mLatinIME); diff --git a/tests/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerServiceTest.java b/tests/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerServiceTest.java index 2272d6ba0..e7c48da19 100644 --- a/tests/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerServiceTest.java +++ b/tests/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerServiceTest.java @@ -53,14 +53,8 @@ public class AndroidSpellCheckerServiceTest extends InputTestsBase { sleep(1000); final SpanGetter span = new SpanGetter(mEditText.getText(), SuggestionSpan.class); - // If no span, the following will crash - final String[] suggestions = span.getSuggestions(); - // For this test we consider "годп" should yield at least 2 suggestions (at this moment - // it yields 5). - assertTrue(suggestions.length >= 2); - // We also assume the top suggestion should be "года", which is the top word in the - // Russian dictionary. - assertEquals("", "года", suggestions[0]); + // We don't ship with Russian LM + assertNull(span.getSpan()); } public void testSpellcheckWithPeriods() { |