aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/latin/InputLogicTests.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/InputLogicTests.java')
-rw-r--r--tests/src/com/android/inputmethod/latin/InputLogicTests.java57
1 files changed, 29 insertions, 28 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
index 50cccec5f..50aba7b94 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
@@ -51,29 +51,9 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> {
private LatinIME mLatinIME;
private TextView mTextView;
private InputConnection mInputConnection;
- private HashMap<Integer, int[]> mProximity;
public InputLogicTests() {
super(LatinIME.class);
- mProximity = createProximity();
- }
-
- private static HashMap<Integer, int[]> createProximity() {
- final HashMap<Integer, int[]> proximity = new HashMap<Integer, int[]>();
- final int[] testProximity = SpellCheckerProximityInfo.getProximityForScript(
- AndroidSpellCheckerService.SCRIPT_LATIN);
- final int ROW_SIZE = SpellCheckerProximityInfo.ROW_SIZE;
- final int NUL = SpellCheckerProximityInfo.NUL;
- for (int row = 0; row * ROW_SIZE < testProximity.length; ++row) {
- final int rowBase = row * ROW_SIZE;
- int column;
- for (column = 1; NUL != testProximity[rowBase + column]; ++column) {
- // Do nothing, just search for a NUL element
- }
- proximity.put(testProximity[row * ROW_SIZE],
- Arrays.copyOfRange(testProximity, rowBase, rowBase + column));
- }
- return proximity;
}
// returns the previous setting value
@@ -185,13 +165,9 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> {
// to keep these tests as pinpoint as possible and avoid bringing it too many dependencies,
// but keep them in mind if something breaks. Commenting them out as is should work.
//mLatinIME.onPressKey(codePoint);
- int[] proximityKeys = mProximity.get(codePoint);
- if (null == proximityKeys) {
- proximityKeys = new int[] { codePoint };
- }
- mLatinIME.onCodeInput(codePoint, proximityKeys,
- KeyboardActionListener.NOT_A_TOUCH_COORDINATE,
- KeyboardActionListener.NOT_A_TOUCH_COORDINATE);
+ mLatinIME.onCodeInput(codePoint,
+ KeyboardActionListener.SPELL_CHECKER_COORDINATE,
+ KeyboardActionListener.SPELL_CHECKER_COORDINATE);
//mLatinIME.onReleaseKey(codePoint, false);
}
@@ -428,7 +404,32 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> {
type(WORD1_TO_TYPE);
mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE);
type(WORD2_TO_TYPE);
- assertEquals("manual pick then space then type", WORD1_TO_TYPE + WORD2_TO_TYPE,
+ assertEquals("manual pick then space then type", EXPECTED_RESULT,
+ mTextView.getText().toString());
+ }
+
+ public void testManualPickThenManualPick() {
+ final String WORD1_TO_TYPE = "this";
+ final String WORD2_TO_PICK = "is";
+ final String EXPECTED_RESULT = "this is";
+ type(WORD1_TO_TYPE);
+ mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE);
+ // Here we fake picking a word through bigram prediction. This test is taking
+ // advantage of the fact that Latin IME blindly trusts the caller of #pickSuggestionManually
+ // to actually pass the right string.
+ mLatinIME.pickSuggestionManually(1, WORD2_TO_PICK);
+ assertEquals("manual pick then manual pick", EXPECTED_RESULT,
+ mTextView.getText().toString());
+ }
+
+ public void testManualPickThenManualPickWithPunctAtStart() {
+ final String WORD1_TO_TYPE = "this";
+ final String WORD2_TO_PICK = "!is";
+ final String EXPECTED_RESULT = "this!is";
+ type(WORD1_TO_TYPE);
+ mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE);
+ mLatinIME.pickSuggestionManually(1, WORD2_TO_PICK);
+ assertEquals("manual pick then manual pick a word with punct at start", EXPECTED_RESULT,
mTextView.getText().toString());
}