aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java (renamed from tests/src/com/android/inputmethod/latin/InputLogicFrenchTests.java)20
-rw-r--r--tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java167
2 files changed, 128 insertions, 59 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicFrenchTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java
index 60a7b05a9..b2b9601b6 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicFrenchTests.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java
@@ -16,7 +16,7 @@
package com.android.inputmethod.latin;
-public class InputLogicFrenchTests extends InputTestsBase {
+public class InputLogicTestsNonEnglish extends InputTestsBase {
public void testAutoCorrectForFrench() {
final String STRING_TO_TYPE = "irq ";
@@ -54,4 +54,22 @@ public class InputLogicFrenchTests extends InputTestsBase {
assertEquals("type word then type space then punctuation from strip twice for French",
EXPECTED_RESULT, mTextView.getText().toString());
}
+
+ public void testAutoCorrectForGerman() {
+ final String STRING_TO_TYPE = "unf ";
+ final String EXPECTED_RESULT = "und ";
+ changeLanguage("de");
+ type(STRING_TO_TYPE);
+ assertEquals("simple auto-correct for German", EXPECTED_RESULT,
+ mTextView.getText().toString());
+ }
+
+ public void testAutoCorrectWithUmlautForGerman() {
+ final String STRING_TO_TYPE = "ueber ";
+ final String EXPECTED_RESULT = "über ";
+ changeLanguage("de");
+ type(STRING_TO_TYPE);
+ assertEquals("auto-correct with umlaut for German", EXPECTED_RESULT,
+ mTextView.getText().toString());
+ }
}
diff --git a/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java b/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java
index 4ac765782..d34055a54 100644
--- a/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java
+++ b/tests/src/com/android/inputmethod/latin/SubtypeLocaleTests.java
@@ -18,58 +18,35 @@ package com.android.inputmethod.latin;
import android.content.Context;
import android.test.AndroidTestCase;
-import android.view.inputmethod.InputMethodInfo;
-import android.view.inputmethod.InputMethodManager;
import android.view.inputmethod.InputMethodSubtype;
-import com.android.inputmethod.keyboard.KeyboardLayoutSet;
+import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import java.util.ArrayList;
import java.util.Locale;
public class SubtypeLocaleTests extends AndroidTestCase {
- private static final Locale LOCALE_zz_QY = SubtypeLocale.LOCALE_NO_LANGUAGE_QWERTY;
- private static final Locale LOCALE_de_QY =
- new Locale(Locale.GERMAN.getLanguage(), SubtypeLocale.QWERTY);
-
- private ArrayList<InputMethodSubtype> mSubtypesList;
+ // Locale to subtypes list.
+ private final ArrayList<InputMethodSubtype> mSubtypesList = new ArrayList<InputMethodSubtype>();
@Override
protected void setUp() throws Exception {
super.setUp();
-
final Context context = getContext();
- final String packageName = context.getApplicationInfo().packageName;
-
+ InputMethodManagerCompatWrapper.init(context);
SubtypeLocale.init(context);
-
- final InputMethodManager imm = (InputMethodManager) context.getSystemService(
- Context.INPUT_METHOD_SERVICE);
- for (final InputMethodInfo imi : imm.getInputMethodList()) {
- if (imi.getPackageName().equals(packageName)) {
- mSubtypesList = new ArrayList<InputMethodSubtype>();
- final int subtypeCount = imi.getSubtypeCount();
- for (int i = 0; i < subtypeCount; i++) {
- final InputMethodSubtype ims = imi.getSubtypeAt(i);
- mSubtypesList.add(ims);
- }
- break;
- }
- }
- assertNotNull("Can not find input method " + packageName, mSubtypesList);
- assertTrue("Can not find keyboard subtype", mSubtypesList.size() > 0);
}
- public void testFullDisplayName() {
+ public void testAllFullDisplayName() {
final StringBuilder messages = new StringBuilder();
int failedCount = 0;
for (final InputMethodSubtype subtype : mSubtypesList) {
- final Locale locale = KeyboardLayoutSet.getKeyboardLayoutSetLocale(subtype);
- if (locale.getLanguage().equals(SubtypeLocale.NO_LANGUAGE)) {
+ final Locale locale = SubtypeLocale.getSubtypeLocale(subtype);
+ if (SubtypeLocale.isNoLanguage(subtype)) {
// This is special language name for language agnostic usage.
continue;
}
- final String keyboardName = SubtypeLocale.getFullDisplayName(locale);
+ final String keyboardName = SubtypeLocale.getFullDisplayName(subtype);
final String languageName = StringUtils.toTitleCase(
locale.getDisplayLanguage(locale), locale);
if (!keyboardName.contains(languageName)) {
@@ -82,24 +59,16 @@ public class SubtypeLocaleTests extends AndroidTestCase {
assertEquals(messages.toString(), 0, failedCount);
}
- public void testFullDisplayNameNoLanguage() {
- assertEquals("zz_QY", "QWERTY", SubtypeLocale.getFullDisplayName(LOCALE_zz_QY));
-
- final String de_QY = SubtypeLocale.getFullDisplayName(LOCALE_de_QY);
- assertTrue("de_QY", de_QY.contains("(QWERTY"));
- assertTrue("de_QY", de_QY.contains(Locale.GERMAN.getDisplayLanguage(Locale.GERMAN)));
- }
-
- public void testMiddleDisplayName() {
+ public void testAllMiddleDisplayName() {
final StringBuilder messages = new StringBuilder();
int failedCount = 0;
for (final InputMethodSubtype subtype : mSubtypesList) {
- final Locale locale = KeyboardLayoutSet.getKeyboardLayoutSetLocale(subtype);
- if (locale.getLanguage().equals(SubtypeLocale.NO_LANGUAGE)) {
+ final Locale locale = SubtypeLocale.getSubtypeLocale(subtype);
+ if (SubtypeLocale.isNoLanguage(subtype)) {
// This is special language name for language agnostic usage.
continue;
}
- final String keyboardName = SubtypeLocale.getMiddleDisplayName(locale);
+ final String keyboardName = SubtypeLocale.getMiddleDisplayName(subtype);
final String languageName = StringUtils.toTitleCase(
locale.getDisplayLanguage(locale), locale);
if (!keyboardName.equals(languageName)) {
@@ -112,21 +81,12 @@ public class SubtypeLocaleTests extends AndroidTestCase {
assertEquals(messages.toString(), 0, failedCount);
}
- public void testMiddleDisplayNameNoLanguage() {
- assertEquals("zz_QY", "QWERTY", SubtypeLocale.getMiddleDisplayName(LOCALE_zz_QY));
- assertEquals("de_QY", "Deutsch", SubtypeLocale.getMiddleDisplayName(LOCALE_de_QY));
- }
-
- public void testShortDisplayName() {
+ public void testAllShortDisplayName() {
final StringBuilder messages = new StringBuilder();
int failedCount = 0;
for (final InputMethodSubtype subtype : mSubtypesList) {
- final Locale locale = KeyboardLayoutSet.getKeyboardLayoutSetLocale(subtype);
- if (locale.getCountry().equals(SubtypeLocale.QWERTY)) {
- // This is special country code for QWERTY keyboard.
- continue;
- }
- final String keyboardName = SubtypeLocale.getShortDisplayName(locale);
+ final Locale locale = SubtypeLocale.getSubtypeLocale(subtype);
+ final String keyboardName = SubtypeLocale.getShortDisplayName(subtype);
final String languageCode = StringUtils.toTitleCase(locale.getLanguage(), locale);
if (!keyboardName.equals(languageCode)) {
failedCount++;
@@ -138,8 +98,99 @@ public class SubtypeLocaleTests extends AndroidTestCase {
assertEquals(messages.toString(), 0, failedCount);
}
- public void testShortDisplayNameNoLanguage() {
- assertEquals("zz_QY", "QY", SubtypeLocale.getShortDisplayName(LOCALE_zz_QY));
- assertEquals("de_QY", "De", SubtypeLocale.getShortDisplayName(LOCALE_de_QY));
+ // Get InputMethodSubtype's display name in its locale.
+ // additional
+ // locale layout Short Middle Full
+ // ------ ------ - ---- --------- -----------------
+ // en_US qwerty F En English English (US) exception
+ // en_GB qwerty F En English English (UK) exception
+ // fr azerty F Fr Français Français
+ // fr_CA qwerty F Fr Français Français (Canada)
+ // de qwertz F De Deutsch Deutsch
+ // zz qwerty F QWERTY QWERTY
+ // fr qwertz T Fr Français Français (QWERTZ)
+ // de qwerty T De Deutsch Deutsch (QWERTY)
+ // zz azerty T AZERTY AZERTY
+
+ public void testSampleSubtypes() {
+ final Context context = getContext();
+ final InputMethodSubtype EN_US = SubtypeUtils.findSubtypeByLocaleAndKeyboardLayoutSet(
+ context, Locale.US, AdditionalSubtype.QWERTY);
+ final InputMethodSubtype EN_GB = SubtypeUtils.findSubtypeByLocaleAndKeyboardLayoutSet(
+ context, Locale.UK, AdditionalSubtype.QWERTY);
+ final InputMethodSubtype FR = SubtypeUtils.findSubtypeByLocaleAndKeyboardLayoutSet(
+ context, Locale.FRENCH, AdditionalSubtype.AZERTY);
+ final InputMethodSubtype FR_CA = SubtypeUtils.findSubtypeByLocaleAndKeyboardLayoutSet(
+ context, Locale.CANADA_FRENCH, AdditionalSubtype.QWERTY);
+ final InputMethodSubtype DE = SubtypeUtils.findSubtypeByLocaleAndKeyboardLayoutSet(
+ context, Locale.GERMAN, AdditionalSubtype.QWERTZ);
+ final InputMethodSubtype ZZ = SubtypeUtils.findSubtypeByLocaleAndKeyboardLayoutSet(
+ context, SubtypeLocale.LOCALE_NO_LANGUAGE, AdditionalSubtype.QWERTY);
+
+ assertFalse(AdditionalSubtype.isAdditionalSubtype(EN_US));
+ assertFalse(AdditionalSubtype.isAdditionalSubtype(EN_GB));
+ assertFalse(AdditionalSubtype.isAdditionalSubtype(FR));
+ assertFalse(AdditionalSubtype.isAdditionalSubtype(FR_CA));
+ assertFalse(AdditionalSubtype.isAdditionalSubtype(DE));
+ assertFalse(AdditionalSubtype.isAdditionalSubtype(ZZ));
+
+ assertEquals("en_US", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(EN_US));
+ assertEquals("en_GB", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(EN_GB));
+ assertEquals("fr ", "azerty", SubtypeLocale.getKeyboardLayoutSetName(FR));
+ assertEquals("fr_CA", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(FR_CA));
+ assertEquals("de ", "qwertz", SubtypeLocale.getKeyboardLayoutSetName(DE));
+ assertEquals("zz ", "qwerty", SubtypeLocale.getKeyboardLayoutSetName(ZZ));
+
+ assertEquals("en_US", "English (US)", SubtypeLocale.getFullDisplayName(EN_US));
+ assertEquals("en_GB", "English (UK)", SubtypeLocale.getFullDisplayName(EN_GB));
+ assertEquals("fr ", "Français", SubtypeLocale.getFullDisplayName(FR));
+ assertEquals("fr_CA", "Français (Canada)", SubtypeLocale.getFullDisplayName(FR_CA));
+ assertEquals("de ", "Deutsch", SubtypeLocale.getFullDisplayName(DE));
+ assertEquals("zz ", "QWERTY", SubtypeLocale.getFullDisplayName(ZZ));
+
+ assertEquals("en_US", "English", SubtypeLocale.getMiddleDisplayName(EN_US));
+ assertEquals("en_GB", "English", SubtypeLocale.getMiddleDisplayName(EN_GB));
+ assertEquals("fr ", "Français", SubtypeLocale.getMiddleDisplayName(FR));
+ assertEquals("fr_CA", "Français", SubtypeLocale.getMiddleDisplayName(FR_CA));
+ assertEquals("de ", "Deutsch", SubtypeLocale.getMiddleDisplayName(DE));
+ assertEquals("zz ", "QWERTY", SubtypeLocale.getMiddleDisplayName(ZZ));
+
+ assertEquals("en_US", "En", SubtypeLocale.getShortDisplayName(EN_US));
+ assertEquals("en_GB", "En", SubtypeLocale.getShortDisplayName(EN_GB));
+ assertEquals("fr ", "Fr", SubtypeLocale.getShortDisplayName(FR));
+ assertEquals("fr_CA", "Fr", SubtypeLocale.getShortDisplayName(FR_CA));
+ assertEquals("de ", "De", SubtypeLocale.getShortDisplayName(DE));
+ assertEquals("zz ", "", SubtypeLocale.getShortDisplayName(ZZ));
+ }
+
+ public void testAdditionalSubtype() {
+ final InputMethodSubtype DE_QWERTY = AdditionalSubtype.createAddtionalSubtype(
+ Locale.GERMAN, AdditionalSubtype.QWERTY);
+ final InputMethodSubtype FR_QWERTZ = AdditionalSubtype.createAddtionalSubtype(
+ Locale.FRENCH, AdditionalSubtype.QWERTZ);
+ final InputMethodSubtype EN_AZERTY = AdditionalSubtype.createAddtionalSubtype(
+ Locale.ENGLISH, AdditionalSubtype.AZERTY);
+ final InputMethodSubtype ZZ_AZERTY = AdditionalSubtype.createAddtionalSubtype(
+ SubtypeLocale.LOCALE_NO_LANGUAGE, AdditionalSubtype.AZERTY);
+
+ assertTrue(AdditionalSubtype.isAdditionalSubtype(FR_QWERTZ));
+ assertTrue(AdditionalSubtype.isAdditionalSubtype(DE_QWERTY));
+ assertTrue(AdditionalSubtype.isAdditionalSubtype(EN_AZERTY));
+ assertTrue(AdditionalSubtype.isAdditionalSubtype(ZZ_AZERTY));
+
+ assertEquals("fr qwertz", "Français (QWERTZ)", SubtypeLocale.getFullDisplayName(FR_QWERTZ));
+ assertEquals("de qwerty", "Deutsch (QWERTY)", SubtypeLocale.getFullDisplayName(DE_QWERTY));
+ assertEquals("en azerty", "English (AZERTY)", SubtypeLocale.getFullDisplayName(EN_AZERTY));
+ assertEquals("zz azerty", "AZERTY", SubtypeLocale.getFullDisplayName(ZZ_AZERTY));
+
+ assertEquals("fr qwertz", "Français", SubtypeLocale.getMiddleDisplayName(FR_QWERTZ));
+ assertEquals("de qwerty", "Deutsch", SubtypeLocale.getMiddleDisplayName(DE_QWERTY));
+ assertEquals("en azerty", "English", SubtypeLocale.getMiddleDisplayName(EN_AZERTY));
+ assertEquals("zz azerty", "AZERTY", SubtypeLocale.getMiddleDisplayName(ZZ_AZERTY));
+
+ assertEquals("fr qwertz", "Fr", SubtypeLocale.getShortDisplayName(FR_QWERTZ));
+ assertEquals("de qwerty", "De", SubtypeLocale.getShortDisplayName(DE_QWERTY));
+ assertEquals("en azerty", "En", SubtypeLocale.getShortDisplayName(EN_AZERTY));
+ assertEquals("zz azerty", "", SubtypeLocale.getShortDisplayName(ZZ_AZERTY));
}
}