aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-02-18 10:58:50 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-02-18 10:58:50 +0000
commit28e0b249650d08f25f2b7da8034e09a244be825c (patch)
treebdbc1ad91678235a76e703a84a6fbfd6d2ccd53a /tests
parent783dabb812d983a7c56dbb1071145c5e58da9ff1 (diff)
parentfe92c174ea08f9f593432f0ab20961700de9e027 (diff)
downloadlatinime-28e0b249650d08f25f2b7da8034e09a244be825c.tar.gz
latinime-28e0b249650d08f25f2b7da8034e09a244be825c.tar.xz
latinime-28e0b249650d08f25f2b7da8034e09a244be825c.zip
Merge "Fix a bug where the cache would be out of sync"
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/inputmethod/latin/InputLogicTests.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
index 4222c66c8..444b8fad3 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
@@ -385,4 +385,41 @@ public class InputLogicTests extends InputTestsBase {
final SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest();
assertEquals("no prediction after period", 0, suggestedWords.size());
}
+
+ public void testPredictionsAfterRecorrection() {
+ final String PREFIX = "A ";
+ final String WORD_TO_TYPE = "Barack";
+ final String FIRST_NON_TYPED_SUGGESTION = "Barrack";
+ final int endOfPrefix = PREFIX.length();
+ final int endOfWord = endOfPrefix + WORD_TO_TYPE.length();
+ final int endOfSuggestion = endOfPrefix + FIRST_NON_TYPED_SUGGESTION.length();
+ final int indexForManualCursor = endOfPrefix + 3; // +3 because it's after "Bar" in "Barack"
+ type(PREFIX);
+ mLatinIME.onUpdateSelection(0, 0, endOfPrefix, endOfPrefix, -1, -1);
+ type(WORD_TO_TYPE);
+ pickSuggestionManually(1, FIRST_NON_TYPED_SUGGESTION);
+ mLatinIME.onUpdateSelection(endOfPrefix, endOfPrefix, endOfSuggestion, endOfSuggestion,
+ -1, -1);
+ runMessages();
+ type(" ");
+ mLatinIME.onUpdateSelection(endOfSuggestion, endOfSuggestion,
+ endOfSuggestion + 1, endOfSuggestion + 1, -1, -1);
+ sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
+ runMessages();
+ // Simulate a manual cursor move
+ mInputConnection.setSelection(indexForManualCursor, indexForManualCursor);
+ mLatinIME.onUpdateSelection(endOfSuggestion + 1, endOfSuggestion + 1,
+ indexForManualCursor, indexForManualCursor, -1, -1);
+ sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
+ runMessages();
+ pickSuggestionManually(0, WORD_TO_TYPE);
+ mLatinIME.onUpdateSelection(indexForManualCursor, indexForManualCursor,
+ endOfWord, endOfWord, -1, -1);
+ sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
+ runMessages();
+ // Test the first prediction is displayed
+ final SuggestedWords suggestedWords = mLatinIME.getSuggestedWords();
+ assertEquals("predictions after recorrection", "Obama",
+ suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
+ }
}