Merge "Fix Serbian Latin subtype handling"

main
Tadashi G. Takaoka 2014-10-28 09:39:59 +00:00 committed by Android (Google) Code Review
commit 1290399123
6 changed files with 316 additions and 103 deletions

View File

@ -39,6 +39,8 @@
<item>hi_ZZ</item> <item>hi_ZZ</item>
<item>sr_ZZ</item> <item>sr_ZZ</item>
</string-array> </string-array>
<string name="subtype_in_root_locale_hi_ZZ">Hinglish</string>
<string name="subtype_in_root_locale_sr_ZZ">Srpski</string>
<!-- Generic subtype label --> <!-- Generic subtype label -->
<string name="subtype_generic">%s</string> <string name="subtype_generic">%s</string>

View File

@ -214,8 +214,7 @@
<!-- Description for Hinglish (https://en.wikipedia.org/wiki/Hinglish) keyboard subtype [CHAR LIMIT=25] --> <!-- Description for Hinglish (https://en.wikipedia.org/wiki/Hinglish) keyboard subtype [CHAR LIMIT=25] -->
<string name="subtype_hi_ZZ">Hinglish</string> <string name="subtype_hi_ZZ">Hinglish</string>
<!-- Description for Serbian (Latin) keyboard subtype [CHAR LIMIT=25] <!-- Description for Serbian (Latin) keyboard subtype [CHAR LIMIT=25]
(Latin) can be an abbreviation to fit in the CHAR LIMIT. (Latin) can be an abbreviation to fit in the CHAR LIMIT. -->
Note for Serbian translator: this should be translated with Latin script and (Latin) should be omitted. -->
<string name="subtype_sr_ZZ">Serbian (Latin)</string> <string name="subtype_sr_ZZ">Serbian (Latin)</string>
<!-- Description for English (UK) keyboard subtype with explicit keyboard layout [CHAR LIMIT=25] <!-- Description for English (UK) keyboard subtype with explicit keyboard layout [CHAR LIMIT=25]
(UK) should be an abbreviation of United Kingdom to fit in the CHAR LIMIT. (UK) should be an abbreviation of United Kingdom to fit in the CHAR LIMIT.
@ -233,16 +232,14 @@
This should be identical to subtype_hi_ZZ aside from the trailing (%s). --> This should be identical to subtype_hi_ZZ aside from the trailing (%s). -->
<string name="subtype_with_layout_hi_ZZ">Hinglish (<xliff:g id="KEYBOARD_LAYOUT" example="QWERTY">%s</xliff:g>)</string> <string name="subtype_with_layout_hi_ZZ">Hinglish (<xliff:g id="KEYBOARD_LAYOUT" example="QWERTY">%s</xliff:g>)</string>
<!-- Description for Serbian (Latin) keyboard subtype with explicit keyboard layout [CHAR LIMIT=25] <!-- Description for Serbian (Latin) keyboard subtype with explicit keyboard layout [CHAR LIMIT=25]
This should be identical to subtype_sr_ZZ aside from the trailing (%s). This should be identical to subtype_sr_ZZ aside from the trailing (%s). -->
Note for Serbian translator: this should be translated with Latin script. -->
<string name="subtype_with_layout_sr_ZZ">Serbian (<xliff:g id="KEYBOARD_LAYOUT" example="QWERTY">%s</xliff:g>)</string> <string name="subtype_with_layout_sr_ZZ">Serbian (<xliff:g id="KEYBOARD_LAYOUT" example="QWERTY">%s</xliff:g>)</string>
<!-- Description for "LANGUAGE_NAME" (Traditional) keyboard subtype [CHAR LIMIT=25] <!-- Description for "LANGUAGE_NAME" (Traditional) keyboard subtype [CHAR LIMIT=25]
(Traditional) can be an abbreviation to fit in the CHAR LIMIT. --> (Traditional) can be an abbreviation to fit in the CHAR LIMIT. -->
<string name="subtype_generic_traditional"><xliff:g id="LANGUAGE_NAME" example="Nepali">%s</xliff:g> (Traditional)</string> <string name="subtype_generic_traditional"><xliff:g id="LANGUAGE_NAME" example="Nepali">%s</xliff:g> (Traditional)</string>
<!-- Description for "LANGUAGE_NAME" (Compact) keyboard subtype [CHAR LIMIT=25] <!-- Description for "LANGUAGE_NAME" (Compact) keyboard subtype [CHAR LIMIT=25]
(Compact) can be an abbreviation to fit in the CHAR LIMIT. (Compact) can be an abbreviation to fit in the CHAR LIMIT. -->
TODO: Remove translatable=false once we are settled down with the naming. --> <string name="subtype_generic_compact"><xliff:g id="LANGUAGE_NAME" example="Hindi">%s</xliff:g> (Compact)</string>
<string name="subtype_generic_compact" translatable="false"><xliff:g id="LANGUAGE_NAME" example="Hindi">%s</xliff:g> (Compact)</string>
<!-- This string is displayed in a language list that allows to choose a language for <!-- This string is displayed in a language list that allows to choose a language for
suggestions in a software keyboard. This setting won't give suggestions in any particular suggestions in a software keyboard. This setting won't give suggestions in any particular
language, hence "No language". language, hence "No language".

View File

@ -31,7 +31,6 @@ import com.android.inputmethod.latin.RichInputMethodSubtype;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale; import java.util.Locale;
/** /**
@ -59,7 +58,8 @@ public final class SubtypeLocaleUtils {
// Keyboard layout to subtype name resource id map. // Keyboard layout to subtype name resource id map.
private static final HashMap<String, Integer> sKeyboardLayoutToNameIdsMap = new HashMap<>(); private static final HashMap<String, Integer> sKeyboardLayoutToNameIdsMap = new HashMap<>();
// Exceptional locale whose name should be displayed in Locale.ROOT. // Exceptional locale whose name should be displayed in Locale.ROOT.
static final HashSet<String> sExceptionalLocaleDisplayedInRootLocale = new HashSet<>(); private static final HashMap<String, Integer> sExceptionalLocaleDisplayedInRootLocale =
new HashMap<>();
// Exceptional locale to subtype name resource id map. // Exceptional locale to subtype name resource id map.
private static final HashMap<String, Integer> sExceptionalLocaleToNameIdsMap = new HashMap<>(); private static final HashMap<String, Integer> sExceptionalLocaleToNameIdsMap = new HashMap<>();
// Exceptional locale to subtype name with layout resource id map. // Exceptional locale to subtype name with layout resource id map.
@ -73,6 +73,8 @@ public final class SubtypeLocaleUtils {
"string/subtype_with_layout_"; "string/subtype_with_layout_";
private static final String SUBTYPE_NAME_RESOURCE_NO_LANGUAGE_PREFIX = private static final String SUBTYPE_NAME_RESOURCE_NO_LANGUAGE_PREFIX =
"string/subtype_no_language_"; "string/subtype_no_language_";
private static final String SUBTYPE_NAME_RESOURCE_IN_ROOT_LOCALE_PREFIX =
"string/subtype_in_root_locale_";
// Keyboard layout set name for the subtypes that don't have a keyboardLayoutSet extra value. // Keyboard layout set name for the subtypes that don't have a keyboardLayoutSet extra value.
// This is for compatibility to keep the same subtype ids as pre-JellyBean. // This is for compatibility to keep the same subtype ids as pre-JellyBean.
private static final HashMap<String, String> sLocaleAndExtraValueToKeyboardLayoutSetMap = private static final HashMap<String, String> sLocaleAndExtraValueToKeyboardLayoutSetMap =
@ -117,7 +119,10 @@ public final class SubtypeLocaleUtils {
final String[] exceptionalLocaleInRootLocale = res.getStringArray( final String[] exceptionalLocaleInRootLocale = res.getStringArray(
R.array.subtype_locale_displayed_in_root_locale); R.array.subtype_locale_displayed_in_root_locale);
for (int i = 0; i < exceptionalLocaleInRootLocale.length; i++) { for (int i = 0; i < exceptionalLocaleInRootLocale.length; i++) {
sExceptionalLocaleDisplayedInRootLocale.add(exceptionalLocaleInRootLocale[i]); final String localeString = exceptionalLocaleInRootLocale[i];
final String resourceName = SUBTYPE_NAME_RESOURCE_IN_ROOT_LOCALE_PREFIX + localeString;
final int resId = res.getIdentifier(resourceName, null, RESOURCE_PACKAGE_NAME);
sExceptionalLocaleDisplayedInRootLocale.put(localeString, resId);
} }
final String[] exceptionalLocales = res.getStringArray( final String[] exceptionalLocales = res.getStringArray(
@ -171,7 +176,7 @@ public final class SubtypeLocaleUtils {
if (NO_LANGUAGE.equals(localeString)) { if (NO_LANGUAGE.equals(localeString)) {
return sResources.getConfiguration().locale; return sResources.getConfiguration().locale;
} }
if (sExceptionalLocaleDisplayedInRootLocale.contains(localeString)) { if (sExceptionalLocaleDisplayedInRootLocale.containsKey(localeString)) {
return Locale.ROOT; return Locale.ROOT;
} }
return LocaleUtils.constructLocaleFromString(localeString); return LocaleUtils.constructLocaleFromString(localeString);
@ -190,7 +195,7 @@ public final class SubtypeLocaleUtils {
public static String getSubtypeLanguageDisplayName(final String localeString) { public static String getSubtypeLanguageDisplayName(final String localeString) {
final Locale displayLocale = getDisplayLocaleOfSubtypeLocale(localeString); final Locale displayLocale = getDisplayLocaleOfSubtypeLocale(localeString);
final String languageString; final String languageString;
if (sExceptionalLocaleDisplayedInRootLocale.contains(localeString)) { if (sExceptionalLocaleDisplayedInRootLocale.containsKey(localeString)) {
languageString = localeString; languageString = localeString;
} else { } else {
final Locale locale = LocaleUtils.constructLocaleFromString(localeString); final Locale locale = LocaleUtils.constructLocaleFromString(localeString);
@ -205,7 +210,16 @@ public final class SubtypeLocaleUtils {
// No language subtype should be displayed in system locale. // No language subtype should be displayed in system locale.
return sResources.getString(R.string.subtype_no_language); return sResources.getString(R.string.subtype_no_language);
} }
final Integer exceptionalNameResId = sExceptionalLocaleToNameIdsMap.get(localeString); final Integer exceptionalNameResId;
if (displayLocale.equals(Locale.ROOT)
&& sExceptionalLocaleDisplayedInRootLocale.containsKey(localeString)) {
exceptionalNameResId = sExceptionalLocaleDisplayedInRootLocale.get(localeString);
} else if (sExceptionalLocaleToNameIdsMap.containsKey(localeString)) {
exceptionalNameResId = sExceptionalLocaleToNameIdsMap.get(localeString);
} else {
exceptionalNameResId = null;
}
final String displayName; final String displayName;
if (exceptionalNameResId != null) { if (exceptionalNameResId != null) {
final RunInLocale<String> getExceptionalName = new RunInLocale<String>() { final RunInLocale<String> getExceptionalName = new RunInLocale<String>() {

View File

@ -17,9 +17,7 @@
package com.android.inputmethod.keyboard; package com.android.inputmethod.keyboard;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources; import android.content.res.Resources;
import android.preference.PreferenceManager;
import android.test.AndroidTestCase; import android.test.AndroidTestCase;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
@ -62,8 +60,8 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
} }
}; };
private SharedPreferences mSharedPreferences; private RichInputMethodManager mRichImm;
private String mSavedAdditionalSubtypes; private InputMethodSubtype[] mSavedAdditionalSubtypes;
private int mScreenMetrics; private int mScreenMetrics;
protected abstract int getKeyboardThemeForTests(); protected abstract int getKeyboardThemeForTests();
@ -72,15 +70,17 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
final Context context = getContext(); final Context context = getContext();
mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(context);
final Resources res = context.getResources(); final Resources res = context.getResources();
RichInputMethodManager.init(context);
mRichImm = RichInputMethodManager.getInstance();
// Save additional subtypes preference. // Save and reset additional subtypes preference.
mSavedAdditionalSubtypes = Settings.readPrefAdditionalSubtypes(mSharedPreferences, res); mSavedAdditionalSubtypes = mRichImm.getAdditionalSubtypes(context);
final String predefinedSubtypes = AdditionalSubtypeUtils.createPrefSubtypes( final InputMethodSubtype[] predefinedAdditionalSubtypes =
res.getStringArray(R.array.predefined_subtypes)); AdditionalSubtypeUtils.createAdditionalSubtypesArray(
// Reset additional subtypes to predefined ones. AdditionalSubtypeUtils.createPrefSubtypes(
Settings.writePrefAdditionalSubtypes(mSharedPreferences, predefinedSubtypes); res.getStringArray(R.array.predefined_subtypes)));
mRichImm.setAdditionalInputMethodSubtypes(predefinedAdditionalSubtypes);
final KeyboardTheme keyboardTheme = KeyboardTheme.searchKeyboardThemeById( final KeyboardTheme keyboardTheme = KeyboardTheme.searchKeyboardThemeById(
getKeyboardThemeForTests(), KeyboardTheme.KEYBOARD_THEMES); getKeyboardThemeForTests(), KeyboardTheme.KEYBOARD_THEMES);
@ -88,10 +88,8 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
KeyboardLayoutSet.onKeyboardThemeChanged(); KeyboardLayoutSet.onKeyboardThemeChanged();
mScreenMetrics = Settings.readScreenMetrics(res); mScreenMetrics = Settings.readScreenMetrics(res);
RichInputMethodManager.init(context);
final RichInputMethodManager richImm = RichInputMethodManager.getInstance();
final InputMethodInfo imi = richImm.getInputMethodInfoOfThisIme(); final InputMethodInfo imi = mRichImm.getInputMethodInfoOfThisIme();
final int subtypeCount = imi.getSubtypeCount(); final int subtypeCount = imi.getSubtypeCount();
for (int index = 0; index < subtypeCount; index++) { for (int index = 0; index < subtypeCount; index++) {
mAllSubtypesList.add(imi.getSubtypeAt(index)); mAllSubtypesList.add(imi.getSubtypeAt(index));
@ -101,7 +99,7 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
@Override @Override
protected void tearDown() throws Exception { protected void tearDown() throws Exception {
// Restore additional subtypes preference. // Restore additional subtypes preference.
Settings.writePrefAdditionalSubtypes(mSharedPreferences, mSavedAdditionalSubtypes); mRichImm.setAdditionalInputMethodSubtypes(mSavedAdditionalSubtypes);
super.tearDown(); super.tearDown();
} }

View File

@ -23,6 +23,7 @@ import android.test.suitebuilder.annotation.SmallTest;
import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodManager; import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.RichInputMethodSubtype; import com.android.inputmethod.latin.RichInputMethodSubtype;
@ -36,6 +37,7 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
private RichInputMethodManager mRichImm; private RichInputMethodManager mRichImm;
private Resources mRes; private Resources mRes;
private InputMethodSubtype mSavedAddtionalSubtypes[];
RichInputMethodSubtype EN_US; RichInputMethodSubtype EN_US;
RichInputMethodSubtype EN_GB; RichInputMethodSubtype EN_GB;
@ -45,6 +47,8 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
RichInputMethodSubtype FR_CH; RichInputMethodSubtype FR_CH;
RichInputMethodSubtype DE; RichInputMethodSubtype DE;
RichInputMethodSubtype DE_CH; RichInputMethodSubtype DE_CH;
RichInputMethodSubtype HI;
RichInputMethodSubtype SR;
RichInputMethodSubtype ZZ; RichInputMethodSubtype ZZ;
RichInputMethodSubtype DE_QWERTY; RichInputMethodSubtype DE_QWERTY;
RichInputMethodSubtype FR_QWERTZ; RichInputMethodSubtype FR_QWERTZ;
@ -54,17 +58,27 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
RichInputMethodSubtype ZZ_AZERTY; RichInputMethodSubtype ZZ_AZERTY;
RichInputMethodSubtype ZZ_PC; RichInputMethodSubtype ZZ_PC;
// This is a preliminary subtype and may not exist. // These are preliminary subtypes and may not exist.
RichInputMethodSubtype HI_LATN; RichInputMethodSubtype HI_LATN; // Hinglish
RichInputMethodSubtype SR_LATN; // Serbian Latin
RichInputMethodSubtype HI_LATN_DVORAK;
RichInputMethodSubtype SR_LATN_QWERTY;
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
final Context context = getContext(); final Context context = getContext();
mRes = context.getResources();
RichInputMethodManager.init(context); RichInputMethodManager.init(context);
mRichImm = RichInputMethodManager.getInstance(); 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 InputMethodInfo imi = mRichImm.getInputMethodInfoOfThisIme();
final int subtypeCount = imi.getSubtypeCount(); final int subtypeCount = imi.getSubtypeCount();
@ -89,6 +103,10 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
Locale.GERMAN.toString(), "qwertz")); Locale.GERMAN.toString(), "qwertz"));
DE_CH = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( DE_CH = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
"de_CH", "swiss")); "de_CH", "swiss"));
HI = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
"hi", "hindi"));
SR = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
"sr", "south_slavic"));
ZZ = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( ZZ = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
SubtypeLocaleUtils.NO_LANGUAGE, "qwerty")); SubtypeLocaleUtils.NO_LANGUAGE, "qwerty"));
DE_QWERTY = new RichInputMethodSubtype( DE_QWERTY = new RichInputMethodSubtype(
@ -117,7 +135,25 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
"hi_ZZ", "qwerty"); "hi_ZZ", "qwerty");
if (hiLatn != null) { if (hiLatn != null) {
HI_LATN = new RichInputMethodSubtype(hiLatn); 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() { public void testAllFullDisplayNameForSpacebar() {
@ -150,10 +186,11 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
continue; continue;
} }
final Locale locale = locales[0]; final Locale locale = locales[0];
if (SubtypeLocaleUtils.sExceptionalLocaleDisplayedInRootLocale.contains( final Locale displayLocale = SubtypeLocaleUtils.getDisplayLocaleOfSubtypeLocale(
locale.toString())) { locale.toString());
if (Locale.ROOT.equals(displayLocale)) {
// Skip test because the language part of this locale string doesn't represent // 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; continue;
} }
final String spacebarText = subtype.getMiddleDisplayName(); final String spacebarText = subtype.getMiddleDisplayName();
@ -162,30 +199,36 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
subtype.getRawSubtype()), spacebarText); subtype.getRawSubtype()), spacebarText);
} else { } else {
assertEquals(subtypeName, assertEquals(subtypeName,
SubtypeLocaleUtils.getSubtypeLocaleDisplayName(locale.getLanguage()), SubtypeLocaleUtils.getSubtypeLanguageDisplayName(locale.toString()),
spacebarText); spacebarText);
} }
} }
} }
// InputMethodSubtype's display name for spacebar text in its locale. // InputMethodSubtype's display name for spacebar text in its locale.
// isAdditionalSubtype (T=true, F=false) // isAdditionalSubtype (T=true, F=false)
// locale layout | Middle Full // locale layout | Middle Full
// ------ ------- - --------- ---------------------- // ------ -------------- - --------- ----------------------
// en_US qwerty F English English (US) exception // en_US qwerty F English English (US) exception
// en_GB qwerty F English English (UK) exception // en_GB qwerty F English English (UK) exception
// es_US spanish F Español Español (EE.UU.) exception // es_US spanish F Español Español (EE.UU.) exception
// fr azerty F Français Français // fr azerty F Français Français
// fr_CA qwerty F Français Français (Canada) // fr_CA qwerty F Français Français (Canada)
// fr_CH swiss F Français Français (Suisse) // fr_CH swiss F Français Français (Suisse)
// de qwertz F Deutsch Deutsch // de qwertz F Deutsch Deutsch
// de_CH swiss F Deutsch Deutsch (Schweiz) // de_CH swiss F Deutsch Deutsch (Schweiz)
// hi_ZZ qwerty F Hinglish Hinglish // hi hindi F हिन्दी हिन्दी
// zz qwerty F QWERTY QWERTY // hi_ZZ qwerty F Hinglish Hinglish exception
// fr qwertz T Français Français // sr south_slavic F Српски Српски
// de qwerty T Deutsch Deutsch // sr_ZZ serbian_qwertz F Srpski Srpski exception
// en_US azerty T English English (US) // zz qwerty F QWERTY QWERTY
// zz azerty T AZERTY AZERTY // 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>() { private final RunInLocale<Void> testsPredefinedSubtypesForSpacebar = new RunInLocale<Void>() {
@Override @Override
@ -198,11 +241,9 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
assertEquals("fr_CH", "Français (Suisse)", FR_CH.getFullDisplayName()); assertEquals("fr_CH", "Français (Suisse)", FR_CH.getFullDisplayName());
assertEquals("de", "Deutsch", DE.getFullDisplayName()); assertEquals("de", "Deutsch", DE.getFullDisplayName());
assertEquals("de_CH", "Deutsch (Schweiz)", DE_CH.getFullDisplayName()); assertEquals("de_CH", "Deutsch (Schweiz)", DE_CH.getFullDisplayName());
assertEquals("hi", "हिन्दी", HI.getFullDisplayName());
assertEquals("sr", "Српски", SR.getFullDisplayName());
assertEquals("zz", "QWERTY", ZZ.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_US", "English", EN_US.getMiddleDisplayName());
assertEquals("en_GB", "English", EN_GB.getMiddleDisplayName()); assertEquals("en_GB", "English", EN_GB.getMiddleDisplayName());
@ -213,10 +254,16 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
assertEquals("de", "Deutsch", DE.getMiddleDisplayName()); assertEquals("de", "Deutsch", DE.getMiddleDisplayName());
assertEquals("de_CH", "Deutsch", DE_CH.getMiddleDisplayName()); assertEquals("de_CH", "Deutsch", DE_CH.getMiddleDisplayName());
assertEquals("zz", "QWERTY", ZZ.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) { if (HI_LATN != null) {
assertEquals("hi_ZZ", "Hinglish", HI_LATN.getFullDisplayName());
assertEquals("hi_ZZ", "Hinglish", HI_LATN.getMiddleDisplayName()); 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; return null;
} }
}; };
@ -239,6 +286,16 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
assertEquals("es_US colemak", "Español", ES_US_COLEMAK.getMiddleDisplayName()); assertEquals("es_US colemak", "Español", ES_US_COLEMAK.getMiddleDisplayName());
assertEquals("zz azerty", "AZERTY", ZZ_AZERTY.getMiddleDisplayName()); assertEquals("zz azerty", "AZERTY", ZZ_AZERTY.getMiddleDisplayName());
assertEquals("zz pc", "PC", ZZ_PC.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; return null;
} }
}; };

View File

@ -23,6 +23,7 @@ import android.test.suitebuilder.annotation.SmallTest;
import android.view.inputmethod.InputMethodInfo; import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodManager; import com.android.inputmethod.latin.RichInputMethodManager;
import com.android.inputmethod.latin.RichInputMethodSubtype; import com.android.inputmethod.latin.RichInputMethodSubtype;
@ -36,6 +37,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
private RichInputMethodManager mRichImm; private RichInputMethodManager mRichImm;
private Resources mRes; private Resources mRes;
private InputMethodSubtype mSavedAddtionalSubtypes[];
InputMethodSubtype EN_US; InputMethodSubtype EN_US;
InputMethodSubtype EN_GB; InputMethodSubtype EN_GB;
@ -45,6 +47,8 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
InputMethodSubtype FR_CH; InputMethodSubtype FR_CH;
InputMethodSubtype DE; InputMethodSubtype DE;
InputMethodSubtype DE_CH; InputMethodSubtype DE_CH;
InputMethodSubtype HI;
InputMethodSubtype SR;
InputMethodSubtype ZZ; InputMethodSubtype ZZ;
InputMethodSubtype DE_QWERTY; InputMethodSubtype DE_QWERTY;
InputMethodSubtype FR_QWERTZ; InputMethodSubtype FR_QWERTZ;
@ -54,17 +58,27 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
InputMethodSubtype ZZ_AZERTY; InputMethodSubtype ZZ_AZERTY;
InputMethodSubtype ZZ_PC; InputMethodSubtype ZZ_PC;
// This is a preliminary subtype and may not exist. // These are preliminary subtypes and may not exist.
InputMethodSubtype HI_LATN; InputMethodSubtype HI_LATN; // Hinglish
InputMethodSubtype SR_LATN; // Serbian Latin
InputMethodSubtype HI_LATN_DVORAK; // Hinglis Dvorak
InputMethodSubtype SR_LATN_QWERTY; // Serbian Latin Qwerty
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
final Context context = getContext(); final Context context = getContext();
mRes = context.getResources();
RichInputMethodManager.init(context); RichInputMethodManager.init(context);
mRichImm = RichInputMethodManager.getInstance(); 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 InputMethodInfo imi = mRichImm.getInputMethodInfoOfThisIme();
final int subtypeCount = imi.getSubtypeCount(); final int subtypeCount = imi.getSubtypeCount();
@ -89,6 +103,10 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
Locale.GERMAN.toString(), "qwertz"); Locale.GERMAN.toString(), "qwertz");
DE_CH = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( DE_CH = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
"de_CH", "swiss"); "de_CH", "swiss");
HI = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
"hi", "hindi");
SR = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
"sr", "south_slavic");
ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
SubtypeLocaleUtils.NO_LANGUAGE, "qwerty"); SubtypeLocaleUtils.NO_LANGUAGE, "qwerty");
DE_QWERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype( DE_QWERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
@ -107,6 +125,22 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
SubtypeLocaleUtils.NO_LANGUAGE, "pcqwerty"); SubtypeLocaleUtils.NO_LANGUAGE, "pcqwerty");
HI_LATN = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet("hi_ZZ", "qwerty"); HI_LATN = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet("hi_ZZ", "qwerty");
if (HI_LATN != null) {
HI_LATN_DVORAK = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
"hi_ZZ", "dvorak");
}
SR_LATN = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet("sr_ZZ", "serbian_qwertz");
if (SR_LATN != null) {
SR_LATN_QWERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
"sr_ZZ", "qwerty");
}
}
@Override
protected void tearDown() throws Exception {
// Restore additional subtypes.
mRichImm.setAdditionalInputMethodSubtypes(mSavedAddtionalSubtypes);
super.tearDown();
} }
public void testAllFullDisplayName() { public void testAllFullDisplayName() {
@ -139,11 +173,9 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
assertEquals("fr_CH", "swiss", SubtypeLocaleUtils.getKeyboardLayoutSetName(FR_CH)); assertEquals("fr_CH", "swiss", SubtypeLocaleUtils.getKeyboardLayoutSetName(FR_CH));
assertEquals("de", "qwertz", SubtypeLocaleUtils.getKeyboardLayoutSetName(DE)); assertEquals("de", "qwertz", SubtypeLocaleUtils.getKeyboardLayoutSetName(DE));
assertEquals("de_CH", "swiss", SubtypeLocaleUtils.getKeyboardLayoutSetName(DE_CH)); assertEquals("de_CH", "swiss", SubtypeLocaleUtils.getKeyboardLayoutSetName(DE_CH));
assertEquals("hi", "hindi", SubtypeLocaleUtils.getKeyboardLayoutSetName(HI));
assertEquals("sr", "south_slavic", SubtypeLocaleUtils.getKeyboardLayoutSetName(SR));
assertEquals("zz", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(ZZ)); assertEquals("zz", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(ZZ));
// This is a preliminary subtype and may not exist.
if (HI_LATN != null) {
assertEquals("hi_ZZ", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(HI_LATN));
}
assertEquals("de qwerty", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(DE_QWERTY)); assertEquals("de qwerty", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(DE_QWERTY));
assertEquals("fr qwertz", "qwertz", SubtypeLocaleUtils.getKeyboardLayoutSetName(FR_QWERTZ)); assertEquals("fr qwertz", "qwertz", SubtypeLocaleUtils.getKeyboardLayoutSetName(FR_QWERTZ));
@ -155,28 +187,46 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
SubtypeLocaleUtils.getKeyboardLayoutSetName(ES_US_COLEMAK)); SubtypeLocaleUtils.getKeyboardLayoutSetName(ES_US_COLEMAK));
assertEquals("zz azerty", "azerty", assertEquals("zz azerty", "azerty",
SubtypeLocaleUtils.getKeyboardLayoutSetName(ZZ_AZERTY)); SubtypeLocaleUtils.getKeyboardLayoutSetName(ZZ_AZERTY));
// These are preliminary subtypes and may not exist.
if (HI_LATN != null) {
assertEquals("hi_ZZ", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(HI_LATN));
assertEquals("hi_ZZ dvorak", "dvorak",
SubtypeLocaleUtils.getKeyboardLayoutSetName(HI_LATN_DVORAK));
}
if (SR_LATN != null) {
assertEquals("sr_ZZ", "serbian_qwertz",
SubtypeLocaleUtils.getKeyboardLayoutSetName(SR_LATN));
assertEquals("sr_ZZ qwerty", "qwerty",
SubtypeLocaleUtils.getKeyboardLayoutSetName(SR_LATN_QWERTY));
}
} }
// InputMethodSubtype's display name in system locale (en_US). // InputMethodSubtype's display name in system locale (en_US).
// isAdditionalSubtype (T=true, F=false) // isAdditionalSubtype (T=true, F=false)
// locale layout | display name // locale layout | display name
// ------ ------- - ---------------------- // ------ -------------- - ----------------------
// en_US qwerty F English (US) exception // en_US qwerty F English (US) exception
// en_GB qwerty F English (UK) exception // en_GB qwerty F English (UK) exception
// es_US spanish F Spanish (US) exception // es_US spanish F Spanish (US) exception
// fr azerty F French // fr azerty F French
// fr_CA qwerty F French (Canada) // fr_CA qwerty F French (Canada)
// fr_CH swiss F French (Switzerland) // fr_CH swiss F French (Switzerland)
// de qwertz F German // de qwertz F German
// de_CH swiss F German (Switzerland) // de_CH swiss F German (Switzerland)
// hi_ZZ qwerty F Hinglish // hi hindi F Hindi
// zz qwerty F Alphabet (QWERTY) // hi_ZZ qwerty F Hinglish exception
// fr qwertz T French (QWERTZ) // sr south_slavic F Serbian
// de qwerty T German (QWERTY) // sr_ZZ serbian_qwertz F Serbian (Latin) exception
// en_US azerty T English (US) (AZERTY) exception // zz qwerty F Alphabet (QWERTY)
// en_UK dvorak T English (UK) (Dvorak) exception // fr qwertz T French (QWERTZ)
// es_US colemak T Spanish (US) (Colemak) exception // de qwerty T German (QWERTY)
// zz pc T Alphabet (PC) // en_US azerty T English (US) (AZERTY) exception
// en_UK dvorak T English (UK) (Dvorak) exception
// es_US colemak T Spanish (US) (Colemak) exception
// hi_ZZ dvorak T Hinglish (Dvorka) exception
// sr_ZZ qwerty T Serbian (QWERTY) exception
// zz pc T Alphabet (PC)
public void testPredefinedSubtypesInEnglishSystemLocale() { public void testPredefinedSubtypesInEnglishSystemLocale() {
final RunInLocale<Void> tests = new RunInLocale<Void>() { final RunInLocale<Void> tests = new RunInLocale<Void>() {
@ -198,13 +248,21 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE));
assertEquals("de_CH", "German (Switzerland)", assertEquals("de_CH", "German (Switzerland)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE_CH)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE_CH));
assertEquals("hi", "Hindi",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI));
assertEquals("sr", "Serbian",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(SR));
assertEquals("zz", "Alphabet (QWERTY)", assertEquals("zz", "Alphabet (QWERTY)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ));
// This is a preliminary subtype and may not exist. // These are preliminary subtypes and may not exist.
if (HI_LATN != null) { if (HI_LATN != null) {
assertEquals("hi_ZZ", "Hinglish", assertEquals("hi_ZZ", "Hinglish",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI_LATN)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI_LATN));
} }
if (SR_LATN != null) {
assertEquals("sr_ZZ", "Serbian (Latin)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(SR_LATN));
}
return null; return null;
} }
}; };
@ -229,6 +287,15 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ_AZERTY)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ_AZERTY));
assertEquals("zz pc", "Alphabet (PC)", assertEquals("zz pc", "Alphabet (PC)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ_PC)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ_PC));
// These are preliminary subtypes and may not exist.
if (HI_LATN_DVORAK != null) {
assertEquals("hi_ZZ", "Hinglish (Dvorak)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI_LATN_DVORAK));
}
if (SR_LATN_QWERTY != null) {
assertEquals("sr_ZZ", "Serbian (QWERTY)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(SR_LATN_QWERTY));
}
return null; return null;
} }
}; };
@ -239,22 +306,27 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
// isAdditionalSubtype (T=true, F=false) // isAdditionalSubtype (T=true, F=false)
// locale layout | display name // locale layout | display name
// ------ ------- - ---------------------- // ------ ------- - ----------------------
// en_US qwerty F Anglais (États-Unis) exception // en_US qwerty F Anglais (États-Unis) exception
// en_GB qwerty F Anglais (Royaume-Uni) exception // en_GB qwerty F Anglais (Royaume-Uni) exception
// es_US spanish F Espagnol (États-Unis) exception // es_US spanish F Espagnol (États-Unis) exception
// fr azerty F Français // fr azerty F Français
// fr_CA qwerty F Français (Canada) // fr_CA qwerty F Français (Canada)
// fr_CH swiss F Français (Suisse) // fr_CH swiss F Français (Suisse)
// de qwertz F Allemand // de qwertz F Allemand
// de_CH swiss F Allemand (Suisse) // de_CH swiss F Allemand (Suisse)
// hi_ZZ qwerty F Hinglish // hi hindi F Hindi exception
// zz qwerty F Alphabet latin (QWERTY) // hi_ZZ qwerty F Hindi/Anglais exception
// fr qwertz T Français (QWERTZ) // sr south_slavic F Serbe exception
// de qwerty T Allemand (QWERTY) // sr_ZZ serbian_qwertz F Serbe (latin) exception
// en_US azerty T Anglais (États-Unis) (AZERTY) exception // zz qwerty F Alphabet latin (QWERTY)
// en_UK dvorak T Anglais (Royaume-Uni) (Dvorak) exception // fr qwertz T Français (QWERTZ)
// es_US colemak T Espagnol (États-Unis) (Colemak) exception // de qwerty T Allemand (QWERTY)
// zz pc T Alphabet latin (PC) // en_US azerty T Anglais (États-Unis) (AZERTY) exception
// en_UK dvorak T Anglais (Royaume-Uni) (Dvorak) exception
// es_US colemak T Espagnol (États-Unis) (Colemak) exception
// hi_ZZ dvorak T Hindi/Anglais (Dvorka) exception
// sr_ZZ qwerty T Serbe (QWERTY) exception
// zz pc T Alphabet latin (PC)
public void testPredefinedSubtypesInFrenchSystemLocale() { public void testPredefinedSubtypesInFrenchSystemLocale() {
final RunInLocale<Void> tests = new RunInLocale<Void>() { final RunInLocale<Void> tests = new RunInLocale<Void>() {
@ -276,13 +348,21 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE));
assertEquals("de_CH", "Allemand (Suisse)", assertEquals("de_CH", "Allemand (Suisse)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE_CH)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE_CH));
assertEquals("hi", "Hindi",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI));
assertEquals("sr", "Serbe",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(SR));
assertEquals("zz", "Alphabet latin (QWERTY)", assertEquals("zz", "Alphabet latin (QWERTY)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ));
// This is a preliminary subtype and may not exist. // These are preliminary subtypes and may not exist.
if (HI_LATN != null) { if (HI_LATN != null) {
assertEquals("hi_ZZ", "Hindi/Anglais", assertEquals("hi_ZZ", "Hindi/Anglais",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI_LATN)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI_LATN));
} }
if (SR_LATN != null) {
assertEquals("sr_ZZ", "Serbe (latin)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(SR_LATN));
}
return null; return null;
} }
}; };
@ -307,12 +387,77 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ_AZERTY)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ_AZERTY));
assertEquals("zz pc", "Alphabet latin (PC)", assertEquals("zz pc", "Alphabet latin (PC)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ_PC)); SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ_PC));
// These are preliminary subtypes and may not exist.
if (HI_LATN_DVORAK != null) {
assertEquals("hi_ZZ", "Hindi/Anglais (Dvorak)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI_LATN_DVORAK));
}
if (SR_LATN_QWERTY != null) {
assertEquals("sr_ZZ", "Serbe (QWERTY)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(SR_LATN_QWERTY));
}
return null; return null;
} }
}; };
tests.runInLocale(mRes, Locale.FRENCH); tests.runInLocale(mRes, Locale.FRENCH);
} }
// InputMethodSubtype's display name in system locale (hi).
// isAdditionalSubtype (T=true, F=false)
// locale layout | display name
// ------ ------- - ----------------------
// hi hindi F हिन्दी
// hi_ZZ qwerty F हिंग्लिश
// hi_ZZ dvorak T हिंग्लिश (Dvorak)
public void testHinglishSubtypesInHindiSystemLocale() {
final RunInLocale<Void> tests = new RunInLocale<Void>() {
@Override
protected Void job (final Resources res) {
assertEquals("hi", "हिन्दी",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI));
// These are preliminary subtypes and may not exist.
if (HI_LATN != null) {
assertEquals("hi_ZZ", "हिंग्लिश",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI_LATN));
assertEquals("hi_ZZ", "हिंग्लिश (Dvorak)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI_LATN_DVORAK));
}
return null;
}
};
tests.runInLocale(mRes, new Locale("hi"));
}
// InputMethodSubtype's display name in system locale (sr).
// isAdditionalSubtype (T=true, F=false)
// locale layout | display name
// ------ -------------- - ----------------------
// sr south_slavic F Српски
// sr_ZZ serbian_qwertz F српски (латиница)
// sr_ZZ qwerty T српски (QWERTY)
public void testSerbianLatinSubtypesInSerbianSystemLocale() {
final RunInLocale<Void> tests = new RunInLocale<Void>() {
@Override
protected Void job (final Resources res) {
assertEquals("sr", "Српски",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(SR));
// These are preliminary subtypes and may not exist.
if (SR_LATN != null) {
// TODO: Uncommented because of the current translation of these strings
// in Seriban are described in Latin script.
// assertEquals("sr_ZZ", "српски (латиница)",
// SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(SR_LATN));
// assertEquals("sr_ZZ", "српски (QWERTY)",
// SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(SR_LATN_QWERTY));
}
return null;
}
};
tests.runInLocale(mRes, new Locale("sr"));
}
public void testIsRtlLanguage() { public void testIsRtlLanguage() {
// Known Right-to-Left language subtypes. // Known Right-to-Left language subtypes.
final InputMethodSubtype ARABIC = mRichImm final InputMethodSubtype ARABIC = mRichImm