aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java9
-rw-r--r--tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java19
-rw-r--r--tests/src/com/android/inputmethod/latin/settings/SpacingAndPunctuationsTests.java2
3 files changed, 18 insertions, 12 deletions
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java b/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java
index a353e5a35..986a233c1 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/MockKeyboardSwitcher.java
@@ -18,6 +18,7 @@ package com.android.inputmethod.keyboard.internal;
import android.text.TextUtils;
+import com.android.inputmethod.event.Event;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.utils.RecapitalizeStatus;
@@ -26,7 +27,7 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
// Argument for {@link KeyboardState#onPressKey} and {@link KeyboardState#onReleaseKey}.
public static final boolean NOT_SLIDING = false;
public static final boolean SLIDING = true;
- // Argument for {@link KeyboardState#onCodeInput}.
+ // Argument for {@link KeyboardState#onEvent}.
public static final boolean SINGLE = true;
public static final boolean MULTI = false;
public static final int CAP_MODE_OFF = Constants.TextUtils.CAP_MODE_OFF;
@@ -183,7 +184,11 @@ public class MockKeyboardSwitcher implements KeyboardState.SwitchActions {
} else {
mAutoCapsState = mAutoCapsMode;
}
- mState.onCodeInput(code, mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
+ final Event event =
+ Event.createSoftwareKeypressEvent(code /* codePoint */, code /* keyCode */,
+ Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE,
+ false /* isKeyRepeat */);
+ mState.onEvent(event, mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE);
}
public void onFinishSlidingInput() {
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,