Loading tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetActionLabelKlpTests.java +83 −102 Original line number Original line Diff line number Diff line Loading @@ -18,34 +18,33 @@ package com.android.inputmethod.keyboard; import android.content.res.Resources; import android.content.res.Resources; import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest; import android.text.InputType; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.RichInputMethodManager; import com.android.inputmethod.latin.utils.RunInLocale; import com.android.inputmethod.latin.utils.RunInLocale; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import java.util.Locale; @MediumTest @MediumTest public class KeyboardLayoutSetActionLabelKlpTests extends KeyboardLayoutSetTestsBase { public class KeyboardLayoutSetActionLabelKlpTests extends KeyboardLayoutSetActionLabelLxxTests { @Override @Override protected int getKeyboardThemeForTests() { protected int getKeyboardThemeForTests() { return KeyboardTheme.THEME_ID_KLP; return KeyboardTheme.THEME_ID_KLP; } } private static void doTestActionKey(final String tag, final KeyboardLayoutSet layoutSet, protected void doTestActionKeyLabel(final String tag, final InputMethodSubtype subtype, final int elementId, final CharSequence label, final int iconId) { final int actionId, final int labelResId) { final Keyboard keyboard = layoutSet.getKeyboard(elementId); final Locale labelLocale = subtype.getLocale().equals(SubtypeLocaleUtils.NO_LANGUAGE) final Key enterKey = keyboard.getKey(Constants.CODE_ENTER); ? null : SubtypeLocaleUtils.getSubtypeLocale(subtype); assertNotNull(tag + " enter key on " + keyboard.mId, enterKey); doTestActionKeyLabel(tag, subtype, actionId, labelLocale, labelResId); assertEquals(tag + " enter label " + enterKey, label, enterKey.getLabel()); assertEquals(tag + " enter icon " + enterKey, iconId, enterKey.getIconId()); } } protected void doTestActionLabel(final String tag, final InputMethodSubtype subtype, protected void doTestActionKeyLabel(final String tag, final InputMethodSubtype subtype, final int actionId, final int labelResId) { final int actionId, final Locale labelLocale, final int labelResId) { final EditorInfo editorInfo = new EditorInfo(); final EditorInfo editorInfo = new EditorInfo(); editorInfo.imeOptions = actionId; editorInfo.imeOptions = actionId; final RunInLocale<String> job = new RunInLocale<String>() { final RunInLocale<String> job = new RunInLocale<String>() { Loading @@ -54,138 +53,120 @@ public class KeyboardLayoutSetActionLabelKlpTests extends KeyboardLayoutSetTests return res.getString(labelResId); return res.getString(labelResId); } } }; }; final Resources res = getContext().getResources(); final String label = job.runInLocale(getContext().getResources(), labelLocale); final String label; doTestActionKeyLabel(tag, subtype, editorInfo, label); if (subtype.getLocale().equals(SubtypeLocaleUtils.NO_LANGUAGE)) { // Using system locale. label = res.getString(labelResId); } else { label = job.runInLocale(res, SubtypeLocaleUtils.getSubtypeLocale(subtype)); } doTestActionLabel(tag, subtype, editorInfo, label); } protected void doTestActionLabel(final String tag, final InputMethodSubtype subtype, final EditorInfo editorInfo, final CharSequence label) { // Test text layouts. editorInfo.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL; final KeyboardLayoutSet layoutSet = createKeyboardLayoutSet(subtype, editorInfo); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_ALPHABET, label, KeyboardIconsSet.ICON_UNDEFINED); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS, label, KeyboardIconsSet.ICON_UNDEFINED); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS_SHIFTED, label, KeyboardIconsSet.ICON_UNDEFINED); // Test phone number layouts. doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_PHONE, label, KeyboardIconsSet.ICON_UNDEFINED); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_PHONE_SYMBOLS, label, KeyboardIconsSet.ICON_UNDEFINED); // Test normal number layout. doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_NUMBER, label, KeyboardIconsSet.ICON_UNDEFINED); // Test number password layouts. editorInfo.inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD; final KeyboardLayoutSet passwordSet = createKeyboardLayoutSet(subtype, editorInfo); doTestActionKey(tag, passwordSet, KeyboardId.ELEMENT_NUMBER, label, KeyboardIconsSet.ICON_UNDEFINED); } protected void doTestActionKeyIcon(final String tag, final InputMethodSubtype subtype, final int actionId, final String iconName) { final int iconId = KeyboardIconsSet.getIconId(iconName); final EditorInfo editorInfo = new EditorInfo(); editorInfo.imeOptions = actionId; // Test text layouts. editorInfo.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL; final KeyboardLayoutSet layoutSet = createKeyboardLayoutSet(subtype, editorInfo); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_ALPHABET, null /* label */, iconId); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS, null /* label */, iconId); doTestActionKey( tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS_SHIFTED, null /* label */, iconId); // Test phone number layouts. doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_PHONE, null /* label */, iconId); doTestActionKey( tag, layoutSet, KeyboardId.ELEMENT_PHONE_SYMBOLS, null /* label */, iconId); // Test normal number layout. doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_NUMBER, null /* label */, iconId); // Test number password layout. editorInfo.inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD; final KeyboardLayoutSet passwordSet = createKeyboardLayoutSet(subtype, editorInfo); doTestActionKey(tag, passwordSet, KeyboardId.ELEMENT_NUMBER, null /* label */, iconId); } } @Override public void testActionUnspecified() { public void testActionUnspecified() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { super.testActionUnspecified(); final String tag = "unspecifiled " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_UNSPECIFIED, KeyboardIconsSet.NAME_ENTER_KEY); } } } @Override public void testActionNone() { public void testActionNone() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { super.testActionNone(); final String tag = "none " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_NONE, KeyboardIconsSet.NAME_ENTER_KEY); } } } @Override public void testActionGo() { public void testActionGo() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "go " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "go " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionLabel(tag, subtype, EditorInfo.IME_ACTION_GO, R.string.label_go_key); doTestActionKeyLabel(tag, subtype, EditorInfo.IME_ACTION_GO, R.string.label_go_key); } } } } @Override public void testActionSearch() { public void testActionSearch() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { super.testActionSearch(); final String tag = "search " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_SEARCH, KeyboardIconsSet.NAME_SEARCH_KEY); } } } @Override public void testActionSend() { public void testActionSend() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "send " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "send " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionLabel(tag, subtype, EditorInfo.IME_ACTION_SEND, R.string.label_send_key); doTestActionKeyLabel(tag, subtype, EditorInfo.IME_ACTION_SEND, R.string.label_send_key); } } } } @Override public void testActionNext() { public void testActionNext() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "next " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "next " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionLabel(tag, subtype, EditorInfo.IME_ACTION_NEXT, R.string.label_next_key); doTestActionKeyLabel(tag, subtype, EditorInfo.IME_ACTION_NEXT, R.string.label_next_key); } } } } @Override public void testActionDone() { public void testActionDone() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "done " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "done " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionLabel(tag, subtype, EditorInfo.IME_ACTION_DONE, R.string.label_done_key); doTestActionKeyLabel(tag, subtype, EditorInfo.IME_ACTION_DONE, R.string.label_done_key); } } } } @Override public void testActionPrevious() { public void testActionPrevious() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "previous " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "previous " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionLabel( doTestActionKeyLabel( tag, subtype, EditorInfo.IME_ACTION_PREVIOUS, R.string.label_previous_key); tag, subtype, EditorInfo.IME_ACTION_PREVIOUS, R.string.label_previous_key); } } } } @Override public void testActionCustom() { public void testActionCustom() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { super.testActionCustom(); final String tag = "custom " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); } final CharSequence customLabel = "customLabel"; final EditorInfo editorInfo = new EditorInfo(); private void doTestActionLabelInLocale(final InputMethodSubtype subtype, editorInfo.imeOptions = EditorInfo.IME_ACTION_UNSPECIFIED; final Locale labelLocale, final Locale systemLocale) { editorInfo.actionLabel = customLabel; final String tag = "label=" + labelLocale + " system=" + systemLocale doTestActionLabel(tag, subtype, editorInfo, customLabel); + " " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final RunInLocale<Void> job = new RunInLocale<Void>() { @Override public Void job(final Resources res) { doTestActionKeyIcon(tag + " unspecified", subtype, EditorInfo.IME_ACTION_UNSPECIFIED, KeyboardIconsSet.NAME_ENTER_KEY); doTestActionKeyIcon(tag + " none", subtype, EditorInfo.IME_ACTION_NONE, KeyboardIconsSet.NAME_ENTER_KEY); doTestActionKeyLabel(tag + " go", subtype, EditorInfo.IME_ACTION_GO, labelLocale, R.string.label_go_key); doTestActionKeyIcon(tag + " search", subtype, EditorInfo.IME_ACTION_SEARCH, KeyboardIconsSet.NAME_SEARCH_KEY); doTestActionKeyLabel(tag + " send", subtype, EditorInfo.IME_ACTION_SEND, labelLocale, R.string.label_send_key); doTestActionKeyLabel(tag + " next", subtype, EditorInfo.IME_ACTION_NEXT, labelLocale, R.string.label_next_key); doTestActionKeyLabel(tag + " done", subtype, EditorInfo.IME_ACTION_DONE, labelLocale, R.string.label_done_key); doTestActionKeyLabel(tag + " previous", subtype, EditorInfo.IME_ACTION_PREVIOUS, labelLocale, R.string.label_previous_key); return null; } } }; job.runInLocale(getContext().getResources(), systemLocale); } public void testActionLabelInOtherLocale() { final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); final InputMethodSubtype italian = richImm.findSubtypeByLocaleAndKeyboardLayoutSet( Locale.ITALIAN.toString(), SubtypeLocaleUtils.QWERTY); // An action label should be displayed in subtype's locale regardless of the system locale. doTestActionLabelInLocale(italian, Locale.ITALIAN, Locale.US); doTestActionLabelInLocale(italian, Locale.ITALIAN, Locale.FRENCH); doTestActionLabelInLocale(italian, Locale.ITALIAN, Locale.ITALIAN); doTestActionLabelInLocale(italian, Locale.ITALIAN, Locale.JAPANESE); } public void testNoLanguageSubtypeActionLabel() { final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); final InputMethodSubtype noLanguage = richImm.findSubtypeByLocaleAndKeyboardLayoutSet( SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.QWERTY); // An action label of no language keyboard should be displayed in the system locale. doTestActionLabelInLocale(noLanguage, Locale.US, Locale.US); // TODO: Uncomment the following test once a bug is fixed. // doTestActionLabelInLocale(noLanguage, Locale.FRENCH, Locale.FRENCH); // doTestActionLabelInLocale(noLanguage, Locale.ITALIAN, Locale.ITALIAN); // doTestActionLabelInLocale(noLanguage, Locale.JAPANESE, Locale.JAPANESE); } } } } tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetActionLabelLxxTests.java +88 −14 Original line number Original line Diff line number Diff line Loading @@ -17,30 +17,99 @@ package com.android.inputmethod.keyboard; package com.android.inputmethod.keyboard; import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest; import android.text.InputType; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; @MediumTest @MediumTest public class KeyboardLayoutSetActionLabelLxxTests extends KeyboardLayoutSetActionLabelKlpTests { public class KeyboardLayoutSetActionLabelLxxTests extends KeyboardLayoutSetTestsBase { @Override @Override protected int getKeyboardThemeForTests() { protected int getKeyboardThemeForTests() { return KeyboardTheme.THEME_ID_LXX_DARK; return KeyboardTheme.THEME_ID_LXX_DARK; } } @Override private static void doTestActionKey(final String tag, final KeyboardLayoutSet layoutSet, final int elementId, final CharSequence label, final int iconId) { final Keyboard keyboard = layoutSet.getKeyboard(elementId); final Key enterKey = keyboard.getKey(Constants.CODE_ENTER); assertNotNull(tag + " enter key on " + keyboard.mId, enterKey); assertEquals(tag + " enter label " + enterKey, label, enterKey.getLabel()); assertEquals(tag + " enter icon " + enterKey, iconId, enterKey.getIconId()); } protected void doTestActionKeyLabel(final String tag, final InputMethodSubtype subtype, final EditorInfo editorInfo, final CharSequence label) { // Test text layouts. editorInfo.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL; final KeyboardLayoutSet layoutSet = createKeyboardLayoutSet(subtype, editorInfo); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_ALPHABET, label, KeyboardIconsSet.ICON_UNDEFINED); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS, label, KeyboardIconsSet.ICON_UNDEFINED); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS_SHIFTED, label, KeyboardIconsSet.ICON_UNDEFINED); // Test phone number layouts. doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_PHONE, label, KeyboardIconsSet.ICON_UNDEFINED); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_PHONE_SYMBOLS, label, KeyboardIconsSet.ICON_UNDEFINED); // Test normal number layout. doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_NUMBER, label, KeyboardIconsSet.ICON_UNDEFINED); // Test number password layouts. editorInfo.inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD; final KeyboardLayoutSet passwordSet = createKeyboardLayoutSet(subtype, editorInfo); doTestActionKey(tag, passwordSet, KeyboardId.ELEMENT_NUMBER, label, KeyboardIconsSet.ICON_UNDEFINED); } protected void doTestActionKeyIcon(final String tag, final InputMethodSubtype subtype, final int actionId, final String iconName) { final int iconId = KeyboardIconsSet.getIconId(iconName); final EditorInfo editorInfo = new EditorInfo(); editorInfo.imeOptions = actionId; // Test text layouts. editorInfo.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL; final KeyboardLayoutSet layoutSet = createKeyboardLayoutSet(subtype, editorInfo); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_ALPHABET, null /* label */, iconId); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS, null /* label */, iconId); doTestActionKey( tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS_SHIFTED, null /* label */, iconId); // Test phone number layouts. doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_PHONE, null /* label */, iconId); doTestActionKey( tag, layoutSet, KeyboardId.ELEMENT_PHONE_SYMBOLS, null /* label */, iconId); // Test normal number layout. doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_NUMBER, null /* label */, iconId); // Test number password layout. editorInfo.inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD; final KeyboardLayoutSet passwordSet = createKeyboardLayoutSet(subtype, editorInfo); doTestActionKey(tag, passwordSet, KeyboardId.ELEMENT_NUMBER, null /* label */, iconId); } public void testActionUnspecified() { public void testActionUnspecified() { super.testActionUnspecified(); for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "unspecifiled " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_UNSPECIFIED, KeyboardIconsSet.NAME_ENTER_KEY); } } } @Override public void testActionNone() { public void testActionNone() { super.testActionNone(); for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "none " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_NONE, KeyboardIconsSet.NAME_ENTER_KEY); } } } @Override public void testActionGo() { public void testActionGo() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "go " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "go " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); Loading @@ -49,12 +118,14 @@ public class KeyboardLayoutSetActionLabelLxxTests extends KeyboardLayoutSetActio } } } } @Override public void testActionSearch() { public void testActionSearch() { super.testActionSearch(); for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "search " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_SEARCH, KeyboardIconsSet.NAME_SEARCH_KEY); } } } @Override public void testActionSend() { public void testActionSend() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "send " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "send " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); Loading @@ -63,7 +134,6 @@ public class KeyboardLayoutSetActionLabelLxxTests extends KeyboardLayoutSetActio } } } } @Override public void testActionNext() { public void testActionNext() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "next " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "next " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); Loading @@ -72,7 +142,6 @@ public class KeyboardLayoutSetActionLabelLxxTests extends KeyboardLayoutSetActio } } } } @Override public void testActionDone() { public void testActionDone() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "done " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "done " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); Loading @@ -81,7 +150,6 @@ public class KeyboardLayoutSetActionLabelLxxTests extends KeyboardLayoutSetActio } } } } @Override public void testActionPrevious() { public void testActionPrevious() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "previous " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "previous " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); Loading @@ -90,8 +158,14 @@ public class KeyboardLayoutSetActionLabelLxxTests extends KeyboardLayoutSetActio } } } } @Override public void testActionCustom() { public void testActionCustom() { super.testActionCustom(); for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "custom " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final CharSequence customLabel = "customLabel"; final EditorInfo editorInfo = new EditorInfo(); editorInfo.imeOptions = EditorInfo.IME_ACTION_UNSPECIFIED; editorInfo.actionLabel = customLabel; doTestActionKeyLabel(tag, subtype, editorInfo, customLabel); } } } } } tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java +6 −6 Original line number Original line Diff line number Diff line Loading @@ -43,7 +43,6 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase { private final ArrayList<InputMethodSubtype> mAsciiCapableSubtypesList = new ArrayList<>(); private final ArrayList<InputMethodSubtype> mAsciiCapableSubtypesList = new ArrayList<>(); private final ArrayList<InputMethodSubtype> mAdditionalSubtypesList = new ArrayList<>(); private final ArrayList<InputMethodSubtype> mAdditionalSubtypesList = new ArrayList<>(); private Context mThemeContext; private int mScreenMetrics; private int mScreenMetrics; protected abstract int getKeyboardThemeForTests(); protected abstract int getKeyboardThemeForTests(); Loading @@ -51,12 +50,13 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase { @Override @Override protected void setUp() throws Exception { protected void setUp() throws Exception { super.setUp(); super.setUp(); mScreenMetrics = mContext.getResources().getInteger(R.integer.config_screen_metrics); final KeyboardTheme keyboardTheme = KeyboardTheme.searchKeyboardThemeById( final KeyboardTheme keyboardTheme = KeyboardTheme.searchKeyboardThemeById( getKeyboardThemeForTests()); getKeyboardThemeForTests()); mThemeContext = new ContextThemeWrapper(mContext, keyboardTheme.mStyleId); setContext(new ContextThemeWrapper(getContext(), keyboardTheme.mStyleId)); RichInputMethodManager.init(mThemeContext); final Context context = getContext(); mScreenMetrics = context.getResources().getInteger(R.integer.config_screen_metrics); RichInputMethodManager.init(context); final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); final InputMethodInfo imi = richImm.getInputMethodInfoOfThisIme(); final InputMethodInfo imi = richImm.getInputMethodInfoOfThisIme(); Loading Loading @@ -122,7 +122,7 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase { protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype, protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype, final EditorInfo editorInfo, final boolean voiceInputKeyEnabled, final EditorInfo editorInfo, final boolean voiceInputKeyEnabled, final boolean languageSwitchKeyEnabled) { final boolean languageSwitchKeyEnabled) { final Context context = mThemeContext; final Context context = getContext(); final Resources res = context.getResources(); final Resources res = context.getResources(); final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res); final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res); final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res); final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res); Loading Loading
tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetActionLabelKlpTests.java +83 −102 Original line number Original line Diff line number Diff line Loading @@ -18,34 +18,33 @@ package com.android.inputmethod.keyboard; import android.content.res.Resources; import android.content.res.Resources; import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest; import android.text.InputType; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.RichInputMethodManager; import com.android.inputmethod.latin.utils.RunInLocale; import com.android.inputmethod.latin.utils.RunInLocale; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import java.util.Locale; @MediumTest @MediumTest public class KeyboardLayoutSetActionLabelKlpTests extends KeyboardLayoutSetTestsBase { public class KeyboardLayoutSetActionLabelKlpTests extends KeyboardLayoutSetActionLabelLxxTests { @Override @Override protected int getKeyboardThemeForTests() { protected int getKeyboardThemeForTests() { return KeyboardTheme.THEME_ID_KLP; return KeyboardTheme.THEME_ID_KLP; } } private static void doTestActionKey(final String tag, final KeyboardLayoutSet layoutSet, protected void doTestActionKeyLabel(final String tag, final InputMethodSubtype subtype, final int elementId, final CharSequence label, final int iconId) { final int actionId, final int labelResId) { final Keyboard keyboard = layoutSet.getKeyboard(elementId); final Locale labelLocale = subtype.getLocale().equals(SubtypeLocaleUtils.NO_LANGUAGE) final Key enterKey = keyboard.getKey(Constants.CODE_ENTER); ? null : SubtypeLocaleUtils.getSubtypeLocale(subtype); assertNotNull(tag + " enter key on " + keyboard.mId, enterKey); doTestActionKeyLabel(tag, subtype, actionId, labelLocale, labelResId); assertEquals(tag + " enter label " + enterKey, label, enterKey.getLabel()); assertEquals(tag + " enter icon " + enterKey, iconId, enterKey.getIconId()); } } protected void doTestActionLabel(final String tag, final InputMethodSubtype subtype, protected void doTestActionKeyLabel(final String tag, final InputMethodSubtype subtype, final int actionId, final int labelResId) { final int actionId, final Locale labelLocale, final int labelResId) { final EditorInfo editorInfo = new EditorInfo(); final EditorInfo editorInfo = new EditorInfo(); editorInfo.imeOptions = actionId; editorInfo.imeOptions = actionId; final RunInLocale<String> job = new RunInLocale<String>() { final RunInLocale<String> job = new RunInLocale<String>() { Loading @@ -54,138 +53,120 @@ public class KeyboardLayoutSetActionLabelKlpTests extends KeyboardLayoutSetTests return res.getString(labelResId); return res.getString(labelResId); } } }; }; final Resources res = getContext().getResources(); final String label = job.runInLocale(getContext().getResources(), labelLocale); final String label; doTestActionKeyLabel(tag, subtype, editorInfo, label); if (subtype.getLocale().equals(SubtypeLocaleUtils.NO_LANGUAGE)) { // Using system locale. label = res.getString(labelResId); } else { label = job.runInLocale(res, SubtypeLocaleUtils.getSubtypeLocale(subtype)); } doTestActionLabel(tag, subtype, editorInfo, label); } protected void doTestActionLabel(final String tag, final InputMethodSubtype subtype, final EditorInfo editorInfo, final CharSequence label) { // Test text layouts. editorInfo.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL; final KeyboardLayoutSet layoutSet = createKeyboardLayoutSet(subtype, editorInfo); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_ALPHABET, label, KeyboardIconsSet.ICON_UNDEFINED); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS, label, KeyboardIconsSet.ICON_UNDEFINED); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS_SHIFTED, label, KeyboardIconsSet.ICON_UNDEFINED); // Test phone number layouts. doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_PHONE, label, KeyboardIconsSet.ICON_UNDEFINED); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_PHONE_SYMBOLS, label, KeyboardIconsSet.ICON_UNDEFINED); // Test normal number layout. doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_NUMBER, label, KeyboardIconsSet.ICON_UNDEFINED); // Test number password layouts. editorInfo.inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD; final KeyboardLayoutSet passwordSet = createKeyboardLayoutSet(subtype, editorInfo); doTestActionKey(tag, passwordSet, KeyboardId.ELEMENT_NUMBER, label, KeyboardIconsSet.ICON_UNDEFINED); } protected void doTestActionKeyIcon(final String tag, final InputMethodSubtype subtype, final int actionId, final String iconName) { final int iconId = KeyboardIconsSet.getIconId(iconName); final EditorInfo editorInfo = new EditorInfo(); editorInfo.imeOptions = actionId; // Test text layouts. editorInfo.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL; final KeyboardLayoutSet layoutSet = createKeyboardLayoutSet(subtype, editorInfo); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_ALPHABET, null /* label */, iconId); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS, null /* label */, iconId); doTestActionKey( tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS_SHIFTED, null /* label */, iconId); // Test phone number layouts. doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_PHONE, null /* label */, iconId); doTestActionKey( tag, layoutSet, KeyboardId.ELEMENT_PHONE_SYMBOLS, null /* label */, iconId); // Test normal number layout. doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_NUMBER, null /* label */, iconId); // Test number password layout. editorInfo.inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD; final KeyboardLayoutSet passwordSet = createKeyboardLayoutSet(subtype, editorInfo); doTestActionKey(tag, passwordSet, KeyboardId.ELEMENT_NUMBER, null /* label */, iconId); } } @Override public void testActionUnspecified() { public void testActionUnspecified() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { super.testActionUnspecified(); final String tag = "unspecifiled " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_UNSPECIFIED, KeyboardIconsSet.NAME_ENTER_KEY); } } } @Override public void testActionNone() { public void testActionNone() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { super.testActionNone(); final String tag = "none " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_NONE, KeyboardIconsSet.NAME_ENTER_KEY); } } } @Override public void testActionGo() { public void testActionGo() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "go " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "go " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionLabel(tag, subtype, EditorInfo.IME_ACTION_GO, R.string.label_go_key); doTestActionKeyLabel(tag, subtype, EditorInfo.IME_ACTION_GO, R.string.label_go_key); } } } } @Override public void testActionSearch() { public void testActionSearch() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { super.testActionSearch(); final String tag = "search " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_SEARCH, KeyboardIconsSet.NAME_SEARCH_KEY); } } } @Override public void testActionSend() { public void testActionSend() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "send " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "send " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionLabel(tag, subtype, EditorInfo.IME_ACTION_SEND, R.string.label_send_key); doTestActionKeyLabel(tag, subtype, EditorInfo.IME_ACTION_SEND, R.string.label_send_key); } } } } @Override public void testActionNext() { public void testActionNext() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "next " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "next " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionLabel(tag, subtype, EditorInfo.IME_ACTION_NEXT, R.string.label_next_key); doTestActionKeyLabel(tag, subtype, EditorInfo.IME_ACTION_NEXT, R.string.label_next_key); } } } } @Override public void testActionDone() { public void testActionDone() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "done " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "done " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionLabel(tag, subtype, EditorInfo.IME_ACTION_DONE, R.string.label_done_key); doTestActionKeyLabel(tag, subtype, EditorInfo.IME_ACTION_DONE, R.string.label_done_key); } } } } @Override public void testActionPrevious() { public void testActionPrevious() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "previous " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "previous " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionLabel( doTestActionKeyLabel( tag, subtype, EditorInfo.IME_ACTION_PREVIOUS, R.string.label_previous_key); tag, subtype, EditorInfo.IME_ACTION_PREVIOUS, R.string.label_previous_key); } } } } @Override public void testActionCustom() { public void testActionCustom() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { super.testActionCustom(); final String tag = "custom " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); } final CharSequence customLabel = "customLabel"; final EditorInfo editorInfo = new EditorInfo(); private void doTestActionLabelInLocale(final InputMethodSubtype subtype, editorInfo.imeOptions = EditorInfo.IME_ACTION_UNSPECIFIED; final Locale labelLocale, final Locale systemLocale) { editorInfo.actionLabel = customLabel; final String tag = "label=" + labelLocale + " system=" + systemLocale doTestActionLabel(tag, subtype, editorInfo, customLabel); + " " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final RunInLocale<Void> job = new RunInLocale<Void>() { @Override public Void job(final Resources res) { doTestActionKeyIcon(tag + " unspecified", subtype, EditorInfo.IME_ACTION_UNSPECIFIED, KeyboardIconsSet.NAME_ENTER_KEY); doTestActionKeyIcon(tag + " none", subtype, EditorInfo.IME_ACTION_NONE, KeyboardIconsSet.NAME_ENTER_KEY); doTestActionKeyLabel(tag + " go", subtype, EditorInfo.IME_ACTION_GO, labelLocale, R.string.label_go_key); doTestActionKeyIcon(tag + " search", subtype, EditorInfo.IME_ACTION_SEARCH, KeyboardIconsSet.NAME_SEARCH_KEY); doTestActionKeyLabel(tag + " send", subtype, EditorInfo.IME_ACTION_SEND, labelLocale, R.string.label_send_key); doTestActionKeyLabel(tag + " next", subtype, EditorInfo.IME_ACTION_NEXT, labelLocale, R.string.label_next_key); doTestActionKeyLabel(tag + " done", subtype, EditorInfo.IME_ACTION_DONE, labelLocale, R.string.label_done_key); doTestActionKeyLabel(tag + " previous", subtype, EditorInfo.IME_ACTION_PREVIOUS, labelLocale, R.string.label_previous_key); return null; } } }; job.runInLocale(getContext().getResources(), systemLocale); } public void testActionLabelInOtherLocale() { final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); final InputMethodSubtype italian = richImm.findSubtypeByLocaleAndKeyboardLayoutSet( Locale.ITALIAN.toString(), SubtypeLocaleUtils.QWERTY); // An action label should be displayed in subtype's locale regardless of the system locale. doTestActionLabelInLocale(italian, Locale.ITALIAN, Locale.US); doTestActionLabelInLocale(italian, Locale.ITALIAN, Locale.FRENCH); doTestActionLabelInLocale(italian, Locale.ITALIAN, Locale.ITALIAN); doTestActionLabelInLocale(italian, Locale.ITALIAN, Locale.JAPANESE); } public void testNoLanguageSubtypeActionLabel() { final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); final InputMethodSubtype noLanguage = richImm.findSubtypeByLocaleAndKeyboardLayoutSet( SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.QWERTY); // An action label of no language keyboard should be displayed in the system locale. doTestActionLabelInLocale(noLanguage, Locale.US, Locale.US); // TODO: Uncomment the following test once a bug is fixed. // doTestActionLabelInLocale(noLanguage, Locale.FRENCH, Locale.FRENCH); // doTestActionLabelInLocale(noLanguage, Locale.ITALIAN, Locale.ITALIAN); // doTestActionLabelInLocale(noLanguage, Locale.JAPANESE, Locale.JAPANESE); } } } }
tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetActionLabelLxxTests.java +88 −14 Original line number Original line Diff line number Diff line Loading @@ -17,30 +17,99 @@ package com.android.inputmethod.keyboard; package com.android.inputmethod.keyboard; import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest; import android.text.InputType; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; @MediumTest @MediumTest public class KeyboardLayoutSetActionLabelLxxTests extends KeyboardLayoutSetActionLabelKlpTests { public class KeyboardLayoutSetActionLabelLxxTests extends KeyboardLayoutSetTestsBase { @Override @Override protected int getKeyboardThemeForTests() { protected int getKeyboardThemeForTests() { return KeyboardTheme.THEME_ID_LXX_DARK; return KeyboardTheme.THEME_ID_LXX_DARK; } } @Override private static void doTestActionKey(final String tag, final KeyboardLayoutSet layoutSet, final int elementId, final CharSequence label, final int iconId) { final Keyboard keyboard = layoutSet.getKeyboard(elementId); final Key enterKey = keyboard.getKey(Constants.CODE_ENTER); assertNotNull(tag + " enter key on " + keyboard.mId, enterKey); assertEquals(tag + " enter label " + enterKey, label, enterKey.getLabel()); assertEquals(tag + " enter icon " + enterKey, iconId, enterKey.getIconId()); } protected void doTestActionKeyLabel(final String tag, final InputMethodSubtype subtype, final EditorInfo editorInfo, final CharSequence label) { // Test text layouts. editorInfo.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL; final KeyboardLayoutSet layoutSet = createKeyboardLayoutSet(subtype, editorInfo); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_ALPHABET, label, KeyboardIconsSet.ICON_UNDEFINED); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS, label, KeyboardIconsSet.ICON_UNDEFINED); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS_SHIFTED, label, KeyboardIconsSet.ICON_UNDEFINED); // Test phone number layouts. doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_PHONE, label, KeyboardIconsSet.ICON_UNDEFINED); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_PHONE_SYMBOLS, label, KeyboardIconsSet.ICON_UNDEFINED); // Test normal number layout. doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_NUMBER, label, KeyboardIconsSet.ICON_UNDEFINED); // Test number password layouts. editorInfo.inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD; final KeyboardLayoutSet passwordSet = createKeyboardLayoutSet(subtype, editorInfo); doTestActionKey(tag, passwordSet, KeyboardId.ELEMENT_NUMBER, label, KeyboardIconsSet.ICON_UNDEFINED); } protected void doTestActionKeyIcon(final String tag, final InputMethodSubtype subtype, final int actionId, final String iconName) { final int iconId = KeyboardIconsSet.getIconId(iconName); final EditorInfo editorInfo = new EditorInfo(); editorInfo.imeOptions = actionId; // Test text layouts. editorInfo.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL; final KeyboardLayoutSet layoutSet = createKeyboardLayoutSet(subtype, editorInfo); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_ALPHABET, null /* label */, iconId); doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS, null /* label */, iconId); doTestActionKey( tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS_SHIFTED, null /* label */, iconId); // Test phone number layouts. doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_PHONE, null /* label */, iconId); doTestActionKey( tag, layoutSet, KeyboardId.ELEMENT_PHONE_SYMBOLS, null /* label */, iconId); // Test normal number layout. doTestActionKey(tag, layoutSet, KeyboardId.ELEMENT_NUMBER, null /* label */, iconId); // Test number password layout. editorInfo.inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD; final KeyboardLayoutSet passwordSet = createKeyboardLayoutSet(subtype, editorInfo); doTestActionKey(tag, passwordSet, KeyboardId.ELEMENT_NUMBER, null /* label */, iconId); } public void testActionUnspecified() { public void testActionUnspecified() { super.testActionUnspecified(); for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "unspecifiled " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_UNSPECIFIED, KeyboardIconsSet.NAME_ENTER_KEY); } } } @Override public void testActionNone() { public void testActionNone() { super.testActionNone(); for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "none " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_NONE, KeyboardIconsSet.NAME_ENTER_KEY); } } } @Override public void testActionGo() { public void testActionGo() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "go " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "go " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); Loading @@ -49,12 +118,14 @@ public class KeyboardLayoutSetActionLabelLxxTests extends KeyboardLayoutSetActio } } } } @Override public void testActionSearch() { public void testActionSearch() { super.testActionSearch(); for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "search " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); doTestActionKeyIcon(tag, subtype, EditorInfo.IME_ACTION_SEARCH, KeyboardIconsSet.NAME_SEARCH_KEY); } } } @Override public void testActionSend() { public void testActionSend() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "send " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "send " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); Loading @@ -63,7 +134,6 @@ public class KeyboardLayoutSetActionLabelLxxTests extends KeyboardLayoutSetActio } } } } @Override public void testActionNext() { public void testActionNext() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "next " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "next " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); Loading @@ -72,7 +142,6 @@ public class KeyboardLayoutSetActionLabelLxxTests extends KeyboardLayoutSetActio } } } } @Override public void testActionDone() { public void testActionDone() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "done " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "done " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); Loading @@ -81,7 +150,6 @@ public class KeyboardLayoutSetActionLabelLxxTests extends KeyboardLayoutSetActio } } } } @Override public void testActionPrevious() { public void testActionPrevious() { for (final InputMethodSubtype subtype : getAllSubtypesList()) { for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "previous " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final String tag = "previous " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); Loading @@ -90,8 +158,14 @@ public class KeyboardLayoutSetActionLabelLxxTests extends KeyboardLayoutSetActio } } } } @Override public void testActionCustom() { public void testActionCustom() { super.testActionCustom(); for (final InputMethodSubtype subtype : getAllSubtypesList()) { final String tag = "custom " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); final CharSequence customLabel = "customLabel"; final EditorInfo editorInfo = new EditorInfo(); editorInfo.imeOptions = EditorInfo.IME_ACTION_UNSPECIFIED; editorInfo.actionLabel = customLabel; doTestActionKeyLabel(tag, subtype, editorInfo, customLabel); } } } } }
tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java +6 −6 Original line number Original line Diff line number Diff line Loading @@ -43,7 +43,6 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase { private final ArrayList<InputMethodSubtype> mAsciiCapableSubtypesList = new ArrayList<>(); private final ArrayList<InputMethodSubtype> mAsciiCapableSubtypesList = new ArrayList<>(); private final ArrayList<InputMethodSubtype> mAdditionalSubtypesList = new ArrayList<>(); private final ArrayList<InputMethodSubtype> mAdditionalSubtypesList = new ArrayList<>(); private Context mThemeContext; private int mScreenMetrics; private int mScreenMetrics; protected abstract int getKeyboardThemeForTests(); protected abstract int getKeyboardThemeForTests(); Loading @@ -51,12 +50,13 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase { @Override @Override protected void setUp() throws Exception { protected void setUp() throws Exception { super.setUp(); super.setUp(); mScreenMetrics = mContext.getResources().getInteger(R.integer.config_screen_metrics); final KeyboardTheme keyboardTheme = KeyboardTheme.searchKeyboardThemeById( final KeyboardTheme keyboardTheme = KeyboardTheme.searchKeyboardThemeById( getKeyboardThemeForTests()); getKeyboardThemeForTests()); mThemeContext = new ContextThemeWrapper(mContext, keyboardTheme.mStyleId); setContext(new ContextThemeWrapper(getContext(), keyboardTheme.mStyleId)); RichInputMethodManager.init(mThemeContext); final Context context = getContext(); mScreenMetrics = context.getResources().getInteger(R.integer.config_screen_metrics); RichInputMethodManager.init(context); final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); final InputMethodInfo imi = richImm.getInputMethodInfoOfThisIme(); final InputMethodInfo imi = richImm.getInputMethodInfoOfThisIme(); Loading Loading @@ -122,7 +122,7 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase { protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype, protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype, final EditorInfo editorInfo, final boolean voiceInputKeyEnabled, final EditorInfo editorInfo, final boolean voiceInputKeyEnabled, final boolean languageSwitchKeyEnabled) { final boolean languageSwitchKeyEnabled) { final Context context = mThemeContext; final Context context = getContext(); final Resources res = context.getResources(); final Resources res = context.getResources(); final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res); final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res); final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res); final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res); Loading