diff options
Diffstat (limited to 'tests/src')
13 files changed, 558 insertions, 24 deletions
diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java index e691639a8..bbffc8dd5 100644 --- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java +++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetSubtypesCountTests.java @@ -25,8 +25,8 @@ import java.util.ArrayList; @SmallTest public class KeyboardLayoutSetSubtypesCountTests extends KeyboardLayoutSetTestsBase { - private static final int NUMBER_OF_SUBTYPES = 63; - private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 40; + private static final int NUMBER_OF_SUBTYPES = 66; + private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 42; private static final int NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES = 2; private static String toString(final ArrayList<InputMethodSubtype> subtypeList) { diff --git a/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecSplitTests.java b/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecSplitTests.java index 42a94f420..d01c2ec79 100644 --- a/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecSplitTests.java +++ b/tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecSplitTests.java @@ -51,10 +51,13 @@ public class MoreKeySpecSplitTests extends InstrumentationTestCase { }.runInLocale(targetContext.getResources(), TEST_LOCALE); final String[] testResourceNames = getAllResourceIdNames( com.android.inputmethod.latin.tests.R.string.class); - mTextsSet.loadStringResourcesInternal(instrumentation.getContext(), testResourceNames, + final Context testContext = instrumentation.getContext(); + final Resources testRes = testContext.getResources(); + final String testResPackageName = testRes.getResourcePackageName( // This dummy raw resource is needed to be able to load string resources from a test // APK successfully. com.android.inputmethod.latin.tests.R.raw.dummy_resource_for_testing); + mTextsSet.loadStringResourcesInternal(testRes, testResourceNames, testResPackageName); } private static String[] getAllResourceIdNames(final Class<?> resourceIdClass) { diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Arabic.java b/tests/src/com/android/inputmethod/keyboard/layout/Arabic.java index 838f98768..b0493d3f1 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/Arabic.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/Arabic.java @@ -72,7 +72,7 @@ public final class Arabic extends LayoutBase { public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) { if (isPhone) { // U+060C: "،" ARABIC COMMA - return joinKeys(key("\u060C", joinMoreKeys(",", SETTINGS_KEY))); + return joinKeys(key("\u060C", SETTINGS_KEY)); } return super.getKeysLeftToSpacebar(isPhone); } @@ -312,7 +312,7 @@ public final class Arabic extends LayoutBase { // U+00BF: "¿" INVERTED QUESTION MARK .replaceKeyOfLabel("?", key("\u061F", joinMoreKeys("?", "\u00BF"))) // U+060C: "،" ARABIC COMMA - .replaceKeyOfLabel(",", key("\u060C", moreKey(","))) + .replaceKeyOfLabel(",", "\u060C") // U+FD3E: "﴾" ORNATE LEFT PARENTHESIS // U+FD3F: "﴿" ORNATE RIGHT PARENTHESIS .replaceKeyOfLabel("(", key("(", ")", @@ -342,7 +342,7 @@ public final class Arabic extends LayoutBase { // U+266A: "♪" EIGHTH NOTE .setMoreKeysOf("\u2022", "\u266A") // U+060C: "،" ARABIC COMMA - .replaceKeyOfLabel(",", key("\u060C", moreKey(","))) + .replaceKeyOfLabel(",", "\u060C") .build(); } } diff --git a/tests/src/com/android/inputmethod/keyboard/layout/ArmenianPhonetic.java b/tests/src/com/android/inputmethod/keyboard/layout/ArmenianPhonetic.java new file mode 100644 index 000000000..204bb01f7 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/ArmenianPhonetic.java @@ -0,0 +1,208 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.keyboard.layout; + +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import com.android.inputmethod.latin.Constants; + +import java.util.Locale; + +/** + * The Armenian Phonetic alphabet keyboard. + */ +public final class ArmenianPhonetic extends LayoutBase { + private static final String LAYOUT_NAME = "armenian_phonetic"; + + public ArmenianPhonetic(final LayoutCustomizer customizer) { + super(customizer, ArmenianSymbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + public static class ArmenianPhoneticCustomizer extends LayoutCustomizer { + public ArmenianPhoneticCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getAlphabetKey() { return ARMENIAN_ALPHABET_KEY; } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + if (isPhone) { + return EMPTY_KEYS; + } + // U+055C: "՜" ARMENIAN EXCLAMATION MARK + // U+00A1: "¡" INVERTED EXCLAMATION MARK + // U+055E: "՞" ARMENIAN QUESTION MARK + // U+00BF: "¿" INVERTED QUESTION MARK + return joinKeys(key("!", joinMoreKeys("\u055C", "\u00A1")), + key("?", joinMoreKeys("\u055E", "\u00BF")), + SHIFT_KEY); + } + + @Override + public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) { + // U+0589: "։" ARMENIAN FULL STOP + // U+055D: "՝" ARMENIAN COMMA + final ExpectedKey fullStopKey = key("\u0589", getPunctuationMoreKeys(isPhone)); + return isPhone ? joinKeys(fullStopKey) : joinKeys("\u055D", fullStopKey); + } + + @Override + public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { + return ARMENIAN_PUNCTUATION_MORE_KEYS; + } + + // U+0531: "Ա" ARMENIAN CAPITAL LETTER AYB + // U+0532: "Բ" ARMENIAN CAPITAL LETTER BEN + // U+0533: "Գ" ARMENIAN CAPITAL LETTER GIM + private static final ExpectedKey ARMENIAN_ALPHABET_KEY = key( + "\u0531\u0532\u0533", Constants.CODE_SWITCH_ALPHA_SYMBOL); + + // U+055E: "՞" ARMENIAN QUESTION MARK + // U+055C: "՜" ARMENIAN EXCLAMATION MARK + // U+055A: "՚" ARMENIAN APOSTROPHE + // U+0559: "ՙ" ARMENIAN MODIFIER LETTER LEFT HALF RING + // U+055D: "՝" ARMENIAN COMMA + // U+055B: "՛" ARMENIAN EMPHASIS MARK + // U+058A: "֊" ARMENIAN HYPHEN + // U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK + // U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK + // U+055F: "՟" ARMENIAN ABBREVIATION MARK + private static final ExpectedKey[] ARMENIAN_PUNCTUATION_MORE_KEYS = joinMoreKeys( + ",", "\u055E", "\u055C", ".", "\u055A", "\u0559", "?", "!", + "\u055D", "\u055B", "\u058A", "\u00BB", "\u00AB", "\u055F", ";", ":"); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + if (isPhone) { + // U+056D: "խ" ARMENIAN SMALL LETTER XEH + // U+0577: "շ" ARMENIAN SMALL LETTER SHA + builder.addKeysOnTheRightOfRow(3, "\u056D") + .addKeysOnTheRightOfRow(4, "\u0577"); + } else { + // U+056D: "խ" ARMENIAN SMALL LETTER XEH + // U+0577: "շ" ARMENIAN SMALL LETTER SHA + builder.addKeysOnTheRightOfRow(2, "\u056D") + .addKeysOnTheRightOfRow(3, "\u0577"); + } + return builder.build(); + } + + // Helper method to create alphabet layout by adding special function keys. + @Override + ExpectedKeyboardBuilder convertCommonLayoutToKeyboard(final ExpectedKeyboardBuilder builder, + final boolean isPhone) { + final LayoutCustomizer customizer = getCustomizer(); + builder.setKeysOfRow(5, (Object[])customizer.getSpaceKeys(isPhone)); + builder.addKeysOnTheLeftOfRow(5, (Object[])customizer.getKeysLeftToSpacebar(isPhone)); + builder.addKeysOnTheRightOfRow(5, (Object[])customizer.getKeysRightToSpacebar(isPhone)); + if (isPhone) { + builder.addKeysOnTheRightOfRow(4, DELETE_KEY) + .addKeysOnTheLeftOfRow(5, customizer.getSymbolsKey()) + .addKeysOnTheRightOfRow(5, key(ENTER_KEY, EMOJI_KEY)); + } else { + builder.addKeysOnTheRightOfRow(1, DELETE_KEY) + .addKeysOnTheRightOfRow(3, ENTER_KEY) + .addKeysOnTheLeftOfRow(5, customizer.getSymbolsKey(), SETTINGS_KEY) + .addKeysOnTheRightOfRow(5, EMOJI_KEY); + } + builder.addKeysOnTheLeftOfRow(4, (Object[])customizer.getLeftShiftKeys(isPhone)) + .addKeysOnTheRightOfRow(4, (Object[])customizer.getRightShiftKeys(isPhone)); + return builder; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0567: "է" ARMENIAN SMALL LETTER EH + key("\u0567", moreKey("1")), + // U+0569: "թ" ARMENIAN SMALL LETTER TO + key("\u0569", moreKey("2")), + // U+0583: "փ" ARMENIAN SMALL LETTER PIWR + key("\u0583", moreKey("3")), + // U+0571: "ձ" ARMENIAN SMALL LETTER JA + key("\u0571", moreKey("4")), + // U+057B: "ջ" ARMENIAN SMALL LETTER JHEH + key("\u057B", moreKey("5")), + // U+0580: "ր" ARMENIAN SMALL LETTER REH + key("\u0580", moreKey("6")), + // U+0579: "չ" ARMENIAN SMALL LETTER CHA + key("\u0579", moreKey("7")), + // U+0573: "ճ" ARMENIAN SMALL LETTER CHEH + key("\u0573", moreKey("8")), + // U+056A: "ժ" ARMENIAN SMALL LETTER ZHE + key("\u056A", moreKey("9")), + // U+056E: "ծ" ARMENIAN SMALL LETTER CA + key("\u056E", moreKey("0"))) + .setKeysOfRow(2, + // U+0584: "ք" ARMENIAN SMALL LETTER KEH + // U+0578: "ո" ARMENIAN SMALL LETTER VO + "\u0584", "\u0578", + // U+0565: "ե" ARMENIAN SMALL LETTER ECH + // U+0587: "և" ARMENIAN SMALL LIGATURE ECH YIWN + key("\u0565", moreKey("\u0587")), + // U+057C: "ռ" ARMENIAN SMALL LETTER RA + // U+057F: "տ" ARMENIAN SMALL LETTER TIWN + // U+0568: "ը" ARMENIAN SMALL LETTER ET + // U+0582: "ւ" ARMENIAN SMALL LETTER YIWN + // U+056B: "ի" ARMENIAN SMALL LETTER INI + // U+0585: "օ" ARMENIAN SMALL LETTER OH + // U+057A: "պ" ARMENIAN SMALL LETTER PEH + "\u057C", "\u057F", "\u0568", "\u0582", "\u056B", "\u0585", "\u057A") + .setKeysOfRow(3, + // U+0561: "ա" ARMENIAN SMALL LETTER AYB + // U+057D: "ս" ARMENIAN SMALL LETTER SEH + // U+0564: "դ" ARMENIAN SMALL LETTER DA + // U+0586: "ֆ" ARMENIAN SMALL LETTER FEH + // U+0563: "գ" ARMENIAN SMALL LETTER GIM + // U+0570: "հ" ARMENIAN SMALL LETTER HO + // U+0575: "յ" ARMENIAN SMALL LETTER YI + // U+056F: "կ" ARMENIAN SMALL LETTER KEN + // U+056C: "լ" ARMENIAN SMALL LETTER LIWN + "\u0561", "\u057D", "\u0564", "\u0586", "\u0563", "\u0570", "\u0575", "\u056F", + "\u056C") + .setKeysOfRow(4, + // U+0566: "զ" ARMENIAN SMALL LETTER ZA + // U+0572: "ղ" ARMENIAN SMALL LETTER GHAD + // U+0581: "ց" ARMENIAN SMALL LETTER CO + // U+057E: "վ" ARMENIAN SMALL LETTER VEW + // U+0562: "բ" ARMENIAN SMALL LETTER BEN + // U+0576: "ն" ARMENIAN SMALL LETTER NOW + // U+0574: "մ" ARMENIAN SMALL LETTER MEN + "\u0566", "\u0572", "\u0581", "\u057E", "\u0562", "\u0576", "\u0574") + .build(); + + private static final class ArmenianSymbols extends Symbols { + public ArmenianSymbols(final LayoutCustomizer customizer) { super(customizer); } + + @Override + public ExpectedKey[][] getLayout(final boolean isPhone) { + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder( + super.getLayout(isPhone)); + // U+055C: "՜" ARMENIAN EXCLAMATION MARK + // U+00A1: "¡" INVERTED EXCLAMATION MARK + // U+055E: "՞" ARMENIAN QUESTION MARK + // U+00BF: "¿" INVERTED QUESTION MARK + builder.setMoreKeysOf("!", "\u055C", "\u00A1") + .setMoreKeysOf("?", "\u055E", "\u00BF"); + return builder.build(); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Farsi.java b/tests/src/com/android/inputmethod/keyboard/layout/Farsi.java index 6da817fd9..a0070891a 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/Farsi.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/Farsi.java @@ -70,7 +70,7 @@ public final class Farsi extends LayoutBase { public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) { if (isPhone) { // U+060C: "،" ARABIC COMMA - return joinKeys(key("\u060C", joinMoreKeys(",", SETTINGS_KEY))); + return joinKeys(key("\u060C", SETTINGS_KEY)); } return super.getKeysLeftToSpacebar(isPhone); } @@ -315,7 +315,7 @@ public final class Farsi extends LayoutBase { // U+00BF: "¿" INVERTED QUESTION MARK .replaceKeyOfLabel("?", key("\u061F", joinMoreKeys("?", "\u00BF"))) // U+060C: "،" ARABIC COMMA - .replaceKeyOfLabel(",", key("\u060C", moreKey(","))) + .replaceKeyOfLabel(",", "\u060C") // U+FD3E: "﴾" ORNATE LEFT PARENTHESIS // U+FD3F: "﴿" ORNATE RIGHT PARENTHESIS .replaceKeyOfLabel("(", key("(", ")", @@ -345,7 +345,7 @@ public final class Farsi extends LayoutBase { // U+266A: "♪" EIGHTH NOTE .setMoreKeysOf("\u2022", "\u266A") // U+060C: "،" ARABIC COMMA - .replaceKeyOfLabel(",", key("\u060C", moreKey(","))) + .replaceKeyOfLabel(",", "\u060C") // U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK // U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK // U+2264: "≤" LESS-THAN OR EQUAL TO diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Hebrew.java b/tests/src/com/android/inputmethod/keyboard/layout/Hebrew.java index 83446dee3..552f0d3d5 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/Hebrew.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/Hebrew.java @@ -91,12 +91,12 @@ public final class Hebrew extends LayoutBase { private static final ExpectedKey CURRENCY_NEW_SHEQEL = key("\u20AA", Symbols.CURRENCY_GENERIC_MORE_KEYS); private static final ExpectedKey[] RTL_PHONE_PUNCTUATION_MORE_KEYS = joinKeys( - ";", "/", key("(", ")"), key(")", "("), "#", "!", ",", "?", - "&", "%", "+", "\"", "-", ":", "'", "@"); + ",", "?", "!", "#", key(")", "("), key("(", ")"), "/", ";", + "'", "@", ":", "-", "\"", "+", "%", "&"); // Punctuation more keys for tablet form factor. private static final ExpectedKey[] RTL_TABLET_PUNCTUATION_MORE_KEYS = joinKeys( - ";", "/", key("(", ")"), key(")", "("), "#", "'", ",", - "&", "%", "+", "\"", "-", ":", "@"); + ",", "'", "#", key(")", "("), key("(", ")"), "/", ";", + "@", ":", "-", "\"", "+", "%", "&"); } @Override diff --git a/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java b/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java index d870931ac..09cc8f9ca 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java @@ -270,13 +270,12 @@ public abstract class LayoutBase extends AbstractLayoutBase { // Punctuation more keys for phone form factor. public static final ExpectedKey[] PHONE_PUNCTUATION_MORE_KEYS = joinKeys( - ";", "/", "(", ")", "#", "!", ",", "?", - "&", "%", "+", "\"", "-", ":", "'", "@"); - + ",", "?", "!", "#", ")", "(", "/", ";", + "'", "@", ":", "-", "\"", "+", "%", "&"); // Punctuation more keys for tablet form factor. public static final ExpectedKey[] TABLET_PUNCTUATION_MORE_KEYS = joinKeys( - ";", "/", "(", ")", "#", "'", ",", - "&", "%", "+", "\"", "-", ":", "@"); + ",", "'", "#", ")", "(", "/", ";", + "@", ":", "-", "\"", "+", "%", "&"); /** * Helper method to create alphabet layout adding special function keys. diff --git a/tests/src/com/android/inputmethod/keyboard/layout/PcQwerty.java b/tests/src/com/android/inputmethod/keyboard/layout/PcQwerty.java new file mode 100644 index 000000000..9da6dcc44 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/PcQwerty.java @@ -0,0 +1,227 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.keyboard.layout; + +import com.android.inputmethod.keyboard.KeyboardId; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * The PC QWERTY alphabet keyboard. + */ +public final class PcQwerty extends LayoutBase { + private static final String LAYOUT_NAME = "pcqwerty"; + + public PcQwerty(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + public static class PcQwertyCustomizer extends LayoutCustomizer { + public PcQwertyCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) { + return joinKeys(SHIFT_KEY); + } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return joinKeys(SHIFT_KEY); + } + + @Override + public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) { + return joinKeys(SETTINGS_KEY); + } + + @Override + public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) { + return isPhone ? joinKeys(key(ENTER_KEY, EMOJI_KEY)) : joinKeys(EMOJI_KEY); + } + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { + final LayoutCustomizer customizer = getCustomizer(); + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + customizer.setAccentedLetters(builder); + builder.replaceKeyOfLabel(ROW1_1, key("`", moreKey("~"))) + .replaceKeyOfLabel(ROW2_11, key("[", moreKey("{"))) + .replaceKeyOfLabel(ROW2_12, key("]", moreKey("}"))) + .replaceKeyOfLabel(ROW2_13, key("\\", moreKey("|"))) + .replaceKeyOfLabel(ROW3_10, key(";", moreKey(":"))) + .replaceKeyOfLabel(ROW3_11, key("'", joinMoreKeys(additionalMoreKey("\""), + customizer.getDoubleQuoteMoreKeys(), + customizer.getSingleQuoteMoreKeys()))) + .setAdditionalMoreKeysPositionOf("'", 4) + .replaceKeyOfLabel(ROW4_8, key(",", moreKey("<"))) + .replaceKeyOfLabel(ROW4_9, key(".", moreKey(">"))) + // U+00BF: "¿" INVERTED QUESTION MARK + .replaceKeyOfLabel(ROW4_10, key("/", joinMoreKeys("?", "\u00BF"))); + if (isPhone) { + // U+221E: "∞" INFINITY + // U+2260: "≠" NOT EQUAL TO + // U+2248: "≈" ALMOST EQUAL TO + builder.replaceKeyOfLabel(ROW1_13, key("=", + joinMoreKeys("\u221E", "\u2260", "\u2248", "+"))); + } else { + // U+221E: "∞" INFINITY + // U+2260: "≠" NOT EQUAL TO + // U+2248: "≈" ALMOST EQUAL TO + builder.replaceKeyOfLabel(ROW1_13, key("=", + joinMoreKeys("+", "\u221E", "\u2260", "\u2248"))); + } + return builder.build(); + } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(final boolean isPhone, final int elementId) { + final ExpectedKeyboardBuilder builder; + if (elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED + || elementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED) { + builder = new ExpectedKeyboardBuilder(getCommonAlphabetLayout(isPhone)); + } else { + builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + final LayoutCustomizer customizer = getCustomizer(); + customizer.setAccentedLetters(builder); + builder.setKeysOfRow(1, + "~", + // U+00A1: "¡" INVERTED EXCLAMATION MARK + key("!", moreKey("\u00A1")), + "@", "#", + customizer.getCurrencyKey(), + // U+2030: "‰" PER MILLE SIGN + key("%", moreKey("\u2030")), + "^", "&", + // U+2020: "†" DAGGER + // U+2021: "‡" DOUBLE DAGGER + // U+2605: "★" BLACK STAR + key("*", joinMoreKeys("\u2020", "\u2021", "\u2605")), + "(", ")", "_", + // U+00B1: "±" PLUS-MINUS SIGN + // U+00D7: "×" MULTIPLICATION SIGN + // U+00F7: "÷" DIVISION SIGN + // U+221A: "√" SQUARE ROOT + key("+", joinMoreKeys("\u00B1", "\u00D7", "\u00F7", "\u221A"))) + .replaceKeyOfLabel(ROW2_11, key("{")) + .replaceKeyOfLabel(ROW2_12, key("}")) + .replaceKeyOfLabel(ROW2_13, key("|")) + .replaceKeyOfLabel(ROW3_10, key(":")) + .replaceKeyOfLabel(ROW3_11, key("\"", joinMoreKeys( + customizer.getDoubleQuoteMoreKeys(), + customizer.getSingleQuoteMoreKeys()))) + // U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK + // U+2264: "≤" LESS-THAN OR EQUAL TO + // U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK + .replaceKeyOfLabel(ROW4_8, 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 + .replaceKeyOfLabel(ROW4_9, key(">", joinMoreKeys("\u203A", "\u2265", "\u00BB"))) + // U+00BF: "¿" INVERTED QUESTION MARK + .replaceKeyOfLabel(ROW4_10, key("?", moreKey("\u00BF"))); + } + builder.toUpperCase(getLocale()); + return builder.build(); + } + + // Helper method to create alphabet layout by adding special function keys. + @Override + ExpectedKeyboardBuilder convertCommonLayoutToKeyboard(final ExpectedKeyboardBuilder builder, + final boolean isPhone) { + final LayoutCustomizer customizer = getCustomizer(); + builder.setKeysOfRow(5, (Object[])customizer.getSpaceKeys(isPhone)); + builder.addKeysOnTheLeftOfRow(5, (Object[])customizer.getKeysLeftToSpacebar(isPhone)); + builder.addKeysOnTheRightOfRow(5, (Object[])customizer.getKeysRightToSpacebar(isPhone)); + if (isPhone) { + builder.addKeysOnTheRightOfRow(3, DELETE_KEY); + } else { + builder.addKeysOnTheRightOfRow(1, DELETE_KEY) + .addKeysOnTheLeftOfRow(2, TAB_KEY) + .addKeysOnTheRightOfRow(3, ENTER_KEY); + } + builder.addKeysOnTheLeftOfRow(4, (Object[])customizer.getLeftShiftKeys(isPhone)) + .addKeysOnTheRightOfRow(4, (Object[])customizer.getRightShiftKeys(isPhone)); + return builder; + } + + @Override + public ExpectedKey[][] getLayout(final boolean isPhone, final int elementId) { + if (elementId == KeyboardId.ELEMENT_SYMBOLS + || elementId == KeyboardId.ELEMENT_SYMBOLS_SHIFTED) { + return null; + } + return super.getLayout(isPhone, elementId); + } + + private static final String ROW1_1 = "ROW1_1"; + private static final String ROW1_13 = "ROW1_13"; + private static final String ROW2_11 = "ROW2_11"; + private static final String ROW2_12 = "ROW2_12"; + private static final String ROW2_13 = "ROW2_13"; + private static final String ROW3_10 = "ROW3_10"; + private static final String ROW3_11 = "ROW3_11"; + private static final String ROW4_8 = "ROW4_8"; + private static final String ROW4_9 = "ROW4_9"; + private static final String ROW4_10 = "ROW4_10"; + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + ROW1_1, + // U+00A1: "¡" INVERTED EXCLAMATION MARK + // 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( + "!", "\u00A1", "\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", joinMoreKeys("$", "\u2074")), + // U+215D: "⅝" VULGAR FRACTION FIVE EIGHTHS + key("5", joinMoreKeys("%", "\u215D")), + key("6", moreKey("^")), + // U+215E: "⅞" VULGAR FRACTION SEVEN EIGHTHS + key("7", joinMoreKeys("&", "\u215E")), + key("8", moreKey("*")), + key("9", moreKey("(")), + // U+207F: "ⁿ" SUPERSCRIPT LATIN SMALL LETTER N + // U+2205: "∅" EMPTY SET + key("0", joinMoreKeys(")", "\u207F", "\u2205")), + // U+2013: "–" EN DASH + // U+2014: "—" EM DASH + // U+00B7: "·" MIDDLE DOT + key("-", joinMoreKeys("_", "\u2013", "\u2014", "\u00B7")), + ROW1_13) + .setKeysOfRow(2, "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", + ROW2_11, ROW2_12, ROW2_13) + .setKeysOfRow(3, "a", "s", "d", "f", "g", "h", "j", "k", "l", ROW3_10, ROW3_11) + .setKeysOfRow(4, "z", "x", "c", "v", "b", "n", "m", ROW4_8, ROW4_9, ROW4_10) + .build(); +} 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 a13ec7529..6176f6a3e 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java @@ -109,10 +109,14 @@ public abstract class AbstractLayoutBase { // Icon ids. private static final int ICON_DELETE = KeyboardIconsSet.getIconId( KeyboardIconsSet.NAME_DELETE_KEY); + private static final int ICON_TAB = KeyboardIconsSet.getIconId( + KeyboardIconsSet.NAME_TAB_KEY); private static final int ICON_SHORTCUT = KeyboardIconsSet.getIconId( KeyboardIconsSet.NAME_SHORTCUT_KEY); private static final int ICON_SETTINGS = KeyboardIconsSet.getIconId( KeyboardIconsSet.NAME_SETTINGS_KEY); + private static final int ICON_LANGUAGE_SWITCH = KeyboardIconsSet.getIconId( + KeyboardIconsSet.NAME_LANGUAGE_SWITCH_KEY); private static final int ICON_ENTER = KeyboardIconsSet.getIconId( KeyboardIconsSet.NAME_ENTER_KEY); private static final int ICON_EMOJI = KeyboardIconsSet.getIconId( @@ -120,8 +124,11 @@ public abstract class AbstractLayoutBase { // Functional keys. public static final ExpectedKey DELETE_KEY = key(ICON_DELETE, Constants.CODE_DELETE); + public static final ExpectedKey TAB_KEY = key(ICON_TAB, Constants.CODE_TAB); public static final ExpectedKey SHORTCUT_KEY = key(ICON_SHORTCUT, Constants.CODE_SHORTCUT); public static final ExpectedKey SETTINGS_KEY = key(ICON_SETTINGS, Constants.CODE_SETTINGS); + public static final ExpectedKey LANGUAGE_SWITCH_KEY = key( + ICON_LANGUAGE_SWITCH, Constants.CODE_LANGUAGE_SWITCH); public static final ExpectedKey ENTER_KEY = key(ICON_ENTER, Constants.CODE_ENTER); public static final ExpectedKey EMOJI_KEY = key(ICON_EMOJI, Constants.CODE_EMOJI); public static final ExpectedKey SPACE_KEY = key( diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/SpanishCustomizer.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/SpanishCustomizer.java index da4a83c73..8974ad6ec 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/tests/SpanishCustomizer.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/SpanishCustomizer.java @@ -38,8 +38,8 @@ class SpanishCustomizer extends LayoutCustomizer { private static final ExpectedKey[] PHONE_PUNCTUATION_MORE_KEYS = AbstractLayoutBase.joinKeys( // U+00A1: "¡" INVERTED EXCLAMATION MARK // U+00BF: "¿" INVERTED QUESTION MARK - "\u00A1", ";", "/", "(", ")", "#", "!", ",", "?", - "\u00BF", "&", "%", "+", "\"", "-", ":", "'", "@"); + ",", "?", "!", "#", ")", "(", "/", ";", "\u00A1", + "'", "@", ":", "-", "\"", "+", "%", "&", "\u00BF"); @Override public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsArmenianAMPhonetic.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsArmenianAMPhonetic.java new file mode 100644 index 000000000..327e9438f --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsArmenianAMPhonetic.java @@ -0,0 +1,38 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.keyboard.layout.tests; + +import android.test.suitebuilder.annotation.SmallTest; + +import com.android.inputmethod.keyboard.layout.ArmenianPhonetic; +import com.android.inputmethod.keyboard.layout.ArmenianPhonetic.ArmenianPhoneticCustomizer; +import com.android.inputmethod.keyboard.layout.LayoutBase; + +import java.util.Locale; + +/** + * hy_AM: Armenian (Armenia) Phonetic/armenian_phonetic + */ +@SmallTest +public final class TestsArmenianAMPhonetic extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("hy", "AM"); + private static final LayoutBase LAYOUT = new ArmenianPhonetic( + new ArmenianPhoneticCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsCatalan.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsCatalan.java index 988eb81a3..151a0a627 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsCatalan.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsCatalan.java @@ -48,12 +48,12 @@ public class TestsCatalan extends LayoutTestsBase { // U+00B7: "·" MIDDLE DOT private static final ExpectedKey[] PHONE_PUNCTUATION_MORE_KEYS = joinKeys( - ";", "/", "(", ")", "#", "\u00B7", "!", ",", "?", - "&", "%", "+", "\"", "-", ":", "'", "@"); + ",", "?", "!", "\u00B7", "#", ")", "(", "/", ";", + "'", "@", ":", "-", "\"", "+", "%", "&"); private static final ExpectedKey[] TABLET_PUNCTUATION_MORE_KEYS = joinKeys( - ";", "/", "(", ")", "#", "\u00B7", "'", ",", - "&", "%", "+", "\"", "-", ":", "@"); + ",", "'", "\u00B7", "#", ")", "(", "/", ";", + "@", ":", "-", "\"", "+", "%", "&"); @Override public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsNoLanguagePcQwerty.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsNoLanguagePcQwerty.java new file mode 100644 index 000000000..cd8d43ca8 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsNoLanguagePcQwerty.java @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2014 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.inputmethod.keyboard.layout.tests; + +import android.test.suitebuilder.annotation.SmallTest; + +import com.android.inputmethod.keyboard.layout.LayoutBase; +import com.android.inputmethod.keyboard.layout.PcQwerty; +import com.android.inputmethod.keyboard.layout.PcQwerty.PcQwertyCustomizer; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * zz: Alphabet/pcqwerty + */ +@SmallTest +public final class TestsNoLanguagePcQwerty extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("zz"); + private static final LayoutBase LAYOUT = new PcQwerty(new NoLanguagePcQwertyCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class NoLanguagePcQwertyCustomizer extends PcQwertyCustomizer { + private final NoLanguageCustomizer mNoLanguageCustomizer; + + public NoLanguagePcQwertyCustomizer(final Locale locale) { + super(locale); + mNoLanguageCustomizer = new NoLanguageCustomizer(locale); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return mNoLanguageCustomizer.setAccentedLetters(builder); + } + } +} |