aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java7
-rw-r--r--tests/src/com/android/inputmethod/keyboard/internal/LanguageOnSpacebarHelperTests.java64
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/Arabic.java5
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/ArmenianPhonetic.java4
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/Dvorak.java61
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/Farsi.java5
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/HindiCompact.java2
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java68
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/Myanmar.java4
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/Symbols.java12
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/SymbolsShifted.java12
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java34
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKey.java12
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyOutput.java31
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyVisual.java21
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDvorakEmail.java91
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDvorakUrl.java91
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEnglishDvorak.java2
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/tests/TestsQwertyEmail.java73
-rw-r--r--tests/src/com/android/inputmethod/keyboard/layout/tests/TestsQwertyUrl.java73
-rw-r--r--tests/src/com/android/inputmethod/latin/InputTestsBase.java9
-rw-r--r--tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java88
-rw-r--r--tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java221
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtilsTests.java10
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/SpacebarLanguageUtilsTests.java240
-rw-r--r--tests/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtilsTests.java21
26 files changed, 971 insertions, 290 deletions
diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java
index cf884bfea..0a76a9d91 100644
--- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java
+++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java
@@ -29,6 +29,7 @@ import com.android.inputmethod.keyboard.KeyboardLayoutSet.Builder;
import com.android.inputmethod.latin.Constants;
import com.android.inputmethod.latin.R;
import com.android.inputmethod.latin.RichInputMethodManager;
+import com.android.inputmethod.latin.RichInputMethodSubtype;
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.ResourceUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@@ -112,13 +113,13 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
"Unknown subtype: locale=" + locale + " keyboardLayout=" + keyboardLayout);
}
- protected final KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
+ protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
final EditorInfo editorInfo) {
return createKeyboardLayoutSet(subtype, editorInfo, false /* voiceInputKeyEnabled */,
false /* languageSwitchKeyEnabled */);
}
- protected final KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
+ protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
final boolean languageSwitchKeyEnabled) {
final Context context = mThemeContext;
@@ -127,7 +128,7 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
final Builder builder = new Builder(context, editorInfo);
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight)
- .setSubtype(subtype)
+ .setSubtype(new RichInputMethodSubtype(subtype))
.setVoiceInputKeyEnabled(voiceInputKeyEnabled)
.setLanguageSwitchKeyEnabled(languageSwitchKeyEnabled);
return builder.build();
diff --git a/tests/src/com/android/inputmethod/keyboard/internal/LanguageOnSpacebarHelperTests.java b/tests/src/com/android/inputmethod/keyboard/internal/LanguageOnSpacebarHelperTests.java
index 6ea27588e..e6198015a 100644
--- a/tests/src/com/android/inputmethod/keyboard/internal/LanguageOnSpacebarHelperTests.java
+++ b/tests/src/com/android/inputmethod/keyboard/internal/LanguageOnSpacebarHelperTests.java
@@ -26,6 +26,7 @@ import android.test.suitebuilder.annotation.SmallTest;
import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.RichInputMethodManager;
+import com.android.inputmethod.latin.RichInputMethodSubtype;
import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils;
import com.android.inputmethod.latin.utils.SubtypeLocaleUtils;
@@ -40,14 +41,14 @@ public class LanguageOnSpacebarHelperTests extends AndroidTestCase {
private RichInputMethodManager mRichImm;
- InputMethodSubtype EN_US_QWERTY;
- InputMethodSubtype EN_GB_QWERTY;
- InputMethodSubtype FR_AZERTY;
- InputMethodSubtype FR_CA_QWERTY;
- InputMethodSubtype FR_CH_SWISS;
- InputMethodSubtype FR_CH_QWERTY;
- InputMethodSubtype FR_CH_QWERTZ;
- InputMethodSubtype ZZ_QWERTY;
+ RichInputMethodSubtype EN_US_QWERTY;
+ RichInputMethodSubtype EN_GB_QWERTY;
+ RichInputMethodSubtype FR_AZERTY;
+ RichInputMethodSubtype FR_CA_QWERTY;
+ RichInputMethodSubtype FR_CH_SWISS;
+ RichInputMethodSubtype FR_CH_QWERTY;
+ RichInputMethodSubtype FR_CH_QWERTZ;
+ RichInputMethodSubtype ZZ_QWERTY;
@Override
protected void setUp() throws Exception {
@@ -57,22 +58,22 @@ public class LanguageOnSpacebarHelperTests extends AndroidTestCase {
mRichImm = RichInputMethodManager.getInstance();
SubtypeLocaleUtils.init(context);
- EN_US_QWERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.US.toString(), "qwerty");
- EN_GB_QWERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.UK.toString(), "qwerty");
- FR_AZERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.FRENCH.toString(), "azerty");
- FR_CA_QWERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.CANADA_FRENCH.toString(), "qwerty");
- FR_CH_SWISS = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- "fr_CH", "swiss");
- FR_CH_QWERTZ = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
- "fr_CH", "qwertz");
- FR_CH_QWERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
- "fr_CH", "qwerty");
- ZZ_QWERTY = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- SubtypeLocaleUtils.NO_LANGUAGE, "qwerty");
+ EN_US_QWERTY = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.US.toString(), "qwerty"));
+ EN_GB_QWERTY = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.UK.toString(), "qwerty"));
+ FR_AZERTY = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.FRENCH.toString(), "azerty"));
+ FR_CA_QWERTY = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.CANADA_FRENCH.toString(), "qwerty"));
+ FR_CH_SWISS = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ "fr_CH", "swiss"));
+ FR_CH_QWERTZ = new RichInputMethodSubtype(
+ AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype("fr_CH", "qwertz"));
+ FR_CH_QWERTY = new RichInputMethodSubtype(
+ AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype("fr_CH", "qwerty"));
+ ZZ_QWERTY = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ SubtypeLocaleUtils.NO_LANGUAGE, "qwerty"));
}
private static List<InputMethodSubtype> asList(final InputMethodSubtype ... subtypes) {
@@ -80,14 +81,14 @@ public class LanguageOnSpacebarHelperTests extends AndroidTestCase {
}
public void testOneSubtype() {
- mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(EN_US_QWERTY));
+ mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(EN_US_QWERTY.getRawSubtype()));
mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */);
assertEquals("one same English (US)", FORMAT_TYPE_NONE,
mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY));
assertEquals("one same NoLanguage", FORMAT_TYPE_FULL_LOCALE,
mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(ZZ_QWERTY));
- mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(FR_AZERTY));
+ mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(FR_AZERTY.getRawSubtype()));
mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(false /* isSame */);
assertEquals("one diff English (US)", FORMAT_TYPE_LANGUAGE_ONLY,
mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY));
@@ -96,8 +97,8 @@ public class LanguageOnSpacebarHelperTests extends AndroidTestCase {
}
public void testTwoSubtypes() {
- mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(EN_US_QWERTY, FR_AZERTY));
-
+ mLanguageOnSpacebarHelper.updateEnabledSubtypes(asList(EN_US_QWERTY.getRawSubtype(),
+ FR_AZERTY.getRawSubtype()));
mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */);
assertEquals("two same English (US)", FORMAT_TYPE_LANGUAGE_ONLY,
mLanguageOnSpacebarHelper.getLanguageOnSpacebarFormatType(EN_US_QWERTY));
@@ -117,7 +118,8 @@ public class LanguageOnSpacebarHelperTests extends AndroidTestCase {
public void testSameLanuageSubtypes() {
mLanguageOnSpacebarHelper.updateEnabledSubtypes(
- asList(EN_US_QWERTY, EN_GB_QWERTY, FR_AZERTY, ZZ_QWERTY));
+ asList(EN_US_QWERTY.getRawSubtype(), EN_GB_QWERTY.getRawSubtype(),
+ FR_AZERTY.getRawSubtype(), ZZ_QWERTY.getRawSubtype()));
mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */);
assertEquals("two same English (US)", FORMAT_TYPE_FULL_LOCALE,
@@ -138,7 +140,9 @@ public class LanguageOnSpacebarHelperTests extends AndroidTestCase {
public void testMultiSameLanuageSubtypes() {
mLanguageOnSpacebarHelper.updateEnabledSubtypes(
- asList(FR_AZERTY, FR_CA_QWERTY, FR_CH_SWISS, FR_CH_QWERTY, FR_CH_QWERTZ));
+ asList(FR_AZERTY.getRawSubtype(), FR_CA_QWERTY.getRawSubtype(),
+ FR_CH_SWISS.getRawSubtype(), FR_CH_QWERTY.getRawSubtype(),
+ FR_CH_QWERTZ.getRawSubtype()));
mLanguageOnSpacebarHelper.updateIsSystemLanguageSameAsInputLanguage(true /* isSame */);
assertEquals("multi same French", FORMAT_TYPE_LANGUAGE_ONLY,
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Arabic.java b/tests/src/com/android/inputmethod/keyboard/layout/Arabic.java
index fa818654e..3f85e4baa 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/Arabic.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/Arabic.java
@@ -78,8 +78,7 @@ public final class Arabic extends LayoutBase {
// U+061F: "؟" ARABIC QUESTION MARK
// U+061B: "؛" ARABIC SEMICOLON
return joinKeys(key("\u060C", joinMoreKeys(
- ":", "!", "\u061F", "\u061B", "-", "\"", "'", SETTINGS_KEY)),
- "_");
+ ":", "!", "\u061F", "\u061B", "-", "\"", "'", SETTINGS_KEY)));
}
@Override
@@ -90,7 +89,7 @@ public final class Arabic extends LayoutBase {
// U+060C: "،" ARABIC COMMA
// U+061F: "؟" ARABIC QUESTION MARK
// U+061B: "؛" ARABIC SEMICOLON
- return joinKeys("/", key(".", getPunctuationMoreKeys(isPhone)));
+ return joinKeys(key(".", getPunctuationMoreKeys(isPhone)));
}
@Override
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/ArmenianPhonetic.java b/tests/src/com/android/inputmethod/keyboard/layout/ArmenianPhonetic.java
index dba91b4da..2cecedceb 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/ArmenianPhonetic.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/ArmenianPhonetic.java
@@ -62,14 +62,14 @@ public final class ArmenianPhonetic extends LayoutBase {
public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) {
// U+055D: "՝" ARMENIAN COMMA
return isPhone ? joinKeys(key("\u055D", SETTINGS_KEY))
- : joinKeys(key("\u055D", SETTINGS_KEY), "_");
+ : joinKeys(key("\u055D", SETTINGS_KEY));
}
@Override
public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) {
// U+0589: "։" ARMENIAN FULL STOP
final ExpectedKey fullStopKey = key("\u0589", getPunctuationMoreKeys(isPhone));
- return isPhone ? joinKeys(fullStopKey) : joinKeys("/", fullStopKey);
+ return joinKeys(fullStopKey);
}
@Override
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Dvorak.java b/tests/src/com/android/inputmethod/keyboard/layout/Dvorak.java
index e75cfd0ff..ba94c8dee 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/Dvorak.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/Dvorak.java
@@ -20,13 +20,14 @@ import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder;
import com.android.inputmethod.keyboard.layout.expected.ExpectedKey.ExpectedAdditionalMoreKey;
+import com.android.inputmethod.latin.settings.CustomInputStyleSettingsFragment;
import java.util.Locale;
/**
- * The QWERTY alphabet keyboard.
+ * The Dvorak alphabet keyboard.
*/
-public final class Dvorak extends LayoutBase {
+public class Dvorak extends LayoutBase {
private static final String LAYOUT_NAME = "dvorak";
public Dvorak(final LayoutCustomizer customizer) {
@@ -51,17 +52,19 @@ public final class Dvorak extends LayoutBase {
@Override
public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) {
- return isPhone ? joinKeys(key("q", SETTINGS_KEY)) :
- joinKeys(SETTINGS_KEY, key("_", moreKey("-")));
+ // U+00A1: "¡" INVERTED EXCLAMATION MARK
+ return isPhone ? joinKeys(key("q", SETTINGS_KEY))
+ : joinKeys(key("!", joinMoreKeys("\u00A1", SETTINGS_KEY)));
}
@Override
public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) {
final ExpectedAdditionalMoreKey[] punctuationMoreKeys =
convertToAdditionalMoreKeys(getPunctuationMoreKeys(isPhone));
+ // U+00BF: "¿" INVERTED QUESTION MARK
return isPhone
? joinKeys(key("z", punctuationMoreKeys))
- : joinKeys("/", key("?", moreKey("!")));
+ : joinKeys(key("?", joinMoreKeys(punctuationMoreKeys, "\u00BF")));
}
private static ExpectedAdditionalMoreKey[] convertToAdditionalMoreKeys(
@@ -76,7 +79,33 @@ public final class Dvorak extends LayoutBase {
}
@Override
- ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; }
+ public ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) {
+ return ALPHABET_COMMON;
+ }
+
+ protected ExpectedKey getRow1_1Key(final boolean isPhone, final int elementId) {
+ if (elementId == KeyboardId.ELEMENT_ALPHABET
+ || elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) {
+ return key("'", joinMoreKeys(additionalMoreKey("1"), "!", "\""));
+ }
+ return key("\"", additionalMoreKey("1"));
+ }
+
+ protected ExpectedKey getRow1_2Key(final boolean isPhone, final int elementId) {
+ if (elementId == KeyboardId.ELEMENT_ALPHABET
+ || elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) {
+ return key(",", joinMoreKeys(additionalMoreKey("2"), "?", "<"));
+ }
+ return key("<", additionalMoreKey("2"));
+ }
+
+ protected ExpectedKey getRow1_3Key(final boolean isPhone, final int elementId) {
+ if (elementId == KeyboardId.ELEMENT_ALPHABET
+ || elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) {
+ return key(".", joinMoreKeys(additionalMoreKey("3"), ">"));
+ }
+ return key(">", additionalMoreKey("3"));
+ }
@Override
public ExpectedKey[][] getLayout(final boolean isPhone, final int elementId) {
@@ -86,18 +115,9 @@ public final class Dvorak extends LayoutBase {
}
final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(
getCommonAlphabetLayout(isPhone));
- if (elementId == KeyboardId.ELEMENT_ALPHABET
- || elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) {
- builder.addKeysOnTheLeftOfRow(1,
- key("'", joinMoreKeys(additionalMoreKey("1"), "!", "\"")),
- key(",", joinMoreKeys(additionalMoreKey("2"), "?", "<")),
- key(".", joinMoreKeys(additionalMoreKey("3"), ">")));
- } else {
- builder.addKeysOnTheLeftOfRow(1,
- key("\"", additionalMoreKey("1")),
- key("<", additionalMoreKey("2")),
- key(">", additionalMoreKey("3")));
- }
+ builder.replaceKeyOfLabel(ROW1_1, getRow1_1Key(isPhone, elementId))
+ .replaceKeyOfLabel(ROW1_2, getRow1_2Key(isPhone, elementId))
+ .replaceKeyOfLabel(ROW1_3, getRow1_3Key(isPhone, elementId));
convertCommonLayoutToKeyboard(builder, isPhone);
getCustomizer().setAccentedLetters(builder);
if (elementId != KeyboardId.ELEMENT_ALPHABET) {
@@ -107,8 +127,13 @@ public final class Dvorak extends LayoutBase {
return builder.build();
}
+ public static final String ROW1_1 = "ROW1_1";
+ public static final String ROW1_2 = "ROW1_2";
+ public static final String ROW1_3 = "ROW1_3";
+
private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder()
.setKeysOfRow(1,
+ ROW1_1, ROW1_2, ROW1_3,
key("p", additionalMoreKey("4")),
key("y", additionalMoreKey("5")),
key("f", additionalMoreKey("6")),
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Farsi.java b/tests/src/com/android/inputmethod/keyboard/layout/Farsi.java
index a513740e7..7390457d0 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/Farsi.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/Farsi.java
@@ -77,8 +77,7 @@ public final class Farsi extends LayoutBase {
// U+061B: "؛" ARABIC SEMICOLON
return joinKeys(key("\u060C", joinMoreKeys(
":", "!", "\u061F", "\u061B", "-", RtlSymbols.DOUBLE_ANGLE_QUOTES_LR_RTL,
- SETTINGS_KEY)),
- "_");
+ SETTINGS_KEY)));
}
@Override
@@ -86,7 +85,7 @@ public final class Farsi extends LayoutBase {
if (isPhone) {
return super.getKeysRightToSpacebar(isPhone);
}
- return joinKeys("/", key(".", getPunctuationMoreKeys(isPhone)));
+ return joinKeys(key(".", getPunctuationMoreKeys(isPhone)));
}
@Override
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/HindiCompact.java b/tests/src/com/android/inputmethod/keyboard/layout/HindiCompact.java
index 2b625c32b..c2a15f3f3 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/HindiCompact.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/HindiCompact.java
@@ -50,7 +50,7 @@ public final class HindiCompact extends LayoutBase {
public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) {
// U+0964: "।" DEVANAGARI DANDA
final ExpectedKey periodKey = key("\u0964", getPunctuationMoreKeys(isPhone));
- return isPhone ? joinKeys(periodKey) : joinKeys("/", periodKey);
+ return joinKeys(periodKey);
}
@Override
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java b/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java
index 0548a010d..b05789b73 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java
@@ -149,6 +149,24 @@ public abstract class LayoutBase extends AbstractLayoutBase {
}
/**
+ * Get the enter key.
+ * @param isPhone true if requesting phone's key.
+ * @return the array of {@link ExpectedKey} that should be placed as an enter key.
+ */
+ public ExpectedKey getEnterKey(final boolean isPhone) {
+ return isPhone ? key(ENTER_KEY, EMOJI_ACTION_KEY) : ENTER_KEY;
+ }
+
+ /**
+ * Get the emoji key.
+ * @param isPhone true if requesting phone's key.
+ * @return the array of {@link ExpectedKey} that should be placed as an emoji key.
+ */
+ public ExpectedKey getEmojiKey(final boolean isPhone) {
+ return EMOJI_NORMAL_KEY;
+ }
+
+ /**
* Get the space keys.
* @param isPhone true if requesting phone's keys.
* @return the array of {@link ExpectedKey} that should be placed at the center of the
@@ -165,8 +183,7 @@ public abstract class LayoutBase extends AbstractLayoutBase {
*/
public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) {
// U+002C: "," COMMA
- return isPhone ? joinKeys(key("\u002C", SETTINGS_KEY))
- : joinKeys(key("\u002C", SETTINGS_KEY), "_");
+ return joinKeys(key("\u002C", SETTINGS_KEY));
}
/**
@@ -176,7 +193,7 @@ public abstract class LayoutBase extends AbstractLayoutBase {
*/
public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) {
final ExpectedKey periodKey = key(".", getPunctuationMoreKeys(isPhone));
- return isPhone ? joinKeys(periodKey) : joinKeys("/", periodKey);
+ return joinKeys(periodKey);
}
/**
@@ -241,7 +258,25 @@ public abstract class LayoutBase extends AbstractLayoutBase {
*/
public final LayoutCustomizer getCustomizer() { return mCustomizer; }
- // Icon id.
+ // Icon ids.
+ private static final int ICON_DELETE = KeyboardIconsSet.getIconId(
+ KeyboardIconsSet.NAME_DELETE_KEY);
+ private static final int ICON_SPACE = KeyboardIconsSet.getIconId(
+ KeyboardIconsSet.NAME_SPACE_KEY);
+ private static final int ICON_TAB = KeyboardIconsSet.getIconId(
+ KeyboardIconsSet.NAME_TAB_KEY);
+ private static final int ICON_SHORTCUT = KeyboardIconsSet.getIconId(
+ KeyboardIconsSet.NAME_SHORTCUT_KEY);
+ private static final int ICON_SETTINGS = KeyboardIconsSet.getIconId(
+ KeyboardIconsSet.NAME_SETTINGS_KEY);
+ private static final int ICON_LANGUAGE_SWITCH = KeyboardIconsSet.getIconId(
+ KeyboardIconsSet.NAME_LANGUAGE_SWITCH_KEY);
+ private static final int ICON_ENTER = KeyboardIconsSet.getIconId(
+ KeyboardIconsSet.NAME_ENTER_KEY);
+ private static final int ICON_EMOJI_ACTION = KeyboardIconsSet.getIconId(
+ KeyboardIconsSet.NAME_EMOJI_ACTION_KEY);
+ private static final int ICON_EMOJI_NORMAL = KeyboardIconsSet.getIconId(
+ KeyboardIconsSet.NAME_EMOJI_NORMAL_KEY);
private static final int ICON_SHIFT = KeyboardIconsSet.getIconId(
KeyboardIconsSet.NAME_SHIFT_KEY);
private static final int ICON_SHIFTED_SHIFT = KeyboardIconsSet.getIconId(
@@ -251,11 +286,21 @@ public abstract class LayoutBase extends AbstractLayoutBase {
private static final int ICON_ZWJ = KeyboardIconsSet.getIconId(
KeyboardIconsSet.NAME_ZWJ_KEY);
- // Functional key.
+ // Functional keys.
+ public static final ExpectedKey DELETE_KEY = key(ICON_DELETE, Constants.CODE_DELETE);
+ public static final ExpectedKey TAB_KEY = key(ICON_TAB, Constants.CODE_TAB);
+ public static final ExpectedKey SHORTCUT_KEY = key(ICON_SHORTCUT, Constants.CODE_SHORTCUT);
+ public static final ExpectedKey SETTINGS_KEY = key(ICON_SETTINGS, Constants.CODE_SETTINGS);
+ public static final ExpectedKey LANGUAGE_SWITCH_KEY = key(
+ ICON_LANGUAGE_SWITCH, Constants.CODE_LANGUAGE_SWITCH);
+ public static final ExpectedKey ENTER_KEY = key(ICON_ENTER, Constants.CODE_ENTER);
+ public static final ExpectedKey EMOJI_ACTION_KEY = key(ICON_EMOJI_ACTION, Constants.CODE_EMOJI);
+ public static final ExpectedKey EMOJI_NORMAL_KEY = key(ICON_EMOJI_NORMAL, Constants.CODE_EMOJI);
+ public static final ExpectedKey SPACE_KEY = key(ICON_SPACE, Constants.CODE_SPACE);
static final ExpectedKey CAPSLOCK_MORE_KEY = key(" ", Constants.CODE_CAPSLOCK);
- static final ExpectedKey SHIFT_KEY = key(ICON_SHIFT,
+ public static final ExpectedKey SHIFT_KEY = key(ICON_SHIFT,
Constants.CODE_SHIFT, CAPSLOCK_MORE_KEY);
- static final ExpectedKey SHIFTED_SHIFT_KEY = key(ICON_SHIFTED_SHIFT,
+ public static final ExpectedKey SHIFTED_SHIFT_KEY = key(ICON_SHIFTED_SHIFT,
Constants.CODE_SHIFT, CAPSLOCK_MORE_KEY);
static final ExpectedKey ALPHABET_KEY = key("ABC", Constants.CODE_SWITCH_ALPHA_SYMBOL);
static final ExpectedKey SYMBOLS_KEY = key("?123", Constants.CODE_SWITCH_ALPHA_SYMBOL);
@@ -271,6 +316,9 @@ public abstract class LayoutBase extends AbstractLayoutBase {
// U+200D: ZERO WIDTH JOINER
static final ExpectedKey ZWNJ_KEY = key(ICON_ZWNJ, "\u200C");
static final ExpectedKey ZWJ_KEY = key(ICON_ZWJ, "\u200D");
+ // Domain key
+ public static final ExpectedKey DOMAIN_KEY =
+ key(".com", joinMoreKeys(".net", ".org", ".gov", ".edu")).preserveCase();
// Punctuation more keys for phone form factor.
public static final ExpectedKey[] PHONE_PUNCTUATION_MORE_KEYS = joinKeys(
@@ -300,12 +348,12 @@ public abstract class LayoutBase extends AbstractLayoutBase {
if (isPhone) {
builder.addKeysOnTheRightOfRow(numberOfRows - 1, DELETE_KEY)
.addKeysOnTheLeftOfRow(numberOfRows, customizer.getSymbolsKey())
- .addKeysOnTheRightOfRow(numberOfRows, key(ENTER_KEY, EMOJI_ACTION_KEY));
+ .addKeysOnTheRightOfRow(numberOfRows, customizer.getEnterKey(isPhone));
} else {
builder.addKeysOnTheRightOfRow(1, DELETE_KEY)
- .addKeysOnTheRightOfRow(numberOfRows - 2, ENTER_KEY)
+ .addKeysOnTheRightOfRow(numberOfRows - 2, customizer.getEnterKey(isPhone))
.addKeysOnTheLeftOfRow(numberOfRows, customizer.getSymbolsKey())
- .addKeysOnTheRightOfRow(numberOfRows, EMOJI_NORMAL_KEY);
+ .addKeysOnTheRightOfRow(numberOfRows, customizer.getEmojiKey(isPhone));
}
builder.addKeysOnTheLeftOfRow(
numberOfRows - 1, (Object[])customizer.getLeftShiftKeys(isPhone));
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Myanmar.java b/tests/src/com/android/inputmethod/keyboard/layout/Myanmar.java
index 15c74ed8c..3c70d3266 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/Myanmar.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/Myanmar.java
@@ -55,14 +55,14 @@ public final class Myanmar extends LayoutBase {
// U+002C: "," COMMA
// U+104A: "၊" MYANMAR SIGN LITTLE SECTION
return isPhone ? joinKeys(key("\u002C", SETTINGS_KEY))
- : joinKeys(key("\u104A", moreKey(","), SETTINGS_KEY), "_");
+ : joinKeys(key("\u104A", moreKey(","), SETTINGS_KEY));
}
@Override
public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) {
// U+104B: "။" MYANMAR SIGN SECTION
final ExpectedKey periodKey = key("\u104B", getPunctuationMoreKeys(isPhone));
- return isPhone ? joinKeys(periodKey) : joinKeys("/", periodKey);
+ return joinKeys(periodKey);
}
@Override
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Symbols.java b/tests/src/com/android/inputmethod/keyboard/layout/Symbols.java
index 2cee2d909..803089721 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/Symbols.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/Symbols.java
@@ -41,18 +41,18 @@ public class Symbols extends AbstractLayoutBase {
customizer.getSingleQuoteMoreKeys(), customizer.getSingleAngleQuoteKeys())));
if (isPhone) {
builder.addKeysOnTheLeftOfRow(3, customizer.getSymbolsShiftKey(isPhone))
- .addKeysOnTheRightOfRow(3, DELETE_KEY)
+ .addKeysOnTheRightOfRow(3, LayoutBase.DELETE_KEY)
.addKeysOnTheLeftOfRow(4, customizer.getAlphabetKey())
- .addKeysOnTheRightOfRow(4, key(ENTER_KEY, EMOJI_ACTION_KEY));
+ .addKeysOnTheRightOfRow(4, customizer.getEnterKey(isPhone));
} else {
// Tablet symbols keyboard has extra two keys at the left edge of the 3rd row.
builder.addKeysOnTheLeftOfRow(3, (Object[])joinKeys("\\", "="));
- builder.addKeysOnTheRightOfRow(1, DELETE_KEY)
- .addKeysOnTheRightOfRow(2, ENTER_KEY)
+ builder.addKeysOnTheRightOfRow(1, LayoutBase.DELETE_KEY)
+ .addKeysOnTheRightOfRow(2, customizer.getEnterKey(isPhone))
.addKeysOnTheLeftOfRow(3, customizer.getSymbolsShiftKey(isPhone))
.addKeysOnTheRightOfRow(3, customizer.getSymbolsShiftKey(isPhone))
.addKeysOnTheLeftOfRow(4, customizer.getAlphabetKey())
- .addKeysOnTheRightOfRow(4, EMOJI_NORMAL_KEY);
+ .addKeysOnTheRightOfRow(4, customizer.getEmojiKey(isPhone));
}
return builder.build();
}
@@ -167,7 +167,7 @@ public class Symbols extends AbstractLayoutBase {
// U+00BF: "¿" INVERTED QUESTION MARK
key("?", moreKey("\u00BF")))
.setKeysOfRow(4,
- key(","), key("_"), SPACE_KEY, key("/"),
+ key(","), key("_"), LayoutBase.SPACE_KEY, key("/"),
// U+2026: "…" HORIZONTAL ELLIPSIS
key(".", moreKey("\u2026")))
.build();
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/SymbolsShifted.java b/tests/src/com/android/inputmethod/keyboard/layout/SymbolsShifted.java
index 7ed103ba0..19cb6075a 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/SymbolsShifted.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/SymbolsShifted.java
@@ -37,20 +37,20 @@ public class SymbolsShifted extends AbstractLayoutBase {
builder.replaceKeyOfLabel(OTHER_CURRENCIES, (Object[])customizer.getOtherCurrencyKeys());
if (isPhone) {
builder.addKeysOnTheLeftOfRow(3, customizer.getBackToSymbolsKey())
- .addKeysOnTheRightOfRow(3, DELETE_KEY)
+ .addKeysOnTheRightOfRow(3, LayoutBase.DELETE_KEY)
.addKeysOnTheLeftOfRow(4, customizer.getAlphabetKey())
- .addKeysOnTheRightOfRow(4, key(ENTER_KEY, EMOJI_ACTION_KEY));
+ .addKeysOnTheRightOfRow(4, customizer.getEnterKey(isPhone));
} else {
// Tablet symbols shifted keyboard has extra two keys at the right edge of the 3rd row.
// U+00BF: "¿" INVERTED QUESTION MARK
// U+00A1: "¡" INVERTED EXCLAMATION MARK
builder.addKeysOnTheRightOfRow(3, (Object[])joinKeys("\u00A1", "\u00BF"));
- builder.addKeysOnTheRightOfRow(1, DELETE_KEY)
- .addKeysOnTheRightOfRow(2, ENTER_KEY)
+ builder.addKeysOnTheRightOfRow(1, LayoutBase.DELETE_KEY)
+ .addKeysOnTheRightOfRow(2, customizer.getEnterKey(isPhone))
.addKeysOnTheLeftOfRow(3, customizer.getBackToSymbolsKey())
.addKeysOnTheRightOfRow(3, customizer.getBackToSymbolsKey())
.addKeysOnTheLeftOfRow(4, customizer.getAlphabetKey())
- .addKeysOnTheRightOfRow(4, EMOJI_NORMAL_KEY);
+ .addKeysOnTheRightOfRow(4, customizer.getEmojiKey(isPhone));
}
return builder.build();
}
@@ -122,7 +122,7 @@ public class SymbolsShifted extends AbstractLayoutBase {
// U+2264: "≤" LESS-THAN OR EQUAL TO
// U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
key("<", joinMoreKeys("\u2039", "\u2264", "\u00AB")),
- SPACE_KEY,
+ LayoutBase.SPACE_KEY,
// U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
// U+2265: "≥" GREATER-THAN EQUAL TO
// U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java
index 0f7bef2a3..3556cb4bf 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java
@@ -16,9 +16,7 @@
package com.android.inputmethod.keyboard.layout.expected;
-import com.android.inputmethod.keyboard.internal.KeyboardIconsSet;
import com.android.inputmethod.keyboard.layout.expected.ExpectedKey.ExpectedAdditionalMoreKey;
-import com.android.inputmethod.latin.Constants;
/**
* Base class to create an expected keyboard for unit test.
@@ -104,36 +102,4 @@ public abstract class AbstractLayoutBase {
public static ExpectedKey[] joinKeys(final Object ... keys) {
return ExpectedKeyboardBuilder.joinKeys(keys);
}
-
- // Icon ids.
- private static final int ICON_DELETE = KeyboardIconsSet.getIconId(
- KeyboardIconsSet.NAME_DELETE_KEY);
- private static final int ICON_SPACE = KeyboardIconsSet.getIconId(
- KeyboardIconsSet.NAME_SPACE_KEY);
- private static final int ICON_TAB = KeyboardIconsSet.getIconId(
- KeyboardIconsSet.NAME_TAB_KEY);
- private static final int ICON_SHORTCUT = KeyboardIconsSet.getIconId(
- KeyboardIconsSet.NAME_SHORTCUT_KEY);
- private static final int ICON_SETTINGS = KeyboardIconsSet.getIconId(
- KeyboardIconsSet.NAME_SETTINGS_KEY);
- private static final int ICON_LANGUAGE_SWITCH = KeyboardIconsSet.getIconId(
- KeyboardIconsSet.NAME_LANGUAGE_SWITCH_KEY);
- private static final int ICON_ENTER = KeyboardIconsSet.getIconId(
- KeyboardIconsSet.NAME_ENTER_KEY);
- private static final int ICON_EMOJI_ACTION = KeyboardIconsSet.getIconId(
- KeyboardIconsSet.NAME_EMOJI_ACTION_KEY);
- private static final int ICON_EMOJI_NORMAL = KeyboardIconsSet.getIconId(
- KeyboardIconsSet.NAME_EMOJI_NORMAL_KEY);
-
- // Functional keys.
- public static final ExpectedKey DELETE_KEY = key(ICON_DELETE, Constants.CODE_DELETE);
- public static final ExpectedKey TAB_KEY = key(ICON_TAB, Constants.CODE_TAB);
- public static final ExpectedKey SHORTCUT_KEY = key(ICON_SHORTCUT, Constants.CODE_SHORTCUT);
- public static final ExpectedKey SETTINGS_KEY = key(ICON_SETTINGS, Constants.CODE_SETTINGS);
- public static final ExpectedKey LANGUAGE_SWITCH_KEY = key(
- ICON_LANGUAGE_SWITCH, Constants.CODE_LANGUAGE_SWITCH);
- public static final ExpectedKey ENTER_KEY = key(ICON_ENTER, Constants.CODE_ENTER);
- public static final ExpectedKey EMOJI_ACTION_KEY = key(ICON_EMOJI_ACTION, Constants.CODE_EMOJI);
- public static final ExpectedKey EMOJI_NORMAL_KEY = key(ICON_EMOJI_NORMAL, Constants.CODE_EMOJI);
- public static final ExpectedKey SPACE_KEY = key(ICON_SPACE, Constants.CODE_SPACE);
}
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKey.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKey.java
index 0e1c71cd1..2674a6a69 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKey.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKey.java
@@ -148,6 +148,18 @@ public class ExpectedKey {
return newInstance(mVisual.toUpperCase(locale), mOutput.toUpperCase(locale));
}
+ public ExpectedKey preserveCase() {
+ final ExpectedKey[] moreKeys = getMoreKeys();
+ final ExpectedKey[] casePreservedMoreKeys = new ExpectedKey[moreKeys.length];
+ for (int index = 0; index < moreKeys.length; index++) {
+ final ExpectedKey moreKey = moreKeys[index];
+ casePreservedMoreKeys[index] = newInstance(
+ moreKey.getVisual().preserveCase(), moreKey.getOutput().preserveCase());
+ }
+ return newInstance(
+ getVisual().preserveCase(), getOutput().preserveCase(), casePreservedMoreKeys);
+ }
+
public boolean equalsTo(final Key key) {
// This key has no "more keys".
return mVisual.equalsTo(key) && mOutput.equalsTo(key) && key.getMoreKeys() == null;
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyOutput.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyOutput.java
index 1be51e60b..737d1695b 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyOutput.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyOutput.java
@@ -42,6 +42,7 @@ abstract class ExpectedKeyOutput {
}
abstract ExpectedKeyOutput toUpperCase(final Locale locale);
+ abstract ExpectedKeyOutput preserveCase();
abstract boolean equalsTo(final String text);
abstract boolean equalsTo(final Key key);
abstract boolean equalsTo(final MoreKeySpec moreKeySpec);
@@ -69,6 +70,11 @@ abstract class ExpectedKeyOutput {
}
@Override
+ ExpectedKeyOutput preserveCase() {
+ return new CasePreservedCode(mCode);
+ }
+
+ @Override
boolean equalsTo(final String text) {
return StringUtils.codePointCount(text) == 1 && text.codePointAt(0) == mCode;
}
@@ -93,6 +99,16 @@ abstract class ExpectedKeyOutput {
return Constants.isLetterCode(mCode) ? StringUtils.newSingleCodePointString(mCode)
: Constants.printableCode(mCode);
}
+
+ private static class CasePreservedCode extends Code {
+ CasePreservedCode(final int code) { super(code); }
+
+ @Override
+ ExpectedKeyOutput toUpperCase(final Locale locale) { return this; }
+
+ @Override
+ ExpectedKeyOutput preserveCase() { return this; }
+ }
}
/**
@@ -109,6 +125,11 @@ abstract class ExpectedKeyOutput {
}
@Override
+ ExpectedKeyOutput preserveCase() {
+ return new CasePreservedText(mText);
+ }
+
+ @Override
boolean equalsTo(final String text) {
return text.equals(text);
}
@@ -134,5 +155,15 @@ abstract class ExpectedKeyOutput {
public String toString() {
return mText;
}
+
+ private static class CasePreservedText extends Text {
+ CasePreservedText(final String text) { super(text); }
+
+ @Override
+ ExpectedKeyOutput toUpperCase(final Locale locale) { return this; }
+
+ @Override
+ ExpectedKeyOutput preserveCase() { return this; }
+ }
}
}
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyVisual.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyVisual.java
index 0a0da32b6..facdf7043 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyVisual.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyVisual.java
@@ -37,6 +37,7 @@ abstract class ExpectedKeyVisual {
}
abstract ExpectedKeyVisual toUpperCase(final Locale locale);
+ abstract ExpectedKeyVisual preserveCase();
abstract boolean equalsTo(final String text);
abstract boolean equalsTo(final Key key);
abstract boolean equalsTo(final MoreKeySpec moreKeySpec);
@@ -59,6 +60,11 @@ abstract class ExpectedKeyVisual {
}
@Override
+ ExpectedKeyVisual preserveCase() {
+ return this;
+ }
+
+ @Override
boolean equalsTo(final String text) {
return false;
}
@@ -103,6 +109,11 @@ abstract class ExpectedKeyVisual {
}
@Override
+ ExpectedKeyVisual preserveCase() {
+ return new CasePreservedLabel(mLabel);
+ }
+
+ @Override
boolean equalsTo(final String text) {
return mLabel.equals(text);
}
@@ -131,5 +142,15 @@ abstract class ExpectedKeyVisual {
public String toString() {
return mLabel;
}
+
+ private static class CasePreservedLabel extends Label {
+ CasePreservedLabel(final String label) { super(label); }
+
+ @Override
+ ExpectedKeyVisual toUpperCase(final Locale locale) { return this; }
+
+ @Override
+ ExpectedKeyVisual preserveCase() { return this; }
+ }
}
}
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDvorakEmail.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDvorakEmail.java
new file mode 100644
index 000000000..37ca09238
--- /dev/null
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDvorakEmail.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.keyboard.layout.tests;
+
+import android.test.suitebuilder.annotation.SmallTest;
+import android.text.InputType;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodSubtype;
+
+import com.android.inputmethod.keyboard.KeyboardId;
+import com.android.inputmethod.keyboard.KeyboardLayoutSet;
+import com.android.inputmethod.keyboard.layout.Dvorak;
+import com.android.inputmethod.keyboard.layout.LayoutBase;
+import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
+import com.android.inputmethod.keyboard.layout.tests.TestsEnglishDvorak.EnglishDvorakCustomizer;
+
+import java.util.Locale;
+
+/**
+ * en_US: English (United States)/dvorak, email input field.
+ */
+@SmallTest
+public class TestsDvorakEmail extends LayoutTestsBase {
+ private static final Locale LOCALE = new Locale("en", "US");
+ private static final LayoutBase LAYOUT = new DvorakEmail(new DvorakEmailCustomizer(LOCALE));
+
+ @Override
+ LayoutBase getLayout() { return LAYOUT; }
+
+ @Override
+ protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
+ final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
+ final boolean languageSwitchKeyEnabled) {
+ final EditorInfo emailField = new EditorInfo();
+ emailField.inputType =
+ InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
+ return super.createKeyboardLayoutSet(
+ subtype, emailField, voiceInputKeyEnabled, languageSwitchKeyEnabled);
+ }
+
+ private static class DvorakEmailCustomizer extends EnglishDvorakCustomizer {
+ DvorakEmailCustomizer(final Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public ExpectedKey getEnterKey(final boolean isPhone) {
+ return isPhone ? LayoutBase.ENTER_KEY : super.getEnterKey(isPhone);
+ }
+
+ @Override
+ public ExpectedKey getEmojiKey(final boolean isPhone) {
+ return LayoutBase.DOMAIN_KEY;
+ }
+
+ @Override
+ public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) {
+ return isPhone ? super.getKeysLeftToSpacebar(isPhone)
+ : joinKeys(key("@", LayoutBase.SETTINGS_KEY));
+ }
+ }
+
+ private static class DvorakEmail extends Dvorak {
+ public DvorakEmail(final LayoutCustomizer customizer) {
+ super(customizer);
+ }
+
+ @Override
+ protected ExpectedKey getRow1_1Key(final boolean isPhone, final int elementId) {
+ if (isPhone && (elementId == KeyboardId.ELEMENT_ALPHABET
+ || elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED)) {
+ return key("@", joinMoreKeys(additionalMoreKey("1")));
+ }
+ return super.getRow1_1Key(isPhone, elementId);
+ }
+ }
+}
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDvorakUrl.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDvorakUrl.java
new file mode 100644
index 000000000..3bcae0ce4
--- /dev/null
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDvorakUrl.java
@@ -0,0 +1,91 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.keyboard.layout.tests;
+
+import android.test.suitebuilder.annotation.SmallTest;
+import android.text.InputType;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodSubtype;
+
+import com.android.inputmethod.keyboard.KeyboardId;
+import com.android.inputmethod.keyboard.KeyboardLayoutSet;
+import com.android.inputmethod.keyboard.layout.Dvorak;
+import com.android.inputmethod.keyboard.layout.LayoutBase;
+import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
+import com.android.inputmethod.keyboard.layout.tests.TestsEnglishDvorak.EnglishDvorakCustomizer;
+
+import java.util.Locale;
+
+/**
+ * en_US: English (United States)/dvorak, URL input field.
+ */
+@SmallTest
+public class TestsDvorakUrl extends LayoutTestsBase {
+ private static final Locale LOCALE = new Locale("en", "US");
+ private static final LayoutBase LAYOUT = new DvorakEmail(new DvorakUrlCustomizer(LOCALE));
+
+ @Override
+ LayoutBase getLayout() { return LAYOUT; }
+
+ @Override
+ protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
+ final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
+ final boolean languageSwitchKeyEnabled) {
+ final EditorInfo emailField = new EditorInfo();
+ emailField.inputType =
+ InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
+ return super.createKeyboardLayoutSet(
+ subtype, emailField, voiceInputKeyEnabled, languageSwitchKeyEnabled);
+ }
+
+ private static class DvorakUrlCustomizer extends EnglishDvorakCustomizer {
+ DvorakUrlCustomizer(final Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public ExpectedKey getEnterKey(final boolean isPhone) {
+ return isPhone ? LayoutBase.ENTER_KEY : super.getEnterKey(isPhone);
+ }
+
+ @Override
+ public ExpectedKey getEmojiKey(final boolean isPhone) {
+ return LayoutBase.DOMAIN_KEY;
+ }
+
+ @Override
+ public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) {
+ return isPhone ? super.getKeysLeftToSpacebar(isPhone)
+ : joinKeys(key("/", LayoutBase.SETTINGS_KEY));
+ }
+ }
+
+ private static class DvorakEmail extends Dvorak {
+ public DvorakEmail(final LayoutCustomizer customizer) {
+ super(customizer);
+ }
+
+ @Override
+ protected ExpectedKey getRow1_1Key(final boolean isPhone, final int elementId) {
+ if (isPhone && (elementId == KeyboardId.ELEMENT_ALPHABET
+ || elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED)) {
+ return key("/", joinMoreKeys(additionalMoreKey("1")));
+ }
+ return super.getRow1_1Key(isPhone, elementId);
+ }
+ }
+}
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEnglishDvorak.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEnglishDvorak.java
index a05269312..e647f8aea 100644
--- a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEnglishDvorak.java
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEnglishDvorak.java
@@ -36,7 +36,7 @@ public class TestsEnglishDvorak extends LayoutTestsBase {
@Override
LayoutBase getLayout() { return LAYOUT; }
- private static class EnglishDvorakCustomizer extends DvorakCustomizer {
+ public static class EnglishDvorakCustomizer extends DvorakCustomizer {
private final EnglishCustomizer mEnglishCustomizer;
EnglishDvorakCustomizer(final Locale locale) {
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsQwertyEmail.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsQwertyEmail.java
new file mode 100644
index 000000000..8563d6933
--- /dev/null
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsQwertyEmail.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.keyboard.layout.tests;
+
+import android.test.suitebuilder.annotation.SmallTest;
+import android.text.InputType;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodSubtype;
+
+import com.android.inputmethod.keyboard.KeyboardLayoutSet;
+import com.android.inputmethod.keyboard.layout.LayoutBase;
+import com.android.inputmethod.keyboard.layout.Qwerty;
+import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
+
+import java.util.Locale;
+
+/**
+ * en_US: English (United States)/qwerty, email input field.
+ */
+@SmallTest
+public class TestsQwertyEmail extends LayoutTestsBase {
+ private static final Locale LOCALE = new Locale("en", "US");
+ private static final LayoutBase LAYOUT = new Qwerty(new EnglishEmailCustomizer(LOCALE));
+
+ @Override
+ LayoutBase getLayout() { return LAYOUT; }
+
+ @Override
+ protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
+ final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
+ final boolean languageSwitchKeyEnabled) {
+ final EditorInfo emailField = new EditorInfo();
+ emailField.inputType =
+ InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
+ return super.createKeyboardLayoutSet(
+ subtype, emailField, voiceInputKeyEnabled, languageSwitchKeyEnabled);
+ }
+
+ private static class EnglishEmailCustomizer extends EnglishCustomizer {
+ EnglishEmailCustomizer(final Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public ExpectedKey getEnterKey(final boolean isPhone) {
+ return isPhone ? LayoutBase.ENTER_KEY : super.getEnterKey(isPhone);
+ }
+
+ @Override
+ public ExpectedKey getEmojiKey(final boolean isPhone) {
+ return LayoutBase.DOMAIN_KEY;
+ }
+
+ @Override
+ public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) {
+ return joinKeys(key("@", LayoutBase.SETTINGS_KEY));
+ }
+ }
+}
diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsQwertyUrl.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsQwertyUrl.java
new file mode 100644
index 000000000..1c1a2bbbd
--- /dev/null
+++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsQwertyUrl.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.keyboard.layout.tests;
+
+import android.test.suitebuilder.annotation.SmallTest;
+import android.text.InputType;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodSubtype;
+
+import com.android.inputmethod.keyboard.KeyboardLayoutSet;
+import com.android.inputmethod.keyboard.layout.LayoutBase;
+import com.android.inputmethod.keyboard.layout.Qwerty;
+import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
+
+import java.util.Locale;
+
+/**
+ * en_US: English (United States)/qwerty, URL input field.
+ */
+@SmallTest
+public class TestsQwertyUrl extends LayoutTestsBase {
+ private static final Locale LOCALE = new Locale("en", "US");
+ private static final LayoutBase LAYOUT = new Qwerty(new EnglishUrlCustomizer(LOCALE));
+
+ @Override
+ LayoutBase getLayout() { return LAYOUT; }
+
+ @Override
+ protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
+ final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
+ final boolean languageSwitchKeyEnabled) {
+ final EditorInfo emailField = new EditorInfo();
+ emailField.inputType =
+ InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
+ return super.createKeyboardLayoutSet(
+ subtype, emailField, voiceInputKeyEnabled, languageSwitchKeyEnabled);
+ }
+
+ private static class EnglishUrlCustomizer extends EnglishCustomizer {
+ EnglishUrlCustomizer(final Locale locale) {
+ super(locale);
+ }
+
+ @Override
+ public ExpectedKey getEnterKey(final boolean isPhone) {
+ return isPhone ? LayoutBase.ENTER_KEY : super.getEnterKey(isPhone);
+ }
+
+ @Override
+ public ExpectedKey getEmojiKey(final boolean isPhone) {
+ return LayoutBase.DOMAIN_KEY;
+ }
+
+ @Override
+ public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) {
+ return joinKeys(key("/", LayoutBase.SETTINGS_KEY));
+ }
+ }
+}
diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
index 986fb1097..d7a649a5b 100644
--- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java
+++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
@@ -36,6 +36,7 @@ import android.widget.EditText;
import android.widget.FrameLayout;
import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils;
+import com.android.inputmethod.event.Event;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
@@ -263,14 +264,16 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> {
// but keep them in mind if something breaks. Commenting them out as is should work.
//mLatinIME.onPressKey(codePoint, 0 /* repeatCount */, true /* isSinglePointer */);
final Key key = mKeyboard.getKey(codePoint);
+ final Event event;
if (key == null) {
- mLatinIME.onCodeInput(codePoint, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE,
- isKeyRepeat);
+ event = Event.createSoftwareKeypressEvent(codePoint, Event.NOT_A_KEY_CODE,
+ Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, isKeyRepeat);
} else {
final int x = key.getX() + key.getWidth() / 2;
final int y = key.getY() + key.getHeight() / 2;
- mLatinIME.onCodeInput(codePoint, x, y, isKeyRepeat);
+ event = mLatinIME.createSoftwareKeypressEvent(codePoint, x, y, isKeyRepeat);
}
+ mLatinIME.onEvent(event);
// Also see the comment at the top of this function about onReleaseKey
//mLatinIME.onReleaseKey(codePoint, false /* withSliding */);
}
diff --git a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
index a5f20b565..2785dec43 100644
--- a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
+++ b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
@@ -23,24 +23,49 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import java.util.ArrayList;
import java.util.Locale;
-import java.util.Random;
@SmallTest
public class SuggestedWordsTests extends AndroidTestCase {
+
+ /**
+ * Helper method to create a dummy {@link SuggestedWordInfo} with specifying
+ * {@link SuggestedWordInfo#KIND_TYPED}.
+ *
+ * @param word the word to be used to create {@link SuggestedWordInfo}.
+ * @return a new instance of {@link SuggestedWordInfo}.
+ */
+ private static SuggestedWordInfo createTypedWordInfo(final String word) {
+ // Use 100 as the frequency because the numerical value does not matter as
+ // long as it's > 1 and < INT_MAX.
+ return new SuggestedWordInfo(word, 100 /* score */,
+ SuggestedWordInfo.KIND_TYPED,
+ null /* sourceDict */,
+ SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
+ 1 /* autoCommitFirstWordConfidence */);
+ }
+
+ /**
+ * Helper method to create a dummy {@link SuggestedWordInfo} with specifying
+ * {@link SuggestedWordInfo#KIND_CORRECTION}.
+ *
+ * @param word the word to be used to create {@link SuggestedWordInfo}.
+ * @return a new instance of {@link SuggestedWordInfo}.
+ */
+ private static SuggestedWordInfo createCorrectionWordInfo(final String word) {
+ return new SuggestedWordInfo(word, 1 /* score */,
+ SuggestedWordInfo.KIND_CORRECTION,
+ null /* sourceDict */,
+ SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
+ SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */);
+ }
+
public void testGetSuggestedWordsExcludingTypedWord() {
final String TYPED_WORD = "typed";
- final int TYPED_WORD_FREQ = 5;
final int NUMBER_OF_ADDED_SUGGESTIONS = 5;
final ArrayList<SuggestedWordInfo> list = new ArrayList<>();
- list.add(new SuggestedWordInfo(TYPED_WORD, TYPED_WORD_FREQ,
- SuggestedWordInfo.KIND_TYPED, null /* sourceDict */,
- SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
- SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */));
+ list.add(createTypedWordInfo(TYPED_WORD));
for (int i = 0; i < NUMBER_OF_ADDED_SUGGESTIONS; ++i) {
- list.add(new SuggestedWordInfo("" + i, 1, SuggestedWordInfo.KIND_CORRECTION,
- null /* sourceDict */,
- SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
- SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */));
+ list.add(createCorrectionWordInfo(Integer.toString(i)));
}
final SuggestedWords words = new SuggestedWords(
@@ -66,19 +91,9 @@ public class SuggestedWordsTests extends AndroidTestCase {
}
// Helper for testGetTransformedWordInfo
- private SuggestedWordInfo createWordInfo(final String s) {
- // Use 100 as the frequency because the numerical value does not matter as
- // long as it's > 1 and < INT_MAX.
- return new SuggestedWordInfo(s, 100,
- SuggestedWordInfo.KIND_TYPED, null /* sourceDict */,
- SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
- new Random().nextInt(1000000) /* autoCommitFirstWordConfidence */);
- }
-
- // Helper for testGetTransformedWordInfo
private SuggestedWordInfo transformWordInfo(final String info,
final int trailingSingleQuotesCount) {
- final SuggestedWordInfo suggestedWordInfo = createWordInfo(info);
+ final SuggestedWordInfo suggestedWordInfo = createTypedWordInfo(info);
final SuggestedWordInfo returnedWordInfo =
Suggest.getTransformedSuggestedWordInfo(suggestedWordInfo,
Locale.ENGLISH, false /* isAllUpperCase */, false /* isFirstCharCapitalized */,
@@ -102,4 +117,35 @@ public class SuggestedWordsTests extends AndroidTestCase {
result = transformWordInfo("didn't", 3);
assertEquals(result.mWord, "didn't''");
}
+
+ public void testGetTypedWordInfoOrNull() {
+ final String TYPED_WORD = "typed";
+ final int NUMBER_OF_ADDED_SUGGESTIONS = 5;
+ final ArrayList<SuggestedWordInfo> list = new ArrayList<>();
+ list.add(createTypedWordInfo(TYPED_WORD));
+ for (int i = 0; i < NUMBER_OF_ADDED_SUGGESTIONS; ++i) {
+ list.add(createCorrectionWordInfo(Integer.toString(i)));
+ }
+
+ // Make sure getTypedWordInfoOrNull() returns non-null object.
+ final SuggestedWords wordsWithTypedWord = new SuggestedWords(
+ list, null /* rawSuggestions */,
+ false /* typedWordValid */,
+ false /* willAutoCorrect */,
+ false /* isObsoleteSuggestions */,
+ false /* isPrediction*/,
+ SuggestedWords.INPUT_STYLE_NONE);
+ final SuggestedWordInfo typedWord = wordsWithTypedWord.getTypedWordInfoOrNull();
+ assertNotNull(typedWord);
+ assertEquals(TYPED_WORD, typedWord.mWord);
+
+ // Make sure getTypedWordInfoOrNull() returns null.
+ final SuggestedWords wordsWithoutTypedWord =
+ wordsWithTypedWord.getSuggestedWordsExcludingTypedWord(
+ SuggestedWords.INPUT_STYLE_NONE);
+ assertNull(wordsWithoutTypedWord.getTypedWordInfoOrNull());
+
+ // Make sure getTypedWordInfoOrNull() returns null.
+ assertNull(SuggestedWords.EMPTY.getTypedWordInfoOrNull());
+ }
}
diff --git a/tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java b/tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java
new file mode 100644
index 000000000..f3273a2d1
--- /dev/null
+++ b/tests/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelperTests.java
@@ -0,0 +1,221 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.inputmethod.latin.suggestions;
+
+import android.test.AndroidTestCase;
+import android.test.suitebuilder.annotation.SmallTest;
+
+import com.android.inputmethod.latin.SuggestedWords;
+
+@SmallTest
+public class SuggestionStripLayoutHelperTests extends AndroidTestCase {
+ private static void confirmShowTypedWord(final String message, final int inputType) {
+ assertFalse(message, SuggestionStripLayoutHelper.shouldOmitTypedWord(
+ inputType,
+ false /* gestureFloatingPreviewTextEnabled */,
+ false /* shouldShowUiToAcceptTypedWord */));
+ assertFalse(message, SuggestionStripLayoutHelper.shouldOmitTypedWord(
+ inputType,
+ true /* gestureFloatingPreviewTextEnabled */,
+ false /* shouldShowUiToAcceptTypedWord */));
+ assertFalse(message, SuggestionStripLayoutHelper.shouldOmitTypedWord(
+ inputType,
+ false /* gestureFloatingPreviewTextEnabled */,
+ true /* shouldShowUiToAcceptTypedWord */));
+ assertFalse(message, SuggestionStripLayoutHelper.shouldOmitTypedWord(
+ inputType,
+ true /* gestureFloatingPreviewTextEnabled */,
+ true /* shouldShowUiToAcceptTypedWord */));
+ }
+
+ public void testShouldShowTypedWord() {
+ confirmShowTypedWord("no input style",
+ SuggestedWords.INPUT_STYLE_NONE);
+ confirmShowTypedWord("application specifed",
+ SuggestedWords.INPUT_STYLE_APPLICATION_SPECIFIED);
+ confirmShowTypedWord("recorrection",
+ SuggestedWords.INPUT_STYLE_RECORRECTION);
+ }
+
+ public void testshouldOmitTypedWordWhileTyping() {
+ assertFalse("typing", SuggestionStripLayoutHelper.shouldOmitTypedWord(
+ SuggestedWords.INPUT_STYLE_TYPING,
+ false /* gestureFloatingPreviewTextEnabled */,
+ false /* shouldShowUiToAcceptTypedWord */));
+ assertFalse("typing", SuggestionStripLayoutHelper.shouldOmitTypedWord(
+ SuggestedWords.INPUT_STYLE_TYPING,
+ true /* gestureFloatingPreviewTextEnabled */,
+ false /* shouldShowUiToAcceptTypedWord */));
+ assertTrue("typing", SuggestionStripLayoutHelper.shouldOmitTypedWord(
+ SuggestedWords.INPUT_STYLE_TYPING,
+ false /* gestureFloatingPreviewTextEnabled */,
+ true /* shouldShowUiToAcceptTypedWord */));
+ assertTrue("typing", SuggestionStripLayoutHelper.shouldOmitTypedWord(
+ SuggestedWords.INPUT_STYLE_TYPING,
+ true /* gestureFloatingPreviewTextEnabled */,
+ true /* shouldShowUiToAcceptTypedWord */));
+ }
+
+ public void testshouldOmitTypedWordWhileGesturing() {
+ assertFalse("gesturing", SuggestionStripLayoutHelper.shouldOmitTypedWord(
+ SuggestedWords.INPUT_STYLE_UPDATE_BATCH,
+ false /* gestureFloatingPreviewTextEnabled */,
+ false /* shouldShowUiToAcceptTypedWord */));
+ assertFalse("gesturing", SuggestionStripLayoutHelper.shouldOmitTypedWord(
+ SuggestedWords.INPUT_STYLE_UPDATE_BATCH,
+ true /* gestureFloatingPreviewTextEnabled */,
+ false /* shouldShowUiToAcceptTypedWord */));
+ assertFalse("gesturing", SuggestionStripLayoutHelper.shouldOmitTypedWord(
+ SuggestedWords.INPUT_STYLE_UPDATE_BATCH,
+ false /* gestureFloatingPreviewTextEnabled */,
+ true /* shouldShowUiToAcceptTypedWord */));
+ assertTrue("gesturing", SuggestionStripLayoutHelper.shouldOmitTypedWord(
+ SuggestedWords.INPUT_STYLE_UPDATE_BATCH,
+ true /* gestureFloatingPreviewTextEnabled */,
+ true /* shouldShowUiToAcceptTypedWord */));
+ }
+
+ public void testshouldOmitTypedWordWhenGestured() {
+ assertFalse("gestured", SuggestionStripLayoutHelper.shouldOmitTypedWord(
+ SuggestedWords.INPUT_STYLE_TAIL_BATCH,
+ false /* gestureFloatingPreviewTextEnabled */,
+ false /* shouldShowUiToAcceptTypedWord */));
+ assertFalse("gestured", SuggestionStripLayoutHelper.shouldOmitTypedWord(
+ SuggestedWords.INPUT_STYLE_TAIL_BATCH,
+ true /* gestureFloatingPreviewTextEnabled */,
+ false /* shouldShowUiToAcceptTypedWord */));
+ assertTrue("gestured", SuggestionStripLayoutHelper.shouldOmitTypedWord(
+ SuggestedWords.INPUT_STYLE_TAIL_BATCH,
+ false /* gestureFloatingPreviewTextEnabled */,
+ true /* shouldShowUiToAcceptTypedWord */));
+ assertTrue("gestured", SuggestionStripLayoutHelper.shouldOmitTypedWord(
+ SuggestedWords.INPUT_STYLE_TAIL_BATCH,
+ true /* gestureFloatingPreviewTextEnabled */,
+ true /* shouldShowUiToAcceptTypedWord */));
+ }
+
+ // Note that this unit test assumes that the number of suggested words in the suggestion strip
+ // is 3.
+ private static final int POSITION_OMIT = -1;
+ private static final int POSITION_LEFT = 0;
+ private static final int POSITION_CENTER = 1;
+ private static final int POSITION_RIGHT = 2;
+
+ public void testGetPositionInSuggestionStrip() {
+ assertEquals("1st word without auto correction", POSITION_CENTER,
+ SuggestionStripLayoutHelper.getPositionInSuggestionStrip(
+ SuggestedWords.INDEX_OF_TYPED_WORD /* indexInSuggestedWords */,
+ false /* willAutoCorrect */,
+ false /* omitTypedWord */,
+ POSITION_CENTER /* centerPositionInStrip */,
+ POSITION_LEFT /* typedWordPositionWhenAutoCorrect */));
+ assertEquals("2nd word without auto correction", POSITION_LEFT,
+ SuggestionStripLayoutHelper.getPositionInSuggestionStrip(
+ SuggestedWords.INDEX_OF_AUTO_CORRECTION /* indexInSuggestedWords */,
+ false /* willAutoCorrect */,
+ false /* omitTypedWord */,
+ POSITION_CENTER /* centerPositionInStrip */,
+ POSITION_LEFT /* typedWordPositionWhenAutoCorrect */));
+ assertEquals("3rd word without auto correction", POSITION_RIGHT,
+ SuggestionStripLayoutHelper.getPositionInSuggestionStrip(
+ 2 /* indexInSuggestedWords */,
+ false /* willAutoCorrect */,
+ false /* omitTypedWord */,
+ POSITION_CENTER /* centerPositionInStrip */,
+ POSITION_LEFT /* typedWordPositionWhenAutoCorrect */));
+
+ assertEquals("typed word with auto correction", POSITION_LEFT,
+ SuggestionStripLayoutHelper.getPositionInSuggestionStrip(
+ SuggestedWords.INDEX_OF_TYPED_WORD /* indexInSuggestedWords */,
+ true /* willAutoCorrect */,
+ false /* omitTypedWord */,
+ POSITION_CENTER /* centerPositionInStrip */,
+ POSITION_LEFT /* typedWordPositionWhenAutoCorrect */));
+ assertEquals("2nd word with auto correction", POSITION_CENTER,
+ SuggestionStripLayoutHelper.getPositionInSuggestionStrip(
+ SuggestedWords.INDEX_OF_AUTO_CORRECTION /* indexInSuggestedWords */,
+ true /* willAutoCorrect */,
+ false /* omitTypedWord */,
+ POSITION_CENTER /* centerPositionInStrip */,
+ POSITION_LEFT /* typedWordPositionWhenAutoCorrect */));
+ assertEquals("3rd word with auto correction", POSITION_RIGHT,
+ SuggestionStripLayoutHelper.getPositionInSuggestionStrip(
+ 2 /* indexInSuggestedWords */,
+ true /* willAutoCorrect */,
+ false /* omitTypedWord */,
+ POSITION_CENTER /* centerPositionInStrip */,
+ POSITION_LEFT /* typedWordPositionWhenAutoCorrect */));
+
+ assertEquals("1st word without auto correction", POSITION_OMIT,
+ SuggestionStripLayoutHelper.getPositionInSuggestionStrip(
+ SuggestedWords.INDEX_OF_TYPED_WORD /* indexInSuggestedWords */,
+ false /* willAutoCorrect */,
+ true /* omitTypedWord */,
+ POSITION_CENTER /* centerPositionInStrip */,
+ POSITION_LEFT /* typedWordPositionWhenAutoCorrect */));
+ assertEquals("2nd word without auto correction", POSITION_CENTER,
+ SuggestionStripLayoutHelper.getPositionInSuggestionStrip(
+ SuggestedWords.INDEX_OF_AUTO_CORRECTION /* indexInSuggestedWords */,
+ false /* willAutoCorrect */,
+ true /* omitTypedWord */,
+ POSITION_CENTER /* centerPositionInStrip */,
+ POSITION_LEFT /* typedWordPositionWhenAutoCorrect */));
+ assertEquals("3rd word without auto correction", POSITION_LEFT,
+ SuggestionStripLayoutHelper.getPositionInSuggestionStrip(
+ 2 /* indexInSuggestedWords */,
+ false /* willAutoCorrect */,
+ true /* omitTypedWord */,
+ POSITION_CENTER /* centerPositionInStrip */,
+ POSITION_LEFT /* typedWordPositionWhenAutoCorrect */));
+ assertEquals("4th word without auto correction", POSITION_RIGHT,
+ SuggestionStripLayoutHelper.getPositionInSuggestionStrip(
+ 3 /* indexInSuggestedWords */,
+ false /* willAutoCorrect */,
+ true /* omitTypedWord */,
+ POSITION_CENTER /* centerPositionInStrip */,
+ POSITION_LEFT /* typedWordPositionWhenAutoCorrect */));
+
+ assertEquals("typed word with auto correction", POSITION_OMIT,
+ SuggestionStripLayoutHelper.getPositionInSuggestionStrip(
+ SuggestedWords.INDEX_OF_TYPED_WORD /* indexInSuggestedWords */,
+ true /* willAutoCorrect */,
+ true /* omitTypedWord */,
+ POSITION_CENTER /* centerPositionInStrip */,
+ POSITION_LEFT /* typedWordPositionWhenAutoCorrect */));
+ assertEquals("2nd word with auto correction", POSITION_CENTER,
+ SuggestionStripLayoutHelper.getPositionInSuggestionStrip(
+ SuggestedWords.INDEX_OF_AUTO_CORRECTION /* indexInSuggestedWords */,
+ true /* willAutoCorrect */,
+ true /* omitTypedWord */,
+ POSITION_CENTER /* centerPositionInStrip */,
+ POSITION_LEFT /* typedWordPositionWhenAutoCorrect */));
+ assertEquals("3rd word with auto correction", POSITION_LEFT,
+ SuggestionStripLayoutHelper.getPositionInSuggestionStrip(
+ 2 /* indexInSuggestedWords */,
+ true /* willAutoCorrect */,
+ true /* omitTypedWord */,
+ POSITION_CENTER /* centerPositionInStrip */,
+ POSITION_LEFT /* typedWordPositionWhenAutoCorrect */));
+ assertEquals("4th word with auto correction", POSITION_RIGHT,
+ SuggestionStripLayoutHelper.getPositionInSuggestionStrip(
+ 3 /* indexInSuggestedWords */,
+ true /* willAutoCorrect */,
+ true /* omitTypedWord */,
+ POSITION_CENTER /* centerPositionInStrip */,
+ POSITION_LEFT /* typedWordPositionWhenAutoCorrect */));
+ }
+}
diff --git a/tests/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtilsTests.java
index 91c9c3775..66a12b99b 100644
--- a/tests/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtilsTests.java
@@ -151,25 +151,25 @@ public class AdditionalSubtypeUtilsTests extends AndroidTestCase {
}
public void testRestorable() {
- final InputMethodSubtype EN_UK_DVORAK =
+ final InputMethodSubtype EN_US_DVORAK =
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
Locale.US.toString(), "dvorak");
final InputMethodSubtype ZZ_AZERTY =
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
SubtypeLocaleUtils.NO_LANGUAGE, "azerty");
- assertEnUsDvorak(EN_UK_DVORAK);
+ assertEnUsDvorak(EN_US_DVORAK);
assertAzerty(ZZ_AZERTY);
// Make sure the subtype can be stored and restored in a deterministic manner.
- final InputMethodSubtype[] subtypes = { EN_UK_DVORAK, ZZ_AZERTY };
+ final InputMethodSubtype[] subtypes = { EN_US_DVORAK, ZZ_AZERTY };
final String prefSubtype = AdditionalSubtypeUtils.createPrefSubtypes(subtypes);
final InputMethodSubtype[] restoredSubtypes =
AdditionalSubtypeUtils.createAdditionalSubtypesArray(prefSubtype);
assertEquals(2, restoredSubtypes.length);
- final InputMethodSubtype restored_EN_UK_DVORAK = restoredSubtypes[0];
+ final InputMethodSubtype restored_EN_US_DVORAK = restoredSubtypes[0];
final InputMethodSubtype restored_ZZ_AZERTY = restoredSubtypes[1];
- assertEnUsDvorak(restored_EN_UK_DVORAK);
+ assertEnUsDvorak(restored_EN_US_DVORAK);
assertAzerty(restored_ZZ_AZERTY);
}
}
diff --git a/tests/src/com/android/inputmethod/latin/utils/SpacebarLanguageUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/SpacebarLanguageUtilsTests.java
index aef517ca8..b766ab2e7 100644
--- a/tests/src/com/android/inputmethod/latin/utils/SpacebarLanguageUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/SpacebarLanguageUtilsTests.java
@@ -24,6 +24,7 @@ import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.RichInputMethodManager;
+import com.android.inputmethod.latin.RichInputMethodSubtype;
import java.util.ArrayList;
import java.util.Locale;
@@ -31,28 +32,28 @@ import java.util.Locale;
@SmallTest
public class SpacebarLanguageUtilsTests extends AndroidTestCase {
// All input method subtypes of LatinIME.
- private final ArrayList<InputMethodSubtype> mSubtypesList = new ArrayList<>();
+ private final ArrayList<RichInputMethodSubtype> mSubtypesList = new ArrayList<>();
private RichInputMethodManager mRichImm;
private Resources mRes;
- InputMethodSubtype EN_US;
- InputMethodSubtype EN_GB;
- InputMethodSubtype ES_US;
- InputMethodSubtype FR;
- InputMethodSubtype FR_CA;
- InputMethodSubtype FR_CH;
- InputMethodSubtype DE;
- InputMethodSubtype DE_CH;
- InputMethodSubtype HI_ZZ;
- InputMethodSubtype ZZ;
- InputMethodSubtype DE_QWERTY;
- InputMethodSubtype FR_QWERTZ;
- InputMethodSubtype EN_US_AZERTY;
- InputMethodSubtype EN_UK_DVORAK;
- InputMethodSubtype ES_US_COLEMAK;
- InputMethodSubtype ZZ_AZERTY;
- InputMethodSubtype ZZ_PC;
+ RichInputMethodSubtype EN_US;
+ RichInputMethodSubtype EN_GB;
+ RichInputMethodSubtype ES_US;
+ RichInputMethodSubtype FR;
+ RichInputMethodSubtype FR_CA;
+ RichInputMethodSubtype FR_CH;
+ RichInputMethodSubtype DE;
+ RichInputMethodSubtype DE_CH;
+ RichInputMethodSubtype HI_ZZ;
+ RichInputMethodSubtype ZZ;
+ RichInputMethodSubtype DE_QWERTY;
+ RichInputMethodSubtype FR_QWERTZ;
+ RichInputMethodSubtype EN_US_AZERTY;
+ RichInputMethodSubtype EN_UK_DVORAK;
+ RichInputMethodSubtype ES_US_COLEMAK;
+ RichInputMethodSubtype ZZ_AZERTY;
+ RichInputMethodSubtype ZZ_PC;
@Override
protected void setUp() throws Exception {
@@ -67,53 +68,60 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
final int subtypeCount = imi.getSubtypeCount();
for (int index = 0; index < subtypeCount; index++) {
final InputMethodSubtype subtype = imi.getSubtypeAt(index);
- mSubtypesList.add(subtype);
+ mSubtypesList.add(new RichInputMethodSubtype(subtype));
}
- 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");
- FR_CH = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- "fr_CH", "swiss");
- DE = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- Locale.GERMAN.toString(), "qwertz");
- DE_CH = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- "de_CH", "swiss");
- HI_ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- "hi_ZZ", "qwerty");
- ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
- SubtypeLocaleUtils.NO_LANGUAGE, "qwerty");
- DE_QWERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
- Locale.GERMAN.toString(), "qwerty");
- FR_QWERTZ = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
- Locale.FRENCH.toString(), "qwertz");
- EN_US_AZERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
- Locale.US.toString(), "azerty");
- EN_UK_DVORAK = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
- Locale.UK.toString(), "dvorak");
- ES_US_COLEMAK = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
- "es_US", "colemak");
- ZZ_AZERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
- SubtypeLocaleUtils.NO_LANGUAGE, "azerty");
- ZZ_PC = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
- SubtypeLocaleUtils.NO_LANGUAGE, "pcqwerty");
+ EN_US = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.US.toString(), "qwerty"));
+ EN_GB = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.UK.toString(), "qwerty"));
+ ES_US = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ "es_US", "spanish"));
+ FR = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.FRENCH.toString(), "azerty"));
+ FR_CA = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.CANADA_FRENCH.toString(), "qwerty"));
+ FR_CH = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ "fr_CH", "swiss"));
+ DE = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ Locale.GERMAN.toString(), "qwertz"));
+ DE_CH = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ "de_CH", "swiss"));
+ HI_ZZ = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ "hi_ZZ", "qwerty"));
+ ZZ = new RichInputMethodSubtype(mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
+ SubtypeLocaleUtils.NO_LANGUAGE, "qwerty"));
+ DE_QWERTY = new RichInputMethodSubtype(
+ AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
+ Locale.GERMAN.toString(), "qwerty"));
+ FR_QWERTZ = new RichInputMethodSubtype(
+ AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
+ Locale.FRENCH.toString(), "qwertz"));
+ EN_US_AZERTY = new RichInputMethodSubtype(
+ AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
+ Locale.US.toString(), "azerty"));
+ EN_UK_DVORAK = new RichInputMethodSubtype(
+ AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
+ Locale.UK.toString(), "dvorak"));
+ ES_US_COLEMAK = new RichInputMethodSubtype(
+ AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
+ "es_US", "colemak"));
+ ZZ_AZERTY = new RichInputMethodSubtype(
+ AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
+ SubtypeLocaleUtils.NO_LANGUAGE, "azerty"));
+ ZZ_PC = new RichInputMethodSubtype(
+ AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
+ SubtypeLocaleUtils.NO_LANGUAGE, "pcqwerty"));
}
public void testAllFullDisplayNameForSpacebar() {
- for (final InputMethodSubtype subtype : mSubtypesList) {
+ for (final RichInputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocaleUtils
- .getSubtypeDisplayNameInSystemLocale(subtype);
- final String spacebarText = SpacebarLanguageUtils.getFullDisplayName(subtype);
+ .getSubtypeDisplayNameInSystemLocale(subtype.getRawSubtype());
+ final String spacebarText = subtype.getFullDisplayName();
final String languageName = SubtypeLocaleUtils
.getSubtypeLocaleDisplayName(subtype.getLocale());
- if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
+ if (subtype.isNoLanguage()) {
assertFalse(subtypeName, spacebarText.contains(languageName));
} else {
assertTrue(subtypeName, spacebarText.contains(languageName));
@@ -122,19 +130,19 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
}
public void testAllMiddleDisplayNameForSpacebar() {
- for (final InputMethodSubtype subtype : mSubtypesList) {
+ for (final RichInputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocaleUtils
- .getSubtypeDisplayNameInSystemLocale(subtype);
+ .getSubtypeDisplayNameInSystemLocale(subtype.getRawSubtype());
if (SubtypeLocaleUtils.sExceptionalLocaleDisplayedInRootLocale.contains(
subtype.getLocale())) {
// 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).
continue;
}
- final String spacebarText = SpacebarLanguageUtils.getMiddleDisplayName(subtype);
- if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
- assertEquals(subtypeName,
- SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(subtype), spacebarText);
+ final String spacebarText = subtype.getMiddleDisplayName();
+ if (subtype.isNoLanguage()) {
+ assertEquals(subtypeName, SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(
+ subtype.getRawSubtype()), spacebarText);
} else {
final Locale locale = SubtypeLocaleUtils.getSubtypeLocale(subtype);
assertEquals(subtypeName,
@@ -166,47 +174,27 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
private final RunInLocale<Void> testsPredefinedSubtypesForSpacebar = new RunInLocale<Void>() {
@Override
protected Void job(final Resources res) {
- assertEquals("en_US", "English (US)",
- SpacebarLanguageUtils.getFullDisplayName(EN_US));
- assertEquals("en_GB", "English (UK)",
- SpacebarLanguageUtils.getFullDisplayName(EN_GB));
- assertEquals("es_US", "Español (EE.UU.)",
- SpacebarLanguageUtils.getFullDisplayName(ES_US));
- assertEquals("fr", "Français",
- SpacebarLanguageUtils.getFullDisplayName(FR));
- assertEquals("fr_CA", "Français (Canada)",
- SpacebarLanguageUtils.getFullDisplayName(FR_CA));
- assertEquals("fr_CH", "Français (Suisse)",
- SpacebarLanguageUtils.getFullDisplayName(FR_CH));
- assertEquals("de", "Deutsch",
- SpacebarLanguageUtils.getFullDisplayName(DE));
- assertEquals("de_CH", "Deutsch (Schweiz)",
- SpacebarLanguageUtils.getFullDisplayName(DE_CH));
- assertEquals("hi_ZZ", "Hinglish",
- SpacebarLanguageUtils.getFullDisplayName(HI_ZZ));
- assertEquals("zz", "QWERTY",
- SpacebarLanguageUtils.getFullDisplayName(ZZ));
-
- assertEquals("en_US", "English",
- SpacebarLanguageUtils.getMiddleDisplayName(EN_US));
- assertEquals("en_GB", "English",
- SpacebarLanguageUtils.getMiddleDisplayName(EN_GB));
- assertEquals("es_US", "Español",
- SpacebarLanguageUtils.getMiddleDisplayName(ES_US));
- assertEquals("fr", "Français",
- SpacebarLanguageUtils.getMiddleDisplayName(FR));
- assertEquals("fr_CA", "Français",
- SpacebarLanguageUtils.getMiddleDisplayName(FR_CA));
- assertEquals("fr_CH", "Français",
- SpacebarLanguageUtils.getMiddleDisplayName(FR_CH));
- assertEquals("de", "Deutsch",
- SpacebarLanguageUtils.getMiddleDisplayName(DE));
- assertEquals("de_CH", "Deutsch",
- SpacebarLanguageUtils.getMiddleDisplayName(DE_CH));
- assertEquals("hi_ZZ", "Hinglish",
- SpacebarLanguageUtils.getMiddleDisplayName(HI_ZZ));
- assertEquals("zz", "QWERTY",
- SpacebarLanguageUtils.getMiddleDisplayName(ZZ));
+ assertEquals("en_US", "English (US)", EN_US.getFullDisplayName());
+ assertEquals("en_GB", "English (UK)", EN_GB.getFullDisplayName());
+ assertEquals("es_US", "Español (EE.UU.)", ES_US.getFullDisplayName());
+ assertEquals("fr", "Français", FR.getFullDisplayName());
+ assertEquals("fr_CA", "Français (Canada)", FR_CA.getFullDisplayName());
+ assertEquals("fr_CH", "Français (Suisse)", FR_CH.getFullDisplayName());
+ assertEquals("de", "Deutsch", DE.getFullDisplayName());
+ assertEquals("de_CH", "Deutsch (Schweiz)", DE_CH.getFullDisplayName());
+ assertEquals("hi_ZZ", "Hinglish", HI_ZZ.getFullDisplayName());
+ assertEquals("zz", "QWERTY", ZZ.getFullDisplayName());
+
+ assertEquals("en_US", "English", EN_US.getMiddleDisplayName());
+ assertEquals("en_GB", "English", EN_GB.getMiddleDisplayName());
+ assertEquals("es_US", "Español", ES_US.getMiddleDisplayName());
+ assertEquals("fr", "Français", FR.getMiddleDisplayName());
+ assertEquals("fr_CA", "Français", FR_CA.getMiddleDisplayName());
+ assertEquals("fr_CH", "Français", FR_CH.getMiddleDisplayName());
+ assertEquals("de", "Deutsch", DE.getMiddleDisplayName());
+ assertEquals("de_CH", "Deutsch", DE_CH.getMiddleDisplayName());
+ assertEquals("hi_ZZ", "Hinglish", HI_ZZ.getMiddleDisplayName());
+ assertEquals("zz", "QWERTY", ZZ.getMiddleDisplayName());
return null;
}
};
@@ -214,35 +202,21 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
private final RunInLocale<Void> testsAdditionalSubtypesForSpacebar = new RunInLocale<Void>() {
@Override
protected Void job(final Resources res) {
- assertEquals("fr qwertz", "Français",
- SpacebarLanguageUtils.getFullDisplayName(FR_QWERTZ));
- assertEquals("de qwerty", "Deutsch",
- SpacebarLanguageUtils.getFullDisplayName(DE_QWERTY));
- assertEquals("en_US azerty", "English (US)",
- SpacebarLanguageUtils.getFullDisplayName(EN_US_AZERTY));
- assertEquals("en_UK dvorak", "English (UK)",
- SpacebarLanguageUtils.getFullDisplayName(EN_UK_DVORAK));
- assertEquals("es_US colemak", "Español (EE.UU.)",
- SpacebarLanguageUtils.getFullDisplayName(ES_US_COLEMAK));
- assertEquals("zz azerty", "AZERTY",
- SpacebarLanguageUtils.getFullDisplayName(ZZ_AZERTY));
- assertEquals("zz pc", "PC",
- SpacebarLanguageUtils.getFullDisplayName(ZZ_PC));
-
- assertEquals("fr qwertz", "Français",
- SpacebarLanguageUtils.getMiddleDisplayName(FR_QWERTZ));
- assertEquals("de qwerty", "Deutsch",
- SpacebarLanguageUtils.getMiddleDisplayName(DE_QWERTY));
- assertEquals("en_US azerty", "English",
- SpacebarLanguageUtils.getMiddleDisplayName(EN_US_AZERTY));
- assertEquals("en_UK dvorak", "English",
- SpacebarLanguageUtils.getMiddleDisplayName(EN_UK_DVORAK));
- assertEquals("es_US colemak", "Español",
- SpacebarLanguageUtils.getMiddleDisplayName(ES_US_COLEMAK));
- assertEquals("zz azerty", "AZERTY",
- SpacebarLanguageUtils.getMiddleDisplayName(ZZ_AZERTY));
- assertEquals("zz pc", "PC",
- SpacebarLanguageUtils.getMiddleDisplayName(ZZ_PC));
+ assertEquals("fr qwertz", "Français", FR_QWERTZ.getFullDisplayName());
+ assertEquals("de qwerty", "Deutsch", DE_QWERTY.getFullDisplayName());
+ assertEquals("en_US azerty", "English (US)", EN_US_AZERTY.getFullDisplayName());
+ assertEquals("en_UK dvorak", "English (UK)", EN_UK_DVORAK.getFullDisplayName());
+ assertEquals("es_US colemak", "Español (EE.UU.)", ES_US_COLEMAK.getFullDisplayName());
+ assertEquals("zz azerty", "AZERTY", ZZ_AZERTY.getFullDisplayName());
+ assertEquals("zz pc", "PC", ZZ_PC.getFullDisplayName());
+
+ assertEquals("fr qwertz", "Français", FR_QWERTZ.getMiddleDisplayName());
+ assertEquals("de qwerty", "Deutsch", DE_QWERTY.getMiddleDisplayName());
+ assertEquals("en_US azerty", "English", EN_US_AZERTY.getMiddleDisplayName());
+ assertEquals("en_UK dvorak", "English", EN_UK_DVORAK.getMiddleDisplayName());
+ assertEquals("es_US colemak", "Español", ES_US_COLEMAK.getMiddleDisplayName());
+ assertEquals("zz azerty", "AZERTY", ZZ_AZERTY.getMiddleDisplayName());
+ assertEquals("zz pc", "PC", ZZ_PC.getMiddleDisplayName());
return null;
}
};
diff --git a/tests/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtilsTests.java
index 4f0b3ccdc..5afbbbe6c 100644
--- a/tests/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtilsTests.java
+++ b/tests/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtilsTests.java
@@ -24,6 +24,7 @@ import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype;
import com.android.inputmethod.latin.RichInputMethodManager;
+import com.android.inputmethod.latin.RichInputMethodSubtype;
import java.util.ArrayList;
import java.util.Locale;
@@ -31,7 +32,7 @@ import java.util.Locale;
@SmallTest
public class SubtypeLocaleUtilsTests extends AndroidTestCase {
// All input method subtypes of LatinIME.
- private final ArrayList<InputMethodSubtype> mSubtypesList = new ArrayList<>();
+ private final ArrayList<RichInputMethodSubtype> mSubtypesList = new ArrayList<>();
private RichInputMethodManager mRichImm;
private Resources mRes;
@@ -67,7 +68,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
final int subtypeCount = imi.getSubtypeCount();
for (int index = 0; index < subtypeCount; index++) {
final InputMethodSubtype subtype = imi.getSubtypeAt(index);
- mSubtypesList.add(subtype);
+ mSubtypesList.add(new RichInputMethodSubtype(subtype));
}
EN_US = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
@@ -107,12 +108,12 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
}
public void testAllFullDisplayName() {
- for (final InputMethodSubtype subtype : mSubtypesList) {
+ for (final RichInputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocaleUtils
- .getSubtypeDisplayNameInSystemLocale(subtype);
- if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
+ .getSubtypeDisplayNameInSystemLocale(subtype.getRawSubtype());
+ if (subtype.isNoLanguage()) {
final String layoutName = SubtypeLocaleUtils
- .getKeyboardLayoutSetDisplayName(subtype);
+ .getKeyboardLayoutSetDisplayName(subtype.getRawSubtype());
assertTrue(subtypeName, subtypeName.contains(layoutName));
} else {
final String languageName = SubtypeLocaleUtils
@@ -308,10 +309,12 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
.findSubtypeByLocaleAndKeyboardLayoutSet("iw", "hebrew");
assertNotNull("Hebrew", HEBREW);
- for (final InputMethodSubtype subtype : mSubtypesList) {
+ for (final RichInputMethodSubtype subtype : mSubtypesList) {
+ final InputMethodSubtype rawSubtype = subtype.getRawSubtype();
final String subtypeName = SubtypeLocaleUtils
- .getSubtypeDisplayNameInSystemLocale(subtype);
- if (subtype.equals(ARABIC) || subtype.equals(FARSI) || subtype.equals(HEBREW)) {
+ .getSubtypeDisplayNameInSystemLocale(rawSubtype);
+ if (rawSubtype.equals(ARABIC) || rawSubtype.equals(FARSI)
+ || rawSubtype.equals(HEBREW)) {
assertTrue(subtypeName, SubtypeLocaleUtils.isRtlLanguage(subtype));
} else {
assertFalse(subtypeName, SubtypeLocaleUtils.isRtlLanguage(subtype));