diff options
author | 2012-02-22 01:17:26 -0800 | |
---|---|---|
committer | 2012-02-22 01:35:11 -0800 | |
commit | bb15f92d4f80677587fae87fa2dd7a29ec465b4c (patch) | |
tree | d70b1f0e716532dc43c07fb1e709aebdf69d54b1 /tests/src/com/android/inputmethod/latin/InputLogicTests.java | |
parent | 5935950d4431dd7eef18ebc370f2abeb614465d4 (diff) | |
download | latinime-bb15f92d4f80677587fae87fa2dd7a29ec465b4c.tar.gz latinime-bb15f92d4f80677587fae87fa2dd7a29ec465b4c.tar.xz latinime-bb15f92d4f80677587fae87fa2dd7a29ec465b4c.zip |
Add some unit tests.
- Type "tgis", manually pick "thus", press backspace.
Backspace should revert the manual pick.
Check "tgis" is the result.
- Type "tgis" followed by a period.
Period should trigger auto-correct to "this".
Check "this" is the result.
- Type "tgis" followed by a period, then backspace.
Period should trigger auto-correct to "this", and backspace should
revert the auto-correction.
Check "tgis." is the result.
Change-Id: I7e23c8a26fbdbe23336149a05ff01bc51707422e
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/InputLogicTests.java')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/InputLogicTests.java | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java index 9d886da3b..78bd4d741 100644 --- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java +++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java @@ -169,6 +169,22 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> { mTextView.getText().toString()); } + public void testPickAutoCorrectionThenBackspace() { + final String WORD_TO_TYPE = "tgis"; + final String WORD_TO_PICK = "this"; + final String EXPECTED_RESULT = "tgis"; + type(WORD_TO_TYPE); + // Choose the auto-correction, which is always in position 0. For "tgis", the + // auto-correction should be "this". + mLatinIME.pickSuggestionManually(0, WORD_TO_PICK); + mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1); + assertEquals("pick typed word over auto-correction then backspace", WORD_TO_PICK, + mTextView.getText().toString()); + type(Keyboard.CODE_DELETE); + assertEquals("pick typed word over auto-correction then backspace", EXPECTED_RESULT, + mTextView.getText().toString()); + } + public void testPickTypedWordOverAutoCorrectionThenBackspace() { final String WORD_TO_TYPE = "tgis"; final String EXPECTED_RESULT = "tgis"; @@ -177,11 +193,29 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> { // 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); + assertEquals("pick typed word over auto-correction then backspace", WORD_TO_TYPE, + mTextView.getText().toString()); type(Keyboard.CODE_DELETE); assertEquals("pick typed word over auto-correction then backspace", EXPECTED_RESULT, mTextView.getText().toString()); } + public void testPickDifferentSuggestionThenBackspace() { + final String WORD_TO_TYPE = "tgis"; + final String WORD_TO_PICK = "thus"; + final String EXPECTED_RESULT = "tgis"; + type(WORD_TO_TYPE); + // Choose the second suggestion, which should be in position 2 and should be "thus" + // when "tgis is typed. + mLatinIME.pickSuggestionManually(2, WORD_TO_PICK); + mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1); + assertEquals("pick different suggestion then backspace", WORD_TO_PICK, + mTextView.getText().toString()); + type(Keyboard.CODE_DELETE); + assertEquals("pick different suggestion then backspace", EXPECTED_RESULT, + mTextView.getText().toString()); + } + public void testDeleteSelection() { final String STRING_TO_TYPE = "some text delete me some text"; final int SELECTION_START = 10; @@ -207,6 +241,23 @@ public class InputLogicTests extends ServiceTestCase<LatinIME> { assertEquals("simple auto-correct", EXPECTED_RESULT, mTextView.getText().toString()); } + public void testAutoCorrectWithPeriod() { + final String STRING_TO_TYPE = "tgis."; + final String EXPECTED_RESULT = "this."; + type(STRING_TO_TYPE); + assertEquals("auto-correct with period", EXPECTED_RESULT, mTextView.getText().toString()); + } + + public void testAutoCorrectWithPeriodThenRevert() { + final String STRING_TO_TYPE = "tgis."; + final String EXPECTED_RESULT = "tgis."; + type(STRING_TO_TYPE); + mLatinIME.onUpdateSelection(0, 0, STRING_TO_TYPE.length(), STRING_TO_TYPE.length(), -1, -1); + type(Keyboard.CODE_DELETE); + assertEquals("auto-correct with period then revert", EXPECTED_RESULT, + mTextView.getText().toString()); + } + public void testDoubleSpace() { final String STRING_TO_TYPE = "this "; final String EXPECTED_RESULT = "this. "; |