aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-08-26 12:25:59 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-08-26 12:25:59 +0000
commit2a2d324eb627807a9d09b491fbb4ac78ffb253fc (patch)
treeff2659369eb2c6e7d4a0400fcdb3cf10b40c518d /tests/src
parentabf05cc0da1ead7e270a7c99bf9f000dabf91f5b (diff)
parent8380f921f7edaeea2033a1e967a14941400fe246 (diff)
downloadlatinime-2a2d324eb627807a9d09b491fbb4ac78ffb253fc.tar.gz
latinime-2a2d324eb627807a9d09b491fbb4ac78ffb253fc.tar.xz
latinime-2a2d324eb627807a9d09b491fbb4ac78ffb253fc.zip
am 8380f921: Fix a bug where the top prediction would disappear.
* commit '8380f921f7edaeea2033a1e967a14941400fe246': Fix a bug where the top prediction would disappear.
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java19
-rw-r--r--tests/src/com/android/inputmethod/latin/settings/SpacingAndPunctuationsTests.java2
2 files changed, 11 insertions, 10 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.
diff --git a/tests/src/com/android/inputmethod/latin/settings/SpacingAndPunctuationsTests.java b/tests/src/com/android/inputmethod/latin/settings/SpacingAndPunctuationsTests.java
index 2cc22fae4..eb76032b1 100644
--- a/tests/src/com/android/inputmethod/latin/settings/SpacingAndPunctuationsTests.java
+++ b/tests/src/com/android/inputmethod/latin/settings/SpacingAndPunctuationsTests.java
@@ -429,7 +429,7 @@ public class SpacingAndPunctuationsTests extends AndroidTestCase {
assertFalse("willAutoCorrect", suggestedWords.mWillAutoCorrect);
assertTrue("isPunctuationSuggestions", suggestedWords.isPunctuationSuggestions());
assertFalse("isObsoleteSuggestions", suggestedWords.mIsObsoleteSuggestions);
- assertFalse("isPrediction", suggestedWords.mIsPrediction);
+ assertFalse("isPrediction", suggestedWords.isPrediction());
assertEquals("size", punctuationLabels.length, suggestedWords.size());
for (int index = 0; index < suggestedWords.size(); index++) {
assertEquals("punctuation label at " + index,