Update tests

This commit is contained in:
Aleksandras Kostarevas 2024-09-19 14:20:57 +03:00
parent 6bcc162f1e
commit 3efcbf730f
18 changed files with 1172 additions and 1182 deletions

View File

@ -40,6 +40,7 @@ import org.futo.inputmethod.latin.RichInputMethodManager;
import org.futo.inputmethod.latin.RichInputMethodSubtype; import org.futo.inputmethod.latin.RichInputMethodSubtype;
import org.futo.inputmethod.latin.Subtypes; import org.futo.inputmethod.latin.Subtypes;
import org.futo.inputmethod.latin.WordComposer; import org.futo.inputmethod.latin.WordComposer;
import org.futo.inputmethod.latin.settings.LongPressKeySettings;
import org.futo.inputmethod.latin.settings.Settings; import org.futo.inputmethod.latin.settings.Settings;
import org.futo.inputmethod.latin.settings.SettingsValues; import org.futo.inputmethod.latin.settings.SettingsValues;
import org.futo.inputmethod.latin.utils.LanguageOnSpacebarUtils; import org.futo.inputmethod.latin.utils.LanguageOnSpacebarUtils;
@ -135,7 +136,8 @@ public final class KeyboardSwitcher implements SwitchActions {
settingsValues.mIsNumberRowEnabled, settingsValues.mIsNumberRowEnabled,
4.0f, 4.0f,
res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE, res.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE,
settingsValues.mShowsActionKey ? settingsValues.mActionKeyId : null settingsValues.mShowsActionKey ? settingsValues.mActionKeyId : null,
LongPressKeySettings.load(mThemeContext)
); );
try { try {

View File

@ -112,6 +112,10 @@ data class LongPressKeySettings(val currentOrder: List<LongPressKey>) {
it.replace("\\", "\\\\") it.replace("\\", "\\\\")
.replace(",", "\\,") .replace(",", "\\,")
}.joinToString(",") }.joinToString(",")
@JvmStatic
fun forTest(): LongPressKeySettings =
LongPressKeySettings(listOf(LongPressKey.Numbers, LongPressKey.LanguageKeys, LongPressKey.MiscLetters))
} }
fun reorderMoreKeys(moreKeys: String): String = fun reorderMoreKeys(moreKeys: String): String =

View File

