aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/latin/InputLogicTests.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-02-18 03:01:35 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2014-02-18 03:01:35 -0800
commit6eb49ba8358d7a8bb31e232fe0c504c1b52e0667 (patch)
tree262668ae49c3dbad1c112a2c0563373e7d4e200a /tests/src/com/android/inputmethod/latin/InputLogicTests.java
parentdb10e81973b4207eebebc377403b67703631918a (diff)
parent28e0b249650d08f25f2b7da8034e09a244be825c (diff)
downloadlatinime-6eb49ba8358d7a8bb31e232fe0c504c1b52e0667.tar.gz
latinime-6eb49ba8358d7a8bb31e232fe0c504c1b52e0667.tar.xz
latinime-6eb49ba8358d7a8bb31e232fe0c504c1b52e0667.zip
am 28e0b249: Merge "Fix a bug where the cache would be out of sync"
* commit '28e0b249650d08f25f2b7da8034e09a244be825c': Fix a bug where the cache would be out of sync
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/InputLogicTests.java')
-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);
+ }
}