diff options
author | 2012-03-07 01:51:59 -0800 | |
---|---|---|
committer | 2012-03-07 01:51:59 -0800 | |
commit | dab392c6f4f5e02be36cde370758a3450bc85fb8 (patch) | |
tree | 0bf00693aec528dec7c9af11d5cf09c230a3e197 | |
parent | 3dd4bcb28339702755f0da25a26ea59bc4fa4a00 (diff) | |
parent | 845b24d9d31072b98958c557366617ad1c34f1b7 (diff) | |
download | latinime-dab392c6f4f5e02be36cde370758a3450bc85fb8.tar.gz latinime-dab392c6f4f5e02be36cde370758a3450bc85fb8.tar.xz latinime-dab392c6f4f5e02be36cde370758a3450bc85fb8.zip |
Merge "Fix a bug with successive manual picks"
-rw-r--r-- | java/src/com/android/inputmethod/latin/LatinIME.java | 8 | ||||
-rw-r--r-- | tests/src/com/android/inputmethod/latin/InputLogicTests.java | 27 |
2 files changed, 34 insertions, 1 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index e3a3b80bb..20423643e 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -1922,6 +1922,14 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar mVoiceProxy.flushAndLogAllTextModificationCounters(index, suggestion, mSettingsValues.mWordSeparators); + if (SPACE_STATE_PHANTOM == mSpaceState && suggestion.length() > 0) { + int firstChar = Character.codePointAt(suggestion, 0); + if ((!mSettingsValues.isWeakSpaceStripper(firstChar)) + && (!mSettingsValues.isWeakSpaceSwapper(firstChar))) { + sendKeyCodePoint(Keyboard.CODE_SPACE); + } + } + if (mInputAttributes.mApplicationSpecifiedCompletionOn && mApplicationSpecifiedCompletions != null && index >= 0 && index < mApplicationSpecifiedCompletions.length) { diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java index e3911f22f..50aba7b94 100644 --- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java +++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java @@ -404,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()); } |