@ -37,6 +37,7 @@ val AllActionsMap = mapOf(
val ActionToId = AllActionsMap.entries.associate { it.value to it.key } val ActionToId = AllActionsMap.entries.associate { it.value to it.key }
val AllActions = AllActionsMap.values.toList() val AllActions = AllActionsMap.values.toList()
val AllActionKeys = AllActionsMap.keys.toList()
val ActionIdToInt = AllActionsMap.entries.associate { it.key to AllActions.indexOf(it.value) } val ActionIdToInt = AllActionsMap.entries.associate { it.key to AllActions.indexOf(it.value) }

View File

@ -36,6 +36,9 @@ val KeySpecShortcuts = listOf(
"*" to listOf("*", "morekeys_star"), "*" to listOf("*", "morekeys_star"),
"=" to listOf("=", "", "", ""), "=" to listOf("=", "", "", ""),
"," to listOf("keyspec_comma"),
"." to listOf("keyspec_period", ""),
"1" to listOf("keyspec_symbols_1", "additional_morekeys_symbols_1", "morekeys_symbols_1"), "1" to listOf("keyspec_symbols_1", "additional_morekeys_symbols_1", "morekeys_symbols_1"),
"2" to listOf("keyspec_symbols_2", "additional_morekeys_symbols_2", "morekeys_symbols_2"), "2" to listOf("keyspec_symbols_2", "additional_morekeys_symbols_2", "morekeys_symbols_2"),
"3" to listOf("keyspec_symbols_3", "additional_morekeys_symbols_3", "morekeys_symbols_3"), "3" to listOf("keyspec_symbols_3", "additional_morekeys_symbols_3", "morekeys_symbols_3"),

View File

@ -80,11 +80,12 @@ data class KeyboardLayoutSetV2Params(
val height: Int?, val height: Int?,
val keyboardLayoutSet: String, val keyboardLayoutSet: String,
val locale: Locale, val locale: Locale,
val editorInfo: EditorInfo, val editorInfo: EditorInfo?,
val numberRow: Boolean, val numberRow: Boolean,
val gap: Float = 4.0f, val gap: Float = 4.0f,
val useSplitLayout: Boolean, val useSplitLayout: Boolean,
val bottomActionKey: Int? val bottomActionKey: Int?,
val longPressKeySettings: LongPressKeySettings? = null
) )
@ -94,14 +95,16 @@ class KeyboardLayoutSetV2 internal constructor(
) { ) {
val script = Script.Latin val script = Script.Latin
val privateParams = params.editorInfo.getPrivateImeOptions() val editorInfo = params.editorInfo ?: EditorInfo()
val privateParams = editorInfo.getPrivateImeOptions()
val forcedLayout = privateParams["org.futo.inputmethod.latin.ForceLayout"] val forcedLayout = privateParams["org.futo.inputmethod.latin.ForceLayout"]
val forcedLocale = privateParams["org.futo.inputmethod.latin.ForceLocale"]?.let { Locale.forLanguageTag(it) } val forcedLocale = privateParams["org.futo.inputmethod.latin.ForceLocale"]?.let { Locale.forLanguageTag(it) }
// Necessary for Java API // Necessary for Java API
fun getScriptId(): Int = script.id fun getScriptId(): Int = script.id
private val keyboardMode = getKeyboardMode(params.editorInfo) private val keyboardMode = getKeyboardMode(editorInfo)
val layoutName = forcedLayout ?: params.keyboardLayoutSet val layoutName = forcedLayout ?: params.keyboardLayoutSet
val mainLayout = LayoutManager.getLayout(context, layoutName) val mainLayout = LayoutManager.getLayout(context, layoutName)
@ -207,15 +210,15 @@ class KeyboardLayoutSetV2 internal constructor(
params.height ?: getRecommendedKeyboardHeight(), params.height ?: getRecommendedKeyboardHeight(),
keyboardMode, keyboardMode,
element.elementId, element.elementId,
params.editorInfo, editorInfo,
false, false,
params.bottomActionKey != null, params.bottomActionKey != null,
params.bottomActionKey ?: -1, params.bottomActionKey ?: -1,
params.editorInfo.actionLabel?.toString() ?: "", editorInfo.actionLabel?.toString() ?: "",
false, false,
false, false,
isNumberRowActive, isNumberRowActive,
LongPressKeySettings.load(context) params.longPressKeySettings ?: LongPressKeySettings.load(context)
) )
val layout = getKeyboardLayoutForElement(element) val layout = getKeyboardLayoutForElement(element)

View File

@ -1,5 +1,6 @@
package org.futo.inputmethod.v2keyboard package org.futo.inputmethod.v2keyboard
import org.futo.inputmethod.keyboard.internal.KeyboardLayoutKind
import org.futo.inputmethod.latin.common.Constants import org.futo.inputmethod.latin.common.Constants
fun getDefaultMoreKeysForKey(code: Int, relevantSpecShortcut: List<String>?): String { fun getDefaultMoreKeysForKey(code: Int, relevantSpecShortcut: List<String>?): String {
@ -14,7 +15,7 @@ fun getDefaultMoreKeysForKey(code: Int, relevantSpecShortcut: List<String>?): St
fun getSpecialFromRow(keyCoordinate: KeyCoordinate, row: Row): String { fun getSpecialFromRow(keyCoordinate: KeyCoordinate, row: Row): String {
if(row.isBottomRow) { if(row.isBottomRow && keyCoordinate.element.kind == KeyboardLayoutKind.Alphabet) {
val numCols = keyCoordinate.measurement.numColumnsByRow.getOrNull(keyCoordinate.regularRow) ?: -10 val numCols = keyCoordinate.measurement.numColumnsByRow.getOrNull(keyCoordinate.regularRow) ?: -10
if(keyCoordinate.regularColumn == 0) { if(keyCoordinate.regularColumn == 0) {
return "!text/morekeys_bottomrow_comma" return "!text/morekeys_bottomrow_comma"

View File

@ -6,8 +6,8 @@ import kotlinx.serialization.Serializable
import org.futo.inputmethod.keyboard.KeyboardId import org.futo.inputmethod.keyboard.KeyboardId
import org.futo.inputmethod.keyboard.internal.KeyboardIconsSet import org.futo.inputmethod.keyboard.internal.KeyboardIconsSet
import org.futo.inputmethod.keyboard.internal.KeyboardParams import org.futo.inputmethod.keyboard.internal.KeyboardParams
import org.futo.inputmethod.keyboard.internal.MoreKeySpec
import org.futo.inputmethod.latin.common.Constants import org.futo.inputmethod.latin.common.Constants
import org.futo.inputmethod.latin.uix.actions.AllActionKeys
import org.futo.inputmethod.latin.utils.InputTypeUtils import org.futo.inputmethod.latin.utils.InputTypeUtils
val FunctionalAttributes = KeyAttributes( val FunctionalAttributes = KeyAttributes(
@ -182,13 +182,14 @@ data class ActionKey(
val attributes = attributes.getEffectiveAttributes(row, keyboard) val attributes = attributes.getEffectiveAttributes(row, keyboard)
val actionId = params.mId.mBottomActionKeyId val actionId = params.mId.mBottomActionKeyId
val actionName = AllActionKeys[actionId]
return ComputedKeyData( return ComputedKeyData(
label = "", label = "",
code = Constants.CODE_ACTION_0 + actionId, code = Constants.CODE_ACTION_0 + actionId,
outputText = null, outputText = null,
width = attributes.width ?: KeyWidth.Regular, width = attributes.width ?: KeyWidth.Regular,
icon = "action_$actionId", icon = "action_$actionName",
style = attributes.style ?: KeyVisualStyle.Functional, style = attributes.style ?: KeyVisualStyle.Functional,
anchored = true, anchored = true,
showPopup = false, showPopup = false,

View File

@ -21,7 +21,6 @@ import android.content.res.Resources;
import android.test.AndroidTestCase; import android.test.AndroidTestCase;
import android.view.ContextThemeWrapper; import android.view.ContextThemeWrapper;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodInfo;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import org.futo.inputmethod.compat.InputMethodSubtypeCompatUtils; import org.futo.inputmethod.compat.InputMethodSubtypeCompatUtils;
@ -30,10 +29,11 @@ import org.futo.inputmethod.latin.RichInputMethodManager;
import org.futo.inputmethod.latin.RichInputMethodSubtype; import org.futo.inputmethod.latin.RichInputMethodSubtype;
import org.futo.inputmethod.latin.Subtypes; import org.futo.inputmethod.latin.Subtypes;
import org.futo.inputmethod.latin.common.Constants; import org.futo.inputmethod.latin.common.Constants;
import org.futo.inputmethod.latin.settings.LongPressKeySettings;
import org.futo.inputmethod.latin.settings.Settings; import org.futo.inputmethod.latin.settings.Settings;
import org.futo.inputmethod.latin.uix.actions.ActionRegistry;
import org.futo.inputmethod.latin.utils.AdditionalSubtypeUtils; import org.futo.inputmethod.latin.utils.AdditionalSubtypeUtils;
import org.futo.inputmethod.latin.utils.ResourceUtils; import org.futo.inputmethod.latin.utils.ResourceUtils;
import org.futo.inputmethod.latin.utils.SubtypeLocaleUtils;
import org.futo.inputmethod.v2keyboard.KeyboardLayoutSetV2; import org.futo.inputmethod.v2keyboard.KeyboardLayoutSetV2;
import org.futo.inputmethod.v2keyboard.KeyboardLayoutSetV2Params; import org.futo.inputmethod.v2keyboard.KeyboardLayoutSetV2Params;
@ -128,24 +128,7 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
protected final InputMethodSubtype getSubtype(final Locale locale, protected final InputMethodSubtype getSubtype(final Locale locale,
final String keyboardLayout) { final String keyboardLayout) {
for (final InputMethodSubtype subtype : mAllSubtypesList) { return Subtypes.INSTANCE.makeSubtype(locale.toString(), keyboardLayout);
final Locale subtypeLocale = SubtypeLocaleUtils.getSubtypeLocale(subtype);
final String subtypeLayout = SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype);
if (locale.equals(subtypeLocale) && keyboardLayout.equals(subtypeLayout)) {
// Found subtype that matches locale and keyboard layout.
return subtype;
}
}
for (final InputMethodSubtype subtype : getSubtypesFilteredBy(FILTER_IS_ASCII_CAPABLE)) {
final Locale subtypeLocale = SubtypeLocaleUtils.getSubtypeLocale(subtype);
if (locale.equals(subtypeLocale)) {
// Create additional subtype.
return AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
locale.toString(), keyboardLayout);
}
}
throw new RuntimeException(
"Unknown subtype: locale=" + locale + " keyboardLayout=" + keyboardLayout);
} }
protected KeyboardLayoutSetV2 createKeyboardLayoutSet(final InputMethodSubtype subtype, protected KeyboardLayoutSetV2 createKeyboardLayoutSet(final InputMethodSubtype subtype,
@ -172,7 +155,8 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
richInputMethodSubtype.getLocale(), richInputMethodSubtype.getLocale(),
editorInfo, false, editorInfo, false,
4.0f, splitLayoutEnabled, 4.0f, splitLayoutEnabled,
languageSwitchKeyEnabled ? 1 : null languageSwitchKeyEnabled ? ActionRegistry.INSTANCE.actionStringIdToIdx("switch_language") : null,
LongPressKeySettings.forTest()
) )
); );
} }

View File

@ -119,32 +119,19 @@ public class Symbols extends AbstractLayoutBase {
// Common symbols keyboard layout. // Common symbols keyboard layout.
private static final ExpectedKey[][] SYMBOLS_COMMON = new ExpectedKeyboardBuilder() private static final ExpectedKey[][] SYMBOLS_COMMON = new ExpectedKeyboardBuilder()
.setKeysOfRow(1, .setKeysOfRow(1,
// U+00B9: "¹" SUPERSCRIPT ONE key("1", joinMoreKeys("¹", "", "½", "", "¼", "")),
// U+00BD: "½" VULGAR FRACTION ONE HALF key("2", joinMoreKeys("²", "", "")),
// U+2153: "" VULGAR FRACTION ONE THIRD key("3", joinMoreKeys("³", "", "¾", "")),
// U+00BC: "¼" VULGAR FRACTION ONE QUARTER key("4", joinMoreKeys("", "")),
// U+215B: "" VULGAR FRACTION ONE EIGHTH key("5", joinMoreKeys("", "", "")),
key("1", joinMoreKeys("\u00B9", "\u00BD", "\u2153", "\u00BC", "\u215B")), key("6", joinMoreKeys("", "")),
// U+00B2: "²" SUPERSCRIPT TWO key("7", joinMoreKeys("", "", "")),
// U+2154: "" VULGAR FRACTION TWO THIRDS key("8", joinMoreKeys("", "")),
key("2", joinMoreKeys("\u00B2", "\u2154")), key("9", joinMoreKeys("", "")),
// U+00B3: "³" SUPERSCRIPT THREE key("0", joinMoreKeys("", "", "", "")))
// U+00BE: "¾" VULGAR FRACTION THREE QUARTERS
// U+215C: "" VULGAR FRACTION THREE EIGHTHS
key("3", joinMoreKeys("\u00B3", "\u00BE", "\u215C")),
// U+2074: "" SUPERSCRIPT FOUR
key("4", moreKey("\u2074")),
// U+215D: "" VULGAR FRACTION FIVE EIGHTHS
key("5", moreKey("\u215D")),
"6",
// U+215E: "" VULGAR FRACTION SEVEN EIGHTHS
key("7", moreKey("\u215E")),
"8", "9",
// U+207F: "" SUPERSCRIPT LATIN SMALL LETTER N
// U+2205: "" EMPTY SET
key("0", joinMoreKeys("\u207F", "\u2205")))
.setKeysOfRow(2, .setKeysOfRow(2,
key("@"), key("#"), key(CURRENCY), key("@"), key("#"), key(CURRENCY),
"_",
// U+2030: "" PER MILLE SIGN // U+2030: "" PER MILLE SIGN
key("%", moreKey("\u2030")), key("%", moreKey("\u2030")),
"&", "&",
@ -163,11 +150,11 @@ public class Symbols extends AbstractLayoutBase {
key("*", joinMoreKeys("\u2020", "\u2021", "\u2605")), key("*", joinMoreKeys("\u2020", "\u2021", "\u2605")),
key(DOUBLE_QUOTE), key(SINGLE_QUOTE), key(":"), key(";"), key(DOUBLE_QUOTE), key(SINGLE_QUOTE), key(":"), key(";"),
// U+00A1: "¡" INVERTED EXCLAMATION MARK // U+00A1: "¡" INVERTED EXCLAMATION MARK
key("!", moreKey("\u00A1")), key("!", joinMoreKeys("\u00A1", "")),
// U+00BF: "¿" INVERTED QUESTION MARK // U+00BF: "¿" INVERTED QUESTION MARK
key("?", moreKey("\u00BF"))) key("?", moreKey("\u00BF")))
.setKeysOfRow(4, .setKeysOfRow(4,
key(","), key("_"), SPACE_KEY, key("/"), key(","), NUMPAD_KEY, SPACE_KEY, key("/"),
// U+2026: "" HORIZONTAL ELLIPSIS // U+2026: "" HORIZONTAL ELLIPSIS
key(".", moreKey("\u2026"))) key(".", moreKey("\u2026")))
.build(); .build();

View File

@ -161,7 +161,8 @@ public class LayoutCustomizer extends AbstractLayoutBase {
* @return the array of {@link ExpectedKey} that should be placed as an enter key. * @return the array of {@link ExpectedKey} that should be placed as an enter key.
*/ */
public ExpectedKey getEnterKey(final boolean isPhone) { public ExpectedKey getEnterKey(final boolean isPhone) {
return isPhone ? key(ENTER_KEY, EMOJI_ACTION_KEY) : ENTER_KEY; return key(ENTER_KEY, SWITCH_LANGUAGE_KEY, TEXT_EDIT_KEY, CLIPBOARD_HISTORY_KEY, EMOJI_KEY,
UNDO_KEY, REDO_KEY);
} }
/** /**

View File

@ -19,6 +19,13 @@ package org.futo.inputmethod.keyboard.layout.expected;
import org.futo.inputmethod.keyboard.internal.KeyboardIconsSet; import org.futo.inputmethod.keyboard.internal.KeyboardIconsSet;
import org.futo.inputmethod.keyboard.layout.expected.ExpectedKey.ExpectedAdditionalMoreKey; import org.futo.inputmethod.keyboard.layout.expected.ExpectedKey.ExpectedAdditionalMoreKey;
import org.futo.inputmethod.latin.common.Constants; import org.futo.inputmethod.latin.common.Constants;
import org.futo.inputmethod.latin.uix.Action;
import org.futo.inputmethod.latin.uix.actions.ActionRegistry;
import org.futo.inputmethod.latin.uix.actions.ClipboardHistoryActionKt;
import org.futo.inputmethod.latin.uix.actions.EmojiActionKt;
import org.futo.inputmethod.latin.uix.actions.SwitchLanguageActionKt;
import org.futo.inputmethod.latin.uix.actions.TextEditActionKt;
import org.futo.inputmethod.latin.uix.actions.UndoRedoActionsKt;
/** /**
* Base class to create an expected keyboard for unit test. * Base class to create an expected keyboard for unit test.
@ -50,6 +57,11 @@ public abstract class AbstractLayoutBase {
return ExpectedKey.newIconInstance(iconId, outputText, moreKeys); return ExpectedKey.newIconInstance(iconId, outputText, moreKeys);
} }
public static ExpectedKey actionKey(final Action action) {
String id = ActionRegistry.INSTANCE.actionToStringId(action);
return iconKey("action_"+id, Constants.CODE_ACTION_0 + ActionRegistry.INSTANCE.actionStringIdToIdx(id));
}
// Helper method to create an {@link ExpectedKey} object that has the icon and the output code. // Helper method to create an {@link ExpectedKey} object that has the icon and the output code.
public static ExpectedKey iconKey(final String iconId, final int code, public static ExpectedKey iconKey(final String iconId, final int code,
final ExpectedKey ... moreKeys) { final ExpectedKey ... moreKeys) {
@ -121,9 +133,9 @@ public abstract class AbstractLayoutBase {
// Functional keys. // Functional keys.
protected static final ExpectedKey DELETE_KEY = iconKey(ICON_DELETE, Constants.CODE_DELETE); protected static final ExpectedKey DELETE_KEY = iconKey(ICON_DELETE, Constants.CODE_DELETE);
protected static final ExpectedKey TAB_KEY = iconKey(ICON_TAB, Constants.CODE_TAB); protected static final ExpectedKey TAB_KEY = iconKey(ICON_TAB, Constants.CODE_TAB);
protected static final ExpectedKey SETTINGS_KEY = iconKey(ICON_SETTINGS, Constants.CODE_SETTINGS); protected static final ExpectedKey SETTINGS_KEY = iconKey("action_settings", Constants.CODE_ACTION_0 + ActionRegistry.INSTANCE.actionStringIdToIdx("settings"));
protected static final ExpectedKey LANGUAGE_SWITCH_KEY = iconKey( protected static final ExpectedKey LANGUAGE_SWITCH_KEY = iconKey(
"action_switch_language", Constants.CODE_LANGUAGE_SWITCH); "action_switch_language", Constants.CODE_ACTION_0 + ActionRegistry.INSTANCE.actionStringIdToIdx("switch_language"));
protected static final ExpectedKey ENTER_KEY = iconKey(ICON_ENTER, Constants.CODE_ENTER); protected static final ExpectedKey ENTER_KEY = iconKey(ICON_ENTER, Constants.CODE_ENTER);
protected static final ExpectedKey EMOJI_ACTION_KEY = iconKey(ICON_EMOJI_ACTION, Constants.CODE_EMOJI); protected static final ExpectedKey EMOJI_ACTION_KEY = iconKey(ICON_EMOJI_ACTION, Constants.CODE_EMOJI);
protected static final ExpectedKey EMOJI_NORMAL_KEY = iconKey(ICON_EMOJI_NORMAL, Constants.CODE_EMOJI); protected static final ExpectedKey EMOJI_NORMAL_KEY = iconKey(ICON_EMOJI_NORMAL, Constants.CODE_EMOJI);
@ -139,6 +151,15 @@ public abstract class AbstractLayoutBase {
protected static final ExpectedKey SYMBOLS_SHIFT_KEY = key("= \\ <", Constants.CODE_SHIFT); protected static final ExpectedKey SYMBOLS_SHIFT_KEY = key("= \\ <", Constants.CODE_SHIFT);
protected static final ExpectedKey TABLET_SYMBOLS_SHIFT_KEY = key("~ [ <", Constants.CODE_SHIFT); protected static final ExpectedKey TABLET_SYMBOLS_SHIFT_KEY = key("~ [ <", Constants.CODE_SHIFT);
protected static final ExpectedKey SWITCH_LANGUAGE_KEY = actionKey(SwitchLanguageActionKt.getSwitchLanguageAction());
protected static final ExpectedKey TEXT_EDIT_KEY = actionKey(TextEditActionKt.getTextEditAction());
protected static final ExpectedKey CLIPBOARD_HISTORY_KEY = actionKey(ClipboardHistoryActionKt.getClipboardHistoryAction());
protected static final ExpectedKey EMOJI_KEY = actionKey(EmojiActionKt.getEmojiAction());
protected static final ExpectedKey UNDO_KEY = actionKey(UndoRedoActionsKt.getUndoAction());
protected static final ExpectedKey REDO_KEY = actionKey(UndoRedoActionsKt.getRedoAction());
protected static final ExpectedKey NUMPAD_KEY = iconKey("numpad", Constants.CODE_TO_NUMBER_LAYOUT);
// U+00A1: "¡" INVERTED EXCLAMATION MARK // U+00A1: "¡" INVERTED EXCLAMATION MARK
// U+00BF: "¿" INVERTED QUESTION MARK // U+00BF: "¿" INVERTED QUESTION MARK
protected static final ExpectedKey[] EXCLAMATION_AND_QUESTION_MARKS = joinKeys( protected static final ExpectedKey[] EXCLAMATION_AND_QUESTION_MARKS = joinKeys(

View File

@ -164,7 +164,7 @@ public class ExpectedKey {
public boolean equalsTo(final Key key) { public boolean equalsTo(final Key key) {
// This key has no "more keys". // This key has no "more keys".
return mVisual.hasSameKeyVisual(key) && mOutput.hasSameKeyOutput(key) return mVisual.hasSameKeyVisual(key) && mOutput.hasSameKeyOutput(key)
&& key.getMoreKeys() == null; && key.getMoreKeys().isEmpty();
} }
public boolean equalsTo(final MoreKeySpec moreKeySpec) { public boolean equalsTo(final MoreKeySpec moreKeySpec) {

View File

@ -22,6 +22,7 @@ import org.futo.inputmethod.keyboard.internal.MoreKeySpec;
import org.futo.inputmethod.latin.common.StringUtils; import org.futo.inputmethod.latin.common.StringUtils;
import java.util.Locale; import java.util.Locale;
import java.util.Objects;
/** /**
* This class represents an expected visual outlook of a key. * This class represents an expected visual outlook of a key.
@ -86,7 +87,7 @@ public abstract class ExpectedKeyVisual {
boolean hasSameKeyVisual(final Key key) { boolean hasSameKeyVisual(final Key key) {
// If the actual key has an icon as its visual, a label has to be null. // If the actual key has an icon as its visual, a label has to be null.
// See {@link KeyboardView#onDrawKeyTopVisuals(Key,Canvas,Paint,KeyDrawParams). // See {@link KeyboardView#onDrawKeyTopVisuals(Key,Canvas,Paint,KeyDrawParams).
return mIconId == key.getIconId() && key.getLabel() == null; return Objects.equals(mIconId, key.getIconId()) && key.getLabel().isEmpty();
} }
@Override @Override
@ -94,7 +95,7 @@ public abstract class ExpectedKeyVisual {
// If the actual more key has an icon as its visual, a label has to be null. // If the actual more key has an icon as its visual, a label has to be null.
// See {@link KeySpecParser#getIconId(String)} and // See {@link KeySpecParser#getIconId(String)} and
// {@link KeySpecParser#getLabel(String)}. // {@link KeySpecParser#getLabel(String)}.
return mIconId == moreKeySpec.mIconId && moreKeySpec.mLabel == null; return Objects.equals(mIconId, moreKeySpec.mIconId) && moreKeySpec.mLabel == null;
} }
@Override @Override
@ -104,7 +105,7 @@ public abstract class ExpectedKeyVisual {
@Override @Override
boolean hasSameKeyVisual(final ExpectedKeyVisual visual) { boolean hasSameKeyVisual(final ExpectedKeyVisual visual) {
return (visual instanceof Icon) && mIconId == ((Icon)visual).mIconId; return (visual instanceof Icon) && Objects.equals(mIconId, ((Icon) visual).mIconId);
} }
@Override @Override
@ -153,7 +154,7 @@ public abstract class ExpectedKeyVisual {
// If the actual key has a label as its visual, an icon has to be undefined. // If the actual key has a label as its visual, an icon has to be undefined.
// See {@link KeyboardView#onDrawKeyTopVisuals(Key,Canvas,Paint,KeyDrawParams). // See {@link KeyboardView#onDrawKeyTopVisuals(Key,Canvas,Paint,KeyDrawParams).
return mLabel.equals(key.getLabel()) return mLabel.equals(key.getLabel())
&& key.getIconId() == KeyboardIconsSet.ICON_UNDEFINED; && key.getIconId().equals(KeyboardIconsSet.ICON_UNDEFINED);
} }
@Override @Override
@ -162,7 +163,7 @@ public abstract class ExpectedKeyVisual {
// See {@link KeySpecParser#getIconId(String)} and // See {@link KeySpecParser#getIconId(String)} and
// {@link KeySpecParser#getLabel(String)}. // {@link KeySpecParser#getLabel(String)}.
return mLabel.equals(moreKeySpec.mLabel) return mLabel.equals(moreKeySpec.mLabel)
&& moreKeySpec.mIconId == KeyboardIconsSet.ICON_UNDEFINED; && Objects.equals(moreKeySpec.mIconId, KeyboardIconsSet.ICON_UNDEFINED);
} }
@Override @Override

View File

@ -165,10 +165,13 @@ abstract class LayoutTestsBase extends KeyboardLayoutSetTestsBase {
final Key actualKey = actualKeyboard[r][c]; final Key actualKey = actualKeyboard[r][c];
final ExpectedKey expectedKey = expectedKeyboard[r][c]; final ExpectedKey expectedKey = expectedKeyboard[r][c];
// Test both keyboards' keys have the same visual outlook and key output. // Test both keyboards' keys have the same visual outlook and key output.
assertTrue(tag + " labels row,column=" + row + "," + column if(!expectedKey.equalsTo(actualKey)) {
+ "\nexpected=" + expectedKey assertTrue(tag + " labels row,column=" + row + "," + column
+ "\nactual =" + ActualKeyboardBuilder.toString(actualKey), + "\nexpected=" + expectedKey
expectedKey.equalsTo(actualKey)); + "\nactual =" + ActualKeyboardBuilder.toString(actualKey),
expectedKey.equalsTo(actualKey));
}
} }
} }
} }

View File

@ -56,18 +56,9 @@ public class TestsQwertyEmail extends LayoutTestsBase {
EnglishEmailCustomizer(final Locale locale) { super(locale); } EnglishEmailCustomizer(final Locale locale) { super(locale); }
@Override @Override
public ExpectedKey getEnterKey(final boolean isPhone) { public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) {
return isPhone ? ENTER_KEY : super.getEnterKey(isPhone); final ExpectedKey periodKey = key(".", getPunctuationMoreKeys(isPhone));
} return joinKeys(key("@"), periodKey);
@Override
public ExpectedKey getEmojiKey(final boolean isPhone) {
return DOMAIN_KEY;
}
@Override
public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) {
return joinKeys(key("@", SETTINGS_KEY));
} }
} }
} }

View File

@ -56,18 +56,9 @@ public class TestsQwertyUrl extends LayoutTestsBase {
EnglishUrlCustomizer(final Locale locale) { super(locale); } EnglishUrlCustomizer(final Locale locale) { super(locale); }
@Override @Override
public ExpectedKey getEnterKey(final boolean isPhone) { public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) {
return isPhone ? ENTER_KEY : super.getEnterKey(isPhone); final ExpectedKey periodKey = key(".", getPunctuationMoreKeys(isPhone));
} return joinKeys(key("/"), periodKey);
@Override
public ExpectedKey getEmojiKey(final boolean isPhone) {
return DOMAIN_KEY;
}
@Override
public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) {
return joinKeys(key("/", SETTINGS_KEY));
} }
} }
} }

View File

@ -127,8 +127,8 @@
"currency_generic": [ "currency_generic": [
"$", "$",
"¢", "¢",
"€",
"£", "£",
"€",
"¥", "¥",
"₱" "₱"
], ],