Add ZWNJ_ZWJ_KEY for keyboard layout test

This CL also refactors Symbols and SymbolsShifted class a bit.

Bug: 13017434
Change-Id: I42bfe96553ea8447fc834d29c09ce1ce7794650d
main
Tadashi G. Takaoka 2014-03-14 13:07:34 +09:00
parent 74f259a74e
commit 746f94c671
6 changed files with 213 additions and 183 deletions

View File

@ -145,6 +145,16 @@ public abstract class LayoutBase extends AbstractLayoutBase {
return isPhone ? EMPTY_KEYS : joinKeys(EXCLAMATION_AND_QUESTION_MARKS, SHIFT_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
* keyboard.
*/
public ExpectedKey[] getSpaceKeys(final boolean isPhone) {
return joinKeys(SPACE_KEY);
}
/**
* Get the keys left to the spacebar.
* @param isPhone true if requesting phone's keys.
@ -232,6 +242,10 @@ public abstract class LayoutBase extends AbstractLayoutBase {
KeyboardIconsSet.NAME_SHIFT_KEY);
private static final int ICON_SHIFTED_SHIFT = KeyboardIconsSet.getIconId(
KeyboardIconsSet.NAME_SHIFT_KEY_SHIFTED);
private static final int ICON_ZWNJ = KeyboardIconsSet.getIconId(
KeyboardIconsSet.NAME_ZWNJ_KEY);
private static final int ICON_ZWJ = KeyboardIconsSet.getIconId(
KeyboardIconsSet.NAME_ZWJ_KEY);
// Functional key.
static final ExpectedKey CAPSLOCK_MORE_KEY = key(" ", Constants.CODE_CAPSLOCK);
@ -249,7 +263,9 @@ public abstract class LayoutBase extends AbstractLayoutBase {
// U+00BF: "¿" INVERTED QUESTION MARK
static final ExpectedKey[] EXCLAMATION_AND_QUESTION_MARKS = joinKeys(
key("!", moreKey("\u00A1")), key("?", moreKey("\u00BF")));
// U+200C: ZERO WIDTH NON-JOINER
// U+200D: ZERO WIDTH JOINER
static final ExpectedKey ZWNJ_ZWJ_KEY = key(ICON_ZWNJ, "\u200C", moreKey(ICON_ZWJ, "\u200D"));
// Punctuation more keys for phone form factor.
public static final ExpectedKey[] PHONE_PUNCTUATION_MORE_KEYS = joinKeys(
@ -273,7 +289,7 @@ public abstract class LayoutBase extends AbstractLayoutBase {
final LayoutCustomizer customizer = getCustomizer();
final ExpectedKey[] spacebar = joinKeys(
customizer.getKeysLeftToSpacebar(isPhone),
SPACEBAR,
customizer.getSpaceKeys(isPhone),
customizer.getKeysRightToSpacebar(isPhone));
builder.setKeysOfRow(4, spacebar);
if (isPhone) {

View File

@ -32,13 +32,28 @@ public class Symbols extends AbstractLayoutBase {
}
public ExpectedKey[][] getLayout(final boolean isPhone) {
final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(isPhone
? toPhoneSymbol(SYMBOLS_COMMON) : toTabletSymbols(SYMBOLS_COMMON));
builder.replaceKeyOfLabel(CURRENCY, mCustomizer.getCurrencyKey());
builder.replaceKeyOfLabel(DOUBLE_QUOTE, key("\"", joinKeys(
mCustomizer.getDoubleQuoteMoreKeys(), mCustomizer.getDoubleAngleQuoteKeys())));
builder.replaceKeyOfLabel(SINGLE_QUOTE, key("'", joinKeys(
mCustomizer.getSingleQuoteMoreKeys(), mCustomizer.getSingleAngleQuoteKeys())));
final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(SYMBOLS_COMMON);
final LayoutCustomizer customizer = mCustomizer;
builder.replaceKeyOfLabel(CURRENCY, customizer.getCurrencyKey());
builder.replaceKeyOfLabel(DOUBLE_QUOTE, key("\"", joinMoreKeys(
customizer.getDoubleQuoteMoreKeys(), customizer.getDoubleAngleQuoteKeys())));
builder.replaceKeyOfLabel(SINGLE_QUOTE, key("'", joinMoreKeys(
customizer.getSingleQuoteMoreKeys(), customizer.getSingleAngleQuoteKeys())));
if (isPhone) {
builder.addKeysOnTheLeftOfRow(3, customizer.getSymbolsShiftKey(isPhone))
.addKeysOnTheRightOfRow(3, DELETE_KEY)
.addKeysOnTheLeftOfRow(4, customizer.getAlphabetKey())
.addKeysOnTheRightOfRow(4, key(ENTER_KEY, EMOJI_KEY));
} else {
// Tablet symbols keyboard has extra two keys at the left edge of the 3rd row.
builder.addKeysOnTheLeftOfRow(3, joinKeys("\\", "="));
builder.addKeysOnTheRightOfRow(1, DELETE_KEY)
.addKeysOnTheRightOfRow(2, ENTER_KEY)
.addKeysOnTheLeftOfRow(3, customizer.getSymbolsShiftKey(isPhone))
.addKeysOnTheRightOfRow(3, customizer.getSymbolsShiftKey(isPhone))
.addKeysOnTheLeftOfRow(4, customizer.getAlphabetKey())
.addKeysOnTheRightOfRow(4, EMOJI_KEY);
}
return builder.build();
}
@ -100,76 +115,61 @@ public class Symbols extends AbstractLayoutBase {
// Common symbols keyboard layout.
private static final ExpectedKey[][] SYMBOLS_COMMON = new ExpectedKeyboardBuilder(10, 9, 7, 5)
.setLabelsOfRow(1, "1", "2", "3", "4", "5", "6", "7", "8", "9", "0")
// U+00B9: "¹" SUPERSCRIPT ONE
// U+00BD: "½" VULGAR FRACTION ONE HALF
// U+2153: "⅓" VULGAR FRACTION ONE THIRD
// U+00BC: "¼" VULGAR FRACTION ONE QUARTER
// U+215B: "⅛" VULGAR FRACTION ONE EIGHTH
.setMoreKeysOf("1", "\u00B9", "\u00BD", "\u2153", "\u00BC", "\u215B")
// U+00B2: "²" SUPERSCRIPT TWO
// U+2154: "⅔" VULGAR FRACTION TWO THIRDS
.setMoreKeysOf("2", "\u00B2", "\u2154")
// U+00B3: "³" SUPERSCRIPT THREE
// U+00BE: "¾" VULGAR FRACTION THREE QUARTERS
// U+215C: "⅜" VULGAR FRACTION THREE EIGHTHS
.setMoreKeysOf("3", "\u00B3", "\u00BE", "\u215C")
// U+2074: "⁴" SUPERSCRIPT FOUR
.setMoreKeysOf("4", "\u2074")
// U+215D: "⅝" VULGAR FRACTION FIVE EIGHTHS
.setMoreKeysOf("5", "\u215D")
// U+215E: "⅞" VULGAR FRACTION SEVEN EIGHTHS
.setMoreKeysOf("7", "\u215E")
// U+207F: "ⁿ" SUPERSCRIPT LATIN SMALL LETTER N
// U+2205: "∅" EMPTY SET
.setMoreKeysOf("0", "\u207F", "\u2205")
.setLabelsOfRow(2, "@", "#", CURRENCY, "%", "&", "-", "+", "(", ")")
// U+2030: "‰" PER MILLE SIGN
.setMoreKeysOf("%", "\u2030")
// U+2013: "" EN DASH
// U+2014: "—" EM DASH
// U+00B7: "·" MIDDLE DOT
.setMoreKeysOf("-", "_", "\u2013", "\u2014", "\u00B7")
// U+00B1: "±" PLUS-MINUS SIGN
.setMoreKeysOf("+", "\u00B1")
.setMoreKeysOf("(", "<", "{", "[")
.setMoreKeysOf(")", ">", "}", "]")
.setLabelsOfRow(3, "*", DOUBLE_QUOTE, SINGLE_QUOTE, ":", ";", "!", "?")
// U+2020: "†" DAGGER
// U+2021: "‡" DOUBLE DAGGER
// U+2605: "★" BLACK STAR
.setMoreKeysOf("*", "\u2020", "\u2021", "\u2605")
// U+00A1: "¡" INVERTED EXCLAMATION MARK
.setMoreKeysOf("!", "\u00A1")
// U+00BF: "¿" INVERTED QUESTION MARK
.setMoreKeysOf("?", "\u00BF")
.setLabelsOfRow(4, "_", "/", " ", ",", ".")
// U+2026: "…" HORIZONTAL ELLIPSIS
.setMoreKeysOf(".", "\u2026")
.setKeysOfRow(1,
// U+00B9: "¹" SUPERSCRIPT ONE
// U+00BD: "½" VULGAR FRACTION ONE HALF
// U+2153: "⅓" VULGAR FRACTION ONE THIRD
// U+00BC: "¼" VULGAR FRACTION ONE QUARTER
// U+215B: "⅛" VULGAR FRACTION ONE EIGHTH
key("1", joinMoreKeys("\u00B9", "\u00BD", "\u2153", "\u00BC", "\u215B")),
// U+00B2: "²" SUPERSCRIPT TWO
// U+2154: "⅔" VULGAR FRACTION TWO THIRDS
key("2", joinMoreKeys("\u00B2", "\u2154")),
// U+00B3: "³" SUPERSCRIPT THREE
// 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")),
key("6"),
// U+215E: "⅞" VULGAR FRACTION SEVEN EIGHTHS
key("7", moreKey("\u215E")),
key("8"),
key("9"),
// U+207F: "ⁿ" SUPERSCRIPT LATIN SMALL LETTER N
// U+2205: "∅" EMPTY SET
key("0", joinMoreKeys("\u207F", "\u2205")))
.setKeysOfRow(2,
key("@"), key("#"), key(CURRENCY),
// U+2030: "‰" PER MILLE SIGN
key("%", moreKey("\u2030")),
key("&"),
// U+2013: "" EN DASH
// U+2014: "—" EM DASH
// U+00B7: "·" MIDDLE DOT
key("-", joinMoreKeys("_", "\u2013", "\u2014", "\u00B7")),
// U+00B1: "±" PLUS-MINUS SIGN
key("+", moreKey("\u00B1")),
key("(", joinMoreKeys("<", "{", "[")),
key(")", joinMoreKeys(">", "}", "]")))
.setKeysOfRow(3,
// U+2020: "†" DAGGER
// U+2021: "‡" DOUBLE DAGGER
// U+2605: "★" BLACK STAR
key("*", joinMoreKeys("\u2020", "\u2021", "\u2605")),
key(DOUBLE_QUOTE), key(SINGLE_QUOTE), key(":"), key(";"),
// U+00A1: "¡" INVERTED EXCLAMATION MARK
key("!", moreKey("\u00A1")),
// U+00BF: "¿" INVERTED QUESTION MARK
key("?", moreKey("\u00BF")))
.setKeysOfRow(4,
key("_"), key("/"), SPACE_KEY, key(","),
// U+2026: "…" HORIZONTAL ELLIPSIS
key(".", moreKey("\u2026")))
.build();
private ExpectedKey[][] toPhoneSymbol(final ExpectedKey[][] common) {
return new ExpectedKeyboardBuilder(common)
.addKeysOnTheLeftOfRow(3, mCustomizer.getSymbolsShiftKey(true /* isPhone */))
.addKeysOnTheRightOfRow(3, DELETE_KEY)
.addKeysOnTheLeftOfRow(4, mCustomizer.getAlphabetKey())
.addKeysOnTheRightOfRow(4, key(ENTER_KEY, EMOJI_KEY))
.build();
}
private ExpectedKey[][] toTabletSymbols(final ExpectedKey[][] common) {
return new ExpectedKeyboardBuilder(common)
.addKeysOnTheLeftOfRow(3,
key("\\"), key("="))
.addKeysOnTheRightOfRow(1, DELETE_KEY)
.addKeysOnTheRightOfRow(2, ENTER_KEY)
.addKeysOnTheLeftOfRow(3, mCustomizer.getSymbolsShiftKey(false /* isPhone */))
.addKeysOnTheRightOfRow(3, mCustomizer.getSymbolsShiftKey(false /* isPhone */))
.addKeysOnTheLeftOfRow(4, mCustomizer.getAlphabetKey())
.addKeysOnTheRightOfRow(4, EMOJI_KEY)
.build();
}
public static class RtlSymbols extends Symbols {
public RtlSymbols(final LayoutCustomizer customizer) {
super(customizer);

View File

@ -32,10 +32,26 @@ public class SymbolsShifted extends AbstractLayoutBase {
}
public ExpectedKey[][] getLayout(final boolean isPhone) {
final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(isPhone
? toPhoneSymbolsShifted(SYMBOLS_SHIFTED_COMMON)
: toTabletSymbolsShifted(SYMBOLS_SHIFTED_COMMON));
builder.replaceKeyOfLabel(OTHER_CURRENCIES, mCustomizer.getOtherCurrencyKeys());
final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(SYMBOLS_SHIFTED_COMMON);
final LayoutCustomizer customizer = mCustomizer;
builder.replaceKeyOfLabel(OTHER_CURRENCIES, customizer.getOtherCurrencyKeys());
if (isPhone) {
builder.addKeysOnTheLeftOfRow(3, customizer.getBackToSymbolsKey())
.addKeysOnTheRightOfRow(3, DELETE_KEY)
.addKeysOnTheLeftOfRow(4, customizer.getAlphabetKey())
.addKeysOnTheRightOfRow(4, key(ENTER_KEY, EMOJI_KEY));
} 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, joinKeys("\u00A1", "\u00BF"));
builder.addKeysOnTheRightOfRow(1, DELETE_KEY)
.addKeysOnTheRightOfRow(2, ENTER_KEY)
.addKeysOnTheLeftOfRow(3, customizer.getBackToSymbolsKey())
.addKeysOnTheRightOfRow(3, customizer.getBackToSymbolsKey())
.addKeysOnTheLeftOfRow(4, customizer.getAlphabetKey())
.addKeysOnTheRightOfRow(4, EMOJI_KEY);
}
return builder.build();
}
@ -54,92 +70,71 @@ public class SymbolsShifted extends AbstractLayoutBase {
};
// Common symbols shifted keyboard layout.
private static final ExpectedKey[][] SYMBOLS_SHIFTED_COMMON =
new ExpectedKeyboardBuilder(10, 1 /* other_currencies */ + 5, 7, 5)
// U+0060: "`" GRAVE ACCENT
// U+2022: "•" BULLET
// U+221A: "√" SQUARE ROOT
// U+03C0: "π" GREEK SMALL LETTER PI
// U+00F7: "÷" DIVISION SIGN
// U+00D7: "×" MULTIPLICATION SIGN
// U+00B6: "¶" PILCROW SIGN
// U+2206: "∆" INCREMENT
.setLabelsOfRow(1,
"~", "\u0060", "|", "\u2022", "\u221A",
"\u03C0", "\u00F7", "\u00D7", "\u00B6", "\u2206")
// U+2022: "•" BULLET
// U+266A: "♪" EIGHTH NOTE
// U+2665: "♥" BLACK HEART SUIT
// U+2660: "♠" BLACK SPADE SUIT
// U+2666: "♦" BLACK DIAMOND SUIT
// U+2663: "♣" BLACK CLUB SUIT
.setMoreKeysOf("\u2022", "\u266A", "\u2665", "\u2660", "\u2666", "\u2663")
// U+03C0: "π" GREEK SMALL LETTER PI
// U+03A0: "Π" GREEK CAPITAL LETTER PI
.setMoreKeysOf("\u03C0", "\u03A0")
// U+00B6: "¶" PILCROW SIGN
// U+00A7: "§" SECTION SIGN
.setMoreKeysOf("\u00B6", "\u00A7")
// U+00B0: "°" DEGREE SIGN
.setLabelsOfRow(2, OTHER_CURRENCIES, "^", "\u00B0", "=", "{", "}")
// U+2191: "↑" UPWARDS ARROW
// U+2193: "↓" DOWNWARDS ARROW
// U+2190: "←" LEFTWARDS ARROW
// U+2192: "→" RIGHTWARDS ARROW
.setMoreKeysOf("^", "\u2191", "\u2193", "\u2190", "\u2192")
// U+00B0: "°" DEGREE SIGN
// U+2032: "" PRIME
// U+2033: "″" DOUBLE PRIME
.setMoreKeysOf("\u00B0", "\u2032", "\u2033")
// U+2260: "≠" NOT EQUAL TO
// U+2248: "≈" ALMOST EQUAL TO
// U+221E: "∞" INFINITY
.setMoreKeysOf("=", "\u2260", "\u2248", "\u221E")
// U+00A9: "©" COPYRIGHT SIGN
// U+00AE: "®" REGISTERED SIGN
// U+2122: "™" TRADE MARK SIGN
// U+2105: "℅" CARE OF
private static final ExpectedKey[][] SYMBOLS_SHIFTED_COMMON = new ExpectedKeyboardBuilder(
10, 1 /* other_currencies */+ 5, 7, 5)
.setKeysOfRow(1,
key("~"),
// U+0060: "`" GRAVE ACCENT
key("\u0060"),
key("|"),
// U+2022: "•" BULLET
// U+266A: "♪" EIGHTH NOTE
// U+2665: "♥" BLACK HEART SUIT
// U+2660: "♠" BLACK SPADE SUIT
// U+2666: "♦" BLACK DIAMOND SUIT
// U+2663: "♣" BLACK CLUB SUIT
key("\u2022", joinMoreKeys("\u266A", "\u2665", "\u2660", "\u2666", "\u2663")),
// U+221A: "√" SQUARE ROOT
key("\u221A"),
// U+03C0: "π" GREEK SMALL LETTER PI
// U+03A0: "Π" GREEK CAPITAL LETTER PI
key("\u03C0", moreKey("\u03A0")),
// U+00F7: "÷" DIVISION SIGN
key("\u00F7"),
// U+00D7: "×" MULTIPLICATION SIGN
key("\u00D7"),
// U+00B6: "¶" PILCROW SIGN
// U+00A7: "§" SECTION SIGN
key("\u00B6", moreKey("\u00A7")),
// U+2206: "∆" INCREMENT
key("\u2206"))
.setKeysOfRow(2,
key(OTHER_CURRENCIES),
// U+2191: "↑" UPWARDS ARROW
// U+2193: "↓" DOWNWARDS ARROW
// U+2190: "←" LEFTWARDS ARROW
// U+2192: "→" RIGHTWARDS ARROW
key("^", joinMoreKeys("\u2191", "\u2193", "\u2190", "\u2192")),
// U+00B0: "°" DEGREE SIGN
// U+2032: "" PRIME
// U+2033: "″" DOUBLE PRIME
key("\u00B0", joinMoreKeys("\u2032", "\u2033")),
// U+2260: "≠" NOT EQUAL TO
// U+2248: "≈" ALMOST EQUAL TO
// U+221E: "∞" INFINITY
key("=", joinMoreKeys("\u2260", "\u2248", "\u221E")),
key("{"),
key("}"))
.setLabelsOfRow(3,
"\\", "\u00A9", "\u00AE", "\u2122", "\u2105",
"[", "]")
.setLabelsOfRow(4,
"<", ">", " ", ",", ".")
// U+2039: "" SINGLE LEFT-POINTING ANGLE QUOTATION MARK
// U+2264: "≤" LESS-THAN OR EQUAL TO
// U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
.setMoreKeysOf("<", "\u2039", "\u2264", "\u00AB")
// U+203A: "" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
// U+2265: "≥" GREATER-THAN EQUAL TO
// U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
.setMoreKeysOf(">", "\u203A", "\u2265", "\u00BB")
// U+2026: "…" HORIZONTAL ELLIPSIS
.setMoreKeysOf(".", "\u2026")
// U+00A9: "©" COPYRIGHT SIGN
// U+00AE: "®" REGISTERED SIGN
// U+2122: "™" TRADE MARK SIGN
// U+2105: "℅" CARE OF
"\\", "\u00A9", "\u00AE", "\u2122", "\u2105", "[", "]")
.setKeysOfRow(4,
// U+2039: "" SINGLE LEFT-POINTING ANGLE QUOTATION MARK
// U+2264: "≤" LESS-THAN OR EQUAL TO
// U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
key("<", joinMoreKeys("\u2039", "\u2264", "\u00AB")),
// U+203A: "" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
// U+2265: "≥" GREATER-THAN EQUAL TO
// U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
key(">", joinMoreKeys("\u203A", "\u2265", "\u00BB")),
SPACE_KEY, key(","),
// U+2026: "…" HORIZONTAL ELLIPSIS
key(".", moreKey("\u2026")))
.build();
private ExpectedKey[][] toPhoneSymbolsShifted(final ExpectedKey[][] common) {
return new ExpectedKeyboardBuilder(common)
.addKeysOnTheLeftOfRow(3, mCustomizer.getBackToSymbolsKey())
.addKeysOnTheRightOfRow(3, DELETE_KEY)
.addKeysOnTheLeftOfRow(4, mCustomizer.getAlphabetKey())
.addKeysOnTheRightOfRow(4, key(ENTER_KEY, EMOJI_KEY))
.build();
}
private ExpectedKey[][] toTabletSymbolsShifted(final ExpectedKey[][] common) {
return new ExpectedKeyboardBuilder(common)
// U+00BF: "¿" INVERTED QUESTION MARK
// U+00A1: "¡" INVERTED EXCLAMATION MARK
.addKeysOnTheRightOfRow(3,
key("\u00A1"), key("\u00BF"))
.addKeysOnTheRightOfRow(1, DELETE_KEY)
.addKeysOnTheRightOfRow(2, ENTER_KEY)
.addKeysOnTheLeftOfRow(3, mCustomizer.getBackToSymbolsKey())
.addKeysOnTheRightOfRow(3, mCustomizer.getBackToSymbolsKey())
.addKeysOnTheLeftOfRow(4, mCustomizer.getAlphabetKey())
.addKeysOnTheRightOfRow(4, EMOJI_KEY)
.build();
}
public static class RtlSymbolsShifted extends SymbolsShifted {
public RtlSymbolsShifted(final LayoutCustomizer customizer) {
super(customizer);

View File

@ -31,54 +31,66 @@ public abstract class AbstractLayoutBase {
// Those helper methods have a lower case name to be readable when defining expected keyboard
// layouts.
// Helper method to create {@link ExpectedKey} object that has the label.
// Helper method to create an {@link ExpectedKey} object that has the label.
public static ExpectedKey key(final String label, final ExpectedKey ... moreKeys) {
return ExpectedKey.newInstance(label, moreKeys);
}
// Helper method to create {@link ExpectedKey} object that has the label and the output text.
// Helper method to create an {@link ExpectedKey} object that has the label and the output text.
public static ExpectedKey key(final String label, final String outputText,
final ExpectedKey ... moreKeys) {
return ExpectedKey.newInstance(label, outputText, moreKeys);
}
// Helper method to create {@link ExpectedKey} object that has the label and the output code.
// Helper method to create an {@link ExpectedKey} object that has the label and the output code.
public static ExpectedKey key(final String label, final int code,
final ExpectedKey ... moreKeys) {
return ExpectedKey.newInstance(label, code, moreKeys);
}
// Helper method to create {@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 text.
public static ExpectedKey key(final int iconId, final String outputText,
final ExpectedKey ... moreKeys) {
return ExpectedKey.newInstance(iconId, outputText, moreKeys);
}
// Helper method to create an {@link ExpectedKey} object that has the icon and the output code.
public static ExpectedKey key(final int iconId, final int code,
final ExpectedKey ... moreKeys) {
return ExpectedKey.newInstance(iconId, code, moreKeys);
}
// Helper method to create {@link ExpectedKey} object that has new "more keys".
// Helper method to create an {@link ExpectedKey} object that has new "more keys".
public static ExpectedKey key(final ExpectedKey key, final ExpectedKey ... moreKeys) {
return ExpectedKey.newInstance(key.getVisual(), key.getOutput(), moreKeys);
}
// Helper method to create {@link ExpectedKey} object for "more key" that has the label.
// Helper method to create an {@link ExpectedKey} object for a "more key" that has the label.
public static ExpectedKey moreKey(final String label) {
return ExpectedKey.newInstance(label);
}
// Helper method to create {@link ExpectedKey} object for "more key" that has the label and the
// output text.
// Helper method to create an {@link ExpectedKey} object for a "more key" that has the label
// and the output text.
public static ExpectedKey moreKey(final String label, final String outputText) {
return ExpectedKey.newInstance(label, outputText);
}
// Helper method to create {@link ExpectedKey} object for "more key" that has the label and the
// output code.
// Helper method to create an {@link ExpectedKey} object for a "more key" that has the label
// and the output code.
public static ExpectedKey moreKey(final String label, final int code) {
return ExpectedKey.newInstance(label, code);
}
// Helper method to create an {@link ExpectedKey} object for a "more key" that has the icon
// and the output text.
public static ExpectedKey moreKey(final int iconId, final String outputText) {
return ExpectedKey.newInstance(iconId, outputText);
}
// Helper method to create {@link ExpectedKey} array by joining {@link ExpectedKey},
// {@link ExpectedKey} array, and {@link String}.
public static ExpectedKey[] moreKeys(final Object ... moreKeys) {
public static ExpectedKey[] joinMoreKeys(final Object ... moreKeys) {
return joinKeys(moreKeys);
}
@ -115,6 +127,6 @@ public abstract class AbstractLayoutBase {
public static final ExpectedKey SETTINGS_KEY = key(ICON_SETTINGS, Constants.CODE_SETTINGS);
public static final ExpectedKey ENTER_KEY = key(ICON_ENTER, Constants.CODE_ENTER);
public static final ExpectedKey EMOJI_KEY = key(ICON_EMOJI, Constants.CODE_EMOJI);
public static final ExpectedKey SPACEBAR = key(
public static final ExpectedKey SPACE_KEY = key(
StringUtils.newSingleCodePointString(Constants.CODE_SPACE));
}

View File

@ -47,6 +47,13 @@ public class ExpectedKey {
ExpectedKeyOutput.newInstance(code), moreKeys);
}
// A key that has an icon and an output text and may have "more keys".
static ExpectedKey newInstance(final int iconId, final String outputText,
final ExpectedKey ... moreKeys) {
return newInstance(ExpectedKeyVisual.newInstance(iconId),
ExpectedKeyOutput.newInstance(outputText), moreKeys);
}
// A key that has an icon and a code point output and may have "more keys".
static ExpectedKey newInstance(final int iconId, final int code,
final ExpectedKey ... moreKeys) {

View File

@ -56,36 +56,36 @@ abstract class LayoutTestsBase extends KeyboardLayoutSetTestsBase {
// Those helper methods have a lower case name to be readable when defining expected keyboard
// layouts.
// Helper method to create {@link ExpectedKey} object that has the label.
// Helper method to create an {@link ExpectedKey} object that has the label.
static ExpectedKey key(final String label, final ExpectedKey ... moreKeys) {
return AbstractLayoutBase.key(label, moreKeys);
}
// Helper method to create {@link ExpectedKey} object that has the label and the output text.
// Helper method to create an {@link ExpectedKey} object that has the label and the output text.
static ExpectedKey key(final String label, final String outputText,
final ExpectedKey ... moreKeys) {
return AbstractLayoutBase.key(label, outputText, moreKeys);
}
// Helper method to create {@link ExpectedKey} object that has new "more keys".
// Helper method to create an {@link ExpectedKey} object that has new "more keys".
static ExpectedKey key(final ExpectedKey key, final ExpectedKey ... moreKeys) {
return AbstractLayoutBase.key(key, moreKeys);
}
// Helper method to create {@link ExpectedKey} object for "more key" that has the label.
// Helper method to create an {@link ExpectedKey} object for a "more key" that has the label.
static ExpectedKey moreKey(final String label) {
return AbstractLayoutBase.moreKey(label);
}
// Helper method to create {@link ExpectedKey} object for "more key" that has the label and the
// output text.
// Helper method to create an {@link ExpectedKey} object for a "more key" that has the label
// and the output text.
static ExpectedKey moreKey(final String label, final String outputText) {
return AbstractLayoutBase.moreKey(label, outputText);
}
// Helper method to create {@link ExpectedKey} array by joining {@link ExpectedKey},
// {@link ExpectedKey} array, and {@link String}.
static ExpectedKey[] moreKeys(final Object ... moreKeys) {
static ExpectedKey[] joinMoreKeys(final Object ... moreKeys) {
return AbstractLayoutBase.joinKeys(moreKeys);
}