aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-08-26 18:54:08 +0900
committerJean Chalard <jchalard@google.com>2014-08-26 20:35:59 +0900
commit8380f921f7edaeea2033a1e967a14941400fe246 (patch)
treedb2e7cd9758440158a6e4096be43161ca2481c5b /tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
parentfdfe73ff1f4b8c9d7d8728baa322d70c3a74df99 (diff)
downloadlatinime-8380f921f7edaeea2033a1e967a14941400fe246.tar.gz
latinime-8380f921f7edaeea2033a1e967a14941400fe246.tar.xz
latinime-8380f921f7edaeea2033a1e967a14941400fe246.zip
Fix a bug where the top prediction would disappear.
This is because prediction can't be easily distinguished in style. This fixes the bug by simulating the right members, but some refactoring should be done to remove useless booleans. Bug: 17271923 Change-Id: Ib88f3fb95678021624e59535492926dd315d26fb
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java')
-rw-r--r--tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java19
1 files changed, 10 insertions, 9 deletions
diff --git a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
index 2785dec43..c28d08cdb 100644
--- a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
+++ b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
@@ -62,6 +62,7 @@ public class SuggestedWordsTests extends AndroidTestCase {
public void testGetSuggestedWordsExcludingTypedWord() {
final String TYPED_WORD = "typed";
final int NUMBER_OF_ADDED_SUGGESTIONS = 5;
+ final int KIND_OF_SECOND_CORRECTION = SuggestedWordInfo.KIND_CORRECTION;
final ArrayList<SuggestedWordInfo> list = new ArrayList<>();
list.add(createTypedWordInfo(TYPED_WORD));
for (int i = 0; i < NUMBER_OF_ADDED_SUGGESTIONS; ++i) {
@@ -73,21 +74,23 @@ public class SuggestedWordsTests extends AndroidTestCase {
false /* typedWordValid */,
false /* willAutoCorrect */,
false /* isObsoleteSuggestions */,
- false /* isPrediction*/,
SuggestedWords.INPUT_STYLE_NONE);
assertEquals(NUMBER_OF_ADDED_SUGGESTIONS + 1, words.size());
assertEquals("typed", words.getWord(0));
assertTrue(words.getInfo(0).isKindOf(SuggestedWordInfo.KIND_TYPED));
assertEquals("0", words.getWord(1));
- assertTrue(words.getInfo(1).isKindOf(SuggestedWordInfo.KIND_CORRECTION));
+ assertTrue(words.getInfo(1).isKindOf(KIND_OF_SECOND_CORRECTION));
assertEquals("4", words.getWord(5));
- assertTrue(words.getInfo(5).isKindOf(SuggestedWordInfo.KIND_CORRECTION));
+ assertTrue(words.getInfo(5).isKindOf(KIND_OF_SECOND_CORRECTION));
- final SuggestedWords wordsWithoutTyped = words.getSuggestedWordsExcludingTypedWord(
- SuggestedWords.INPUT_STYLE_NONE);
+ final SuggestedWords wordsWithoutTyped =
+ words.getSuggestedWordsExcludingTypedWordForRecorrection();
+ // Make sure that the typed word has indeed been excluded, by testing the size of the
+ // suggested words, the string and the kind of the top suggestion, which should match
+ // the string and kind of what we inserted after the typed word.
assertEquals(words.size() - 1, wordsWithoutTyped.size());
assertEquals("0", wordsWithoutTyped.getWord(0));
- assertTrue(wordsWithoutTyped.getInfo(0).isKindOf(SuggestedWordInfo.KIND_CORRECTION));
+ assertTrue(wordsWithoutTyped.getInfo(0).isKindOf(KIND_OF_SECOND_CORRECTION));
}
// Helper for testGetTransformedWordInfo
@@ -133,7 +136,6 @@ public class SuggestedWordsTests extends AndroidTestCase {
false /* typedWordValid */,
false /* willAutoCorrect */,
false /* isObsoleteSuggestions */,
- false /* isPrediction*/,
SuggestedWords.INPUT_STYLE_NONE);
final SuggestedWordInfo typedWord = wordsWithTypedWord.getTypedWordInfoOrNull();
assertNotNull(typedWord);
@@ -141,8 +143,7 @@ public class SuggestedWordsTests extends AndroidTestCase {
// Make sure getTypedWordInfoOrNull() returns null.
final SuggestedWords wordsWithoutTypedWord =
- wordsWithTypedWord.getSuggestedWordsExcludingTypedWord(
- SuggestedWords.INPUT_STYLE_NONE);
+ wordsWithTypedWord.getSuggestedWordsExcludingTypedWordForRecorrection();
assertNull(wordsWithoutTypedWord.getTypedWordInfoOrNull());
// Make sure getTypedWordInfoOrNull() returns null.