aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/latin/utils/SpacebarLanguageUtilsTests.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2014-10-28 09:39:59 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-10-28 09:40:00 +0000
commit1290399123e515d0068e0d8604e87972890178c0 (patch)
tree58851f99f2a18273524dc792ab11a4b60c9bb7e5 /tests/src/com/android/inputmethod/latin/utils/SpacebarLanguageUtilsTests.java
parentdabc12974c01992f9eb612658b4e860de52f2284 (diff)
parentfec52199741454f70d5934c8553e1b5561dc2674 (diff)
downloadlatinime-1290399123e515d0068e0d8604e87972890178c0.tar.gz
latinime-1290399123e515d0068e0d8604e87972890178c0.tar.xz
latinime-1290399123e515d0068e0d8604e87972890178c0.zip
Merge "Fix Serbian Latin subtype handling"
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/utils/SpacebarLanguageUtilsTests.java')
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/SpacebarLanguageUtilsTests.java117
1 files changed, 87 insertions, 30 deletions
diff --git a/tests/src/com/android/inputmethod/latin/utils/SpacebarLanguageUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/SpacebarLanguageUtilsTests.java
index e6131cf65..83afd782d 100644
--- a/tests/src/com/android/inputmethod/latin/utils/SpacebarLanguageUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/SpacebarLanguageUtilsTests.java
@@ -23,6 +23,7 @@ import android.test.suitebuilder.annotation.SmallTest;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;
+import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.RichInputMethodSubtype;
@@ -36,6 +37,7 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
private RichInputMethodManager mRichImm;
private Resources mRes;
+ private InputMethodSubtype mSavedAddtionalSubtypes[];
RichInputMethodSubtype EN_US;
RichInputMethodSubtype EN_GB;
@@ -45,6 +47,8 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
RichInputMethodSubtype FR_CH;
RichInputMethodSubtype DE;
RichInputMethodSubtype DE_CH;
+ RichInputMethodSubtype HI;
+ RichInputMethodSubtype SR;
RichInputMethodSubtype ZZ;
RichInputMethodSubtype DE_QWERTY;
RichInputMethodSubtype FR_QWERTZ;
@@ -54,17 +58,27 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
RichInputMethodSubtype ZZ_AZERTY;
RichInputMethodSubtype ZZ_PC;
- // This is a preliminary subtype and may not exist.
- RichInputMethodSubtype HI_LATN;
+ // These are preliminary subtypes and may not exist.
+ RichInputMethodSubtype HI_LATN; // Hinglish
+ RichInputMethodSubtype SR_LATN; // Serbian Latin
+ RichInputMethodSubtype HI_LATN_DVORAK;
+ RichInputMethodSubtype SR_LATN_QWERTY;
@Override
protected void setUp() throws Exception {
super.setUp();
final Context context = getContext();
+ mRes = context.getResources();
RichInputMethodManager.init(context);
mRichImm = RichInputMethodManager.getInstance();
- mRes = context.getResources();
- SubtypeLocaleUtils.init(context);
+
+ // Save and reset additional subtypes
+ mSavedAddtionalSubtypes = mRichImm.getAdditionalSubtypes(context);
+ final InputMethodSubtype[] predefinedAddtionalSubtypes =
+ AdditionalSubtypeUtils.createAdditionalSubtypesArray(
+ AdditionalSubtypeUtils.createPrefSubtypes(
+ mRes.getStringArray(R.array.predefined_subtypes)));
+ mRichImm.setAdditionalInputMethodSubtypes(predefinedAddtionalSubtypes);
final InputMethodInfo imi = mRichImm.getInputMethodInfoOfThisIme();
final int subtypeCount = imi.getSubtypeCount();
@@ -89,6 +103,10 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
Locale.GERMAN.toString(), "qwertz"));
DE_CH = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
"de_CH", "swiss"));
+ HI = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ "hi", "hindi"));
+ SR = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ "sr", "south_slavic"));
ZZ = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
SubtypeLocaleUtils.NO_LANGUAGE, "qwerty"));
DE_QWERTY = new RichInputMethodSubtype(
@@ -117,9 +135,27 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
"hi_ZZ", "qwerty");
if (hiLatn != null) {
HI_LATN = new RichInputMethodSubtype(hiLatn);
+ HI_LATN_DVORAK = new RichInputMethodSubtype(
+ AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
+ "hi_ZZ", "dvorak"));
+ }
+ final InputMethodSubtype srLatn = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ "sr_ZZ", "serbian_qwertz");
+ if (srLatn != null) {
+ SR_LATN = new RichInputMethodSubtype(srLatn);
+ SR_LATN_QWERTY = new RichInputMethodSubtype(
+ AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
+ "sr_ZZ", "qwerty"));
}
}
+ @Override
+ protected void tearDown() throws Exception {
+ // Restore additional subtypes.
+ mRichImm.setAdditionalInputMethodSubtypes(mSavedAddtionalSubtypes);
+ super.tearDown();
+ }
+
public void testAllFullDisplayNameForSpacebar() {
for (final RichInputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocaleUtils
@@ -150,10 +186,11 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
continue;
}
final Locale locale = locales[0];
- if (SubtypeLocaleUtils.sExceptionalLocaleDisplayedInRootLocale.contains(
- locale.toString())) {
+ final Locale displayLocale = SubtypeLocaleUtils.getDisplayLocaleOfSubtypeLocale(
+ locale.toString());
+ if (Locale.ROOT.equals(displayLocale)) {
// Skip test because the language part of this locale string doesn't represent
- // the locale to be displayed on the spacebar (for example hi_ZZ and Hinglish).
+ // the locale to be displayed on the spacebar (for example Hinglish).
continue;
}
final String spacebarText = subtype.getMiddleDisplayName();
@@ -162,30 +199,36 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
subtype.getRawSubtype()), spacebarText);
} else {
assertEquals(subtypeName,
- SubtypeLocaleUtils.getSubtypeLocaleDisplayName(locale.getLanguage()),
+ SubtypeLocaleUtils.getSubtypeLanguageDisplayName(locale.toString()),
spacebarText);
}
}
}
// InputMethodSubtype's display name for spacebar text in its locale.
- // isAdditionalSubtype (T=true, F=false)
- // locale layout | Middle Full
- // ------ ------- - --------- ----------------------
- // en_US qwerty F English English (US) exception
- // en_GB qwerty F English English (UK) exception
- // es_US spanish F Español Español (EE.UU.) exception
- // fr azerty F Français Français
- // fr_CA qwerty F Français Français (Canada)
- // fr_CH swiss F Français Français (Suisse)
- // de qwertz F Deutsch Deutsch
- // de_CH swiss F Deutsch Deutsch (Schweiz)
- // hi_ZZ qwerty F Hinglish Hinglish
- // zz qwerty F QWERTY QWERTY
- // fr qwertz T Français Français
- // de qwerty T Deutsch Deutsch
- // en_US azerty T English English (US)
- // zz azerty T AZERTY AZERTY
+ // isAdditionalSubtype (T=true, F=false)
+ // locale layout | Middle Full
+ // ------ -------------- - --------- ----------------------
+ // en_US qwerty F English English (US) exception
+ // en_GB qwerty F English English (UK) exception
+ // es_US spanish F Español Español (EE.UU.) exception
+ // fr azerty F Français Français
+ // fr_CA qwerty F Français Français (Canada)
+ // fr_CH swiss F Français Français (Suisse)
+ // de qwertz F Deutsch Deutsch
+ // de_CH swiss F Deutsch Deutsch (Schweiz)
+ // hi hindi F हिन्दी हिन्दी
+ // hi_ZZ qwerty F Hinglish Hinglish exception
+ // sr south_slavic F Српски Српски
+ // sr_ZZ serbian_qwertz F Srpski Srpski exception
+ // zz qwerty F QWERTY QWERTY
+ // fr qwertz T Français Français
+ // de qwerty T Deutsch Deutsch
+ // en_US azerty T English English (US)
+ // en_GB dvorak T English English (UK)
+ // hi_ZZ dvorak T Hinglish Hinglish exception
+ // sr_ZZ qwerty T Srpski Srpski exception
+ // zz azerty T AZERTY AZERTY
private final RunInLocale<Void> testsPredefinedSubtypesForSpacebar = new RunInLocale<Void>() {
@Override
@@ -198,11 +241,9 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
assertEquals("fr_CH", "Français (Suisse)", FR_CH.getFullDisplayName());
assertEquals("de", "Deutsch", DE.getFullDisplayName());
assertEquals("de_CH", "Deutsch (Schweiz)", DE_CH.getFullDisplayName());
+ assertEquals("hi", "हिन्दी", HI.getFullDisplayName());
+ assertEquals("sr", "Српски", SR.getFullDisplayName());
assertEquals("zz", "QWERTY", ZZ.getFullDisplayName());
- // This is a preliminary subtype and may not exist.
- if (HI_LATN != null) {
- assertEquals("hi_ZZ", "Hinglish", HI_LATN.getFullDisplayName());
- }
assertEquals("en_US", "English", EN_US.getMiddleDisplayName());
assertEquals("en_GB", "English", EN_GB.getMiddleDisplayName());
@@ -213,10 +254,16 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
assertEquals("de", "Deutsch", DE.getMiddleDisplayName());
assertEquals("de_CH", "Deutsch", DE_CH.getMiddleDisplayName());
assertEquals("zz", "QWERTY", ZZ.getMiddleDisplayName());
- // This is a preliminary subtype and may not exist.
+
+ // These are preliminary subtypes and may not exist.
if (HI_LATN != null) {
+ assertEquals("hi_ZZ", "Hinglish", HI_LATN.getFullDisplayName());
assertEquals("hi_ZZ", "Hinglish", HI_LATN.getMiddleDisplayName());
}
+ if (SR_LATN != null) {
+ assertEquals("sr_ZZ", "Srpski", SR_LATN.getFullDisplayName());
+ assertEquals("sr_ZZ", "Srpski", SR_LATN.getMiddleDisplayName());
+ }
return null;
}
};
@@ -239,6 +286,16 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
assertEquals("es_US colemak", "Español", ES_US_COLEMAK.getMiddleDisplayName());
assertEquals("zz azerty", "AZERTY", ZZ_AZERTY.getMiddleDisplayName());
assertEquals("zz pc", "PC", ZZ_PC.getMiddleDisplayName());
+
+ // These are preliminary subtypes and may not exist.
+ if (HI_LATN_DVORAK != null) {
+ assertEquals("hi_ZZ dvorak", "Hinglish", HI_LATN_DVORAK.getFullDisplayName());
+ assertEquals("hi_ZZ dvorak", "Hinglish", HI_LATN_DVORAK.getMiddleDisplayName());
+ }
+ if (SR_LATN_QWERTY != null) {
+ assertEquals("sr_ZZ qwerty", "Srpski", SR_LATN_QWERTY.getFullDisplayName());
+ assertEquals("sr_ZZ qwerty", "Srpski", SR_LATN_QWERTY.getMiddleDisplayName());
+ }
return null;
}
};