am 4e28a6a8: Fix an IOOB exception
* commit '4e28a6a844d057abd4d078fba5b2d2e2cd11747b': Fix an IOOB exceptionmain
commit
3bd8eee3e8
|
@ -429,7 +429,7 @@ public class SuggestedWords {
|
|||
*/
|
||||
@UsedForTesting
|
||||
public SuggestedWordInfo getTypedWordInfoOrNull() {
|
||||
if (this == EMPTY) {
|
||||
if (SuggestedWords.INDEX_OF_TYPED_WORD >= size()) {
|
||||
return null;
|
||||
}
|
||||
final SuggestedWordInfo info = getInfo(SuggestedWords.INDEX_OF_TYPED_WORD);
|
||||
|
|
|
@ -148,5 +148,15 @@ public class SuggestedWordsTests extends AndroidTestCase {
|
|||
|
||||
// Make sure getTypedWordInfoOrNull() returns null.
|
||||
assertNull(SuggestedWords.EMPTY.getTypedWordInfoOrNull());
|
||||
|
||||
final SuggestedWords emptySuggestedWords = new SuggestedWords(
|
||||
new ArrayList<SuggestedWordInfo>(), null /* rawSuggestions */,
|
||||
false /* typedWordValid */,
|
||||
false /* willAutoCorrect */,
|
||||
false /* isObsoleteSuggestions */,
|
||||
SuggestedWords.INPUT_STYLE_NONE);
|
||||
assertNull(emptySuggestedWords.getTypedWordInfoOrNull());
|
||||
|
||||
assertNull(SuggestedWords.EMPTY.getTypedWordInfoOrNull());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue