diff options
Diffstat (limited to 'tests/src/com/android/inputmethod/latin')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java | 130 |
1 files changed, 59 insertions, 71 deletions
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; } }; |