diff options
author | 2015-02-25 15:57:59 -0800 | |
---|---|---|
committer | 2015-02-25 17:59:58 -0800 | |
commit | 5551302d275e3f54da9d86bcea633556ad12db8e (patch) | |
tree | 546240c21be53d829fe1521b6db126671e8e3594 /tests | |
parent | ed378c78a15757c7386d84c6cd7470d56ed00c76 (diff) | |
download | latinime-5551302d275e3f54da9d86bcea633556ad12db8e.tar.gz latinime-5551302d275e3f54da9d86bcea633556ad12db8e.tar.xz latinime-5551302d275e3f54da9d86bcea633556ad12db8e.zip |
Don't assume that correctable words are invalid
Currently, the Delight3DictionaryFacilitator sets a boolean flag when the top
suggestion score exceeds the auto-correction threshold. This flag is used to
trigger auto-correction of the typed word. Also, the existing logic assumes
that if allowsToBeAutoCorrected then the word is invalid, which is no longer
true after we stopped using whitelists.
Bug 19518376.
Change-Id: Ifa7f6a09c07d25ac68c6cf3aec91f358bd88689f
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java index f658d726b..657cec8d7 100644 --- a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java +++ b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java @@ -59,6 +59,14 @@ public class SuggestedWordsTests extends AndroidTestCase { SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */); } + private static ArrayList<SuggestedWordInfo> createCorrectionWordInfos(final String... words) { + final ArrayList<SuggestedWordInfo> infos = new ArrayList<>(); + for (final String word : words) { + infos.add(createCorrectionWordInfo(word)); + } + return infos; + } + // Helper for testGetTransformedWordInfo private static SuggestedWordInfo transformWordInfo(final String info, final int trailingSingleQuotesCount) { @@ -72,6 +80,30 @@ public class SuggestedWordsTests extends AndroidTestCase { return returnedWordInfo; } + public void testRemoveDupesNoDupes() { + final ArrayList<SuggestedWordInfo> infos = createCorrectionWordInfos("a", "c"); + assertEquals(-1, SuggestedWordInfo.removeDups("b", infos)); + assertEquals(2, infos.size()); + } + + public void testRemoveDupesTypedWordNotDupe() { + final ArrayList<SuggestedWordInfo> infos = createCorrectionWordInfos("a", "a", "c"); + assertEquals(-1, SuggestedWordInfo.removeDups("b", infos)); + assertEquals(2, infos.size()); + } + + public void testRemoveDupesTypedWordOnlyDupe() { + final ArrayList<SuggestedWordInfo> infos = createCorrectionWordInfos("a", "b", "c"); + assertEquals(1, SuggestedWordInfo.removeDups("b", infos)); + assertEquals(2, infos.size()); + } + + public void testRemoveDupesTypedWordNotOnlyDupe() { + final ArrayList<SuggestedWordInfo> infos = createCorrectionWordInfos("a", "b", "b", "c"); + assertEquals(1, SuggestedWordInfo.removeDups("b", infos)); + assertEquals(2, infos.size()); + } + public void testGetTransformedSuggestedWordInfo() { SuggestedWordInfo result = transformWordInfo("word", 0); assertEquals(result.mWord, "word"); |