diff options
author | 2014-08-08 09:01:07 +0000 | |
---|---|---|
committer | 2014-08-08 09:01:07 +0000 | |
commit | 9306c027b199c201fe08fddb1f2f125c3243b09d (patch) | |
tree | 502ff3300bdb796aca6752c5738aeab8d35a8d52 /tests/src | |
parent | 16dd35bfb60494000f899b1fa334a2c98af79857 (diff) | |
parent | aaa2ce26203f3e85e7783ccd21275702ebfbe366 (diff) | |
download | latinime-9306c027b199c201fe08fddb1f2f125c3243b09d.tar.gz latinime-9306c027b199c201fe08fddb1f2f125c3243b09d.tar.xz latinime-9306c027b199c201fe08fddb1f2f125c3243b09d.zip |
am aaa2ce26: am 6fef4ff0: Merge "Use suggestions in the distracter filter." into lmp-dev
* commit 'aaa2ce26203f3e85e7783ccd21275702ebfbe366':
Use suggestions in the distracter filter.
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 "à". |