diff options
author | 2014-08-08 08:05:11 +0000 | |
---|---|---|
committer | 2014-08-07 16:56:07 +0000 | |
commit | 6fef4ff00d78fcf1b4bcd840899bcf02d1b6869f (patch) | |
tree | 669f0345f19d182e376bda2c93e53c3631f7defe /tests/src | |
parent | 83a96fe5c748926d53a3771d2913a0a1012753c2 (diff) | |
parent | 33ca0c80c1b0fa6b695bbd9907e8942996b8c0b5 (diff) | |
download | latinime-6fef4ff00d78fcf1b4bcd840899bcf02d1b6869f.tar.gz latinime-6fef4ff00d78fcf1b4bcd840899bcf02d1b6869f.tar.xz latinime-6fef4ff00d78fcf1b4bcd840899bcf02d1b6869f.zip |
Merge "Use suggestions in the distracter filter." into lmp-dev
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/DistracterFilterTest.java | 62 |
1 files changed, 54 insertions, 8 deletions
diff --git a/tests/src/com/android/inputmethod/latin/DistracterFilterTest.java b/tests/src/com/android/inputmethod/latin/DistracterFilterTest.java index 70b8f530a..6285d16f0 100644 --- a/tests/src/com/android/inputmethod/latin/DistracterFilterTest.java +++ b/tests/src/com/android/inputmethod/latin/DistracterFilterTest.java @@ -16,9 +16,13 @@ package com.android.inputmethod.latin; +import java.util.ArrayList; import java.util.Locale; +import android.content.Context; +import android.test.AndroidTestCase; import android.test.suitebuilder.annotation.LargeTest; +import android.view.inputmethod.InputMethodSubtype; import com.android.inputmethod.latin.utils.DistracterFilterCheckingExactMatches; @@ -26,14 +30,24 @@ import com.android.inputmethod.latin.utils.DistracterFilterCheckingExactMatches; * Unit test for DistracterFilter */ @LargeTest -public class DistracterFilterTest extends InputTestsBase { +public class DistracterFilterTest extends AndroidTestCase { private DistracterFilterCheckingExactMatches mDistracterFilter; @Override protected void setUp() throws Exception { super.setUp(); - mDistracterFilter = new DistracterFilterCheckingExactMatches(getContext()); - mDistracterFilter.updateEnabledSubtypes(mLatinIME.getEnabledSubtypesForTest()); + final Context context = getContext(); + mDistracterFilter = new DistracterFilterCheckingExactMatches(context); + RichInputMethodManager.init(context); + final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); + final ArrayList<InputMethodSubtype> subtypes = new ArrayList<>(); + subtypes.add(richImm.findSubtypeByLocaleAndKeyboardLayoutSet( + Locale.US.toString(), "qwerty")); + subtypes.add(richImm.findSubtypeByLocaleAndKeyboardLayoutSet( + Locale.FRENCH.toString(), "azerty")); + subtypes.add(richImm.findSubtypeByLocaleAndKeyboardLayoutSet( + Locale.GERMAN.toString(), "qwertz")); + mDistracterFilter.updateEnabledSubtypes(subtypes); } public void testIsDistractorToWordsInDictionaries() { @@ -104,24 +118,56 @@ public class DistracterFilterTest extends InputTestsBase { assertFalse(mDistracterFilter.isDistracterToWordsInDictionaries( EMPTY_PREV_WORDS_INFO, typedWord, localeEnUs)); - final Locale localeDeDe = new Locale("de", "DE"); + typedWord = "thabk"; + // For this test case, we consider "thabk" is a distracter to "thank" + assertTrue(mDistracterFilter.isDistracterToWordsInDictionaries( + EMPTY_PREV_WORDS_INFO, typedWord, localeEnUs)); - typedWord = "fuer"; - // For this test case, we consider "fuer" is a distracter to "für". + typedWord = "thanks"; + // For this test case, we consider "thanks" is not a distracter to any other word + // in dictionaries. + assertFalse(mDistracterFilter.isDistracterToWordsInDictionaries( + EMPTY_PREV_WORDS_INFO, typedWord, localeEnUs)); + + typedWord = "thabks"; + // For this test case, we consider "thabks" is a distracter to "thanks" assertTrue(mDistracterFilter.isDistracterToWordsInDictionaries( - EMPTY_PREV_WORDS_INFO, typedWord, localeDeDe)); + EMPTY_PREV_WORDS_INFO, typedWord, localeEnUs)); + + typedWord = "think"; + // For this test case, we consider "think" is not a distracter to any other word + // in dictionaries. + assertFalse(mDistracterFilter.isDistracterToWordsInDictionaries( + EMPTY_PREV_WORDS_INFO, typedWord, localeEnUs)); + + typedWord = "thibk"; + // For this test case, we consider "thibk" is a distracter to "think" + assertTrue(mDistracterFilter.isDistracterToWordsInDictionaries( + EMPTY_PREV_WORDS_INFO, typedWord, localeEnUs)); + + typedWord = "tgis"; + // For this test case, we consider "tgis" is a distracter to "this" + assertTrue(mDistracterFilter.isDistracterToWordsInDictionaries( + EMPTY_PREV_WORDS_INFO, typedWord, localeEnUs)); + + final Locale localeDeDe = new Locale("de"); typedWord = "fUEr"; // For this test case, we consider "fUEr" is a distracter to "für". assertTrue(mDistracterFilter.isDistracterToWordsInDictionaries( EMPTY_PREV_WORDS_INFO, typedWord, localeDeDe)); + typedWord = "fuer"; + // For this test case, we consider "fuer" is a distracter to "für". + assertTrue(mDistracterFilter.isDistracterToWordsInDictionaries( + EMPTY_PREV_WORDS_INFO, typedWord, localeDeDe)); + typedWord = "fur"; // For this test case, we consider "fur" is a distracter to "für". assertTrue(mDistracterFilter.isDistracterToWordsInDictionaries( EMPTY_PREV_WORDS_INFO, typedWord, localeDeDe)); - final Locale localeFrFr = new Locale("fr", "FR"); + final Locale localeFrFr = new Locale("fr"); typedWord = "a"; // For this test case, we consider "a" is a distracter to "à". |