From 0dabae720a83f9099667dea4de002007fdf35d60 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 18 Mar 2014 15:38:44 +0900 Subject: [PATCH] Support additional more keys for keyboard layout test Bug: 13017434 Change-Id: I44c31dce3391d9638979539bb5e58c0525186fb4 --- .../inputmethod/keyboard/layout/Azerty.java | 20 +- .../keyboard/layout/Bulgarian.java | 38 ++-- .../keyboard/layout/BulgarianBds.java | 40 ++-- .../keyboard/layout/EastSlavic.java | 54 ++--- .../inputmethod/keyboard/layout/Greek.java | 2 +- .../keyboard/layout/LayoutBase.java | 4 +- .../inputmethod/keyboard/layout/Nordic.java | 20 +- .../inputmethod/keyboard/layout/Qwerty.java | 20 +- .../inputmethod/keyboard/layout/Qwertz.java | 20 +- .../keyboard/layout/SouthSlavic.java | 20 +- .../inputmethod/keyboard/layout/Spanish.java | 20 +- .../inputmethod/keyboard/layout/Swiss.java | 20 +- .../layout/expected/AbstractLayoutBase.java | 10 + .../keyboard/layout/expected/ExpectedKey.java | 206 ++++++++++++++++-- .../expected/ExpectedKeyboardBuilder.java | 30 ++- .../layout/tests/EnglishCustomizer.java | 76 +++++++ .../layout/tests/FrenchCustomizer.java | 88 ++++++++ .../layout/tests/GermanCustomizer.java | 86 ++++++++ .../layout/tests/LayoutTestsBase.java | 7 + .../layout/tests/PortugueseCustomizer.java | 80 +++++++ .../layout/tests/SpanishCustomizer.java | 104 +++++++++ .../keyboard/layout/tests/TestsAfrikaans.java | 14 +- .../layout/tests/TestsAzerbaijaniAZ.java | 11 +- .../layout/tests/TestsBelarusianBY.java | 10 +- .../keyboard/layout/tests/TestsCatalan.java | 18 +- .../keyboard/layout/tests/TestsCroatian.java | 2 +- .../keyboard/layout/tests/TestsCzech.java | 20 +- .../keyboard/layout/tests/TestsDanish.java | 17 +- .../keyboard/layout/tests/TestsDutch.java | 80 ++++--- .../keyboard/layout/tests/TestsDutchBE.java | 75 +------ .../keyboard/layout/tests/TestsEnglishUK.java | 2 +- .../keyboard/layout/tests/TestsEnglishUS.java | 59 +---- .../keyboard/layout/tests/TestsEsperanto.java | 34 +-- .../layout/tests/TestsEstonianEE.java | 29 ++- .../keyboard/layout/tests/TestsFinnish.java | 11 +- .../keyboard/layout/tests/TestsFrench.java | 76 ++----- .../keyboard/layout/tests/TestsFrenchCA.java | 67 +----- .../keyboard/layout/tests/TestsFrenchCH.java | 60 +---- .../layout/tests/TestsFrenchQwertz.java | 68 +----- .../keyboard/layout/tests/TestsGerman.java | 71 +----- .../keyboard/layout/tests/TestsGermanCH.java | 61 +----- .../layout/tests/TestsGermanQwerty.java | 69 +----- .../keyboard/layout/tests/TestsHungarian.java | 13 +- .../keyboard/layout/tests/TestsIcelandic.java | 16 +- .../keyboard/layout/tests/TestsItalian.java | 16 +- .../keyboard/layout/tests/TestsKazakh.java | 14 +- .../keyboard/layout/tests/TestsKyrgyz.java | 14 +- .../keyboard/layout/tests/TestsLatvian.java | 21 +- .../layout/tests/TestsLithuanian.java | 21 +- .../layout/tests/TestsMacedonian.java | 12 +- .../layout/tests/TestsNoLanguage.java | 24 +- .../keyboard/layout/tests/TestsNorwegian.java | 10 +- .../keyboard/layout/tests/TestsPolish.java | 7 +- .../layout/tests/TestsPortugueseBR.java | 65 +----- .../layout/tests/TestsPortuguesePT.java | 17 +- .../keyboard/layout/tests/TestsRomanian.java | 5 +- .../keyboard/layout/tests/TestsRussian.java | 10 +- .../keyboard/layout/tests/TestsSerbian.java | 12 +- .../keyboard/layout/tests/TestsSlovak.java | 25 +-- .../keyboard/layout/tests/TestsSlovenian.java | 4 +- .../keyboard/layout/tests/TestsSpanish.java | 18 +- .../keyboard/layout/tests/TestsSpanishUS.java | 86 +------- .../keyboard/layout/tests/TestsSwahili.java | 10 +- .../keyboard/layout/tests/TestsSwedish.java | 24 +- .../keyboard/layout/tests/TestsTagalog.java | 13 +- .../keyboard/layout/tests/TestsTurkish.java | 12 +- .../keyboard/layout/tests/TestsUkrainian.java | 8 +- .../layout/tests/TestsVietnamese.java | 18 +- .../keyboard/layout/tests/TestsZulu.java | 2 +- 69 files changed, 1133 insertions(+), 1183 deletions(-) create mode 100644 tests/src/com/android/inputmethod/keyboard/layout/tests/EnglishCustomizer.java create mode 100644 tests/src/com/android/inputmethod/keyboard/layout/tests/FrenchCustomizer.java create mode 100644 tests/src/com/android/inputmethod/keyboard/layout/tests/GermanCustomizer.java create mode 100644 tests/src/com/android/inputmethod/keyboard/layout/tests/PortugueseCustomizer.java create mode 100644 tests/src/com/android/inputmethod/keyboard/layout/tests/SpanishCustomizer.java diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Azerty.java b/tests/src/com/android/inputmethod/keyboard/layout/Azerty.java index eaa25823f..a0949637b 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/Azerty.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/Azerty.java @@ -61,16 +61,16 @@ public final class Azerty extends LayoutBase { private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() .setKeysOfRow(1, - key("a", moreKey("1")), - key("z", moreKey("2")), - key("e", moreKey("3")), - key("r", moreKey("4")), - key("t", moreKey("5")), - key("y", moreKey("6")), - key("u", moreKey("7")), - key("i", moreKey("8")), - key("o", moreKey("9")), - key("p", moreKey("0"))) + key("a", additionalMoreKey("1")), + key("z", additionalMoreKey("2")), + key("e", additionalMoreKey("3")), + key("r", additionalMoreKey("4")), + key("t", additionalMoreKey("5")), + key("y", additionalMoreKey("6")), + key("u", additionalMoreKey("7")), + key("i", additionalMoreKey("8")), + key("o", additionalMoreKey("9")), + key("p", additionalMoreKey("0"))) .setKeysOfRow(2, "q", "s", "d", "f", "g", "h", "j", "k", "l", "m") .setKeysOfRow(3, "w", "x", "c", "v", "b", "n", ROW3_QUOTE) .build(); diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Bulgarian.java b/tests/src/com/android/inputmethod/keyboard/layout/Bulgarian.java index 0972cc12f..3282e44ae 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/Bulgarian.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/Bulgarian.java @@ -77,29 +77,29 @@ public final class Bulgarian extends LayoutBase { key("\u043F", moreKey("0")), // U+0447: "ч" CYRILLIC SMALL LETTER CHE "\u0447") - // U+0430: "а" CYRILLIC SMALL LETTER A - // U+0441: "с" CYRILLIC SMALL LETTER ES - // U+0434: "д" CYRILLIC SMALL LETTER DE - // U+0444: "ф" CYRILLIC SMALL LETTER EF - // U+0433: "г" CYRILLIC SMALL LETTER GHE - // U+0445: "х" CYRILLIC SMALL LETTER HA - // U+0439: "й" CYRILLIC SMALL LETTER SHORT I - // U+043A: "к" CYRILLIC SMALL LETTER KA - // U+043B: "л" CYRILLIC SMALL LETTER EL - // U+0448: "ш" CYRILLIC SMALL LETTER SHA - // U+0449: "щ" CYRILLIC SMALL LETTER SHCHA .setKeysOfRow(2, + // U+0430: "а" CYRILLIC SMALL LETTER A + // U+0441: "с" CYRILLIC SMALL LETTER ES + // U+0434: "д" CYRILLIC SMALL LETTER DE + // U+0444: "ф" CYRILLIC SMALL LETTER EF + // U+0433: "г" CYRILLIC SMALL LETTER GHE + // U+0445: "х" CYRILLIC SMALL LETTER HA + // U+0439: "й" CYRILLIC SMALL LETTER SHORT I + // U+043A: "к" CYRILLIC SMALL LETTER KA + // U+043B: "л" CYRILLIC SMALL LETTER EL + // U+0448: "ш" CYRILLIC SMALL LETTER SHA + // U+0449: "щ" CYRILLIC SMALL LETTER SHCHA "\u0430", "\u0441", "\u0434", "\u0444", "\u0433", "\u0445", "\u0439", "\u043A", "\u043B", "\u0448", "\u0449") - // U+0437: "з" CYRILLIC SMALL LETTER ZE - // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN - // U+0446: "ц" CYRILLIC SMALL LETTER TSE - // U+0436: "ж" CYRILLIC SMALL LETTER ZHE - // U+0431: "б" CYRILLIC SMALL LETTER BE - // U+043D: "н" CYRILLIC SMALL LETTER EN - // U+043C: "м" CYRILLIC SMALL LETTER EM - // U+044E: "ю" CYRILLIC SMALL LETTER YU .setKeysOfRow(3, + // U+0437: "з" CYRILLIC SMALL LETTER ZE + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+0446: "ц" CYRILLIC SMALL LETTER TSE + // U+0436: "ж" CYRILLIC SMALL LETTER ZHE + // U+0431: "б" CYRILLIC SMALL LETTER BE + // U+043D: "н" CYRILLIC SMALL LETTER EN + // U+043C: "м" CYRILLIC SMALL LETTER EM + // U+044E: "ю" CYRILLIC SMALL LETTER YU "\u0437", "\u044C", "\u0446", "\u0436", "\u0431", "\u043D", "\u043C", "\u044E") .build(); } diff --git a/tests/src/com/android/inputmethod/keyboard/layout/BulgarianBds.java b/tests/src/com/android/inputmethod/keyboard/layout/BulgarianBds.java index f8de93491..20a5f7dac 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/BulgarianBds.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/BulgarianBds.java @@ -67,30 +67,30 @@ public final class BulgarianBds extends LayoutBase { key("\u0446", moreKey("0")), // U+0431: "б" CYRILLIC SMALL LETTER BE "\u0431") - // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN - // U+044F: "я" CYRILLIC SMALL LETTER YA - // U+0430: "а" CYRILLIC SMALL LETTER A - // U+043E: "о" CYRILLIC SMALL LETTER O - // U+0436: "ж" CYRILLIC SMALL LETTER ZHE - // U+0433: "г" CYRILLIC SMALL LETTER GHE - // U+0442: "т" CYRILLIC SMALL LETTER TE - // U+043D: "н" CYRILLIC SMALL LETTER EN - // U+0432: "в" CYRILLIC SMALL LETTER VE - // U+043C: "м" CYRILLIC SMALL LETTER EM - // U+0447: "ч" CYRILLIC SMALL LETTER CHE .setKeysOfRow(2, + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+044F: "я" CYRILLIC SMALL LETTER YA + // U+0430: "а" CYRILLIC SMALL LETTER A + // U+043E: "о" CYRILLIC SMALL LETTER O + // U+0436: "ж" CYRILLIC SMALL LETTER ZHE + // U+0433: "г" CYRILLIC SMALL LETTER GHE + // U+0442: "т" CYRILLIC SMALL LETTER TE + // U+043D: "н" CYRILLIC SMALL LETTER EN + // U+0432: "в" CYRILLIC SMALL LETTER VE + // U+043C: "м" CYRILLIC SMALL LETTER EM + // U+0447: "ч" CYRILLIC SMALL LETTER CHE "\u044C", "\u044F", "\u0430", "\u043E", "\u0436", "\u0433", "\u0442", "\u043D", "\u0432", "\u043C", "\u0447") - // U+044E: "ю" CYRILLIC SMALL LETTER YU - // U+0439: "й" CYRILLIC SMALL LETTER SHORT I - // U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN - // U+044D: "э" CYRILLIC SMALL LETTER E - // U+0444: "ф" CYRILLIC SMALL LETTER EF - // U+0445: "х" CYRILLIC SMALL LETTER HA - // U+043F: "п" CYRILLIC SMALL LETTER PE - // U+0440: "р" CYRILLIC SMALL LETTER ER - // U+043B: "л" CYRILLIC SMALL LETTER EL .setKeysOfRow(3, + // U+044E: "ю" CYRILLIC SMALL LETTER YU + // U+0439: "й" CYRILLIC SMALL LETTER SHORT I + // U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN + // U+044D: "э" CYRILLIC SMALL LETTER E + // U+0444: "ф" CYRILLIC SMALL LETTER EF + // U+0445: "х" CYRILLIC SMALL LETTER HA + // U+043F: "п" CYRILLIC SMALL LETTER PE + // U+0440: "р" CYRILLIC SMALL LETTER ER + // U+043B: "л" CYRILLIC SMALL LETTER EL "\u044E", "\u0439", "\u044A", "\u044D", "\u0444", "\u0445", "\u043F", "\u0440", "\u043B") .build(); diff --git a/tests/src/com/android/inputmethod/keyboard/layout/EastSlavic.java b/tests/src/com/android/inputmethod/keyboard/layout/EastSlavic.java index f6de53fa7..7fcc974c2 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/EastSlavic.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/EastSlavic.java @@ -63,47 +63,47 @@ public final class EastSlavic extends LayoutBase { private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() .setKeysOfRow(1, // U+0443: "у" CYRILLIC SMALL LETTER U - key("\u0439", moreKey("1")), + key("\u0439", additionalMoreKey("1")), // U+0446: "ц" CYRILLIC SMALL LETTER TSE - key("\u0446", moreKey("2")), + key("\u0446", additionalMoreKey("2")), // U+0439: "й" CYRILLIC SMALL LETTER SHORT I - key("\u0443", moreKey("3")), + key("\u0443", additionalMoreKey("3")), // U+043A: "к" CYRILLIC SMALL LETTER KA - key("\u043A", moreKey("4")), + key("\u043A", additionalMoreKey("4")), // U+0435: "е" CYRILLIC SMALL LETTER IE - key("\u0435", moreKey("5")), + key("\u0435", additionalMoreKey("5")), // U+043D: "н" CYRILLIC SMALL LETTER EN - key("\u043D", moreKey("6")), + key("\u043D", additionalMoreKey("6")), // U+0433: "г" CYRILLIC SMALL LETTER GHE - key("\u0433", moreKey("7")), + key("\u0433", additionalMoreKey("7")), // U+0448: "ш" CYRILLIC SMALL LETTER SHA - key("\u0448", moreKey("8")), - key(ROW1_9, moreKey("9")), + key("\u0448", additionalMoreKey("8")), + key(ROW1_9, additionalMoreKey("9")), // U+0437: "з" CYRILLIC SMALL LETTER ZE - key("\u0437", moreKey("0")), + key("\u0437", additionalMoreKey("0")), // U+0445: "х" CYRILLIC SMALL LETTER HA "\u0445") - // U+0444: "ф" CYRILLIC SMALL LETTER EF - // U+0432: "в" CYRILLIC SMALL LETTER VE - // U+0430: "а" CYRILLIC SMALL LETTER A - // U+043F: "п" CYRILLIC SMALL LETTER PE - // U+0440: "р" CYRILLIC SMALL LETTER ER - // U+043E: "о" CYRILLIC SMALL LETTER O - // U+043B: "л" CYRILLIC SMALL LETTER EL - // U+0434: "д" CYRILLIC SMALL LETTER DE - // U+0436: "ж" CYRILLIC SMALL LETTER ZHE .setKeysOfRow(2, + // U+0444: "ф" CYRILLIC SMALL LETTER EF + // U+0432: "в" CYRILLIC SMALL LETTER VE + // U+0430: "а" CYRILLIC SMALL LETTER A + // U+043F: "п" CYRILLIC SMALL LETTER PE + // U+0440: "р" CYRILLIC SMALL LETTER ER + // U+043E: "о" CYRILLIC SMALL LETTER O + // U+043B: "л" CYRILLIC SMALL LETTER EL + // U+0434: "д" CYRILLIC SMALL LETTER DE + // U+0436: "ж" CYRILLIC SMALL LETTER ZHE "\u0444", ROW2_2, "\u0432", "\u0430", "\u043F", "\u0440", "\u043E", "\u043B", "\u0434", "\u0436", ROW2_11) - // U+044F: "я" CYRILLIC SMALL LETTER YA - // U+0447: "ч" CYRILLIC SMALL LETTER CHE - // U+0441: "с" CYRILLIC SMALL LETTER ES - // U+043C: "м" CYRILLIC SMALL LETTER EM - // U+0442: "т" CYRILLIC SMALL LETTER TE - // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN - // U+0431: "б" CYRILLIC SMALL LETTER BE - // U+044E: "ю" CYRILLIC SMALL LETTER YU .setKeysOfRow(3, + // U+044F: "я" CYRILLIC SMALL LETTER YA + // U+0447: "ч" CYRILLIC SMALL LETTER CHE + // U+0441: "с" CYRILLIC SMALL LETTER ES + // U+043C: "м" CYRILLIC SMALL LETTER EM + // U+0442: "т" CYRILLIC SMALL LETTER TE + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+0431: "б" CYRILLIC SMALL LETTER BE + // U+044E: "ю" CYRILLIC SMALL LETTER YU "\u044F", "\u0447", "\u0441", "\u043C", ROW3_5, "\u0442", "\u044C", "\u0431", "\u044E") .build(); diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Greek.java b/tests/src/com/android/inputmethod/keyboard/layout/Greek.java index 1a71fad95..0ec9f4cf4 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/Greek.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/Greek.java @@ -36,7 +36,7 @@ public final class Greek extends LayoutBase { @Override public String getName() { return LAYOUT_NAME; } - public static class GreekCustomizer extends EuroLayoutCustomizer { + public static class GreekCustomizer extends EuroCustomizer { public GreekCustomizer(final Locale locale) { super(locale); } @Override diff --git a/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java b/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java index 256a0d1a5..d870931ac 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java @@ -188,8 +188,8 @@ public abstract class LayoutBase extends AbstractLayoutBase { /** * The layout customize class for countries that use Euro. */ - public static class EuroLayoutCustomizer extends LayoutCustomizer { - public EuroLayoutCustomizer(final Locale locale) { + public static class EuroCustomizer extends LayoutCustomizer { + public EuroCustomizer(final Locale locale) { super(locale); } diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Nordic.java b/tests/src/com/android/inputmethod/keyboard/layout/Nordic.java index cee7eee8d..c791c404d 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/Nordic.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/Nordic.java @@ -41,16 +41,16 @@ public final class Nordic extends LayoutBase { private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() .setKeysOfRow(1, - key("q", moreKey("1")), - key("w", moreKey("2")), - key("e", moreKey("3")), - key("r", moreKey("4")), - key("t", moreKey("5")), - key("y", moreKey("6")), - key("u", moreKey("7")), - key("i", moreKey("8")), - key("o", moreKey("9")), - key("p", moreKey("0")), + key("q", additionalMoreKey("1")), + key("w", additionalMoreKey("2")), + key("e", additionalMoreKey("3")), + key("r", additionalMoreKey("4")), + key("t", additionalMoreKey("5")), + key("y", additionalMoreKey("6")), + key("u", additionalMoreKey("7")), + key("i", additionalMoreKey("8")), + key("o", additionalMoreKey("9")), + key("p", additionalMoreKey("0")), ROW1_11) .setKeysOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l", ROW2_10, ROW2_11) .setKeysOfRow(3, "z", "x", "c", "v", "b", "n", "m") diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Qwerty.java b/tests/src/com/android/inputmethod/keyboard/layout/Qwerty.java index 7ede74cef..d790a1e53 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/Qwerty.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/Qwerty.java @@ -37,16 +37,16 @@ public final class Qwerty extends LayoutBase { private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() .setKeysOfRow(1, - key("q", moreKey("1")), - key("w", moreKey("2")), - key("e", moreKey("3")), - key("r", moreKey("4")), - key("t", moreKey("5")), - key("y", moreKey("6")), - key("u", moreKey("7")), - key("i", moreKey("8")), - key("o", moreKey("9")), - key("p", moreKey("0"))) + key("q", additionalMoreKey("1")), + key("w", additionalMoreKey("2")), + key("e", additionalMoreKey("3")), + key("r", additionalMoreKey("4")), + key("t", additionalMoreKey("5")), + key("y", additionalMoreKey("6")), + key("u", additionalMoreKey("7")), + key("i", additionalMoreKey("8")), + key("o", additionalMoreKey("9")), + key("p", additionalMoreKey("0"))) .setKeysOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l") .setKeysOfRow(3, "z", "x", "c", "v", "b", "n", "m") .build(); diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Qwertz.java b/tests/src/com/android/inputmethod/keyboard/layout/Qwertz.java index 6fce3f6d9..26ba6cffb 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/Qwertz.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/Qwertz.java @@ -34,16 +34,16 @@ public final class Qwertz extends LayoutBase { private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() .setKeysOfRow(1, - key("q", moreKey("1")), - key("w", moreKey("2")), - key("e", moreKey("3")), - key("r", moreKey("4")), - key("t", moreKey("5")), - key("z", moreKey("6")), - key("u", moreKey("7")), - key("i", moreKey("8")), - key("o", moreKey("9")), - key("p", moreKey("0"))) + key("q", additionalMoreKey("1")), + key("w", additionalMoreKey("2")), + key("e", additionalMoreKey("3")), + key("r", additionalMoreKey("4")), + key("t", additionalMoreKey("5")), + key("z", additionalMoreKey("6")), + key("u", additionalMoreKey("7")), + key("i", additionalMoreKey("8")), + key("o", additionalMoreKey("9")), + key("p", additionalMoreKey("0"))) .setKeysOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l") .setKeysOfRow(3, "y", "x", "c", "v", "b", "n", "m") .build(); diff --git a/tests/src/com/android/inputmethod/keyboard/layout/SouthSlavic.java b/tests/src/com/android/inputmethod/keyboard/layout/SouthSlavic.java index 4f8911baa..be8b435d4 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/SouthSlavic.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/SouthSlavic.java @@ -63,24 +63,24 @@ public final class SouthSlavic extends LayoutBase { private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() .setKeysOfRow(1, // U+0459: "љ" CYRILLIC SMALL LETTER LJE - key("\u0459", moreKey("1")), + key("\u0459", additionalMoreKey("1")), // U+045A: "њ" CYRILLIC SMALL LETTER NJE - key("\u045A", moreKey("2")), + key("\u045A", additionalMoreKey("2")), // U+0435: "е" CYRILLIC SMALL LETTER IE - key("\u0435", moreKey("3")), + key("\u0435", additionalMoreKey("3")), // U+0440: "р" CYRILLIC SMALL LETTER ER - key("\u0440", moreKey("4")), + key("\u0440", additionalMoreKey("4")), // U+0442: "т" CYRILLIC SMALL LETTER TE - key("\u0442", moreKey("5")), - key(ROW1_6, moreKey("6")), + key("\u0442", additionalMoreKey("5")), + key(ROW1_6, additionalMoreKey("6")), // U+0443: "у" CYRILLIC SMALL LETTER U - key("\u0443", moreKey("7")), + key("\u0443", additionalMoreKey("7")), // U+0438: "и" CYRILLIC SMALL LETTER I - key("\u0438", moreKey("8")), + key("\u0438", additionalMoreKey("8")), // U+043E: "о" CYRILLIC SMALL LETTER O - key("\u043E", moreKey("9")), + key("\u043E", additionalMoreKey("9")), // U+043F: "п" CYRILLIC SMALL LETTER PE - key("\u043F", moreKey("0")), + key("\u043F", additionalMoreKey("0")), // U+0448: "ш" CYRILLIC SMALL LETTER SHA "\u0448") .setKeysOfRow(2, diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Spanish.java b/tests/src/com/android/inputmethod/keyboard/layout/Spanish.java index 9e6556089..225b9f604 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/Spanish.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/Spanish.java @@ -36,16 +36,16 @@ public final class Spanish extends LayoutBase { private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() .setKeysOfRow(1, - key("q", moreKey("1")), - key("w", moreKey("2")), - key("e", moreKey("3")), - key("r", moreKey("4")), - key("t", moreKey("5")), - key("y", moreKey("6")), - key("u", moreKey("7")), - key("i", moreKey("8")), - key("o", moreKey("9")), - key("p", moreKey("0"))) + key("q", additionalMoreKey("1")), + key("w", additionalMoreKey("2")), + key("e", additionalMoreKey("3")), + key("r", additionalMoreKey("4")), + key("t", additionalMoreKey("5")), + key("y", additionalMoreKey("6")), + key("u", additionalMoreKey("7")), + key("i", additionalMoreKey("8")), + key("o", additionalMoreKey("9")), + key("p", additionalMoreKey("0"))) .setKeysOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l", ROW2_10) .setKeysOfRow(3, "z", "x", "c", "v", "b", "n", "m") .build(); diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Swiss.java b/tests/src/com/android/inputmethod/keyboard/layout/Swiss.java index c6562e245..01a602054 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/Swiss.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/Swiss.java @@ -38,16 +38,16 @@ public final class Swiss extends LayoutBase { private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() .setKeysOfRow(1, - key("q", moreKey("1")), - key("w", moreKey("2")), - key("e", moreKey("3")), - key("r", moreKey("4")), - key("t", moreKey("5")), - key("z", moreKey("6")), - key("u", moreKey("7")), - key("i", moreKey("8")), - key("o", moreKey("9")), - key("p", moreKey("0")), + key("q", additionalMoreKey("1")), + key("w", additionalMoreKey("2")), + key("e", additionalMoreKey("3")), + key("r", additionalMoreKey("4")), + key("t", additionalMoreKey("5")), + key("z", additionalMoreKey("6")), + key("u", additionalMoreKey("7")), + key("i", additionalMoreKey("8")), + key("o", additionalMoreKey("9")), + key("p", additionalMoreKey("0")), ROW1_11) .setKeysOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l", ROW2_10, ROW2_11) .setKeysOfRow(3, "y", "x", "c", "v", "b", "n", "m") diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java index f9427bc2d..cce9d5f39 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java @@ -17,6 +17,7 @@ package com.android.inputmethod.keyboard.layout.expected; import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey.ExpectedAdditionalMoreKey; import com.android.inputmethod.latin.Constants; import com.android.inputmethod.latin.utils.StringUtils; @@ -61,6 +62,15 @@ public abstract class AbstractLayoutBase { return ExpectedKey.newInstance(key.getVisual(), key.getOutput(), moreKeys); } + // Helper method to create an {@link ExpectedAdditionalMoreKey} object for an + // "additional more key" that has the label. + // The additional more keys can be defined independently from other more keys. The position of + // the additional more keys in the long press popup keyboard can be controlled by specifying + // special marker "%" in the usual more keys definitions. + public static ExpectedAdditionalMoreKey additionalMoreKey(final String label) { + return ExpectedAdditionalMoreKey.newInstance(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); diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKey.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKey.java index 98c08aded..ad08ba5a6 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKey.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKey.java @@ -18,7 +18,9 @@ package com.android.inputmethod.keyboard.layout.expected; import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.internal.MoreKeySpec; +import com.android.inputmethod.latin.utils.CollectionUtils; +import java.util.ArrayList; import java.util.Arrays; import java.util.Locale; @@ -29,44 +31,73 @@ public class ExpectedKey { static ExpectedKey EMPTY_KEY = newInstance(""); // A key that has a string label and may have "more keys". - static ExpectedKey newInstance(final String label, final ExpectedKey ... moreKeys) { + static ExpectedKey newInstance(final String label, final ExpectedKey... moreKeys) { return newInstance(label, label, moreKeys); } // A key that has a string label and a different output text and may have "more keys". static ExpectedKey newInstance(final String label, final String outputText, - final ExpectedKey ... moreKeys) { + final ExpectedKey... moreKeys) { return newInstance(ExpectedKeyVisual.newInstance(label), ExpectedKeyOutput.newInstance(outputText), moreKeys); } // A key that has a string label and a code point output and may have "more keys". static ExpectedKey newInstance(final String label, final int code, - final ExpectedKey ... moreKeys) { + final ExpectedKey... moreKeys) { return newInstance(ExpectedKeyVisual.newInstance(label), 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) { + 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) { + final ExpectedKey... moreKeys) { return newInstance(ExpectedKeyVisual.newInstance(iconId), ExpectedKeyOutput.newInstance(code), moreKeys); } static ExpectedKey newInstance(final ExpectedKeyVisual visual, final ExpectedKeyOutput output, - final ExpectedKey ... moreKeys) { + final ExpectedKey... moreKeys) { if (moreKeys.length == 0) { return new ExpectedKey(visual, output); } - return new ExpectedKeyWithMoreKeys(visual, output, moreKeys); + // The more keys are the extra keys that the main keyboard key may have in its long press + // popup keyboard. + // The additional more keys can be defined independently from other more keys. + // The position of the additional more keys in the long press popup keyboard can be + // controlled by specifying special marker "%" in the usual more keys definitions. + final ArrayList moreKeysList = CollectionUtils.newArrayList(); + final ArrayList additionalMoreKeys = + CollectionUtils.newArrayList(); + int firstAdditionalMoreKeyIndex = -1; + for (int index = 0; index < moreKeys.length; index++) { + final ExpectedKey moreKey = moreKeys[index]; + if (moreKey instanceof ExpectedAdditionalMoreKey) { + additionalMoreKeys.add((ExpectedAdditionalMoreKey) moreKey); + if (firstAdditionalMoreKeyIndex < 0) { + firstAdditionalMoreKeyIndex = index; + } + } else { + moreKeysList.add(moreKey); + } + } + if (additionalMoreKeys.isEmpty()) { + return new ExpectedKeyWithMoreKeys(visual, output, moreKeys); + } + final ExpectedKey[] moreKeysArray = moreKeysList.toArray( + new ExpectedKey[moreKeysList.size()]); + final ExpectedAdditionalMoreKey[] additionalMoreKeysArray = additionalMoreKeys.toArray( + new ExpectedAdditionalMoreKey[additionalMoreKeys.size()]); + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + visual, output, moreKeysArray, firstAdditionalMoreKeyIndex, + additionalMoreKeysArray); } private static final ExpectedKey[] EMPTY_KEYS = new ExpectedKey[0]; @@ -89,6 +120,27 @@ public class ExpectedKey { return EMPTY_KEYS; } + public ExpectedKey setMoreKeys(final ExpectedKey... moreKeys) { + return newInstance(mVisual, mOutput, moreKeys); + } + + public ExpectedKey setAdditionalMoreKeys( + final ExpectedAdditionalMoreKey... additionalMoreKeys) { + if (additionalMoreKeys.length == 0) { + return this; + } + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + mVisual, mOutput, EMPTY_KEYS, 0 /* additionalMoreKeysIndex */, additionalMoreKeys); + } + + public ExpectedKey setAdditionalMoreKeysIndex(final int additionalMoreKeysIndex) { + if (additionalMoreKeysIndex == 0) { + return this; + } + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + mVisual, mOutput, EMPTY_KEYS, additionalMoreKeysIndex); + } + protected ExpectedKey(final ExpectedKeyVisual visual, final ExpectedKeyOutput output) { mVisual = visual; mOutput = output; @@ -110,14 +162,14 @@ public class ExpectedKey { @Override public boolean equals(final Object object) { if (object instanceof ExpectedKey) { - final ExpectedKey key = (ExpectedKey)object; + final ExpectedKey key = (ExpectedKey) object; return mVisual.equalsTo(key.mVisual) && mOutput.equalsTo(key.mOutput) && Arrays.equals(getMoreKeys(), key.getMoreKeys()); } return false; } - private static int hashCode(final Object ... objects) { + private static int hashCode(final Object... objects) { return Arrays.hashCode(objects); } @@ -134,14 +186,43 @@ public class ExpectedKey { return mVisual + "|" + mOutput; } + /** + * This class represents an expected "additional more key". + * + * The additional more keys can be defined independently from other more keys. The position of + * the additional more keys in the long press popup keyboard can be controlled by specifying + * special marker "%" in the usual more keys definitions. + */ + public static class ExpectedAdditionalMoreKey extends ExpectedKey { + public static ExpectedAdditionalMoreKey newInstance(final String label) { + return new ExpectedAdditionalMoreKey(ExpectedKeyVisual.newInstance(label), + ExpectedKeyOutput.newInstance(label)); + } + + public static ExpectedAdditionalMoreKey newInstance(final ExpectedKey key) { + return new ExpectedAdditionalMoreKey(key.getVisual(), key.getOutput()); + } + + ExpectedAdditionalMoreKey(final ExpectedKeyVisual visual, final ExpectedKeyOutput output) { + super(visual, output); + } + + @Override + public ExpectedAdditionalMoreKey toUpperCase(final Locale locale) { + final ExpectedKey upperCaseKey = super.toUpperCase(locale); + return new ExpectedAdditionalMoreKey( + upperCaseKey.getVisual(), upperCaseKey.getOutput()); + } + } + /** * This class represents an expected key that has "more keys". */ - private static final class ExpectedKeyWithMoreKeys extends ExpectedKey { + private static class ExpectedKeyWithMoreKeys extends ExpectedKey { private final ExpectedKey[] mMoreKeys; - ExpectedKeyWithMoreKeys(final ExpectedKeyVisual visual, - final ExpectedKeyOutput output, final ExpectedKey ... moreKeys) { + ExpectedKeyWithMoreKeys(final ExpectedKeyVisual visual, final ExpectedKeyOutput output, + final ExpectedKey... moreKeys) { super(visual, output); mMoreKeys = moreKeys; } @@ -161,16 +242,37 @@ public class ExpectedKey { return mMoreKeys; } + @Override + public ExpectedKey setAdditionalMoreKeys( + final ExpectedAdditionalMoreKey... additionalMoreKeys) { + if (additionalMoreKeys.length == 0) { + return this; + } + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + getVisual(), getOutput(), mMoreKeys, 0 /* additionalMoreKeysIndex */, + additionalMoreKeys); + } + + @Override + public ExpectedKey setAdditionalMoreKeysIndex(final int additionalMoreKeysIndex) { + if (additionalMoreKeysIndex == 0) { + return this; + } + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + getVisual(), getOutput(), mMoreKeys, additionalMoreKeysIndex); + } + @Override public boolean equalsTo(final Key key) { if (getVisual().equalsTo(key) && getOutput().equalsTo(key)) { - final MoreKeySpec[] moreKeys = key.getMoreKeys(); + final MoreKeySpec[] moreKeySpecs = key.getMoreKeys(); + final ExpectedKey[] moreKeys = getMoreKeys(); // This key should have at least one "more key". - if (moreKeys == null || moreKeys.length != mMoreKeys.length) { + if (moreKeySpecs == null || moreKeySpecs.length != moreKeys.length) { return false; } - for (int index = 0; index < moreKeys.length; index++) { - if (!mMoreKeys[index].equalsTo(moreKeys[index])) { + for (int index = 0; index < moreKeySpecs.length; index++) { + if (!moreKeys[index].equalsTo(moreKeySpecs[index])) { return false; } } @@ -187,7 +289,77 @@ public class ExpectedKey { @Override public String toString() { - return super.toString() + "^" + Arrays.toString(mMoreKeys); + return super.toString() + "^" + Arrays.toString(getMoreKeys()); + } + } + + /** + * This class represents an expected key that has "more keys" and "additional more keys". + */ + private static final class ExpectedKeyWithMoreKeysAndAdditionalMoreKeys + extends ExpectedKeyWithMoreKeys { + private final ExpectedAdditionalMoreKey[] mAdditionalMoreKeys; + private final int mAdditionalMoreKeysIndex; + + ExpectedKeyWithMoreKeysAndAdditionalMoreKeys(final ExpectedKeyVisual visual, + final ExpectedKeyOutput output, final ExpectedKey[] moreKeys, + final int additionalMoreKeysIndex, + final ExpectedAdditionalMoreKey... additionalMoreKeys) { + super(visual, output, moreKeys); + mAdditionalMoreKeysIndex = additionalMoreKeysIndex; + mAdditionalMoreKeys = additionalMoreKeys; + } + + @Override + public ExpectedKey setMoreKeys(final ExpectedKey... moreKeys) { + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + getVisual(), getOutput(), moreKeys, mAdditionalMoreKeysIndex, + mAdditionalMoreKeys); + } + + @Override + public ExpectedKey setAdditionalMoreKeys( + final ExpectedAdditionalMoreKey... additionalMoreKeys) { + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + getVisual(), getOutput(), super.getMoreKeys(), mAdditionalMoreKeysIndex, + additionalMoreKeys); + } + + @Override + public ExpectedKey setAdditionalMoreKeysIndex(final int additionalMoreKeysIndex) { + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + getVisual(), getOutput(), super.getMoreKeys(), additionalMoreKeysIndex, + mAdditionalMoreKeys); + } + + @Override + public ExpectedKey toUpperCase(final Locale locale) { + final ExpectedKey[] moreKeys = super.getMoreKeys(); + final ExpectedKey[] upperCaseMoreKeys = new ExpectedKey[moreKeys.length]; + for (int i = 0; i < moreKeys.length; i++) { + upperCaseMoreKeys[i] = moreKeys[i].toUpperCase(locale); + } + final ExpectedAdditionalMoreKey[] upperCaseAdditionalMoreKeys = + new ExpectedAdditionalMoreKey[mAdditionalMoreKeys.length]; + for (int i = 0; i < mAdditionalMoreKeys.length; i++) { + upperCaseAdditionalMoreKeys[i] = mAdditionalMoreKeys[i].toUpperCase(locale); + } + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + getVisual().toUpperCase(locale), getOutput().toUpperCase(locale), + upperCaseMoreKeys, mAdditionalMoreKeysIndex, upperCaseAdditionalMoreKeys); + } + + @Override + public ExpectedKey[] getMoreKeys() { + final ExpectedKey[] moreKeys = super.getMoreKeys(); + final ExpectedKey[] edittedMoreKeys = Arrays.copyOf( + moreKeys, moreKeys.length + mAdditionalMoreKeys.length); + System.arraycopy(edittedMoreKeys, mAdditionalMoreKeysIndex, + edittedMoreKeys, mAdditionalMoreKeysIndex + mAdditionalMoreKeys.length, + moreKeys.length - mAdditionalMoreKeysIndex); + System.arraycopy(mAdditionalMoreKeys, 0, edittedMoreKeys, mAdditionalMoreKeysIndex, + mAdditionalMoreKeys.length); + return edittedMoreKeys; } } } diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java index c73fbf7b2..f068ad11d 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java @@ -163,11 +163,38 @@ public final class ExpectedKeyboardBuilder extends AbstractKeyboardBuilder