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.java86
1 files changed, 84 insertions, 2 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
index fef704a0e..9d886da3b 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
@@ -159,11 +159,26 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> {
}
public void testPickSuggestionThenBackspace() {
- final String WORD_TO_TYPE = "tgis";
+ final String WORD_TO_TYPE = "this";
+ final String EXPECTED_RESULT = "this";
type(WORD_TO_TYPE);
mLatinIME.pickSuggestionManually(0, WORD_TO_TYPE);
+ mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
type(Keyboard.CODE_DELETE);
- assertEquals("press suggestion then backspace", WORD_TO_TYPE,
+ assertEquals("press suggestion then backspace", EXPECTED_RESULT,
+ mTextView.getText().toString());
+ }
+
+ public void testPickTypedWordOverAutoCorrectionThenBackspace() {
+ final String WORD_TO_TYPE = "tgis";
+ final String EXPECTED_RESULT = "tgis";
+ type(WORD_TO_TYPE);
+ // Choose the typed word, which should be in position 1 (because position 0 should
+ // be occupied by the "this" auto-correction, as checked by testAutoCorrect())
+ mLatinIME.pickSuggestionManually(1, WORD_TO_TYPE);
+ mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
+ type(Keyboard.CODE_DELETE);
+ assertEquals("pick typed word over auto-correction then backspace", EXPECTED_RESULT,
mTextView.getText().toString());
}
@@ -314,4 +329,71 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> {
}
assertEquals("delete whole composing word", "", mTextView.getText().toString());
}
+
+ public void testManuallyPickedWordThenColon() {
+ final String WORD_TO_TYPE = "this";
+ final String PUNCTUATION = ":";
+ final String EXPECTED_RESULT = "this:";
+ type(WORD_TO_TYPE);
+ mLatinIME.pickSuggestionManually(0, WORD_TO_TYPE);
+ type(PUNCTUATION);
+ assertEquals("manually pick word then colon",
+ EXPECTED_RESULT, mTextView.getText().toString());
+ }
+
+ public void testManuallyPickedWordThenOpenParen() {
+ final String WORD_TO_TYPE = "this";
+ final String PUNCTUATION = "(";
+ final String EXPECTED_RESULT = "this (";
+ type(WORD_TO_TYPE);
+ mLatinIME.pickSuggestionManually(0, WORD_TO_TYPE);
+ type(PUNCTUATION);
+ assertEquals("manually pick word then open paren",
+ EXPECTED_RESULT, mTextView.getText().toString());
+ }
+
+ public void testManuallyPickedWordThenCloseParen() {
+ final String WORD_TO_TYPE = "this";
+ final String PUNCTUATION = ")";
+ final String EXPECTED_RESULT = "this)";
+ type(WORD_TO_TYPE);
+ mLatinIME.pickSuggestionManually(0, WORD_TO_TYPE);
+ type(PUNCTUATION);
+ assertEquals("manually pick word then close paren",
+ EXPECTED_RESULT, mTextView.getText().toString());
+ }
+
+ public void testManuallyPickedWordThenSmiley() {
+ final String WORD_TO_TYPE = "this";
+ final String SPECIAL_KEY = ":-)";
+ final String EXPECTED_RESULT = "this :-)";
+ type(WORD_TO_TYPE);
+ mLatinIME.pickSuggestionManually(0, WORD_TO_TYPE);
+ mLatinIME.onTextInput(SPECIAL_KEY);
+ assertEquals("manually pick word then press the smiley key",
+ EXPECTED_RESULT, mTextView.getText().toString());
+ }
+
+ public void testManuallyPickedWordThenDotCom() {
+ final String WORD_TO_TYPE = "this";
+ final String SPECIAL_KEY = ".com";
+ final String EXPECTED_RESULT = "this.com";
+ type(WORD_TO_TYPE);
+ mLatinIME.pickSuggestionManually(0, WORD_TO_TYPE);
+ mLatinIME.onTextInput(SPECIAL_KEY);
+ assertEquals("manually pick word then press the .com key",
+ EXPECTED_RESULT, mTextView.getText().toString());
+ }
+
+ public void testTypeWordTypeDotThenPressDotCom() {
+ final String WORD_TO_TYPE = "this.";
+ final String SPECIAL_KEY = ".com";
+ final String EXPECTED_RESULT = "this.com";
+ type(WORD_TO_TYPE);
+ mLatinIME.onTextInput(SPECIAL_KEY);
+ assertEquals("type word type dot then press the .com key",
+ EXPECTED_RESULT, mTextView.getText().toString());
+ }
+
+ // TODO: Add some tests for non-BMP characters
}