From 5b5ed3d6092ea539d8cfebd786c63ec0c784040b Mon Sep 17 00:00:00 2001 From: Jean Chalard Date: Mon, 21 Oct 2013 14:40:32 +0900 Subject: [PATCH] Fix a bug where autocaps would jam auto-commit Bug: 11311002 Change-Id: I62955e364c9ffc75322cf05fa3ad7985f1d09259 --- java/src/com/android/inputmethod/latin/Suggest.java | 2 +- .../android/inputmethod/latin/SuggestedWordsTests.java | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java index 72b9c417c..0a4c7a55d 100644 --- a/java/src/com/android/inputmethod/latin/Suggest.java +++ b/java/src/com/android/inputmethod/latin/Suggest.java @@ -479,7 +479,7 @@ public final class Suggest { } return new SuggestedWordInfo(sb.toString(), wordInfo.mScore, wordInfo.mKind, wordInfo.mSourceDict, wordInfo.mIndexOfTouchPointOfSecondWord, - SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */); + wordInfo.mAutoCommitFirstWordConfidence); } public void close() { diff --git a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java index a594baf0b..375352067 100644 --- a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java +++ b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java @@ -25,6 +25,7 @@ import com.android.inputmethod.latin.utils.CollectionUtils; import java.util.ArrayList; import java.util.Locale; +import java.util.Random; @SmallTest public class SuggestedWordsTests extends AndroidTestCase { @@ -72,15 +73,20 @@ public class SuggestedWordsTests extends AndroidTestCase { return new SuggestedWordInfo(s, 100, SuggestedWordInfo.KIND_TYPED, null /* sourceDict */, SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */, - SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */); + new Random().nextInt(1000000) /* autoCommitFirstWordConfidence */); } // Helper for testGetTransformedWordInfo private SuggestedWordInfo transformWordInfo(final String info, final int trailingSingleQuotesCount) { - return Suggest.getTransformedSuggestedWordInfo(createWordInfo(info), + final SuggestedWordInfo suggestedWordInfo = createWordInfo(info); + final SuggestedWordInfo returnedWordInfo = + Suggest.getTransformedSuggestedWordInfo(suggestedWordInfo, Locale.ENGLISH, false /* isAllUpperCase */, false /* isFirstCharCapitalized */, trailingSingleQuotesCount); + assertEquals(suggestedWordInfo.mAutoCommitFirstWordConfidence, + returnedWordInfo.mAutoCommitFirstWordConfidence); + return returnedWordInfo; } public void testGetTransformedSuggestedWordInfo() {