aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/inputmethod/latin/InputTestsBase.java8
-rw-r--r--tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java45
2 files changed, 15 insertions, 38 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
index 6860bea45..ee7942450 100644
--- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java
+++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
@@ -39,6 +39,8 @@ import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils;
import com.android.inputmethod.event.Event;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
+import com.android.inputmethod.latin.Dictionary;
+import com.android.inputmethod.latin.Dictionary.PhonyDictionary;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import com.android.inputmethod.latin.settings.DebugSettings;
import com.android.inputmethod.latin.settings.Settings;
@@ -61,6 +63,10 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> {
protected static final int DELAY_TO_WAIT_FOR_PREDICTIONS = 200;
private final int TIMEOUT_TO_WAIT_FOR_LOADING_MAIN_DICTIONARY_IN_SECONDS = 60;
+ // Type for a test phony dictionary
+ private static final String TYPE_TEST = "test";
+ private static final PhonyDictionary DICTIONARY_TEST = new PhonyDictionary(TYPE_TEST);
+
protected LatinIME mLatinIME;
protected Keyboard mKeyboard;
protected MyEditText mEditText;
@@ -353,7 +359,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> {
protected void pickSuggestionManually(final String suggestion) {
mLatinIME.pickSuggestionManually(new SuggestedWordInfo(suggestion, 1,
- SuggestedWordInfo.KIND_CORRECTION, null /* sourceDict */,
+ SuggestedWordInfo.KIND_CORRECTION, DICTIONARY_TEST,
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */));
}
diff --git a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
index 563261f8f..221541e4a 100644
--- a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
+++ b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
@@ -59,40 +59,6 @@ public class SuggestedWordsTests extends AndroidTestCase {
SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */);
}
- 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) {
- list.add(createCorrectionWordInfo(Integer.toString(i)));
- }
-
- final SuggestedWords words = new SuggestedWords(
- list, null /* rawSuggestions */,
- false /* typedWordValid */,
- false /* willAutoCorrect */,
- false /* isObsoleteSuggestions */,
- 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(KIND_OF_SECOND_CORRECTION));
- assertEquals("4", words.getWord(5));
- assertTrue(words.getInfo(5).isKindOf(KIND_OF_SECOND_CORRECTION));
-
- 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(KIND_OF_SECOND_CORRECTION));
- }
-
// Helper for testGetTransformedWordInfo
private SuggestedWordInfo transformWordInfo(final String info,
final int trailingSingleQuotesCount) {
@@ -141,9 +107,14 @@ public class SuggestedWordsTests extends AndroidTestCase {
assertNotNull(typedWord);
assertEquals(TYPED_WORD, typedWord.mWord);
- // Make sure getTypedWordInfoOrNull() returns null.
- final SuggestedWords wordsWithoutTypedWord =
- wordsWithTypedWord.getSuggestedWordsExcludingTypedWordForRecorrection();
+ // Make sure getTypedWordInfoOrNull() returns null when no typed word.
+ list.remove(0);
+ final SuggestedWords wordsWithoutTypedWord = new SuggestedWords(
+ list, null /* rawSuggestions */,
+ false /* typedWordValid */,
+ false /* willAutoCorrect */,
+ false /* isObsoleteSuggestions */,
+ SuggestedWords.INPUT_STYLE_NONE);
assertNull(wordsWithoutTypedWord.getTypedWordInfoOrNull());
// Make sure getTypedWordInfoOrNull() returns null.