Fix a bug where predictions would not pop upon manual pick
Bug: 12295276 Change-Id: Id359c92acde44758b12929e7bac719d5c9c7577b
This commit is contained in:
parent
33b2aaafc2
commit
6bca9ac43d
3 changed files with 41 additions and 3 deletions
|
@ -472,7 +472,7 @@ public final class WordComposer {
|
||||||
mCapsCount = 0;
|
mCapsCount = 0;
|
||||||
mDigitsCount = 0;
|
mDigitsCount = 0;
|
||||||
mIsBatchMode = false;
|
mIsBatchMode = false;
|
||||||
mPreviousWordForSuggestion = mTypedWord.toString();
|
mPreviousWordForSuggestion = committedWord;
|
||||||
mTypedWord.setLength(0);
|
mTypedWord.setLength(0);
|
||||||
mCodePointSize = 0;
|
mCodePointSize = 0;
|
||||||
mTrailingSingleQuotesCount = 0;
|
mTrailingSingleQuotesCount = 0;
|
||||||
|
|
|
@ -1621,8 +1621,11 @@ public final class InputLogic {
|
||||||
chosenWord, separatorString, prevWord);
|
chosenWord, separatorString, prevWord);
|
||||||
final boolean shouldDiscardPreviousWordForSuggestion;
|
final boolean shouldDiscardPreviousWordForSuggestion;
|
||||||
if (0 == StringUtils.codePointCount(separatorString)) {
|
if (0 == StringUtils.codePointCount(separatorString)) {
|
||||||
// Separator is 0-length. Discard the word only if the current language has spaces.
|
// Separator is 0-length, we can keep the previous word for suggestion. Either this
|
||||||
shouldDiscardPreviousWordForSuggestion = settingsValues.mCurrentLanguageHasSpaces;
|
// was a manual pick or the language has no spaces in which case we want to keep the
|
||||||
|
// previous word, or it was the keyboard closing or the cursor moving in which case it
|
||||||
|
// will be reset anyway.
|
||||||
|
shouldDiscardPreviousWordForSuggestion = false;
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, we discard if the separator contains any non-whitespace.
|
// Otherwise, we discard if the separator contains any non-whitespace.
|
||||||
shouldDiscardPreviousWordForSuggestion =
|
shouldDiscardPreviousWordForSuggestion =
|
||||||
|
|
|
@ -348,4 +348,39 @@ public class InputLogicTests extends InputTestsBase {
|
||||||
helperTestComposing("a'", true);
|
helperTestComposing("a'", true);
|
||||||
}
|
}
|
||||||
// TODO: Add some tests for non-BMP characters
|
// TODO: Add some tests for non-BMP characters
|
||||||
|
|
||||||
|
public void testPredictionsAfterSpace() {
|
||||||
|
final String WORD_TO_TYPE = "Barack ";
|
||||||
|
type(WORD_TO_TYPE);
|
||||||
|
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
|
||||||
|
runMessages();
|
||||||
|
// Test the first prediction is displayed
|
||||||
|
final SuggestedWords suggestedWords = mLatinIME.getSuggestedWords();
|
||||||
|
assertEquals("predictions after space", "Obama",
|
||||||
|
suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testPredictionsAfterManualPick() {
|
||||||
|
final String WORD_TO_TYPE = "Barack";
|
||||||
|
type(WORD_TO_TYPE);
|
||||||
|
// Choose the auto-correction, which is always in position 0. For "Barack", the
|
||||||
|
// auto-correction should be "Barack".
|
||||||
|
pickSuggestionManually(0, WORD_TO_TYPE);
|
||||||
|
runMessages();
|
||||||
|
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
|
||||||
|
// Test the first prediction is displayed
|
||||||
|
final SuggestedWords suggestedWords = mLatinIME.getSuggestedWords();
|
||||||
|
assertEquals("predictions after manual pick", "Obama",
|
||||||
|
suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testNoPredictionsAfterPeriod() {
|
||||||
|
final String WORD_TO_TYPE = "Barack. ";
|
||||||
|
type(WORD_TO_TYPE);
|
||||||
|
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS);
|
||||||
|
runMessages();
|
||||||
|
// Test the first prediction is displayed
|
||||||
|
final SuggestedWords suggestedWords = mLatinIME.getSuggestedWords();
|
||||||
|
assertEquals("no prediction after period", 0, suggestedWords.size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue