diff options
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/com/android/inputmethod/keyboard/SpacebarTextTests.java | 31 | ||||
-rw-r--r-- | tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java | 130 |
2 files changed, 73 insertions, 88 deletions
diff --git a/tests/src/com/android/inputmethod/keyboard/SpacebarTextTests.java b/tests/src/com/android/inputmethod/keyboard/SpacebarTextTests.java index 015c2711c..4db54477c 100644 --- a/tests/src/com/android/inputmethod/keyboard/SpacebarTextTests.java +++ b/tests/src/com/android/inputmethod/keyboard/SpacebarTextTests.java @@ -17,7 +17,6 @@ package com.android.inputmethod.keyboard; import android.content.Context; -import android.content.res.Resources; import android.test.AndroidTestCase; import android.view.inputmethod.InputMethodSubtype; @@ -35,7 +34,6 @@ public class SpacebarTextTests extends AndroidTestCase { private final ArrayList<InputMethodSubtype> mSubtypesList = CollectionUtils.newArrayList(); private RichInputMethodManager mRichImm; - private Resources mRes; @Override protected void setUp() throws Exception { @@ -43,14 +41,13 @@ public class SpacebarTextTests extends AndroidTestCase { final Context context = getContext(); RichInputMethodManager.init(context); mRichImm = RichInputMethodManager.getInstance(); - mRes = context.getResources(); SubtypeLocale.init(context); } public void testAllFullDisplayName() { for (final InputMethodSubtype subtype : mSubtypesList) { - final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype, mRes); - final String spacebarText = MainKeyboardView.getFullDisplayName(subtype, mRes); + final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype); + final String spacebarText = MainKeyboardView.getFullDisplayName(subtype); final String languageName = SubtypeLocale.getSubtypeLocaleDisplayName(subtype.getLocale()); if (SubtypeLocale.isNoLanguage(subtype)) { @@ -63,7 +60,7 @@ public class SpacebarTextTests extends AndroidTestCase { public void testAllMiddleDisplayName() { for (final InputMethodSubtype subtype : mSubtypesList) { - final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype, mRes); + final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype); final String spacebarText = MainKeyboardView.getMiddleDisplayName(subtype); if (SubtypeLocale.isNoLanguage(subtype)) { assertEquals(subtypeName, @@ -78,7 +75,7 @@ public class SpacebarTextTests extends AndroidTestCase { public void testAllShortDisplayName() { for (final InputMethodSubtype subtype : mSubtypesList) { - final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype, mRes); + final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype); final Locale locale = SubtypeLocale.getSubtypeLocale(subtype); final String spacebarText = MainKeyboardView.getShortDisplayName(subtype); final String languageCode = StringUtils.toTitleCase(locale.getLanguage(), locale); @@ -120,17 +117,17 @@ public class SpacebarTextTests extends AndroidTestCase { SubtypeLocale.NO_LANGUAGE, "qwerty"); assertEquals("en_US", "English (US)", - MainKeyboardView.getFullDisplayName(EN_US, mRes)); + MainKeyboardView.getFullDisplayName(EN_US)); assertEquals("en_GB", "English (UK)", - MainKeyboardView.getFullDisplayName(EN_GB, mRes)); + MainKeyboardView.getFullDisplayName(EN_GB)); assertEquals("fr ", "Français", - MainKeyboardView.getFullDisplayName(FR, mRes)); + MainKeyboardView.getFullDisplayName(FR)); assertEquals("fr_CA", "Français (Canada)", - MainKeyboardView.getFullDisplayName(FR_CA, mRes)); + MainKeyboardView.getFullDisplayName(FR_CA)); assertEquals("de ", "Deutsch", - MainKeyboardView.getFullDisplayName(DE, mRes)); + MainKeyboardView.getFullDisplayName(DE)); assertEquals("zz ", "QWERTY", - MainKeyboardView.getFullDisplayName(ZZ, mRes)); + MainKeyboardView.getFullDisplayName(ZZ)); assertEquals("en_US", "English", MainKeyboardView.getMiddleDisplayName(EN_US)); assertEquals("en_GB", "English", MainKeyboardView.getMiddleDisplayName(EN_GB)); @@ -158,13 +155,13 @@ public class SpacebarTextTests extends AndroidTestCase { SubtypeLocale.NO_LANGUAGE, "azerty", null); assertEquals("fr qwertz", "Français (QWERTZ)", - MainKeyboardView.getFullDisplayName(FR_QWERTZ, mRes)); + MainKeyboardView.getFullDisplayName(FR_QWERTZ)); assertEquals("de qwerty", "Deutsch (QWERTY)", - MainKeyboardView.getFullDisplayName(DE_QWERTY, mRes)); + MainKeyboardView.getFullDisplayName(DE_QWERTY)); assertEquals("en_US azerty", "English (US) (AZERTY)", - MainKeyboardView.getFullDisplayName(US_AZERTY, mRes)); + MainKeyboardView.getFullDisplayName(US_AZERTY)); assertEquals("zz azerty", "AZERTY", - MainKeyboardView.getFullDisplayName(ZZ_AZERTY, mRes)); + MainKeyboardView.getFullDisplayName(ZZ_AZERTY)); assertEquals("fr qwertz", "Français", MainKeyboardView.getMiddleDisplayName(FR_QWERTZ)); assertEquals("de qwerty", "Deutsch", MainKeyboardView.getMiddleDisplayName(DE_QWERTY)); diff --git a/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java b/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java index 4e81de668..9af6dbc74 100644 --- a/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java +++ b/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java @@ -33,6 +33,18 @@ public class SubtypeLocaleTests extends AndroidTestCase { private RichInputMethodManager mRichImm; private Resources mRes; + InputMethodSubtype EN_US; + InputMethodSubtype EN_GB; + InputMethodSubtype ES_US; + InputMethodSubtype FR; + InputMethodSubtype FR_CA; + InputMethodSubtype DE; + InputMethodSubtype ZZ; + InputMethodSubtype DE_QWERTY; + InputMethodSubtype FR_QWERTZ; + InputMethodSubtype US_AZERTY; + InputMethodSubtype ZZ_AZERTY; + @Override protected void setUp() throws Exception { super.setUp(); @@ -41,11 +53,35 @@ public class SubtypeLocaleTests extends AndroidTestCase { mRichImm = RichInputMethodManager.getInstance(); mRes = context.getResources(); SubtypeLocale.init(context); + + EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( + Locale.US.toString(), "qwerty"); + EN_GB = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( + Locale.UK.toString(), "qwerty"); + ES_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( + "es_US", "spanish"); + FR = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( + Locale.FRENCH.toString(), "azerty"); + FR_CA = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( + Locale.CANADA_FRENCH.toString(), "qwerty"); + DE = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( + Locale.GERMAN.toString(), "qwertz"); + ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( + SubtypeLocale.NO_LANGUAGE, "qwerty"); + DE_QWERTY = AdditionalSubtype.createAdditionalSubtype( + Locale.GERMAN.toString(), "qwerty", null); + FR_QWERTZ = AdditionalSubtype.createAdditionalSubtype( + Locale.FRENCH.toString(), "qwertz", null); + US_AZERTY = AdditionalSubtype.createAdditionalSubtype( + Locale.US.toString(), "azerty", null); + ZZ_AZERTY = AdditionalSubtype.createAdditionalSubtype( + SubtypeLocale.NO_LANGUAGE, "azerty", null); + } public void testAllFullDisplayName() { for (final InputMethodSubtype subtype : mSubtypesList) { - final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype, mRes); + final String subtypeName = SubtypeLocale.getSubtypeDisplayName(subtype); if (SubtypeLocale.isNoLanguage(subtype)) { final String noLanguage = mRes.getString(R.string.subtype_no_language); assertTrue(subtypeName, subtypeName.contains(noLanguage)); @@ -74,21 +110,6 @@ public class SubtypeLocaleTests extends AndroidTestCase { // zz azerty T No language (AZERTY) in system locale public void testPredefinedSubtypesInEnglish() { - final InputMethodSubtype EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - Locale.US.toString(), "qwerty"); - final InputMethodSubtype EN_GB = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - Locale.UK.toString(), "qwerty"); - final InputMethodSubtype ES_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - "es_US", "spanish"); - final InputMethodSubtype FR = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - Locale.FRENCH.toString(), "azerty"); - final InputMethodSubtype FR_CA = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - Locale.CANADA_FRENCH.toString(), "qwerty"); - final InputMethodSubtype DE = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - Locale.GERMAN.toString(), "qwertz"); - final InputMethodSubtype ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - SubtypeLocale.NO_LANGUAGE, "qwerty"); - assertEquals("en_US", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(EN_US)); assertEquals("en_GB", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(EN_GB)); assertEquals("es_US", "spanish", SubtypeLocale.getKeyboardLayoutSetName(ES_US)); @@ -101,19 +122,19 @@ public class SubtypeLocaleTests extends AndroidTestCase { @Override protected Void job(Resources res) { assertEquals("en_US", "English (US)", - SubtypeLocale.getSubtypeDisplayName(EN_US, res)); + SubtypeLocale.getSubtypeDisplayName(EN_US)); assertEquals("en_GB", "English (UK)", - SubtypeLocale.getSubtypeDisplayName(EN_GB, res)); + SubtypeLocale.getSubtypeDisplayName(EN_GB)); assertEquals("es_US", "Español (EE.UU.)", - SubtypeLocale.getSubtypeDisplayName(ES_US, res)); + SubtypeLocale.getSubtypeDisplayName(ES_US)); assertEquals("fr ", "Français", - SubtypeLocale.getSubtypeDisplayName(FR, res)); + SubtypeLocale.getSubtypeDisplayName(FR)); assertEquals("fr_CA", "Français (Canada)", - SubtypeLocale.getSubtypeDisplayName(FR_CA, res)); + SubtypeLocale.getSubtypeDisplayName(FR_CA)); assertEquals("de ", "Deutsch", - SubtypeLocale.getSubtypeDisplayName(DE, res)); + SubtypeLocale.getSubtypeDisplayName(DE)); assertEquals("zz ", "No language (QWERTY)", - SubtypeLocale.getSubtypeDisplayName(ZZ, res)); + SubtypeLocale.getSubtypeDisplayName(ZZ)); return null; } }; @@ -121,26 +142,17 @@ public class SubtypeLocaleTests extends AndroidTestCase { } public void testAdditionalSubtypesInEnglish() { - final InputMethodSubtype DE_QWERTY = AdditionalSubtype.createAdditionalSubtype( - Locale.GERMAN.toString(), "qwerty", null); - final InputMethodSubtype FR_QWERTZ = AdditionalSubtype.createAdditionalSubtype( - Locale.FRENCH.toString(), "qwertz", null); - final InputMethodSubtype US_AZERTY = AdditionalSubtype.createAdditionalSubtype( - Locale.US.toString(), "azerty", null); - final InputMethodSubtype ZZ_AZERTY = AdditionalSubtype.createAdditionalSubtype( - SubtypeLocale.NO_LANGUAGE, "azerty", null); - final RunInLocale<Void> tests = new RunInLocale<Void>() { @Override protected Void job(Resources res) { assertEquals("fr qwertz", "Français (QWERTZ)", - SubtypeLocale.getSubtypeDisplayName(FR_QWERTZ, res)); + SubtypeLocale.getSubtypeDisplayName(FR_QWERTZ)); assertEquals("de qwerty", "Deutsch (QWERTY)", - SubtypeLocale.getSubtypeDisplayName(DE_QWERTY, res)); + SubtypeLocale.getSubtypeDisplayName(DE_QWERTY)); assertEquals("en_US azerty", "English (US) (AZERTY)", - SubtypeLocale.getSubtypeDisplayName(US_AZERTY, res)); + SubtypeLocale.getSubtypeDisplayName(US_AZERTY)); assertEquals("zz azerty", "No language (AZERTY)", - SubtypeLocale.getSubtypeDisplayName(ZZ_AZERTY, res)); + SubtypeLocale.getSubtypeDisplayName(ZZ_AZERTY)); return null; } }; @@ -148,38 +160,23 @@ public class SubtypeLocaleTests extends AndroidTestCase { } public void testPredefinedSubtypesInFrench() { - final InputMethodSubtype EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - Locale.US.toString(), "qwerty"); - final InputMethodSubtype EN_GB = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - Locale.UK.toString(), "qwerty"); - final InputMethodSubtype ES_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - "es_US", "spanish"); - final InputMethodSubtype FR = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - Locale.FRENCH.toString(), "azerty"); - final InputMethodSubtype FR_CA = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - Locale.CANADA_FRENCH.toString(), "qwerty"); - final InputMethodSubtype DE = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - Locale.GERMAN.toString(), "qwertz"); - final InputMethodSubtype ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( - SubtypeLocale.NO_LANGUAGE, "qwerty"); - final RunInLocale<Void> tests = new RunInLocale<Void>() { @Override protected Void job(Resources res) { assertEquals("en_US", "English (US)", - SubtypeLocale.getSubtypeDisplayName(EN_US, res)); + SubtypeLocale.getSubtypeDisplayName(EN_US)); assertEquals("en_GB", "English (UK)", - SubtypeLocale.getSubtypeDisplayName(EN_GB, res)); + SubtypeLocale.getSubtypeDisplayName(EN_GB)); assertEquals("es_US", "Español (EE.UU.)", - SubtypeLocale.getSubtypeDisplayName(ES_US, res)); + SubtypeLocale.getSubtypeDisplayName(ES_US)); assertEquals("fr ", "Français", - SubtypeLocale.getSubtypeDisplayName(FR, res)); + SubtypeLocale.getSubtypeDisplayName(FR)); assertEquals("fr_CA", "Français (Canada)", - SubtypeLocale.getSubtypeDisplayName(FR_CA, res)); + SubtypeLocale.getSubtypeDisplayName(FR_CA)); assertEquals("de ", "Deutsch", - SubtypeLocale.getSubtypeDisplayName(DE, res)); + SubtypeLocale.getSubtypeDisplayName(DE)); assertEquals("zz ", "Pas de langue (QWERTY)", - SubtypeLocale.getSubtypeDisplayName(ZZ, res)); + SubtypeLocale.getSubtypeDisplayName(ZZ)); return null; } }; @@ -187,26 +184,17 @@ public class SubtypeLocaleTests extends AndroidTestCase { } public void testAdditionalSubtypesInFrench() { - final InputMethodSubtype DE_QWERTY = AdditionalSubtype.createAdditionalSubtype( - Locale.GERMAN.toString(), "qwerty", null); - final InputMethodSubtype FR_QWERTZ = AdditionalSubtype.createAdditionalSubtype( - Locale.FRENCH.toString(), "qwertz", null); - final InputMethodSubtype US_AZERTY = AdditionalSubtype.createAdditionalSubtype( - Locale.US.toString(), "azerty", null); - final InputMethodSubtype ZZ_AZERTY = AdditionalSubtype.createAdditionalSubtype( - SubtypeLocale.NO_LANGUAGE, "azerty", null); - final RunInLocale<Void> tests = new RunInLocale<Void>() { @Override protected Void job(Resources res) { assertEquals("fr qwertz", "Français (QWERTZ)", - SubtypeLocale.getSubtypeDisplayName(FR_QWERTZ, res)); + SubtypeLocale.getSubtypeDisplayName(FR_QWERTZ)); assertEquals("de qwerty", "Deutsch (QWERTY)", - SubtypeLocale.getSubtypeDisplayName(DE_QWERTY, res)); + SubtypeLocale.getSubtypeDisplayName(DE_QWERTY)); assertEquals("en_US azerty", "English (US) (AZERTY)", - SubtypeLocale.getSubtypeDisplayName(US_AZERTY, res)); + SubtypeLocale.getSubtypeDisplayName(US_AZERTY)); assertEquals("zz azerty", "Aucune langue (AZERTY)", - SubtypeLocale.getSubtypeDisplayName(ZZ_AZERTY, res)); + SubtypeLocale.getSubtypeDisplayName(ZZ_AZERTY)); return null; } }; |