diff options
101 files changed, 8631 insertions, 812 deletions
diff --git a/java/res/xml-sw600dp/key_space_5kw.xml b/java/res/xml-sw600dp/key_space_5kw.xml index 86af89f50..71ae5fd8f 100644 --- a/java/res/xml-sw600dp/key_space_5kw.xml +++ b/java/res/xml-sw600dp/key_space_5kw.xml @@ -23,7 +23,7 @@ > <switch> <case - latin:languageCode="fa" + latin:languageCode="fa|ne" latin:languageSwitchKeyEnabled="true" > <Key @@ -35,7 +35,7 @@ latin:keyStyle="zwnjKeyStyle" /> </case> <case - latin:languageCode="fa" + latin:languageCode="fa|ne" latin:languageSwitchKeyEnabled="false" > <Key diff --git a/java/res/xml-sw600dp/key_space_symbols.xml b/java/res/xml-sw600dp/key_space_symbols.xml index d6f7cab09..b3cb5ac78 100644 --- a/java/res/xml-sw600dp/key_space_symbols.xml +++ b/java/res/xml-sw600dp/key_space_symbols.xml @@ -21,7 +21,7 @@ <merge xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin" > - <include - latin:backgroundType="normal" - latin:keyboardLayout="@xml/key_space_5kw" /> + <Key + latin:keyStyle="spaceKeyStyle" + latin:keyWidth="45.0%p" /> </merge> diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml index 94327f9e9..05cb2938b 100644 --- a/java/res/xml/method.xml +++ b/java/res/xml/method.xml @@ -50,10 +50,10 @@ hr: Croatian/qwertz hu: Hungarian/qwertz hy_AM: Armenian (Armenia) Phonetic/armenian_phonetic - in: Indonesian/qwerty # "id" is official language code of Indonesian. + in: Indonesian/qwerty # "id" is the official language code of Indonesian. is: Icelandic/qwerty it: Italian/qwerty - iw: Hebrew/hebrew # "he" is official language code of Hebrew. + iw: Hebrew/hebrew # "he" is the official language code of Hebrew. ka_GE: Georgian (Georgia)/georgian kk: Kazakh/east_slavic km_KH: Khmer (Cambodia)/khmer @@ -65,8 +65,8 @@ mn_MN: Mongolian (Mongolia)/mongolian ms_MY: Malay (Malaysia)/qwerty nb: Norwegian Bokmål/nordic - ne_NP: Nepali (Nepal) Romanized/nepali_romanized) - ne_NP: Nepali (Nepal) Traditional/nepali_traditional) + ne_NP: Nepali (Nepal) Romanized/nepali_romanized + ne_NP: Nepali (Nepal) Traditional/nepali_traditional nl: Dutch/qwerty nl_BE: Dutch (Belgium)/azerty pl: Polish/qwerty diff --git a/java/src/com/android/inputmethod/event/Event.java b/java/src/com/android/inputmethod/event/Event.java index 31092f176..ed487e13f 100644 --- a/java/src/com/android/inputmethod/event/Event.java +++ b/java/src/com/android/inputmethod/event/Event.java @@ -120,6 +120,34 @@ public class Event { FLAG_DEAD, next); } + /** + * Create an input event with nothing but a code point. This is the most basic possible input + * event; it contains no information on many things the IME requires to function correctly, + * so avoid using it unless really nothing is known about this input. + * @param codePoint the code point. + * @return an event for this code point. + */ + public static Event createEventForCodePointFromUnknownSource(final int codePoint) { + // TODO: should we have a different type of event for this? After all, it's not a key press. + return new Event(EVENT_INPUT_KEYPRESS, codePoint, NOT_A_KEY_CODE, + Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, FLAG_NONE, null /* next */); + } + + /** + * Creates an input event with a code point and x, y coordinates. This is typically used when + * resuming a previously-typed word, when the coordinates are still known. + * @param codePoint the code point to input. + * @param x the X coordinate. + * @param y the Y coordinate. + * @return an event for this code point and coordinates. + */ + public static Event createEventForCodePointFromAlreadyTypedText(final int codePoint, + final int x, final int y) { + // TODO: should we have a different type of event for this? After all, it's not a key press. + return new Event(EVENT_INPUT_KEYPRESS, codePoint, NOT_A_KEY_CODE, x, y, FLAG_NONE, + null /* next */); + } + public static Event createNotHandledEvent() { return new Event(EVENT_NOT_HANDLED, NOT_A_CODE_POINT, NOT_A_KEY_CODE, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, FLAG_NONE, null); @@ -130,6 +158,12 @@ public class Event { return 0 != (FLAG_DEAD & mFlags); } + // Returns whether this is a fake key press from the suggestion strip. This happens with + // punctuation signs selected from the suggestion strip. + public boolean isSuggestionStripPress() { + return EVENT_INPUT_KEYPRESS == mType && Constants.SUGGESTION_STRIP_COORDINATE == mX; + } + // TODO: remove this method - we should not have to test this public boolean isCommittable() { return EVENT_INPUT_KEYPRESS == mType || EVENT_MODE_KEY == mType || EVENT_TOGGLE == mType; diff --git a/java/src/com/android/inputmethod/event/InputTransaction.java b/java/src/com/android/inputmethod/event/InputTransaction.java index 3f709a674..2e9014f20 100644 --- a/java/src/com/android/inputmethod/event/InputTransaction.java +++ b/java/src/com/android/inputmethod/event/InputTransaction.java @@ -33,11 +33,7 @@ public class InputTransaction { // Initial conditions public final SettingsValues mSettingsValues; - // If the key inserts a code point, mKeyCode is always equal to the code points. Otherwise, - // it's always a code that may not be a code point, typically a negative number. - public final int mKeyCode; - public final int mX; // Pressed x-coordinate, or one of Constants.*_COORDINATE - public final int mY; // Pressed y-coordinate, or one of Constants.*_COORDINATE + public final Event mEvent; public final long mTimestamp; public final int mSpaceState; public final int mShiftState; @@ -45,13 +41,10 @@ public class InputTransaction { // Outputs private int mRequiredShiftUpdate = SHIFT_NO_UPDATE; - public InputTransaction(final SettingsValues settingsValues, final int keyCode, - final int x, final int y, final long timestamp, final int spaceState, - final int shiftState) { + public InputTransaction(final SettingsValues settingsValues, final Event event, + final long timestamp, final int spaceState, final int shiftState) { mSettingsValues = settingsValues; - mKeyCode = keyCode; - mX = x; - mY = y; + mEvent = event; mTimestamp = timestamp; mSpaceState = spaceState; mShiftState = shiftState; diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java index 79d088f2e..6c9b5adc3 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java @@ -34,29 +34,47 @@ public final class KeyboardIconsSet { public static final int ICON_UNDEFINED = 0; private static final int ATTR_UNDEFINED = 0; + private static final String NAME_UNDEFINED = "undefined"; + public static final String NAME_SHIFT_KEY = "shift_key"; + public static final String NAME_SHIFT_KEY_SHIFTED = "shift_key_shifted"; + public static final String NAME_DELETE_KEY = "delete_key"; + public static final String NAME_SETTINGS_KEY = "settings_key"; + public static final String NAME_SPACE_KEY = "space_key"; + public static final String NAME_SPACE_KEY_FOR_NUMBER_LAYOUT = "space_key_for_number_layout"; + public static final String NAME_ENTER_KEY = "enter_key"; + public static final String NAME_SEARCH_KEY = "search_key"; + public static final String NAME_TAB_KEY = "tab_key"; + public static final String NANE_TAB_KEY_PREVIEW = "tab_key_preview"; + public static final String NAME_SHORTCUT_KEY = "shortcut_key"; + public static final String NAME_SHORTCUT_KEY_DISABLED = "shortcut_key_disabled"; + public static final String NAME_LANGUAGE_SWITCH_KEY = "language_switch_key"; + public static final String NAME_ZWNJ_KEY = "zwnj_key"; + public static final String NAME_ZWJ_KEY = "zwj_key"; + public static final String NAME_EMOJI_KEY = "emoji_key"; + private static final SparseIntArray ATTR_ID_TO_ICON_ID = new SparseIntArray(); // Icon name to icon id map. private static final HashMap<String, Integer> sNameToIdsMap = CollectionUtils.newHashMap(); private static final Object[] NAMES_AND_ATTR_IDS = { - "undefined", ATTR_UNDEFINED, - "shift_key", R.styleable.Keyboard_iconShiftKey, - "delete_key", R.styleable.Keyboard_iconDeleteKey, - "settings_key", R.styleable.Keyboard_iconSettingsKey, - "space_key", R.styleable.Keyboard_iconSpaceKey, - "enter_key", R.styleable.Keyboard_iconEnterKey, - "search_key", R.styleable.Keyboard_iconSearchKey, - "tab_key", R.styleable.Keyboard_iconTabKey, - "shortcut_key", R.styleable.Keyboard_iconShortcutKey, - "space_key_for_number_layout", R.styleable.Keyboard_iconSpaceKeyForNumberLayout, - "shift_key_shifted", R.styleable.Keyboard_iconShiftKeyShifted, - "shortcut_key_disabled", R.styleable.Keyboard_iconShortcutKeyDisabled, - "tab_key_preview", R.styleable.Keyboard_iconTabKeyPreview, - "language_switch_key", R.styleable.Keyboard_iconLanguageSwitchKey, - "zwnj_key", R.styleable.Keyboard_iconZwnjKey, - "zwj_key", R.styleable.Keyboard_iconZwjKey, - "emoji_key", R.styleable.Keyboard_iconEmojiKey, + NAME_UNDEFINED, ATTR_UNDEFINED, + NAME_SHIFT_KEY, R.styleable.Keyboard_iconShiftKey, + NAME_DELETE_KEY, R.styleable.Keyboard_iconDeleteKey, + NAME_SETTINGS_KEY, R.styleable.Keyboard_iconSettingsKey, + NAME_SPACE_KEY, R.styleable.Keyboard_iconSpaceKey, + NAME_ENTER_KEY, R.styleable.Keyboard_iconEnterKey, + NAME_SEARCH_KEY, R.styleable.Keyboard_iconSearchKey, + NAME_TAB_KEY, R.styleable.Keyboard_iconTabKey, + NAME_SHORTCUT_KEY, R.styleable.Keyboard_iconShortcutKey, + NAME_SPACE_KEY_FOR_NUMBER_LAYOUT, R.styleable.Keyboard_iconSpaceKeyForNumberLayout, + NAME_SHIFT_KEY_SHIFTED, R.styleable.Keyboard_iconShiftKeyShifted, + NAME_SHORTCUT_KEY_DISABLED, R.styleable.Keyboard_iconShortcutKeyDisabled, + NANE_TAB_KEY_PREVIEW, R.styleable.Keyboard_iconTabKeyPreview, + NAME_LANGUAGE_SWITCH_KEY, R.styleable.Keyboard_iconLanguageSwitchKey, + NAME_ZWNJ_KEY, R.styleable.Keyboard_iconZwnjKey, + NAME_ZWJ_KEY, R.styleable.Keyboard_iconZwjKey, + NAME_EMOJI_KEY, R.styleable.Keyboard_iconEmojiKey, }; private static int NUM_ICONS = NAMES_AND_ATTR_IDS.length / 2; diff --git a/java/src/com/android/inputmethod/latin/LastComposedWord.java b/java/src/com/android/inputmethod/latin/LastComposedWord.java index 8546cebd5..2a16ab5ab 100644 --- a/java/src/com/android/inputmethod/latin/LastComposedWord.java +++ b/java/src/com/android/inputmethod/latin/LastComposedWord.java @@ -18,6 +18,10 @@ package com.android.inputmethod.latin; import android.text.TextUtils; +import com.android.inputmethod.event.Event; + +import java.util.ArrayList; + /** * This class encapsulates data about a word previously composed, but that has been * committed already. This is used for resuming suggestion, and cancel auto-correction. @@ -41,6 +45,7 @@ public final class LastComposedWord { public static final String NOT_A_SEPARATOR = ""; public final int[] mPrimaryKeyCodes; + public final ArrayList<Event> mEvents; public final String mTypedWord; public final CharSequence mCommittedWord; public final String mSeparatorString; @@ -52,19 +57,21 @@ public final class LastComposedWord { private boolean mActive; public static final LastComposedWord NOT_A_COMPOSED_WORD = - new LastComposedWord(null, null, "", "", NOT_A_SEPARATOR, null, - WordComposer.CAPS_MODE_OFF); + new LastComposedWord(null, new ArrayList<Event>(), null, "", "", + NOT_A_SEPARATOR, null, WordComposer.CAPS_MODE_OFF); // Warning: this is using the passed objects as is and fully expects them to be // immutable. Do not fiddle with their contents after you passed them to this constructor. - public LastComposedWord(final int[] primaryKeyCodes, final InputPointers inputPointers, - final String typedWord, final CharSequence committedWord, final String separatorString, + public LastComposedWord(final int[] primaryKeyCodes, final ArrayList<Event> events, + final InputPointers inputPointers, final String typedWord, + final CharSequence committedWord, final String separatorString, final String prevWord, final int capitalizedMode) { mPrimaryKeyCodes = primaryKeyCodes; if (inputPointers != null) { mInputPointers.copy(inputPointers); } mTypedWord = typedWord; + mEvents = new ArrayList<Event>(events); mCommittedWord = committedWord; mSeparatorString = separatorString; mActive = true; diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java index 125976932..2ac11aa29 100644 --- a/java/src/com/android/inputmethod/latin/WordComposer.java +++ b/java/src/com/android/inputmethod/latin/WordComposer.java @@ -16,10 +16,14 @@ package com.android.inputmethod.latin; +import com.android.inputmethod.event.Event; +import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.CoordinateUtils; import com.android.inputmethod.latin.utils.StringUtils; +import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; /** * A place to store the currently composing word with information such as adjacent key codes as well @@ -41,6 +45,8 @@ public final class WordComposer { // and mCodePointSize can go past that. If mCodePointSize is greater than MAX_WORD_LENGTH, // this just does not contain the associated code points past MAX_WORD_LENGTH. private int[] mPrimaryKeyCodes; + // The list of events that served to compose this string. + private final ArrayList<Event> mEvents; private final InputPointers mInputPointers = new InputPointers(MAX_WORD_LENGTH); // This is the typed word, as a StringBuilder. This has the same contents as mPrimaryKeyCodes // but under a StringBuilder representation for ease of use, depending on what is more useful @@ -82,6 +88,7 @@ public final class WordComposer { public WordComposer() { mPrimaryKeyCodes = new int[MAX_WORD_LENGTH]; + mEvents = CollectionUtils.newArrayList(); mTypedWord = new StringBuilder(MAX_WORD_LENGTH); mAutoCorrection = null; mTrailingSingleQuotesCount = 0; @@ -95,6 +102,7 @@ public final class WordComposer { public WordComposer(final WordComposer source) { mPrimaryKeyCodes = Arrays.copyOf(source.mPrimaryKeyCodes, source.mPrimaryKeyCodes.length); + mEvents = new ArrayList<Event>(source.mEvents); mTypedWord = new StringBuilder(source.mTypedWord); mInputPointers.copy(source.mInputPointers); mCapsCount = source.mCapsCount; @@ -115,6 +123,7 @@ public final class WordComposer { */ public void reset() { mTypedWord.setLength(0); + mEvents.clear(); mAutoCorrection = null; mCapsCount = 0; mDigitsCount = 0; @@ -170,11 +179,16 @@ public final class WordComposer { } /** - * Add a new keystroke, with the pressed key's code point with the touch point coordinates. + * Add a new event for a key stroke, with the pressed key's code point with the touch point + * coordinates. */ - public void add(final int primaryCode, final int keyX, final int keyY) { + public void add(final Event event) { + final int primaryCode = event.mCodePoint; + final int keyX = event.mX; + final int keyY = event.mY; final int newIndex = size(); mTypedWord.appendCodePoint(primaryCode); + mEvents.add(event); refreshSize(); mCursorPositionWithinWord = mCodePointSize; if (newIndex < MAX_WORD_LENGTH) { @@ -202,6 +216,7 @@ public final class WordComposer { public void setCursorPositionWithinWord(final int posWithinWord) { mCursorPositionWithinWord = posWithinWord; + // TODO: compute where that puts us inside the events } public boolean isCursorFrontOrMiddleOfComposingWord() { @@ -268,7 +283,7 @@ public final class WordComposer { final int codePoint = Character.codePointAt(word, i); // We don't want to override the batch input points that are held in mInputPointers // (See {@link #add(int,int,int)}). - add(codePoint, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE); + add(Event.createEventForCodePointFromUnknownSource(codePoint)); } } @@ -285,8 +300,9 @@ public final class WordComposer { reset(); final int length = codePoints.length; for (int i = 0; i < length; ++i) { - add(codePoints[i], CoordinateUtils.xFromArray(coordinates, i), - CoordinateUtils.yFromArray(coordinates, i)); + add(Event.createEventForCodePointFromAlreadyTypedText(codePoints[i], + CoordinateUtils.xFromArray(coordinates, i), + CoordinateUtils.yFromArray(coordinates, i))); } mIsResumed = true; mPreviousWordForSuggestion = null == previousWord ? null : previousWord.toString(); @@ -305,6 +321,8 @@ public final class WordComposer { "In WordComposer: mCodes and mTypedWords have non-matching lengths"); } final int lastChar = mTypedWord.codePointBefore(stringBuilderLength); + // TODO: with events and composition, this is absolutely not necessarily true. + mEvents.remove(mEvents.size() - 1); if (Character.isSupplementaryCodePoint(lastChar)) { mTypedWord.delete(stringBuilderLength - 2, stringBuilderLength); } else { @@ -445,7 +463,7 @@ public final class WordComposer { // the last composed word to ensure this does not happen. final int[] primaryKeyCodes = mPrimaryKeyCodes; mPrimaryKeyCodes = new int[MAX_WORD_LENGTH]; - final LastComposedWord lastComposedWord = new LastComposedWord(primaryKeyCodes, + final LastComposedWord lastComposedWord = new LastComposedWord(primaryKeyCodes, mEvents, mInputPointers, mTypedWord.toString(), committedWord, separatorString, prevWord, mCapitalizedMode); mInputPointers.reset(); @@ -458,6 +476,7 @@ public final class WordComposer { mIsBatchMode = false; mPreviousWordForSuggestion = committedWord.toString(); mTypedWord.setLength(0); + mEvents.clear(); mCodePointSize = 0; mTrailingSingleQuotesCount = 0; mIsFirstCharCapitalized = false; @@ -480,6 +499,8 @@ public final class WordComposer { public void resumeSuggestionOnLastComposedWord(final LastComposedWord lastComposedWord, final String previousWord) { mPrimaryKeyCodes = lastComposedWord.mPrimaryKeyCodes; + mEvents.clear(); + Collections.copy(mEvents, lastComposedWord.mEvents); mInputPointers.set(lastComposedWord.mInputPointers); mTypedWord.setLength(0); mTypedWord.append(lastComposedWord.mTypedWord); diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java index f7e528648..cb55aa06c 100644 --- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java +++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java @@ -368,16 +368,13 @@ public final class InputLogic { // var because it's confusing. Instead the switch() should handle this in a readable manner. final int code = Event.NOT_A_CODE_POINT == event.mCodePoint ? event.mKeyCode : event.mCodePoint; - final int x = event.mX; - final int y = event.mY; - final InputTransaction inputTransaction = new InputTransaction(settingsValues, code, x, y, + final InputTransaction inputTransaction = new InputTransaction(settingsValues, event, SystemClock.uptimeMillis(), mSpaceState, getActualCapsMode(settingsValues, keyboardShiftMode)); if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { - ResearchLogger.latinIME_onCodeInput(inputTransaction.mKeyCode, - inputTransaction.mX, inputTransaction.mY); + ResearchLogger.latinIME_onCodeInput(code, event.mX, event.mY); } - if (inputTransaction.mKeyCode != Constants.CODE_DELETE + if (event.mKeyCode != Constants.CODE_DELETE || inputTransaction.mTimestamp > mLastKeyTime + Constants.LONG_PRESS_MILLISECONDS) { mDeleteCount = 0; } @@ -388,97 +385,104 @@ public final class InputLogic { } // TODO: Consolidate the double-space period timer, mLastKeyTime, and the space state. - if (inputTransaction.mKeyCode != Constants.CODE_SPACE) { + if (event.mCodePoint != Constants.CODE_SPACE) { handler.cancelDoubleSpacePeriodTimer(); } boolean didAutoCorrect = false; - switch (inputTransaction.mKeyCode) { - case Constants.CODE_DELETE: - handleBackspace(inputTransaction, handler); - LatinImeLogger.logOnDelete(inputTransaction.mX, inputTransaction.mY); - break; - case Constants.CODE_SHIFT: - performRecapitalization(inputTransaction.mSettingsValues); - inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW); - break; - case Constants.CODE_CAPSLOCK: - // Note: Changing keyboard to shift lock state is handled in - // {@link KeyboardSwitcher#onCodeInput(int)}. - break; - case Constants.CODE_SYMBOL_SHIFT: - // Note: Calling back to the keyboard on the symbol Shift key is handled in - // {@link #onPressKey(int,int,boolean)} and {@link #onReleaseKey(int,boolean)}. - break; - case Constants.CODE_SWITCH_ALPHA_SYMBOL: - // Note: Calling back to the keyboard on symbol key is handled in - // {@link #onPressKey(int,int,boolean)} and {@link #onReleaseKey(int,boolean)}. - break; - case Constants.CODE_SETTINGS: - onSettingsKeyPressed(); - break; - case Constants.CODE_SHORTCUT: - // We need to switch to the shortcut IME. This is handled by LatinIME since the - // input logic has no business with IME switching. - break; - case Constants.CODE_ACTION_NEXT: - performEditorAction(EditorInfo.IME_ACTION_NEXT); - break; - case Constants.CODE_ACTION_PREVIOUS: - performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); - break; - case Constants.CODE_LANGUAGE_SWITCH: - handleLanguageSwitchKey(); - break; - case Constants.CODE_EMOJI: - // Note: Switching emoji keyboard is being handled in - // {@link KeyboardState#onCodeInput(int,int)}. - break; - case Constants.CODE_ENTER: - final EditorInfo editorInfo = getCurrentInputEditorInfo(); - final int imeOptionsActionId = - InputTypeUtils.getImeOptionsActionIdFromEditorInfo(editorInfo); - if (InputTypeUtils.IME_ACTION_CUSTOM_LABEL == imeOptionsActionId) { - // Either we have an actionLabel and we should performEditorAction with actionId - // regardless of its value. - performEditorAction(editorInfo.actionId); - } else if (EditorInfo.IME_ACTION_NONE != imeOptionsActionId) { - // We didn't have an actionLabel, but we had another action to execute. - // EditorInfo.IME_ACTION_NONE explicitly means no action. In contrast, - // EditorInfo.IME_ACTION_UNSPECIFIED is the default value for an action, so it - // means there should be an action and the app didn't bother to set a specific - // code for it - presumably it only handles one. It does not have to be treated - // in any specific way: anything that is not IME_ACTION_NONE should be sent to - // performEditorAction. - performEditorAction(imeOptionsActionId); - } else { - // No action label, and the action from imeOptions is NONE: this is a regular - // enter key that should input a carriage return. + if (Event.NOT_A_KEY_CODE != event.mKeyCode) { + // A special key, like delete, shift, emoji, or the settings key. + switch (event.mKeyCode) { + case Constants.CODE_DELETE: + handleBackspace(inputTransaction, handler); + LatinImeLogger.logOnDelete(event.mX, event.mY); + break; + case Constants.CODE_SHIFT: + performRecapitalization(inputTransaction.mSettingsValues); + inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW); + break; + case Constants.CODE_CAPSLOCK: + // Note: Changing keyboard to shift lock state is handled in + // {@link KeyboardSwitcher#onCodeInput(int)}. + break; + case Constants.CODE_SYMBOL_SHIFT: + // Note: Calling back to the keyboard on the symbol Shift key is handled in + // {@link #onPressKey(int,int,boolean)} and {@link #onReleaseKey(int,boolean)}. + break; + case Constants.CODE_SWITCH_ALPHA_SYMBOL: + // Note: Calling back to the keyboard on symbol key is handled in + // {@link #onPressKey(int,int,boolean)} and {@link #onReleaseKey(int,boolean)}. + break; + case Constants.CODE_SETTINGS: + onSettingsKeyPressed(); + break; + case Constants.CODE_SHORTCUT: + // We need to switch to the shortcut IME. This is handled by LatinIME since the + // input logic has no business with IME switching. + break; + case Constants.CODE_ACTION_NEXT: + performEditorAction(EditorInfo.IME_ACTION_NEXT); + break; + case Constants.CODE_ACTION_PREVIOUS: + performEditorAction(EditorInfo.IME_ACTION_PREVIOUS); + break; + case Constants.CODE_LANGUAGE_SWITCH: + handleLanguageSwitchKey(); + break; + case Constants.CODE_EMOJI: + // Note: Switching emoji keyboard is being handled in + // {@link KeyboardState#onCodeInput(int,int)}. + break; + case Constants.CODE_ALPHA_FROM_EMOJI: + // Note: Switching back from Emoji keyboard to the main keyboard is being + // handled in {@link KeyboardState#onCodeInput(int,int)}. + break; + case Constants.CODE_SHIFT_ENTER: + // TODO: remove this object + final InputTransaction tmpTransaction = new InputTransaction( + inputTransaction.mSettingsValues, inputTransaction.mEvent, + inputTransaction.mTimestamp, inputTransaction.mSpaceState, + inputTransaction.mShiftState); + didAutoCorrect = handleNonSpecialCharacter(tmpTransaction, handler); + break; + default: + throw new RuntimeException("Unknown key code : " + event.mKeyCode); + } + } else { + switch (event.mCodePoint) { + case Constants.CODE_ENTER: + final EditorInfo editorInfo = getCurrentInputEditorInfo(); + final int imeOptionsActionId = + InputTypeUtils.getImeOptionsActionIdFromEditorInfo(editorInfo); + if (InputTypeUtils.IME_ACTION_CUSTOM_LABEL == imeOptionsActionId) { + // Either we have an actionLabel and we should performEditorAction with + // actionId regardless of its value. + performEditorAction(editorInfo.actionId); + } else if (EditorInfo.IME_ACTION_NONE != imeOptionsActionId) { + // We didn't have an actionLabel, but we had another action to execute. + // EditorInfo.IME_ACTION_NONE explicitly means no action. In contrast, + // EditorInfo.IME_ACTION_UNSPECIFIED is the default value for an action, so it + // means there should be an action and the app didn't bother to set a specific + // code for it - presumably it only handles one. It does not have to be treated + // in any specific way: anything that is not IME_ACTION_NONE should be sent to + // performEditorAction. + performEditorAction(imeOptionsActionId); + } else { + // No action label, and the action from imeOptions is NONE: this is a regular + // enter key that should input a carriage return. + didAutoCorrect = handleNonSpecialCharacter(inputTransaction, handler); + } + break; + default: didAutoCorrect = handleNonSpecialCharacter(inputTransaction, handler); + break; } - break; - case Constants.CODE_SHIFT_ENTER: - // TODO: remove this object - final InputTransaction tmpTransaction = new InputTransaction( - inputTransaction.mSettingsValues, inputTransaction.mKeyCode, - inputTransaction.mX, inputTransaction.mY, inputTransaction.mTimestamp, - inputTransaction.mSpaceState, inputTransaction.mShiftState); - didAutoCorrect = handleNonSpecialCharacter(tmpTransaction, handler); - break; - case Constants.CODE_ALPHA_FROM_EMOJI: - // Note: Switching back from Emoji keyboard to the main keyboard is being handled in - // {@link KeyboardState#onCodeInput(int,int)}. - break; - default: - didAutoCorrect = handleNonSpecialCharacter(inputTransaction, handler); - break; - } - // Reset after any single keystroke, except shift, capslock, and symbol-shift - if (!didAutoCorrect && inputTransaction.mKeyCode != Constants.CODE_SHIFT - && inputTransaction.mKeyCode != Constants.CODE_CAPSLOCK - && inputTransaction.mKeyCode != Constants.CODE_SWITCH_ALPHA_SYMBOL) + } + if (!didAutoCorrect && event.mKeyCode != Constants.CODE_SHIFT + && event.mKeyCode != Constants.CODE_CAPSLOCK + && event.mKeyCode != Constants.CODE_SWITCH_ALPHA_SYMBOL) mLastComposedWord.deactivate(); - if (Constants.CODE_DELETE != inputTransaction.mKeyCode) { + if (Constants.CODE_DELETE != event.mKeyCode) { mEnteredText = null; } mConnection.endBatchEdit(); @@ -632,15 +636,16 @@ public final class InputLogic { private boolean handleNonSpecialCharacter(final InputTransaction inputTransaction, // TODO: remove this argument final LatinIME.UIHandler handler) { + final int codePoint = inputTransaction.mEvent.mCodePoint; mSpaceState = SpaceState.NONE; final boolean didAutoCorrect; - if (inputTransaction.mSettingsValues.isWordSeparator(inputTransaction.mKeyCode) - || Character.getType(inputTransaction.mKeyCode) == Character.OTHER_SYMBOL) { + if (inputTransaction.mSettingsValues.isWordSeparator(codePoint) + || Character.getType(codePoint) == Character.OTHER_SYMBOL) { didAutoCorrect = handleSeparator(inputTransaction, - Constants.SUGGESTION_STRIP_COORDINATE == inputTransaction.mX, handler); + inputTransaction.mEvent.isSuggestionStripPress(), handler); if (inputTransaction.mSettingsValues.mIsInternal) { - LatinImeLoggerUtils.onSeparator((char)inputTransaction.mKeyCode, - inputTransaction.mX, inputTransaction.mY); + LatinImeLoggerUtils.onSeparator((char)codePoint, + inputTransaction.mEvent.mX, inputTransaction.mEvent.mY); } } else { didAutoCorrect = false; @@ -674,6 +679,7 @@ public final class InputLogic { final InputTransaction inputTransaction, // TODO: Remove this argument final LatinIME.UIHandler handler) { + final int codePoint = inputTransaction.mEvent.mCodePoint; // TODO: refactor this method to stop flipping isComposingWord around all the time, and // make it shorter (possibly cut into several pieces). Also factor handleNonSpecialCharacter // which has the same name as other handle* methods but is not the same. @@ -682,7 +688,7 @@ public final class InputLogic { // TODO: remove isWordConnector() and use isUsuallyFollowedBySpace() instead. // See onStartBatchInput() to see how to do it. if (SpaceState.PHANTOM == inputTransaction.mSpaceState - && !settingsValues.isWordConnector(inputTransaction.mKeyCode)) { + && !settingsValues.isWordConnector(codePoint)) { if (isComposingWord) { // Sanity check throw new RuntimeException("Should not be composing here"); @@ -704,7 +710,7 @@ public final class InputLogic { if (!isComposingWord // We only start composing if this is a word code point. Essentially that means it's a // a letter or a word connector. - && settingsValues.isWordCodePoint(inputTransaction.mKeyCode) + && settingsValues.isWordCodePoint(codePoint) // We never go into composing state if suggestions are not requested. && settingsValues.isSuggestionsRequested() && // In languages with spaces, we only start composing a word when we are not already @@ -715,8 +721,8 @@ public final class InputLogic { // the character is a single quote or a dash. The idea here is, single quote and dash // are not separators and they should be treated as normal characters, except in the // first position where they should not start composing a word. - isComposingWord = (Constants.CODE_SINGLE_QUOTE != inputTransaction.mKeyCode - && Constants.CODE_DASH != inputTransaction.mKeyCode); + isComposingWord = (Constants.CODE_SINGLE_QUOTE != codePoint + && Constants.CODE_DASH != codePoint); // Here we don't need to reset the last composed word. It will be reset // when we commit this one, if we ever do; if on the other hand we backspace // it entirely and resume suggestions on the previous word, we'd like to still @@ -724,7 +730,7 @@ public final class InputLogic { resetComposingState(false /* alsoResetLastComposedWord */); } if (isComposingWord) { - mWordComposer.add(inputTransaction.mKeyCode, inputTransaction.mX, inputTransaction.mY); + mWordComposer.add(inputTransaction.mEvent); // If it's the first letter, make note of auto-caps state if (mWordComposer.size() == 1) { // We pass 1 to getPreviousWordForSuggestion because we were not composing a word @@ -737,9 +743,9 @@ public final class InputLogic { mWordComposer.getTypedWord()), 1); } else { final boolean swapWeakSpace = maybeStripSpace(inputTransaction, - Constants.SUGGESTION_STRIP_COORDINATE == inputTransaction.mX); + inputTransaction.mEvent.isSuggestionStripPress()); - sendKeyCodePoint(settingsValues, inputTransaction.mKeyCode); + sendKeyCodePoint(settingsValues, codePoint); if (swapWeakSpace) { swapSwapperAndSpace(inputTransaction); @@ -750,8 +756,8 @@ public final class InputLogic { } handler.postUpdateSuggestionStrip(); if (settingsValues.mIsInternal) { - LatinImeLoggerUtils.onNonSeparator((char)inputTransaction.mKeyCode, inputTransaction.mX, - inputTransaction.mY); + LatinImeLoggerUtils.onNonSeparator((char)codePoint, inputTransaction.mEvent.mX, + inputTransaction.mEvent.mY); } } @@ -765,9 +771,10 @@ public final class InputLogic { final boolean isFromSuggestionStrip, // TODO: remove this argument final LatinIME.UIHandler handler) { + final int codePoint = inputTransaction.mEvent.mCodePoint; boolean didAutoCorrect = false; // We avoid sending spaces in languages without spaces if we were composing. - final boolean shouldAvoidSendingCode = Constants.CODE_SPACE == inputTransaction.mKeyCode + final boolean shouldAvoidSendingCode = Constants.CODE_SPACE == codePoint && !inputTransaction.mSettingsValues.mSpacingAndPunctuations .mCurrentLanguageHasSpaces && mWordComposer.isComposingWord(); @@ -781,46 +788,44 @@ public final class InputLogic { if (mWordComposer.isComposingWord()) { if (inputTransaction.mSettingsValues.mCorrectionEnabled) { final String separator = shouldAvoidSendingCode ? LastComposedWord.NOT_A_SEPARATOR - : StringUtils.newSingleCodePointString(inputTransaction.mKeyCode); + : StringUtils.newSingleCodePointString(codePoint); commitCurrentAutoCorrection(inputTransaction.mSettingsValues, separator, handler); didAutoCorrect = true; } else { commitTyped(inputTransaction.mSettingsValues, - StringUtils.newSingleCodePointString(inputTransaction.mKeyCode)); + StringUtils.newSingleCodePointString(codePoint)); } } final boolean swapWeakSpace = maybeStripSpace(inputTransaction, isFromSuggestionStrip); - final boolean isInsideDoubleQuoteOrAfterDigit = - Constants.CODE_DOUBLE_QUOTE == inputTransaction.mKeyCode + final boolean isInsideDoubleQuoteOrAfterDigit = Constants.CODE_DOUBLE_QUOTE == codePoint && mConnection.isInsideDoubleQuoteOrAfterDigit(); final boolean needsPrecedingSpace; if (SpaceState.PHANTOM != inputTransaction.mSpaceState) { needsPrecedingSpace = false; - } else if (Constants.CODE_DOUBLE_QUOTE == inputTransaction.mKeyCode) { + } else if (Constants.CODE_DOUBLE_QUOTE == codePoint) { // Double quotes behave like they are usually preceded by space iff we are // not inside a double quote or after a digit. needsPrecedingSpace = !isInsideDoubleQuoteOrAfterDigit; } else { needsPrecedingSpace = inputTransaction.mSettingsValues.isUsuallyPrecededBySpace( - inputTransaction.mKeyCode); + codePoint); } if (needsPrecedingSpace) { promotePhantomSpace(inputTransaction.mSettingsValues); } if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { - ResearchLogger.latinIME_handleSeparator(inputTransaction.mKeyCode, - mWordComposer.isComposingWord()); + ResearchLogger.latinIME_handleSeparator(codePoint, mWordComposer.isComposingWord()); } if (!shouldAvoidSendingCode) { - sendKeyCodePoint(inputTransaction.mSettingsValues, inputTransaction.mKeyCode); + sendKeyCodePoint(inputTransaction.mSettingsValues, codePoint); } - if (Constants.CODE_SPACE == inputTransaction.mKeyCode) { + if (Constants.CODE_SPACE == codePoint) { if (inputTransaction.mSettingsValues.isSuggestionsRequested()) { if (maybeDoubleSpacePeriod(inputTransaction.mSettingsValues, handler)) { inputTransaction.requireShiftUpdate(InputTransaction.SHIFT_UPDATE_NOW); @@ -837,9 +842,8 @@ public final class InputLogic { swapSwapperAndSpace(inputTransaction); mSpaceState = SpaceState.SWAP_PUNCTUATION; } else if ((SpaceState.PHANTOM == inputTransaction.mSpaceState - && inputTransaction.mSettingsValues.isUsuallyFollowedBySpace( - inputTransaction.mKeyCode)) - || (Constants.CODE_DOUBLE_QUOTE == inputTransaction.mKeyCode + && inputTransaction.mSettingsValues.isUsuallyFollowedBySpace(codePoint)) + || (Constants.CODE_DOUBLE_QUOTE == codePoint && isInsideDoubleQuoteOrAfterDigit)) { // If we are in phantom space state, and the user presses a separator, we want to // stay in phantom space state so that the next keypress has a chance to add the @@ -1056,7 +1060,8 @@ public final class InputLogic { */ private boolean maybeStripSpace(final InputTransaction inputTransaction, final boolean isFromSuggestionStrip) { - if (Constants.CODE_ENTER == inputTransaction.mKeyCode && + final int codePoint = inputTransaction.mEvent.mCodePoint; + if (Constants.CODE_ENTER == codePoint && SpaceState.SWAP_PUNCTUATION == inputTransaction.mSpaceState) { mConnection.removeTrailingSpace(); return false; @@ -1064,12 +1069,10 @@ public final class InputLogic { if ((SpaceState.WEAK == inputTransaction.mSpaceState || SpaceState.SWAP_PUNCTUATION == inputTransaction.mSpaceState) && isFromSuggestionStrip) { - if (inputTransaction.mSettingsValues.isUsuallyPrecededBySpace( - inputTransaction.mKeyCode)) { + if (inputTransaction.mSettingsValues.isUsuallyPrecededBySpace(codePoint)) { return false; } - if (inputTransaction.mSettingsValues.isUsuallyFollowedBySpace( - inputTransaction.mKeyCode)) { + if (inputTransaction.mSettingsValues.isUsuallyFollowedBySpace(codePoint)) { return true; } mConnection.removeTrailingSpace(); diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java index afa8fe3a8..c26e223c9 100644 --- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java +++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripLayoutHelper.java @@ -511,7 +511,8 @@ final class SuggestionStripLayoutHelper { final String importantNoticeTitle) { final TextView titleView = (TextView)importantNoticeStrip.findViewById( R.id.important_notice_title); - final int width = stripWidth - titleView.getPaddingLeft() - titleView.getPaddingRight(); + final int width = titleView.getWidth() - titleView.getPaddingLeft() + - titleView.getPaddingRight(); titleView.setTextColor(mColorAutoCorrect); titleView.setText(importantNoticeTitle); titleView.setTextScaleX(1.0f); // Reset textScaleX. diff --git a/native/jni/src/suggest/policyimpl/dictionary/header/header_policy.cpp b/native/jni/src/suggest/policyimpl/dictionary/header/header_policy.cpp index ecc9fdab1..6ed65d921 100644 --- a/native/jni/src/suggest/policyimpl/dictionary/header/header_policy.cpp +++ b/native/jni/src/suggest/policyimpl/dictionary/header/header_policy.cpp @@ -47,11 +47,11 @@ const char *const HeaderPolicy::MAX_BIGRAM_COUNT_KEY = "MAX_BIGRAM_COUNT"; const int HeaderPolicy::DEFAULT_MULTIPLE_WORDS_DEMOTION_RATE = 100; const float HeaderPolicy::MULTIPLE_WORD_COST_MULTIPLIER_SCALE = 100.0f; -const int HeaderPolicy::DEFAULT_FORGETTING_CURVE_OCCURRENCES_TO_LEVEL_UP = 4; -const int HeaderPolicy::DEFAULT_FORGETTING_CURVE_PROBABILITY_VALUES_TABLE_ID = 0; -// 4 days +const int HeaderPolicy::DEFAULT_FORGETTING_CURVE_OCCURRENCES_TO_LEVEL_UP = 2; +const int HeaderPolicy::DEFAULT_FORGETTING_CURVE_PROBABILITY_VALUES_TABLE_ID = 3; +// 30 days const int HeaderPolicy::DEFAULT_FORGETTING_CURVE_DURATION_TO_LEVEL_DOWN_IN_SECONDS = - 4 * 24 * 60 * 60; + 30 * 24 * 60 * 60; const int HeaderPolicy::DEFAULT_MAX_UNIGRAM_COUNT = 10000; const int HeaderPolicy::DEFAULT_MAX_BIGRAM_COUNT = 10000; diff --git a/tests/src/com/android/inputmethod/keyboard/layout/AlphabetShifted.java b/tests/src/com/android/inputmethod/keyboard/layout/AlphabetShifted.java deleted file mode 100644 index b81061ab8..000000000 --- a/tests/src/com/android/inputmethod/keyboard/layout/AlphabetShifted.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.internal.KeyboardIconsSet; -import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; -import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; -import com.android.inputmethod.keyboard.layout.expected.LayoutBase; -import com.android.inputmethod.latin.Constants; - -import java.util.Locale; - -/** - * The generic upper case alphabet keyboard layout. - */ -public final class AlphabetShifted extends LayoutBase { - public static ExpectedKey[][] getDefaultLayout(final ExpectedKey[][] lowerCaseKeyboard, - final Locale locale) { - final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(lowerCaseKeyboard); - builder.toUpperCase(locale); - builder.replaceKeysOfAll(SHIFT_KEY, SHIFTED_SHIFT_KEY); - return builder.build(); - } - - // Icon id. - private static final int ICON_SHIFTED_SHIFT = KeyboardIconsSet.getIconId("shift_key_shifted"); - - // Functional key. - private static final ExpectedKey SHIFTED_SHIFT_KEY = key( - ICON_SHIFTED_SHIFT, Constants.CODE_SHIFT, CAPSLOCK_MORE_KEY); -} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Arabic.java b/tests/src/com/android/inputmethod/keyboard/layout/Arabic.java new file mode 100644 index 000000000..65b050be7 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/Arabic.java @@ -0,0 +1,355 @@ +/* + * 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.Symbols.RtlSymbols; +import com.android.inputmethod.keyboard.layout.SymbolsShifted.RtlSymbolsShifted; +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; + +public final class Arabic extends LayoutBase { + private static final String LAYOUT_NAME = "arabic"; + + public Arabic(final LayoutCustomizer customizer) { + super(customizer, ArabicSymbols.class, ArabicSymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + public static class ArabicCustomizer extends LayoutCustomizer { + public ArabicCustomizer(final Locale locale) { + super(locale); + } + + @Override + public ExpectedKey getAlphabetKey() { return ARABIC_ALPHABET_KEY; } + + @Override + public ExpectedKey getSymbolsKey() { return ARABIC_SYMBOLS_KEY; } + + @Override + public ExpectedKey getBackToSymbolsKey() { return ARABIC_BACK_TO_SYMBOLS_KEY; } + + @Override + public ExpectedKey[] getDoubleAngleQuoteKeys() { + return RtlSymbols.DOUBLE_ANGLE_QUOTES_LR_RTL; + } + + @Override + public ExpectedKey[] getSingleAngleQuoteKeys() { + return RtlSymbols.SINGLE_ANGLE_QUOTES_LR_RTL; + } + + @Override + public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) { + return EMPTY_KEYS; + } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return EMPTY_KEYS; + } + + @Override + public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) { + if (isPhone) { + // U+060C: "،" ARABIC COMMA + return joinKeys(key("\u060C", joinMoreKeys(",", SETTINGS_KEY))); + } + return super.getKeysLeftToSpacebar(isPhone); + } + + @Override + public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) { + if (isPhone) { + return super.getKeysRightToSpacebar(isPhone); + } + // U+060C: "،" ARABIC COMMA + // U+061F: "؟" ARABIC QUESTION MARK + // U+061B: "؛" ARABIC SEMICOLON + return joinKeys( + key("\u060C", joinMoreKeys(":", "!", "\u061F", "\u061B", "-", "/", "\"", "'")), + key(".", getPunctuationMoreKeys(isPhone))); + } + + @Override + public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { + return ARABIC_DIACRITICS; + } + + // U+0623: "ا" ARABIC LETTER ALEF + // U+200C: ZERO WIDTH NON-JOINER + // U+0628: "ب" ARABIC LETTER BEH + // U+062C: "پ" ARABIC LETTER PEH + private static final ExpectedKey ARABIC_ALPHABET_KEY = key( + "\u0623\u200C\u0628\u200C\u062C", Constants.CODE_SWITCH_ALPHA_SYMBOL); + // U+0663: "٣" ARABIC-INDIC DIGIT THREE + // U+0662: "٢" ARABIC-INDIC DIGIT TWO + // U+0661: "١" ARABIC-INDIC DIGIT ONE + // U+061F: "؟" ARABIC QUESTION MARK + private static final ExpectedKey ARABIC_SYMBOLS_KEY = key( + "\u0663\u0662\u0661\u061F", Constants.CODE_SWITCH_ALPHA_SYMBOL); + // U+0663: "٣" ARABIC-INDIC DIGIT THREE + // U+0662: "٢" ARABIC-INDIC DIGIT TWO + // U+0661: "١" ARABIC-INDIC DIGIT ONE + // U+061F: "؟" ARABIC QUESTION MARK + private static final ExpectedKey ARABIC_BACK_TO_SYMBOLS_KEY = key( + "\u0663\u0662\u0661\u061F", Constants.CODE_SHIFT); + + private static final ExpectedKey[] ARABIC_DIACRITICS = { + // U+0655: "ٕ" ARABIC HAMZA BELOW + // U+0654: "ٔ" ARABIC HAMZA ABOVE + // U+0652: "ْ" ARABIC SUKUN + // U+064D: "ٍ" ARABIC KASRATAN + // U+064C: "ٌ" ARABIC DAMMATAN + // U+064B: "ً" ARABIC FATHATAN + // U+0651: "ّ" ARABIC SHADDA + // U+0656: "ٖ" ARABIC SUBSCRIPT ALEF + // U+0670: "ٰ" ARABIC LETTER SUPERSCRIPT ALEF + // U+0653: "ٓ" ARABIC MADDAH ABOVE + // U+0650: "ِ" ARABIC KASRA + // U+064F: "ُ" ARABIC DAMMA + // U+064E: "َ" ARABIC FATHA + // U+0640: "ـ" ARABIC TATWEEL + moreKey(" \u0655", "\u0655"), moreKey(" \u0654", "\u0654"), + moreKey(" \u0652", "\u0652"), moreKey(" \u064D", "\u064D"), + moreKey(" \u064C", "\u064C"), moreKey(" \u064B", "\u064B"), + moreKey(" \u0651", "\u0651"), moreKey(" \u0656", "\u0656"), + moreKey(" \u0670", "\u0670"), moreKey(" \u0653", "\u0653"), + moreKey(" \u0650", "\u0650"), moreKey(" \u064F", "\u064F"), + moreKey(" \u064E", "\u064E"), moreKey("\u0640\u0640\u0640", "\u0640") + }; + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { + if (isPhone) { + return ALPHABET_COMMON; + } else { + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + // U+0626: "ئ" ARABIC LETTER YEH WITH HAMZA ABOVE + builder.insertKeysAtRow(3, 2, key("\u0626")); + return builder.build(); + } + } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(final boolean isPhone, final int elementId) { + return null; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0636: "ض" ARABIC LETTER DAD + // U+0661: "١" ARABIC-INDIC DIGIT ONE + key("\u0636", joinMoreKeys("1", "\u0661")), + // U+0635: "ص" ARABIC LETTER SAD + // U+0662: "٢" ARABIC-INDIC DIGIT TWO + key("\u0635", joinMoreKeys("2", "\u0662")), + // U+062B: "ث" ARABIC LETTER THEH + // U+0663: "٣" ARABIC-INDIC DIGIT THREE + key("\u062B", joinMoreKeys("3", "\u0663")), + // U+0642: "ق" ARABIC LETTER QAF + // U+0664: "٤" ARABIC-INDIC DIGIT FOUR + // U+06A8: "ڨ" ARABIC LETTER QAF WITH THREE DOTS ABOVE + key("\u0642", joinMoreKeys("4", "\u0664", "\u06A8")), + // U+0641: "ف" ARABIC LETTER FEH + // U+0665: "٥" ARABIC-INDIC DIGIT FIVE + // U+06A4: "ڤ" ARABIC LETTER VEH + // U+06A2: "ڢ" ARABIC LETTER FEH WITH DOT MOVED BELOW + // U+06A5: "ڥ" ARABIC LETTER FEH WITH THREE DOTS BELOW + key("\u0641", joinMoreKeys("5", "\u0665", "\u06A4", "\u06A2", "\u06A5")), + // U+063A: "غ" ARABIC LETTER GHAIN + // U+0666: "٦" ARABIC-INDIC DIGIT SIX + key("\u063A", joinMoreKeys("6", "\u0666")), + // U+0639: "ع" ARABIC LETTER AIN + // U+0667: "٧" ARABIC-INDIC DIGIT SEVEN + key("\u0639", joinMoreKeys("7", "\u0667")), + // U+0647: "ه" ARABIC LETTER HEH + // U+0668: "٨" ARABIC-INDIC DIGIT EIGHT + // U+FEEB: "ﻫ" ARABIC LETTER HEH INITIAL FORM + // U+0647 U+200D: ARABIC LETTER HEH + ZERO WIDTH JOINER + key("\u0647", joinMoreKeys("8", "\u0668", moreKey("\uFEEB", "\u0647\u200D"))), + // U+062E: "خ" ARABIC LETTER KHAH + // U+0669: "٩" ARABIC-INDIC DIGIT NINE + key("\u062E", joinMoreKeys("9", "\u0669")), + // U+062D: "ح" ARABIC LETTER HAH + // U+0660: "٠" ARABIC-INDIC DIGIT ZERO + key("\u062D", joinMoreKeys("0", "\u0660")), + // U+062C: "ج" ARABIC LETTER JEEM + // U+0686: "چ" ARABIC LETTER TCHEH + key("\u062C", moreKey("\u0686"))) + .setKeysOfRow(2, + // U+0634: "ش" ARABIC LETTER SHEEN + // U+069C: "ڜ" ARABIC LETTER SEEN WITH THREE DOTS BELOW AND THREE DOTS ABOVE + key("\u0634", moreKey("\u069C")), + // U+0633: "س" ARABIC LETTER SEEN + key("\u0633"), + // U+064A: "ي" ARABIC LETTER YEH + // U+0626: "ئ" ARABIC LETTER YEH WITH HAMZA ABOVE + // U+0649: "ى" ARABIC LETTER ALEF MAKSURA + key("\u064A", joinMoreKeys("\u0626", "\u0649")), + // U+0628: "ب" ARABIC LETTER BEH + // U+067E: "پ" ARABIC LETTER PEH + key("\u0628", moreKey("\u067E")), + // U+0644: "ل" ARABIC LETTER LAM + // U+FEFB: "ﻻ" ARABIC LIGATURE LAM WITH ALEF ISOLATED FORM + // U+0627: "ا" ARABIC LETTER ALEF + // U+FEF7: "ﻷ" ARABIC LIGATURE LAM WITH ALEF WITH HAMZA ABOVE ISOLATED FORM + // U+0623: "أ" ARABIC LETTER ALEF WITH HAMZA ABOVE + // U+FEF9: "ﻹ" ARABIC LIGATURE LAM WITH ALEF WITH HAMZA BELOW ISOLATED FORM + // U+0625: "إ" ARABIC LETTER ALEF WITH HAMZA BELOW + // U+FEF5: "ﻵ" ARABIC LIGATURE LAM WITH ALEF WITH MADDA ABOVE ISOLATED FORM + // U+0622: "آ" ARABIC LETTER ALEF WITH MADDA ABOVE --> + key("\u0644", + moreKey("\uFEFB", "\u0644\u0627"), moreKey("\uFEF7", "\u0644\u0623"), + moreKey("\uFEF9", "\u0644\u0625"), moreKey("\uFEF5", "\u0644\u0622")), + // U+0627: "ا" ARABIC LETTER ALEF + // U+0622: "آ" ARABIC LETTER ALEF WITH MADDA ABOVE + // U+0621: "ء" ARABIC LETTER HAMZA + // U+0623: "أ" ARABIC LETTER ALEF WITH HAMZA ABOVE + // U+0625: "إ" ARABIC LETTER ALEF WITH HAMZA BELOW + // U+0671: "ٱ" ARABIC LETTER ALEF WASLA + key("\u0627", joinMoreKeys("\u0622", "\u0621", "\u0623", "\u0625", "\u0671")), + // U+062A: "ت" ARABIC LETTER TEH + key("\u062A"), + // U+0646: "ن" ARABIC LETTER NOON + key("\u0646"), + // U+0645: "م" ARABIC LETTER MEEM + key("\u0645"), + // U+0643: "ك" ARABIC LETTER KAF + // U+06AF: "گ" ARABIC LETTER GAF + // U+06A9: "ک" ARABIC LETTER KEHEH + key("\u0643", joinMoreKeys("\u06AF", "\u06A9")), + // U+0637: "ط" ARABIC LETTER TAH + key("\u0637")) + .setKeysOfRow(3, joinKeys( + // U+0630: "ذ" ARABIC LETTER THAL + // U+0621: "ء" ARABIC LETTER HAMZA + // U+0624: "ؤ" ARABIC LETTER WAW WITH HAMZA ABOVE + // U+0631: "ر" ARABIC LETTER REH + "\u0630", "\u0621", "\u0624", "\u0631", + // U+0649: "ى" ARABIC LETTER ALEF MAKSURA + // U+0626: "ئ" ARABIC LETTER YEH WITH HAMZA ABOVE + key("\u0649", moreKey("\u0626")), + // U+0629: "ة" ARABIC LETTER TEH MARBUTA + // U+0648: "و" ARABIC LETTER WAW + "\u0629", "\u0648", + // U+0632: "ز" ARABIC LETTER ZAIN + // U+0698: "ژ" ARABIC LETTER JEH + key("\u0632", moreKey("\u0698")), + // U+0638: "ظ" ARABIC LETTER ZAH + // U+062F: "د" ARABIC LETTER DAL + "\u0638", "\u062F")) + .build(); + + private static class ArabicSymbols extends RtlSymbols { + public ArabicSymbols(final LayoutCustomizer customizer) { + super(customizer); + } + + @Override + public ExpectedKey[][] getLayout(final boolean isPhone) { + return new ExpectedKeyboardBuilder(super.getLayout(isPhone)) + // U+0661: "١" ARABIC-INDIC DIGIT ONE + // 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 + .replaceKeyOfLabel("1", key("\u0661", + joinMoreKeys("1", "\u00B9", "\u00BD", "\u2153", "\u00BC", "\u215B"))) + // U+0662: "٢" ARABIC-INDIC DIGIT TWO + // U+00B2: "²" SUPERSCRIPT TWO + // U+2154: "⅔" VULGAR FRACTION TWO THIRDS + .replaceKeyOfLabel("2", key("\u0662", joinMoreKeys("2", "\u00B2", "\u2154"))) + // U+0663: "٣" ARABIC-INDIC DIGIT THREE + // U+00B3: "³" SUPERSCRIPT THREE + // U+00BE: "¾" VULGAR FRACTION THREE QUARTERS + // U+215C: "⅜" VULGAR FRACTION THREE EIGHTHS + .replaceKeyOfLabel("3", key("\u0663", + joinMoreKeys("3", "\u00B3", "\u00BE", "\u215C"))) + // U+0664: "٤" ARABIC-INDIC DIGIT FOUR + // U+2074: "⁴" SUPERSCRIPT FOUR + .replaceKeyOfLabel("4", key("\u0664", joinMoreKeys("4", "\u2074"))) + // U+0665: "٥" ARABIC-INDIC DIGIT FIVE + // U+215D: "⅝" VULGAR FRACTION FIVE EIGHTHS + .replaceKeyOfLabel("5", key("\u0665", joinMoreKeys("5", "\u215D"))) + // U+0666: "٦" ARABIC-INDIC DIGIT SIX + .replaceKeyOfLabel("6", key("\u0666", moreKey("6"))) + // U+0667: "٧" ARABIC-INDIC DIGIT SEVEN + // U+215E: "⅞" VULGAR FRACTION SEVEN EIGHTHS + .replaceKeyOfLabel("7", key("\u0667", joinMoreKeys("7", "\u215E"))) + // U+0668: "٨" ARABIC-INDIC DIGIT EIGHT + .replaceKeyOfLabel("8", key("\u0668", moreKey("8"))) + // U+0669: "٩" ARABIC-INDIC DIGIT NINE + .replaceKeyOfLabel("9", key("\u0669", moreKey("9"))) + // U+0660: "٠" ARABIC-INDIC DIGIT ZERO + // U+066B: "٫" ARABIC DECIMAL SEPARATOR + // U+066C: "٬" ARABIC THOUSANDS SEPARATOR + // U+207F: "ⁿ" SUPERSCRIPT LATIN SMALL LETTER N + // U+2205: "∅" EMPTY SET + .replaceKeyOfLabel("0", key("\u0660", + joinMoreKeys("0", "\u066B", "\u066C", "\u207F", "\u2205"))) + // U+066A: "٪" ARABIC PERCENT SIGN + // U+2030: "‰" PER MILLE SIGN + .replaceKeyOfLabel("%", key("\u066A", joinMoreKeys("%", "\u2030"))) + // U+061B: "؛" ARABIC SEMICOLON + .replaceKeyOfLabel(";", key("\u061B", moreKey(";"))) + // U+061F: "؟" ARABIC QUESTION MARK + // U+00BF: "¿" INVERTED QUESTION MARK + .replaceKeyOfLabel("?", key("\u061F", joinMoreKeys("?", "\u00BF"))) + // U+060C: "،" ARABIC COMMA + .replaceKeyOfLabel(",", key("\u060C", moreKey(","))) + // U+FD3E: "﴾" ORNATE LEFT PARENTHESIS + // U+FD3F: "﴿" ORNATE RIGHT PARENTHESIS + .replaceKeyOfLabel("(", key("(", ")", + moreKey("\uFD3E", "\uFD3F"), moreKey("<", ">"), moreKey("{", "}"), + moreKey("[", "]"))) + // U+FD3F: "﴿" ORNATE RIGHT PARENTHESIS + // U+FD3E: "﴾" ORNATE LEFT PARENTHESIS + .replaceKeyOfLabel(")", key(")", "(", + moreKey("\uFD3F", "\uFD3E"), moreKey(">", "<"), moreKey("}", "{"), + moreKey("]", "["))) + // U+2605: "★" BLACK STAR + // U+066D: "٭" ARABIC FIVE POINTED STAR + .setMoreKeysOf("*", "\u2605", "\u066D") + .build(); + } + } + + private static class ArabicSymbolsShifted extends RtlSymbolsShifted { + public ArabicSymbolsShifted(final LayoutCustomizer customizer) { + super(customizer); + } + + @Override + public ExpectedKey[][] getLayout(final boolean isPhone) { + return new ExpectedKeyboardBuilder(super.getLayout(isPhone)) + // U+2022: "•" BULLET + // U+266A: "♪" EIGHTH NOTE + .setMoreKeysOf("\u2022", "\u266A") + // U+060C: "،" ARABIC COMMA + .replaceKeyOfLabel(",", key("\u060C", moreKey(","))) + .build(); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Azerty.java b/tests/src/com/android/inputmethod/keyboard/layout/Azerty.java new file mode 100644 index 000000000..24d85cf76 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/Azerty.java @@ -0,0 +1,77 @@ +/* + * 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; + +/** + * The AZERTY alphabet keyboard. + */ +public final class Azerty extends LayoutBase { + public Azerty(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return "azerty"; } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { + final LayoutCustomizer customizer = getCustomizer(); + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + customizer.setAccentedLetters(builder); + builder.replaceKeyOfLabel(ROW3_QUOTE, key("'", joinMoreKeys( + customizer.getSingleQuoteMoreKeys(), + customizer.getSingleAngleQuoteKeys()))); + 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); + getCustomizer().setAccentedLetters(builder); + builder.replaceKeyOfLabel(ROW3_QUOTE, key("?")); + } + builder.toUpperCase(getLocale()); + return builder.build(); + } + + private static final String ROW3_QUOTE = "ROW3_QUOUTE"; + + 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"))) + .setLabelsOfRow(2, "q", "s", "d", "f", "g", "h", "j", "k", "l", "m") + .setLabelsOfRow(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 new file mode 100644 index 000000000..a1ad54957 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/Bulgarian.java @@ -0,0 +1,105 @@ +/* + * 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.EastSlavic.EastSlavicCustomizer; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public final class Bulgarian extends LayoutBase { + private static final String LAYOUT_NAME = "bulgarian"; + + public Bulgarian(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + public static class BulgarianCustomizer extends LayoutCustomizer { + private final EastSlavicCustomizer mEastSlavicCustomizer; + + public BulgarianCustomizer(final Locale locale) { + super(locale); + mEastSlavicCustomizer = new EastSlavicCustomizer(locale); + } + + @Override + public ExpectedKey getAlphabetKey() { + return mEastSlavicCustomizer.getAlphabetKey(); + } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+044F: "я" CYRILLIC SMALL LETTER YA + key("\u044F", moreKey("1")), + // U+0432: "в" CYRILLIC SMALL LETTER VE + key("\u0432", moreKey("2")), + // U+0435: "е" CYRILLIC SMALL LETTER IE + key("\u0435", moreKey("3")), + // U+0440: "р" CYRILLIC SMALL LETTER ER + key("\u0440", moreKey("4")), + // U+0442: "т" CYRILLIC SMALL LETTER TE + key("\u0442", moreKey("5")), + // U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN + key("\u044A", moreKey("6")), + // U+0443: "у" CYRILLIC SMALL LETTER U + key("\u0443", moreKey("7")), + // U+0438: "и" CYRILLIC SMALL LETTER I + // U+045D: "ѝ" CYRILLIC SMALL LETTER I WITH GRAVE + key("\u0438", joinMoreKeys("8", "\u045D")), + // U+043E: "о" CYRILLIC SMALL LETTER O + key("\u043E", moreKey("9")), + // U+043F: "п" CYRILLIC SMALL LETTER PE + key("\u043F", moreKey("0")), + // U+0447: "ч" CYRILLIC SMALL LETTER CHE + key("\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 + .setLabelsOfRow(2, + "\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 + .setLabelsOfRow(3, + "\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 new file mode 100644 index 000000000..b47b59216 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/BulgarianBds.java @@ -0,0 +1,97 @@ +/* + * 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.EastSlavic.EastSlavicCustomizer; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public final class BulgarianBds extends LayoutBase { + private static final String LAYOUT_NAME = "bulgarian_bds"; + + public BulgarianBds(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + public static class BulgarianBdsCustomizer extends EastSlavicCustomizer { + public BulgarianBdsCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0443: "у" CYRILLIC SMALL LETTER U + key("\u0443", moreKey("1")), + // U+0435: "е" CYRILLIC SMALL LETTER IE + key("\u0435", moreKey("2")), + // U+0438: "и" CYRILLIC SMALL LETTER I + // U+045D: "ѝ" CYRILLIC SMALL LETTER I WITH GRAVE + key("\u0438", joinMoreKeys("3", "\u045D")), + // U+0448: "ш" CYRILLIC SMALL LETTER SHA + key("\u0448", moreKey("4")), + // U+0449: "щ" CYRILLIC SMALL LETTER SHCHA + key("\u0449", moreKey("5")), + // U+043A: "к" CYRILLIC SMALL LETTER KA + key("\u043A", moreKey("6")), + // U+0441: "с" CYRILLIC SMALL LETTER ES + key("\u0441", moreKey("7")), + // U+0434: "д" CYRILLIC SMALL LETTER DE + key("\u0434", moreKey("8")), + // U+0437: "з" CYRILLIC SMALL LETTER ZE + key("\u0437", moreKey("9")), + // U+0446: "ц" CYRILLIC SMALL LETTER TSE + key("\u0446", moreKey("0")), + // U+0431: "б" CYRILLIC SMALL LETTER BE + key("\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 + .setLabelsOfRow(2, + "\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 + .setLabelsOfRow(3, + "\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 new file mode 100644 index 000000000..6d2e245a7 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/EastSlavic.java @@ -0,0 +1,110 @@ +/* + * 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; + +public final class EastSlavic extends LayoutBase { + private static final String LAYOUT_NAME = "east_slavic"; + + public EastSlavic(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + public static class EastSlavicCustomizer extends LayoutCustomizer { + public EastSlavicCustomizer(final Locale locale) { + super(locale); + } + + @Override + public final ExpectedKey getAlphabetKey() { return EAST_SLAVIC_ALPHABET_KEY; } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS; + } + + // U+0410: "А" CYRILLIC CAPITAL LETTER A + // U+0411: "Б" CYRILLIC CAPITAL LETTER BE + // U+0412: "В" CYRILLIC CAPITAL LETTER VE + private static final ExpectedKey EAST_SLAVIC_ALPHABET_KEY = key( + "\u0410\u0411\u0412", Constants.CODE_SWITCH_ALPHA_SYMBOL); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; } + + public static final String ROW1_9 = "ROW1_9"; + public static final String ROW2_2 = "ROW2_2"; + public static final String ROW2_11 = "ROW2_11"; + public static final String ROW3_5 = "ROW3_5"; + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0443: "у" CYRILLIC SMALL LETTER U + key("\u0439", moreKey("1")), + // U+0446: "ц" CYRILLIC SMALL LETTER TSE + key("\u0446", moreKey("2")), + // U+0439: "й" CYRILLIC SMALL LETTER SHORT I + key("\u0443", moreKey("3")), + // U+043A: "к" CYRILLIC SMALL LETTER KA + key("\u043A", moreKey("4")), + // U+0435: "е" CYRILLIC SMALL LETTER IE + key("\u0435", moreKey("5")), + // U+043D: "н" CYRILLIC SMALL LETTER EN + key("\u043D", moreKey("6")), + // U+0433: "г" CYRILLIC SMALL LETTER GHE + key("\u0433", moreKey("7")), + // U+0448: "ш" CYRILLIC SMALL LETTER SHA + key("\u0448", moreKey("8")), + key(ROW1_9, moreKey("9")), + // U+0437: "з" CYRILLIC SMALL LETTER ZE + key("\u0437", moreKey("0")), + // U+0445: "х" CYRILLIC SMALL LETTER HA + key("\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 + .setLabelsOfRow(2, + "\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 + .setLabelsOfRow(3, + "\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 new file mode 100644 index 000000000..762170b3d --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/Greek.java @@ -0,0 +1,148 @@ +/* + * 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 com.android.inputmethod.latin.Constants; + +import java.util.Locale; + +/** + * The Greek alphabet keyboard. + */ +public final class Greek extends LayoutBase { + private static final String LAYOUT_NAME = "greek"; + + public Greek(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + public static class GreekCustomizer extends EuroLayoutCustomizer { + public GreekCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getAlphabetKey() { return GREEK_ALPHABET_KEY; } + + // U+0391: "Α" GREEK CAPITAL LETTER ALPHA + // U+0392: "Β" GREEK CAPITAL LETTER BETA + // U+0393: "Γ" GREEK CAPITAL LETTER GAMMA + private static final ExpectedKey GREEK_ALPHABET_KEY = key( + "\u0391\u0392\u0393", Constants.CODE_SWITCH_ALPHA_SYMBOL); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + builder.replaceKeyOfLabel(ROW1_1, ROW1_1_SEMICOLON); + builder.replaceKeyOfLabel(ROW1_2, ROW1_2_FINAL_SIGMA); + return builder.build(); + } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(final boolean isPhone, final int elementId) { + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + builder.toUpperCase(getLocale()); + if (elementId == KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED + || elementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED) { + builder.replaceKeyOfLabel(ROW1_1, ROW1_1_COLON); + } else { + builder.replaceKeyOfLabel(ROW1_1, ROW1_1_SEMICOLON); + } + builder.replaceKeyOfLabel(ROW1_2, ROW1_2_FINAL_SIGMA); + return builder.build(); + } + + private static final String ROW1_1 = "ROW1_1"; + private static final ExpectedKey ROW1_1_SEMICOLON = key(";", joinMoreKeys("1", ":")); + private static final ExpectedKey ROW1_1_COLON = key(":", joinMoreKeys("1", ";")); + + private static final String ROW1_2 = "ROW2_2"; + // U+03C2: "ς" GREEK SMALL LETTER FINAL SIGMA + private static final ExpectedKey ROW1_2_FINAL_SIGMA = key("\u03C2", moreKey("2")); + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + key(ROW1_1, moreKey("1")), + key(ROW1_2, moreKey("2")), + // U+03B5: "ε" GREEK SMALL LETTER EPSILON + // U+03AD: "έ" GREEK SMALL LETTER EPSILON WITH TONOS + key("\u03B5", joinMoreKeys("3", "\u03AD")), + // U+03C1: "ρ" GREEK SMALL LETTER RHO + key("\u03C1", moreKey("4")), + // U+03C4: "τ" GREEK SMALL LETTER TAU + key("\u03C4", moreKey("5")), + // U+03C5: "υ" GREEK SMALL LETTER UPSILON + // U+03CD: "ύ" GREEK SMALL LETTER UPSILON WITH TONOS + // U+03CB: "ϋ" GREEK SMALL LETTER UPSILON WITH DIALYTIKA + // U+03B0: "ΰ" GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS + key("\u03C5", joinMoreKeys("6", "\u03CD", "\u03CB", "\u03B0")), + // U+03B8: "θ" GREEK SMALL LETTER THETA + key("\u03B8", moreKey("7")), + // U+03B9: "ι" GREEK SMALL LETTER IOTA + // U+03AF: "ί" GREEK SMALL LETTER IOTA WITH TONOS + // U+03CA: "ϊ" GREEK SMALL LETTER IOTA WITH DIALYTIKA + // U+0390: "ΐ" GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS + key("\u03B9", joinMoreKeys("8", "\u03AF", "\u03CA", "\u0390")), + // U+03BF: "ο" GREEK SMALL LETTER OMICRON + // U+03CC: "ό" GREEK SMALL LETTER OMICRON WITH TONOS + key("\u03BF", joinMoreKeys("9", "\u03CC")), + // U+03C0: "π" GREEK SMALL LETTER PI + key("\u03C0", moreKey("0"))) + .setKeysOfRow(2, + // U+03B1: "α" GREEK SMALL LETTER ALPHA + // U+03AC: "ά" GREEK SMALL LETTER ALPHA WITH TONOS + key("\u03B1", moreKey("\u03AC")), + // U+03C3: "σ" GREEK SMALL LETTER SIGMA + key("\u03C3"), + // U+03B4: "δ" GREEK SMALL LETTER DELTA + key("\u03B4"), + // U+03C6: "φ" GREEK SMALL LETTER PHI + key("\u03C6"), + // U+03B3: "γ" GREEK SMALL LETTER GAMMA + key("\u03B3"), + // U+03B7: "η" GREEK SMALL LETTER ETA + // U+03AE: "ή" GREEK SMALL LETTER ETA WITH TONOS + key("\u03B7", moreKey("\u03AE")), + // U+03BE: "ξ" GREEK SMALL LETTER XI + key("\u03BE"), + // U+03BA: "κ" GREEK SMALL LETTER KAPPA + key("\u03BA"), + // U+03BB: "λ" GREEK SMALL LETTER LAMDA + key("\u03BB")) + .setKeysOfRow(3, + // U+03B6: "ζ" GREEK SMALL LETTER ZETA + key("\u03B6"), + // U+03C7: "χ" GREEK SMALL LETTER CHI + key("\u03C7"), + // U+03C8: "ψ" GREEK SMALL LETTER PSI + key("\u03C8"), + // U+03C9: "ω" GREEK SMALL LETTER OMEGA + // U+03CE: "ώ" GREEK SMALL LETTER OMEGA WITH TONOS + key("\u03C9", moreKey("\u03CE")), + // U+03B2: "β" GREEK SMALL LETTER BETA + key("\u03B2"), + // U+03BD: "ν" GREEK SMALL LETTER NU + key("\u03BD"), + // U+03BC: "μ" GREEK SMALL LETTER MU + key("\u03BC")) + .build(); +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Hindi.java b/tests/src/com/android/inputmethod/keyboard/layout/Hindi.java new file mode 100644 index 000000000..0ba768b85 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/Hindi.java @@ -0,0 +1,363 @@ +/* + * 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 com.android.inputmethod.latin.Constants; + +import java.util.Locale; + +/** + * The Hindi keyboard. + */ +public final class Hindi extends LayoutBase { + private static final String LAYOUT_NAME = "hindi"; + + public Hindi(final LayoutCustomizer customizer) { + super(customizer, HindiSymbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + public static class HindiCustomizer extends LayoutCustomizer { + public HindiCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getAlphabetKey() { return HINDI_ALPHABET_KEY; } + + @Override + public ExpectedKey getSymbolsKey() { return HINDI_SYMBOLS_KEY; } + + @Override + public ExpectedKey getBackToSymbolsKey() { return HINDI_BACK_TO_SYMBOLS_KEY; } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_HINDI; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS; + } + + // U+0915: "क" DEVANAGARI LETTER KA + // U+0916: "ख" DEVANAGARI LETTER KHA + // U+0917: "ग" DEVANAGARI LETTER GA + private static final ExpectedKey HINDI_ALPHABET_KEY = key( + "\u0915\u0916\u0917", Constants.CODE_SWITCH_ALPHA_SYMBOL); + // U+0967: "१" DEVANAGARI DIGIT ONE + // U+0968: "२" DEVANAGARI DIGIT TWO + // U+0969: "३" DEVANAGARI DIGIT THREE + private static final String HINDI_SYMBOLS_LABEL = "?\u0967\u0968\u0969"; + private static final ExpectedKey HINDI_SYMBOLS_KEY = key(HINDI_SYMBOLS_LABEL, + Constants.CODE_SWITCH_ALPHA_SYMBOL); + private static final ExpectedKey HINDI_BACK_TO_SYMBOLS_KEY = key(HINDI_SYMBOLS_LABEL, + Constants.CODE_SHIFT); + + // U+20B9: "₹" INDIAN RUPEE SIGN + private static final ExpectedKey CURRENCY_HINDI = key("\u20B9", + Symbols.DOLLAR_SIGN, Symbols.CENT_SIGN, Symbols.EURO_SIGN, Symbols.POUND_SIGN, + Symbols.YEN_SIGN, Symbols.PESO_SIGN); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) { + if (elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) { + return getCommonAlphabetLayout(isPhone); + } + return ALPHABET_SHIFTED_COMMON; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+094C: "ौ" DEVANAGARI VOWEL SIGN AU + // U+094C/U+0902: "ौं" DEVANAGARI VOWEL SIGN AU/DEVANAGARI SIGN ANUSVARA + // U+0967: "१" DEVANAGARI DIGIT ONE + key("\u094C", joinMoreKeys("\u094C\u0902", "\u0967", "1")), + // U+0948: "ै" DEVANAGARI VOWEL SIGN AI + // U+0948/U+0902: "ैं" DEVANAGARI VOWEL SIGN AI/DEVANAGARI SIGN ANUSVARA + // U+0968: "२" DEVANAGARI DIGIT TWO + key("\u0948", joinMoreKeys("\u0948\u0902", "\u0968", "2")), + // U+093E: "ा" DEVANAGARI VOWEL SIGN AA + // U+093E/U+0902: "ां" DEVANAGARI VOWEL SIGN AA/DEVANAGARI SIGN ANUSVARA + // U+093E/U+0901: "ाँ" DEVANAGARI VOWEL SIGN AA/DEVANAGARI SIGN CANDRABINDU + // U+0969: "३" DEVANAGARI DIGIT THREE + key("\u093E", joinMoreKeys("\u093E\u0902", "\u093E\u0901", "\u0969", "3")), + // U+0940: "ी" DEVANAGARI VOWEL SIGN II + // U+0940/U+0902: "ीं" DEVANAGARI VOWEL SIGN II/DEVANAGARI SIGN ANUSVARA + // U+096A: "४" DEVANAGARI DIGIT FOUR + key("\u0940", joinMoreKeys("\u0940\u0902", "\u096A", "4")), + // U+0942: "ू" DEVANAGARI VOWEL SIGN UU + // U+0942/U+0902: "ूं" DEVANAGARI VOWEL SIGN UU/DEVANAGARI SIGN ANUSVARA + // U+0942/U+0901: "ूँ" DEVANAGARI VOWEL SIGN UU/DEVANAGARI SIGN CANDRABINDU + // U+096B: "५" DEVANAGARI DIGIT FIVE + key("\u0942", joinMoreKeys("\u0942\u0902", "\u0942\u0901", "\u096B", "5")), + // U+092C: "ब" DEVANAGARI LETTER BA + // U+092C/U+0952: "ब॒" DEVANAGARI LETTER BA/DEVANAGARI STRESS SIGN ANUDATTA + // U+096C: "६" DEVANAGARI DIGIT SIX + key("\u092C", joinMoreKeys("\u092C\u0952", "\u096C", "6")), + // U+0939: "ह" DEVANAGARI LETTER HA + // U+096D: "७" DEVANAGARI DIGIT SEVEN + key("\u0939", joinMoreKeys("\u096D", "7")), + // U+0917: "ग" DEVANAGARI LETTER GA + // U+091C/U+094D/U+091E: + // "ज्ञ" DEVANAGARI LETTER JA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER NYA + // U+0917/U+093C: "ग़" DEVANAGARI LETTER GA/DEVANAGARI SIGN NUKTA + // U+0917/U+0952: "ग॒" DEVANAGARI LETTER GA/DEVANAGARI STRESS SIGN ANUDATTA + // U+096E: "८" DEVANAGARI DIGIT EIGHT + key("\u0917", joinMoreKeys("\u091C\u094D\u091E", "\u0917\u093C", "\u0917\u0952", + "\u096E", "8")), + // U+0926: "द" DEVANAGARI LETTER DA + // U+096F: "९" DEVANAGARI DIGIT NINE + key("\u0926", joinMoreKeys("\u096F", "9")), + // U+091C: "ज" DEVANAGARI LETTER JA + // U+091C/U+0952: "ज॒" DEVANAGARI LETTER JA/DEVANAGARI STRESS SIGN ANUDATTA + // U+091C/U+094D/U+091E: + // "ज्ञ" DEVANAGARI LETTER JA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER NYA + // U+091C/U+093C: "ज़" DEVANAGARI LETTER JA/DEVANAGARI SIGN NUKTA + // U+0966: "०" DEVANAGARI DIGIT ZERO + key("\u091C", joinMoreKeys("\u091C\u0952", "\u091C\u094D\u091E", "\u091C\u093C", + "\u0966", "0")), + // U+0921: "ड" DEVANAGARI LETTER DDA + // U+0921/U+0952: "ड॒" DEVANAGARI LETTER DDA/DEVANAGARI STRESS SIGN ANUDATTA + // U+0921/U+093C: "ड़" DEVANAGARI LETTER DDA/DEVANAGARI SIGN NUKTA + key("\u0921", joinMoreKeys("\u0921\u0952", "\u0921\u093C"))) + .setKeysOfRow(2, + // U+094B: "ो" DEVANAGARI VOWEL SIGN O + // U+094B/U+0902: "қं" DEVANAGARI VOWEL SIGN O/DEVANAGARI SIGN ANUSVARA + // U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O + // U+094A: "ॊ" DEVANAGARI VOWEL SIGN SHORT O + key("\u094B", joinMoreKeys("\u094B\u0902", "\u0949", "\u094A")), + // U+0947: "े" DEVANAGARI VOWEL SIGN E + // U+0947/U+0902: "ें" DEVANAGARI VOWEL SIGN E/DEVANAGARI SIGN ANUSVARA + key("\u0947", moreKey("\u0947\u0902")), + // U+094D: "्" DEVANAGARI SIGN VIRAMA + key("\u094D"), + // U+093F: "ि" DEVANAGARI VOWEL SIGN I + // U+093F/U+0902: "िं" DEVANAGARI VOWEL SIGN I/DEVANAGARI SIGN ANUSVARA + key("\u093F", moreKey("\u093F\u0902")), + // U+0941: "ु" DEVANAGARI VOWEL SIGN U + // U+0941/U+0902: "ुं" DEVANAGARI VOWEL SIGN U/DEVANAGARI SIGN ANUSVARA + // U+0941/U+0901: "ुँ" DEVANAGARI VOWEL SIGN U/DEVANAGARI SIGN CANDRABINDU + key("\u0941", joinMoreKeys("\u0941\u0902", "\u0941\u0901")), + // U+092A: "प" DEVANAGARI LETTER PA + key("\u092A"), + // U+0930: "र" DEVANAGARI LETTER RA + // U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R + // U+0930/U+093C: "ऱ" DEVANAGARI LETTER RA/DEVANAGARI SIGN NUKTA + // U+0960: "ॠ" DEVANAGARI LETTER VOCALIC RR + key("\u0930", joinMoreKeys("\u090B", "\u0930\u093C", "\u0960")), + // U+0915: "क" DEVANAGARI LETTER KA + // U+0915/U+093C: "क़" DEVANAGARI LETTER KA/DEVANAGARI SIGN NUKTA + key("\u0915", moreKey("\u0915\u093C")), + // U+0924: "त" DEVANAGARI LETTER TA + // U+0924/U+094D/U+0930: + // "त्र" DEVANAGARI LETTER TA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA + key("\u0924", moreKey("\u0924\u094D\u0930")), + // U+091A: "च" DEVANAGARI LETTER CA + key("\u091A"), + // U+091F: "ट" DEVANAGARI LETTER TTA + key("\u091F")) + .setKeysOfRow(3, + // U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O + key("\u0949"), + // U+0902: "ं" DEVANAGARI SIGN ANUSVARA + key("\u0902"), + // U+092E: "म" DEVANAGARI LETTER MA + // U+0950: "ॐ" DEVANAGARI OM + key("\u092E", moreKey("\u0950")), + // U+0928: "न" DEVANAGARI LETTER NA + // U+091E: "ञ" DEVANAGARI LETTER NYA + // U+0919: "ङ" DEVANAGARI LETTER NGA + // U+0928/U+093C: "ऩ" DEVANAGARI LETTER NA/DEVANAGARI SIGN NUKTA + key("\u0928", joinMoreKeys("\u091E", "\u0919", "\u0928\u093C")), + // U+0935: "व" DEVANAGARI LETTER VA + key("\u0935"), + // U+0932: "ल" DEVANAGARI LETTER LA + // U+090C: "ऌ" DEVANAGARI LETTER VOCALIC L + // U+0961: "ॡ" DEVANAGARI LETTER VOCALIC LL + key("\u0932", joinMoreKeys("\u090C", "\u0961")), + // U+0938: "स" DEVANAGARI LETTER SA + key("\u0938"), + // U+092F: "य" DEVANAGARI LETTER YA + // U+095F: "य़" DEVANAGARI LETTER YYA + key("\u092F", moreKey("\u095F")), + // U+093C: "़" DEVANAGARI SIGN NUKTA + // U+097D: "ॽ" DEVANAGARI LETTER GLOTTAL STOP + // U+0970: "॰" DEVANAGARI ABBREVIATION SIGN + // U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA + key("\u093C", joinMoreKeys("\u097D", "\u0970", "\u093D"))) + .build(); + + private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0914: "औ" DEVANAGARI LETTER AU + // U+0912/U+0902: "ऒं" DEVANAGARI LETTER SHORT O//DEVANAGARI SIGN ANUSVARA + key("\u0914", moreKey("\u0912\u0902")), + // U+0910: "ऐ" DEVANAGARI LETTER AI + // U+0910/U+0902: "ऐं" DEVANAGARI LETTER AI/DEVANAGARI SIGN ANUSVARA + key("\u0910", moreKey("\u0910\u0902")), + // U+0906: "आ" DEVANAGARI LETTER AA + // U+0906/U+0902: "आं" DEVANAGARI LETTER AA/DEVANAGARI SIGN ANUSVARA + // U+0906/U+0901: "आँ" DEVANAGARI LETTER AA/DEVANAGARI SIGN CANDRABINDU + key("\u0906", joinMoreKeys("\u0906\u0902", "\u0906\u0901")), + // U+0908: "ई" DEVANAGARI LETTER II + // U+0908/U+0902: "ईं" DEVANAGARI LETTER II/DEVANAGARI SIGN ANUSVARA + key("\u0908", moreKey("\u0908\u0902")), + // U+090A: "ऊ" DEVANAGARI LETTER UU + // U+090A/U+0902: "ऊं" DEVANAGARI LETTER UU/DEVANAGARI SIGN ANUSVARA + // U+090A/U+0901: "ऊँ" DEVANAGARI LETTER UU/DEVANAGARI SIGN CANDRABINDU + key("\u090A", joinMoreKeys("\u090A\u0902", "\u090A\u0901")), + // U+092D: "भ" DEVANAGARI LETTER BHA + key("\u092D"), + // U+0903: "ः" DEVANAGARI SIGN VISARGA + key("\u0903"), + // U+0918: "घ" DEVANAGARI LETTER GHA + key("\u0918"), + // U+0927: "ध" DEVANAGARI LETTER DHA + // U+0915/U+094D/U+0937: + // "क्ष" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER SSA + // U+0936/U+094D/U+0930: + // "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA + key("\u0927", joinMoreKeys("\u0915\u094D\u0937", "\u0936\u094D\u0930")), + // U+091D: "झ" DEVANAGARI LETTER JHA + key("\u091D"), + // U+0922: "ढ" DEVANAGARI LETTER DDHA + key("\u0922")) + .setKeysOfRow(2, + // U+0913: "ओ" DEVANAGARI LETTER O + // U+0913/U+0902: "ओं" DEVANAGARI LETTER O/DEVANAGARI SIGN ANUSVARA + // U+0911: "ऑ" DEVANAGARI LETTER CANDRA O + // U+0912: "ऒ" DEVANAGARI LETTER SHORT O + key("\u0913", joinMoreKeys("\u0913\u0902", "\u0911", "\u0912")), + // U+090F: "ए" DEVANAGARI LETTER E + // U+090F/U+0902: "एं" DEVANAGARI LETTER E/DEVANAGARI SIGN ANUSVARA + // U+090F/U+0901: "एँ" DEVANAGARI LETTER E/DEVANAGARI SIGN CANDRABINDU + // U+090D: "ऍ" DEVANAGARI LETTER CANDRA E + // U+090E: "ऎ" DEVANAGARI LETTER SHORT E + key("\u090F", joinMoreKeys("\u090F\u0902", "\u090F\u0901", "\u090D", "\u090E")), + // U+0905: "अ" DEVANAGARI LETTER A + // U+0905/U+0902: "अं" DEVANAGARI LETTER A/DEVANAGARI SIGN ANUSVARA + // U+0905/U+0901: "अँ" DEVANAGARI LETTER A/DEVANAGARI SIGN CANDRABINDU + key("\u0905", joinMoreKeys("\u0905\u0902", "\u0905\u0901")), + // U+0907: "इ" DEVANAGARI LETTER I + // U+0907/U+0902: "इं" DEVANAGARI LETTER I/DEVANAGARI SIGN ANUSVARA + // U+0907/U+0901: "इं" DEVANAGARI LETTER I/DEVANAGARI SIGN CANDRABINDU + key("\u0907", joinMoreKeys("\u0907\u0902", "\u0907\u0901")), + // U+0909: "उ" DEVANAGARI LETTER U + // U+0909/U+0902: "उं" DEVANAGARI LETTER U/DEVANAGARI SIGN ANUSVARA + // U+0909/U+0901: "उँ" DEVANAGARI LETTER U/DEVANAGARI SIGN CANDRABINDU + key("\u0909", joinMoreKeys("\u0909\u0902", "\u0909\u0901")), + // U+092B: "फ" DEVANAGARI LETTER PHA + // U+092B/U+093C: "फ़" DEVANAGARI LETTER PHA/DEVANAGARI SIGN NUKTA + key("\u092B", moreKey("\u092B\u093C")), + // U+0931: "ऱ" DEVANAGARI LETTER RRA + // U+094D/U+0930: "्र" DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA + // U+0930/U+094D: "र्" DEVANAGARI LETTER RA/DEVANAGARI SIGN VIRAMA + key("\u0931", joinMoreKeys("\u094D\u0930", "\u0930\u094D")), + // U+0916: "ख" DEVANAGARI LETTER KHA + // U+0916/U+093C: "ख़" DEVANAGARI LETTER KHA/DEVANAGARI SIGN NUKTA + key("\u0916", moreKey("\u0916\u093C")), + // U+0925: "थ" DEVANAGARI LETTER THA + key("\u0925"), + // U+091B: "छ" DEVANAGARI LETTER CHA + key("\u091B"), + // U+0920: "ठ" DEVANAGARI LETTER TTHA + key("\u0920")) + .setKeysOfRow(3, + // U+0911: "ऑ" DEVANAGARI LETTER CANDRA O + key("\u0911"), + // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU + // U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E + key("\u0901", moreKey("\u0945")), + // U+0923: "ण" DEVANAGARI LETTER NNA + key("\u0923"), + // U+0929: "ऩ" DEVANAGARI LETTER NNNA + key("\u0929"), + // U+0933: "ळ" DEVANAGARI LETTER LLA + // U+0934: "ऴ" DEVANAGARI LETTER LLLA + key("\u0933", moreKey("\u0934")), + // U+0936: "श" DEVANAGARI LETTER SHA + key("\u0936"), + // U+0937: "ष" DEVANAGARI LETTER SSA + key("\u0937"), + // U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R + // U+0944: "ॄ" DEVANAGARI VOWEL SIGN VOCALIC RR + key("\u0943", moreKey("\u0944")), + // U+091E: "ञ" DEVANAGARI LETTER NYA + key("\u091E")) + .build(); + + static class HindiSymbols extends Symbols { + public HindiSymbols(final LayoutCustomizer customizer) { + super(customizer); + } + + @Override + public ExpectedKey[][] getLayout(final boolean isPhone) { + return new ExpectedKeyboardBuilder(super.getLayout(isPhone)) + // U+0967: "१" DEVANAGARI DIGIT ONE + // 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 + .replaceKeyOfLabel("1", key("\u0967", + joinMoreKeys("1", "\u00B9", "\u00BD", "\u2153", "\u00BC", "\u215B"))) + // U+0968: "२" DEVANAGARI DIGIT TWO + // U+00B2: "²" SUPERSCRIPT TWO + // U+2154: "⅔" VULGAR FRACTION TWO THIRDS + .replaceKeyOfLabel("2", key("\u0968", joinMoreKeys("2", "\u00B2", "\u2154"))) + // U+0969: "३" DEVANAGARI DIGIT THREE + // U+00B3: "³" SUPERSCRIPT THREE + // U+00BE: "¾" VULGAR FRACTION THREE QUARTERS + // U+215C: "⅜" VULGAR FRACTION THREE EIGHTHS + .replaceKeyOfLabel("3", key("\u0969", + joinMoreKeys("3", "\u00B3", "\u00BE","\u215C"))) + // U+096A: "४" DEVANAGARI DIGIT FOUR + // U+2074: "⁴" SUPERSCRIPT FOUR + .replaceKeyOfLabel("4", key("\u096A", joinMoreKeys("4", "\u2074"))) + // U+096B: "५" DEVANAGARI DIGIT FIVE + // U+215D: "⅝" VULGAR FRACTION FIVE EIGHTHS + .replaceKeyOfLabel("5", key("\u096B", joinMoreKeys("5", "\u215D"))) + // U+096C: "६" DEVANAGARI DIGIT SIX + .replaceKeyOfLabel("6", key("\u096C", moreKey("6"))) + // U+096D: "७" DEVANAGARI DIGIT SEVEN + // U+215E: "⅞" VULGAR FRACTION SEVEN EIGHTHS + .replaceKeyOfLabel("7", key("\u096D", joinMoreKeys("7", "\u215E"))) + // U+096E: "८" DEVANAGARI DIGIT EIGHT + .replaceKeyOfLabel("8", key("\u096E", moreKey("8"))) + // U+096F: "९" DEVANAGARI DIGIT NINE + .replaceKeyOfLabel("9", key("\u096F", moreKey("9"))) + // U+0966: "०" DEVANAGARI DIGIT ZERO + // U+207F: "ⁿ" SUPERSCRIPT LATIN SMALL LETTER N + // U+2205: "∅" EMPTY SET + .replaceKeyOfLabel("0", key("\u0966", joinMoreKeys("0", "\u207F", "\u2205"))) + .build(); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java b/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java new file mode 100644 index 000000000..2c1ac2e4f --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/LayoutBase.java @@ -0,0 +1,362 @@ +/* + * 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.internal.KeyboardIconsSet; +import com.android.inputmethod.keyboard.layout.expected.AbstractLayoutBase; +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 base class of keyboard layout. + */ +public abstract class LayoutBase extends AbstractLayoutBase { + + /** + * This class is used to customize common keyboard layout to language specific layout. + */ + public static class LayoutCustomizer { + private final Locale mLocale; + + // Empty keys definition to remove keys by adding this. + protected static final ExpectedKey[] EMPTY_KEYS = joinKeys(); + + public LayoutCustomizer(final Locale locale) { + mLocale = locale; + } + + public final Locale getLocale() { + return mLocale; + } + + /** + * Set accented letters to common layout. + * @param builder the {@link ExpectedKeyboardBuilder} object that contains common keyboard + * layout. + * @return the {@link ExpectedKeyboardBuilder} object that contains accented letters as + * "more keys". + */ + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder; + } + + /** + * Get the function key to switch to alphabet layout. + * @return the {@link ExpectedKey} of the alphabet key. + */ + public ExpectedKey getAlphabetKey() { return ALPHABET_KEY; } + + /** + * Get the function key to switch to symbols layout. + * @return the {@link ExpectedKey} of the symbols key. + */ + public ExpectedKey getSymbolsKey() { return SYMBOLS_KEY; } + + /** + * Get the function key to switch to symbols shift layout. + * @param isPhone true if requesting phone's key. + * @return the {@link ExpectedKey} of the symbols shift key. + */ + public ExpectedKey getSymbolsShiftKey(boolean isPhone) { + return isPhone ? SYMBOLS_SHIFT_KEY : TABLET_SYMBOLS_SHIFT_KEY; + } + + /** + * Get the function key to switch from symbols shift to symbols layout. + * @return the {@link ExpectedKey} of the back to symbols key. + */ + public ExpectedKey getBackToSymbolsKey() { return BACK_TO_SYMBOLS_KEY; } + + /** + * Get the currency key. + * @return the {@link ExpectedKey} of the currency key. + */ + public ExpectedKey getCurrencyKey() { return Symbols.CURRENCY_DOLLAR; } + + /** + * Get other currencies keys. + * @return the array of {@link ExpectedKey} that represents other currency keys. + */ + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_THAN_DOLLAR; + } + + /** + * Get "more keys" of double quotation mark. + * @return the array of {@link ExpectedKey} of more double quotation marks in natural order. + */ + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_9LR; } + + /** + * Get "more keys" of single quotation mark. + * @return the array of {@link ExpectedKey} of more single quotation marks in natural order. + */ + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_9LR; } + + /** + * Get double angle quotation marks in natural order. + * @return the array of {@link ExpectedKey} of double angle quotation marks in natural + * order. + */ + public ExpectedKey[] getDoubleAngleQuoteKeys() { return Symbols.DOUBLE_ANGLE_QUOTES_LR; } + + /** + * Get single angle quotation marks in natural order. + * @return the array of {@link ExpectedKey} of single angle quotation marks in natural + * order. + */ + public ExpectedKey[] getSingleAngleQuoteKeys() { return Symbols.SINGLE_ANGLE_QUOTES_LR; } + + /** + * Get the left shift keys. + * @param isPhone true if requesting phone's keys. + * @return the array of {@link ExpectedKey} that should be placed at left edge of the + * keyboard. + */ + public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) { + return joinKeys(SHIFT_KEY); + } + + /** + * Get the right shift keys. + * @param isPhone true if requesting phone's keys. + * @return the array of {@link ExpectedKey} that should be placed at right edge of the + * keyboard. + */ + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + 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. + * @return the array of {@link ExpectedKey} that should be placed at left of the spacebar. + */ + public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) { + return isPhone ? joinKeys(key(",", SETTINGS_KEY)) : joinKeys(key("/")); + } + + /** + * Get the keys right to the spacebar. + * @param isPhone true if requesting phone's keys. + * @return the array of {@link ExpectedKey} that should be placed at right of the spacebar. + */ + public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) { + final ExpectedKey periodKey = key(".", getPunctuationMoreKeys(isPhone)); + return isPhone ? joinKeys(periodKey) : joinKeys(key(","), periodKey); + } + + /** + * Get "more keys" for the punctuation key (usually the period key). + * @param isPhone true if requesting phone's keys. + * @return the array of {@link ExpectedKey} that are "more keys" of the punctuation key. + */ + public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { + return isPhone ? PHONE_PUNCTUATION_MORE_KEYS + : TABLET_PUNCTUATION_MORE_KEYS; + } + } + + /** + * The layout customize class for countries that use Euro. + */ + public static class EuroLayoutCustomizer extends LayoutCustomizer { + public EuroLayoutCustomizer(final Locale locale) { + super(locale); + } + + @Override + public final ExpectedKey getCurrencyKey() { return Symbols.CURRENCY_EURO; } + + @Override + public final ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_THAN_EURO; + } + } + + private final LayoutCustomizer mCustomizer; + private final Symbols mSymbols; + private final SymbolsShifted mSymbolsShifted; + + LayoutBase(final LayoutCustomizer customizer, final Class<? extends Symbols> symbolsClass, + final Class<? extends SymbolsShifted> symbolsShiftedClass) { + mCustomizer = customizer; + try { + mSymbols = symbolsClass.getDeclaredConstructor(LayoutCustomizer.class) + .newInstance(customizer); + mSymbolsShifted = symbolsShiftedClass.getDeclaredConstructor(LayoutCustomizer.class) + .newInstance(customizer); + } catch (final Exception e) { + throw new RuntimeException("Unknown Symbols/SymbolsShifted class", e); + } + } + + /** + * The layout name. + * @return the name of this layout. + */ + public abstract String getName(); + + /** + * The locale of this layout. + * @return the locale of this layout. + */ + public final Locale getLocale() { return mCustomizer.getLocale(); } + + /** + * The layout customizer for this layout. + * @return the layout customizer; + */ + public final LayoutCustomizer getCustomizer() { return mCustomizer; } + + // Icon id. + private static final int ICON_SHIFT = KeyboardIconsSet.getIconId( + 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); + static final ExpectedKey SHIFT_KEY = key(ICON_SHIFT, + Constants.CODE_SHIFT, CAPSLOCK_MORE_KEY); + static final ExpectedKey SHIFTED_SHIFT_KEY = key(ICON_SHIFTED_SHIFT, + Constants.CODE_SHIFT, CAPSLOCK_MORE_KEY); + static final ExpectedKey ALPHABET_KEY = key("ABC", Constants.CODE_SWITCH_ALPHA_SYMBOL); + static final ExpectedKey SYMBOLS_KEY = key("?123", Constants.CODE_SWITCH_ALPHA_SYMBOL); + static final ExpectedKey BACK_TO_SYMBOLS_KEY = key("?123", Constants.CODE_SHIFT); + static final ExpectedKey SYMBOLS_SHIFT_KEY = key("= \\ <", Constants.CODE_SHIFT); + static final ExpectedKey TABLET_SYMBOLS_SHIFT_KEY = key("~ [ <", Constants.CODE_SHIFT); + + // U+00A1: "¡" INVERTED EXCLAMATION MARK + // 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( + ";", "/", "(", ")", "#", "!", ",", "?", + "&", "%", "+", "\"", "-", ":", "'", "@"); + + // 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. + * @param builder the {@link ExpectedKeyboardBuilder} object that contains common keyboard + * layout + * @param isPhone true if requesting phone's layout. + * @return the {@link ExpectedKeyboardBuilder} object that is customized and have special keys. + */ + ExpectedKeyboardBuilder convertCommonLayoutToKeyboard(final ExpectedKeyboardBuilder builder, + final boolean isPhone) { + final LayoutCustomizer customizer = getCustomizer(); + final ExpectedKey[] spacebar = joinKeys( + customizer.getKeysLeftToSpacebar(isPhone), + customizer.getSpaceKeys(isPhone), + customizer.getKeysRightToSpacebar(isPhone)); + builder.setKeysOfRow(4, spacebar); + if (isPhone) { + builder.addKeysOnTheRightOfRow(3, DELETE_KEY) + .addKeysOnTheLeftOfRow(4, customizer.getSymbolsKey()) + .addKeysOnTheRightOfRow(4, key(ENTER_KEY, EMOJI_KEY)); + } else { + builder.addKeysOnTheRightOfRow(1, DELETE_KEY) + .addKeysOnTheRightOfRow(2, ENTER_KEY) + .addKeysOnTheLeftOfRow(4, customizer.getSymbolsKey(), SETTINGS_KEY) + .addKeysOnTheRightOfRow(4, EMOJI_KEY); + + } + builder.addKeysOnTheLeftOfRow(3, customizer.getLeftShiftKeys(isPhone)) + .addKeysOnTheRightOfRow(3, customizer.getRightShiftKeys(isPhone)); + return builder; + } + + /** + * Get common alphabet layout. This layout doesn't contain any special keys. + * @param isPhone true if requesting phone's layout. + * @return the common alphabet keyboard layout. + */ + abstract ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone); + + /** + * Get common alphabet shifted layout. This layout doesn't contain any special keys. + * @param isPhone true if requesting phone's layout. + * @param elementId the element id of the requesting shifted mode. + * @return the common alphabet shifted keyboard layout. + */ + ExpectedKey[][] getCommonAlphabetShiftLayout(final boolean isPhone, final int elementId) { + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder( + getCommonAlphabetLayout(isPhone)); + getCustomizer().setAccentedLetters(builder); + builder.toUpperCase(getLocale()); + return builder.build(); + } + + /** + * Get the complete expected keyboard layout. + * @param isPhone true if requesting phone's layout. + * @param elementId the element id of the requesting keyboard mode. + * @return + */ + public ExpectedKey[][] getLayout(final boolean isPhone, final int elementId) { + if (elementId == KeyboardId.ELEMENT_SYMBOLS) { + return mSymbols.getLayout(isPhone); + } + if (elementId == KeyboardId.ELEMENT_SYMBOLS_SHIFTED) { + return mSymbolsShifted.getLayout(isPhone); + } + final ExpectedKeyboardBuilder builder; + if (elementId == KeyboardId.ELEMENT_ALPHABET) { + builder = new ExpectedKeyboardBuilder(getCommonAlphabetLayout(isPhone)); + getCustomizer().setAccentedLetters(builder); + } else { + final ExpectedKey[][] commonLayout = getCommonAlphabetShiftLayout(isPhone, elementId); + if (commonLayout == null) { + return null; + } + builder = new ExpectedKeyboardBuilder(commonLayout); + } + convertCommonLayoutToKeyboard(builder, isPhone); + if (elementId != KeyboardId.ELEMENT_ALPHABET) { + builder.replaceKeysOfAll(SHIFT_KEY, SHIFTED_SHIFT_KEY); + } + return builder.build(); + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/NepaliRomanized.java b/tests/src/com/android/inputmethod/keyboard/layout/NepaliRomanized.java new file mode 100644 index 000000000..29258945e --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/NepaliRomanized.java @@ -0,0 +1,176 @@ +/* + * 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.Hindi.HindiCustomizer; +import com.android.inputmethod.keyboard.layout.Hindi.HindiSymbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * The nepali_romanized layout + */ +public final class NepaliRomanized extends LayoutBase { + private static final String LAYOUT_NAME = "nepali_romanized"; + + public NepaliRomanized(final LayoutCustomizer customizer) { + super(customizer, HindiSymbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + public static class NepaliRomanizedCustomizer extends HindiCustomizer { + public NepaliRomanizedCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_NEPALI; } + + @Override + public ExpectedKey[] getSpaceKeys(final boolean isPhone) { + return joinKeys(SPACE_KEY, ZWNJ_ZWJ_KEY); + } + + // U+0930/U+0941/U+002E "रु." NEPALESE RUPEE SIGN + private static final ExpectedKey CURRENCY_NEPALI = key("\u0930\u0941\u002E", + Symbols.DOLLAR_SIGN, Symbols.CENT_SIGN, Symbols.EURO_SIGN, Symbols.POUND_SIGN, + Symbols.YEN_SIGN, Symbols.PESO_SIGN); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) { + if (elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) { + return getCommonAlphabetLayout(isPhone); + } + return ALPHABET_SHIFTED_COMMON; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+091F: "ट" DEVANAGARI LETTER TTA + // U+0967: "१" DEVANAGARI DIGIT ONE + // U+093C: "़" DEVANAGARI SIGN NUKTA + key("\u091F", joinMoreKeys("\u0967", "1", "\u093C")), + // U+094C: "ौ" DEVANAGARI VOWEL SIGN AU + // U+0968: "२" DEVANAGARI DIGIT TWO + key("\u094C", joinMoreKeys("\u0968", "2")), + // U+0947: "े" DEVANAGARI VOWEL SIGN E + // U+0969: "३" DEVANAGARI DIGIT THREE + key("\u0947", joinMoreKeys("\u0969", "3")), + // U+0930: "र" DEVANAGARI LETTER RA + // U+096A: "४" DEVANAGARI DIGIT FOUR + key("\u0930", joinMoreKeys("\u096A", "4")), + // U+0924: "त" DEVANAGARI LETTER TA + // U+096B: "५" DEVANAGARI DIGIT FIVE + key("\u0924", joinMoreKeys("\u096B", "5")), + // U+092F: "य" DEVANAGARI LETTER YA + // U+096C: "६" DEVANAGARI DIGIT SIX + key("\u092F", joinMoreKeys("\u096C", "6")), + // U+0941: "ु" DEVANAGARI VOWEL SIGN U + // U+096D: "७" DEVANAGARI DIGIT SEVEN + key("\u0941", joinMoreKeys("\u096D", "7")), + // U+093F: "ि" DEVANAGARI VOWEL SIGN I + // U+096E: "८" DEVANAGARI DIGIT EIGHT + key("\u093F", joinMoreKeys("\u096E", "8")), + // U+094B: "ो" DEVANAGARI VOWEL SIGN O + // U+096F: "९" DEVANAGARI DIGIT NINE + key("\u094B", joinMoreKeys("\u096F", "9")), + // U+092A: "प" DEVANAGARI LETTER PA + // U+0966: "०" DEVANAGARI DIGIT ZERO + key("\u092A", joinMoreKeys("\u0966", "0")), + // U+0907: "इ" DEVANAGARI LETTER I + key("\u0907")) + // U+093E: "ा" DEVANAGARI VOWEL SIGN AA + // U+0938: "स" DEVANAGARI LETTER SA + // U+0926: "द" DEVANAGARI LETTER DA + // U+0909: "उ" DEVANAGARI LETTER U + // U+0917: "ग" DEVANAGARI LETTER GA + // U+0939: "ह" DEVANAGARI LETTER HA + // U+091C: "ज" DEVANAGARI LETTER JA + // U+0915: "क" DEVANAGARI LETTER KA + // U+0932: "ल" DEVANAGARI LETTER LA + // U+090F: "ए" DEVANAGARI LETTER E + // U+0950: "ॐ" DEVANAGARI OM + .setLabelsOfRow(2, + "\u093E", "\u0938", "\u0926", "\u0909", "\u0917", "\u0939", "\u091C", "\u0915", + "\u0932", "\u090F", "\u0950") + // U+0937: "ष" DEVANAGARI LETTER SSA + // U+0921: "ड" DEVANAGARI LETTER DDA + // U+091A: "च" DEVANAGARI LETTER CA + // U+0935: "व" DEVANAGARI LETTER VA + // U+092C: "ब" DEVANAGARI LETTER BHA + // U+0928: "न" DEVANAGARI LETTER NA + // U+092E: "म" DEVANAGARI LETTER MA + // U+0964: "।" DEVANAGARI DANDA + // U+094D: "्" DEVANAGARI SIGN VIRAMA + .setLabelsOfRow(3, + "\u0937", "\u0921", "\u091A", "\u0935", "\u092C", "\u0928", "\u092E", "\u0964", + "\u094D") + // U+0964: "।" DEVANAGARI DANDA + // U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA + .setMoreKeysOf("\u0964", "\u093D") + .build(); + + private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() + // U+0920: "ठ" DEVANAGARI LETTER TTHA + // U+0914: "औ" DEVANAGARI LETTER AU + // U+0948: "ै" DEVANAGARI VOWEL SIGN AI + // U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R + // U+0925: "थ" DEVANAGARI LETTER THA + // U+091E: "ञ" DEVANAGARI LETTER NYA + // U+0942: "ू" DEVANAGARI VOWEL SIGN UU + // U+0940: "ी" DEVANAGARI VOWEL SIGN II + // U+0913: "ओ" DEVANAGARI LETTER O + // U+092B: "फ" DEVANAGARI LETTER PHA + // U+0908: "ई" DEVANAGARI LETTER II + .setLabelsOfRow(1, + "\u0920", "\u0914", "\u0948", "\u0943", "\u0925", "\u091E", "\u0942", "\u0940", + "\u0913", "\u092B", "\u0908") + // U+0906: "आ" DEVANAGARI LETTER AA + // U+0936: "श" DEVANAGARI LETTER SHA + // U+0927: "ध" DEVANAGARI LETTER DHA + // U+090A: "ऊ" DEVANAGARI LETTER UU + // U+0918: "घ" DEVANAGARI LETTER GHA + // U+0905: "अ" DEVANAGARI LETTER A + // U+091D: "झ" DEVANAGARI LETTER JHA + // U+0916: "ख" DEVANAGARI LETTER KHA + // U+0965: "॥" DEVANAGARI DOUBLE DANDA + // U+0910: "ऐ" DEVANAGARI LETTER AI + // U+0903: "ः" DEVANAGARI SIGN VISARGA + .setLabelsOfRow(2, + "\u0906", "\u0936", "\u0927", "\u090A", "\u0918", "\u0905", "\u091D", "\u0916", + "\u0965", "\u0910", "\u0903") + // U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R + // U+0922: "ढ" DEVANAGARI LETTER DDHA + // U+091B: "छ" DEVANAGARI LETTER CHA + // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU + // U+092D: "भ" DEVANAGARI LETTER BHA + // U+0923: "ण" DEVANAGARI LETTER NNA + // U+0902: "ं" DEVANAGARI SIGN ANUSVARA + // U+0919: "ङ" DEVANAGARI LETTER NGA + // U+094D: "्" DEVANAGARI SIGN VIRAMA + .setLabelsOfRow(3, + "\u090B", "\u0922", "\u091B", "\u0901", "\u092D", "\u0923", "\u0902", "\u0919", + "\u094D") + .build(); +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/NepaliTraditional.java b/tests/src/com/android/inputmethod/keyboard/layout/NepaliTraditional.java new file mode 100644 index 000000000..658dec03e --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/NepaliTraditional.java @@ -0,0 +1,254 @@ +/* + * 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.Hindi.HindiSymbols; +import com.android.inputmethod.keyboard.layout.NepaliRomanized.NepaliRomanizedCustomizer; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * The nepali_traditional keyboard. + */ +public final class NepaliTraditional extends LayoutBase { + private static final String LAYOUT_NAME = "nepali_traditional"; + + public NepaliTraditional(final LayoutCustomizer customizer) { + super(customizer, HindiSymbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + public static class NepaliTraditionalCustomizer extends NepaliRomanizedCustomizer { + public NepaliTraditionalCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { return EMPTY_KEYS; } + + @Override + public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) { + if (isPhone) { + // U+094D: "्" DEVANAGARI SIGN VIRAMA + return joinKeys(key("\u094D", PHONE_PUNCTUATION_MORE_KEYS)); + } + return super.getKeysRightToSpacebar(isPhone); + } + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + if (isPhone) { + builder.addKeysOnTheRightOfRow(3, + // U+0947: "े" DEVANAGARI VOWEL SIGN E + // U+0903: "ः" DEVANAGARI SIGN VISARGA + // U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA + key("\u0947", joinMoreKeys("\u0903", "\u093D")), + // U+0964: "।" DEVANAGARI DANDA + key("\u0964"), + // U+0930: "र" DEVANAGARI LETTER RA + // U+0930/U+0941: "रु" DEVANAGARI LETTER RA/DEVANAGARI VOWEL SIGN U + key("\u0930", moreKey("\u0930\u0941"))); + } else { + builder.addKeysOnTheRightOfRow(3, + // U+0903: "ः" DEVANAGARI SIGN VISARGA + // U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA + key("\u0903", moreKey("\u093D")), + // U+0947: "े" DEVANAGARI VOWEL SIGN E + key("\u0947"), + // U+0964: "।" DEVANAGARI DANDA + key("\u0964"), + // U+0930: "र" DEVANAGARI LETTER RA + key("\u0930", moreKey("!")), + // U+094D: "्" DEVANAGARI SIGN VIRAMA + key("\u094D", moreKey("?"))); + } + return builder.build(); + } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) { + if (elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) { + return getCommonAlphabetLayout(isPhone); + } + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder( + ALPHABET_SHIFTED_COMMON); + if (isPhone) { + builder.addKeysOnTheRightOfRow(3, + // U+0902: "ं" DEVANAGARI SIGN ANUSVARA + key("\u0902"), + // U+0919: "ङ" DEVANAGARI LETTER NGA + key("\u0919"), + // U+0948: "ै" DEVANAGARI VOWEL SIGN AI + // U+0936/U+094D/U+0930: + // "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA + key("\u0948", moreKey("\u0936\u094D\u0930"))); + } else { + builder.addKeysOnTheRightOfRow(3, + // U+0902: "ं" DEVANAGARI SIGN ANUSVARA + key("\u0902"), + // U+0919: "ङ" DEVANAGARI LETTER NGA + key("\u0919"), + // U+0948: "ै" DEVANAGARI VOWEL SIGN AI + // U+0936/U+094D/U+0930: + // "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA + key("\u0948", moreKey("\u0936\u094D\u0930")), + // U+0930/U+0941: "रु" DEVANAGARI LETTER RA/DEVANAGARI VOWEL SIGN U + key("\u0930\u0941", moreKey("!")), + key("?")); + } + return builder.build(); + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+091F: "ट" DEVANAGARI LETTER TTA + // U+0967: "१" DEVANAGARI DIGIT ONE + key("\u091F", joinMoreKeys("\u0967", "1")), + // U+0927: "ध" DEVANAGARI LETTER DHA + // U+0968: "२" DEVANAGARI DIGIT TWO + key("\u0927", joinMoreKeys("\u0968", "2")), + // U+092D: "भ" DEVANAGARI LETTER BHA + // U+0969: "३" DEVANAGARI DIGIT THREE + key("\u092D", joinMoreKeys("\u0969", "3")), + // U+091A: "च" DEVANAGARI LETTER CA + // U+096A: "४" DEVANAGARI DIGIT FOUR + key("\u091A", joinMoreKeys("\u096A", "4")), + // U+0924: "त" DEVANAGARI LETTER TA + // U+096B: "५" DEVANAGARI DIGIT FIVE + key("\u0924", joinMoreKeys("\u096B", "5")), + // U+0925: "थ" DEVANAGARI LETTER THA + // U+096C: "६" DEVANAGARI DIGIT SIX + key("\u0925", joinMoreKeys("\u096C", "6")), + // U+0917: "ग" DEVANAGARI LETTER G + // U+096D: "७" DEVANAGARI DIGIT SEVEN + key("\u0917", joinMoreKeys("\u096D", "7")), + // U+0937: "ष" DEVANAGARI LETTER SSA + // U+096E: "८" DEVANAGARI DIGIT EIGHT + key("\u0937", joinMoreKeys("\u096E", "8")), + // U+092F: "य" DEVANAGARI LETTER YA + // U+096F: "९" DEVANAGARI DIGIT NINE + key("\u092F", joinMoreKeys("\u096F", "9")), + // U+0909: "उ" DEVANAGARI LETTER U + // U+0966: "०" DEVANAGARI DIGIT ZERO + key("\u0909", joinMoreKeys("\u0966", "0")), + // U+0907: "इ" DEVANAGARI LETTER I + // U+0914: "औ" DEVANAGARI LETTER AU + key("\u0907", moreKey("\u0914"))) + // U+092C: "ब" DEVANAGARI LETTER BA + // U+0915: "क" DEVANAGARI LETTER KA + // U+092E: "म" DEVANAGARI LETTER MA + // U+093E: "ा" DEVANAGARI VOWEL SIGN AA + // U+0928: "न" DEVANAGARI LETTER NA + // U+091C: "ज" DEVANAGARI LETTER JA + // U+0935: "व" DEVANAGARI LETTER VA + // U+092A: "प" DEVANAGARI LETTER PA + // U+093F: "ि" DEVANAGARI VOWEL SIGN I + // U+0938: "स" DEVANAGARI LETTER SA + // U+0941: "ु" DEVANAGARI VOWEL SIGN U + .setLabelsOfRow(2, + "\u092C", "\u0915", "\u092E", "\u093E", "\u0928", "\u091C", "\u0935", "\u092A", + "\u093F", "\u0938", "\u0941") + // U+0936: "श" DEVANAGARI LETTER SHA + // U+0939: "ह" DEVANAGARI LETTER HA + // U+0905: "अ" DEVANAGARI LETTER A + // U+0916: "ख" DEVANAGARI LETTER KHA + // U+0926: "द" DEVANAGARI LETTER DA + // U+0932: "ल" DEVANAGARI LETTER LA + .setLabelsOfRow(3, "\u0936", "\u0939", "\u0905", "\u0916", "\u0926", "\u0932") + .build(); + + private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0924/U+094D/U+0924: + // "त्त" DEVANAGARI LETTER TA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER TA + // U+091E: "ञ" DEVANAGARI LETTER NYA + // U+091C/U+094D/U+091E: "ज्ञ" DEVANAGARI LETTER JA/DEVANAGARI SIGN + // VIRAMA/DEVANAGARI LETTER NYA + // U+0965: "॥" DEVANAGARI DOUBLE DANDA + key("\u0924\u094D\u0924", + joinMoreKeys("\u091E", "\u091C\u094D\u091E", "\u0965")), + // U+0921/U+094D/U+0922: + // "ड्ढ" DEVANAGARI LETTER DDA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER DDHA + // U+0908: "ई" DEVANAGARI LETTER II + key("\u0921\u094D\u0922", moreKey("\u0908")), + // U+0910: "ऐ" DEVANAGARI LETTER AI + // U+0918: "घ" DEVANAGARI LETTER GHA + key("\u0910", moreKey("\u0918")), + // U+0926/U+094D/U+0935: + // "द्व" DEVANAGARI LETTER DA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER VA + // U+0926/U+094D/U+0927: + // "द्ध" DEVANAGARI LETTER DA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER DHA + key("\u0926\u094D\u0935", moreKey("\u0926\u094D\u0927")), + // U+091F/U+094D/U+091F: + // "ट्ट" DEVANAGARI LETTER TTA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER TTA + // U+091B: "छ" DEVANAGARI LETTER CHA + key("\u091F\u094D\u091F", moreKey("\u091B")), + // U+0920/U+094D/U+0920: + // "ठ्ठ" DEVANAGARI LETTER TTHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER TTHA + // U+091F: "ट" DEVANAGARI LETTER TTA + key("\u0920\u094D\u0920", moreKey("\u091F")), + // U+090A: "ऊ" DEVANAGARI LETTER UU + // U+0920: "ठ" DEVANAGARI LETTER TTHA + key("\u090A", moreKey("\u0920")), + // U+0915/U+094D/U+0937: + // "क्ष" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER SSA + // U+0921: "ड" DEVANAGARI LETTER DDA + key("\u0915\u094D\u0937", moreKey("\u0921")), + // U+0907: "इ" DEVANAGARI LETTER I + // U+0922: "ढ" DEVANAGARI LETTER DDHA + key("\u0907", moreKey("\u0922")), + // U+090F: "ए" DEVANAGARI LETTER E + // U+0923: "ण" DEVANAGARI LETTER NNA + key("\u090F", moreKey("\u0923")), + // U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R + // U+0913: "ओ" DEVANAGARI LETTER O + key("\u0943", moreKey("\u0913"))) + // U+0906: "आ" DEVANAGARI LETTER AA + // U+0919/U+094D: "ङ्" DEVANAGARI LETTER NGA/DEVANAGARI SIGN VIRAMA + // U+0921/U+094D/U+0921: + // "ड्ड" DEVANAGARI LETTER DDA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER DDA + // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU + // U+0926/U+094D/U+0926: + // "द्द" DEVANAGARI LETTER DA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER DA + // U+091D: "झ" DEVANAGARI LETTER JHA + // U+094B: "ो" DEVANAGARI VOWEL SIGN O + // U+092B: "फ" DEVANAGARI LETTER PHA + // U+0940: "ी" DEVANAGARI VOWEL SIGN II + // U+091F/U+094D/U+0920: + // "ट्ठ" DEVANAGARI LETTER TTA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER TTHA + // U+0942: "ू" DEVANAGARI VOWEL SIGN UU + .setLabelsOfRow(2, + "\u0906", "\u0919\u094D", "\u0921\u094D\u0921", "\u0901", "\u0926\u094D\u0926", + "\u091D", "\u094B", "\u092B", "\u0940", "\u091F\u094D\u0920", "\u0942") + // U+0915/U+094D: "क्" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA + // U+0939/U+094D/U+092E: + // "ह्म" DEVANAGARI LETTER HA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER MA + // U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R + // U+0950: "ॐ" DEVANAGARI OM + // U+094C: "ौ" DEVANAGARI VOWEL SIGN AU + // U+0926/U+094D/U+092F: + // "द्य" DEVANAGARI LETTER DA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER YA + .setLabelsOfRow(3, + "\u0915\u094D", "\u0939\u094D\u092E", "\u090B", "\u0950", "\u094C", + "\u0926\u094D\u092F") + .build(); +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Nordic.java b/tests/src/com/android/inputmethod/keyboard/layout/Nordic.java new file mode 100644 index 000000000..a535ad2ed --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/Nordic.java @@ -0,0 +1,58 @@ +/* + * 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; + +/** + * The Nordic alphabet keyboard. + */ +public final class Nordic extends LayoutBase { + private static final String LAYOUT_NAME = "nordic"; + + public Nordic(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; } + + public static final String ROW1_11 = "ROW1_11"; + public static final String ROW2_10 = "ROW2_10"; + public static final String ROW2_11 = "ROW2_11"; + + 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(ROW1_11)) + .setLabelsOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l", ROW2_10, ROW2_11) + .setLabelsOfRow(3, "z", "x", "c", "v", "b", "n", "m") + .build(); +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Qwerty.java b/tests/src/com/android/inputmethod/keyboard/layout/Qwerty.java index 325b78450..a0da7e37d 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/Qwerty.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/Qwerty.java @@ -18,30 +18,35 @@ 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.keyboard.layout.expected.LayoutBase; /** * The QWERTY alphabet keyboard. */ public final class Qwerty extends LayoutBase { - public static final String LAYOUT_NAME = "qwerty"; + private static final String LAYOUT_NAME = "qwerty"; - public static ExpectedKey[][] getLayout(final boolean isPhone) { - return getDefaultAlphabetLayout(ALPHABET_COMMON, isPhone); + public Qwerty(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); } - private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder(10, 9, 7, 3) - .setLabelsOfRow(1, "q", "w", "e", "r", "t", "y", "u", "i", "o", "p") - .setMoreKeysOf("q", "1") - .setMoreKeysOf("w", "2") - .setMoreKeysOf("e", "3") - .setMoreKeysOf("r", "4") - .setMoreKeysOf("t", "5") - .setMoreKeysOf("y", "6") - .setMoreKeysOf("u", "7") - .setMoreKeysOf("i", "8") - .setMoreKeysOf("o", "9") - .setMoreKeysOf("p", "0") + @Override + public String getName() { return LAYOUT_NAME; } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; } + + 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"))) .setLabelsOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l") .setLabelsOfRow(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 new file mode 100644 index 000000000..25f4734c4 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/Qwertz.java @@ -0,0 +1,50 @@ +/* + * 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; + +public final class Qwertz extends LayoutBase { + private static final String LAYOUT_NAME = "qwertz"; + + public Qwertz(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; } + + 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"))) + .setLabelsOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l") + .setLabelsOfRow(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 new file mode 100644 index 000000000..ad226ddec --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/SouthSlavic.java @@ -0,0 +1,110 @@ +/* + * 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; + +public final class SouthSlavic extends LayoutBase { + private static final String LAYOUT_NAME = "south_slavic"; + + public SouthSlavic(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + public static class SouthSlavicLayoutCustomizer extends LayoutCustomizer { + public SouthSlavicLayoutCustomizer(final Locale locale) { + super(locale); + } + + @Override + public final ExpectedKey getAlphabetKey() { return SOUTH_SLAVIC_ALPHABET_KEY; } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS; + } + + // U+0410: "А" CYRILLIC CAPITAL LETTER A + // U+0411: "Б" CYRILLIC CAPITAL LETTER BE + // U+0412: "В" CYRILLIC CAPITAL LETTER VE + private static final ExpectedKey SOUTH_SLAVIC_ALPHABET_KEY = key( + "\u0410\u0411\u0412", Constants.CODE_SWITCH_ALPHA_SYMBOL); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; } + + public static final String ROW1_6 = "ROW1_6"; + public static final String ROW2_11 = "ROW2_11"; + public static final String ROW3_1 = "ROW3_1"; + public static final String ROW3_8 = "ROW3_8"; + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0459: "љ" CYRILLIC SMALL LETTER LJE + key("\u0459", moreKey("1")), + // U+045A: "њ" CYRILLIC SMALL LETTER NJE + key("\u045A", moreKey("2")), + // U+0435: "е" CYRILLIC SMALL LETTER IE + key("\u0435", moreKey("3")), + // U+0440: "р" CYRILLIC SMALL LETTER ER + key("\u0440", moreKey("4")), + // U+0442: "т" CYRILLIC SMALL LETTER TE + key("\u0442", moreKey("5")), + key(ROW1_6, moreKey("6")), + // U+0443: "у" CYRILLIC SMALL LETTER U + key("\u0443", moreKey("7")), + // U+0438: "и" CYRILLIC SMALL LETTER I + key("\u0438", moreKey("8")), + // U+043E: "о" CYRILLIC SMALL LETTER O + key("\u043E", moreKey("9")), + // U+043F: "п" CYRILLIC SMALL LETTER PE + key("\u043F", moreKey("0")), + // U+0448: "ш" CYRILLIC SMALL LETTER SHA + key("\u0448")) + // 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+0458: "ј" CYRILLIC SMALL LETTER JE + // U+043A: "к" CYRILLIC SMALL LETTER KA + // U+043B: "л" CYRILLIC SMALL LETTER EL + // U+0447: "ч" CYRILLIC SMALL LETTER CHE + .setLabelsOfRow(2, + "\u0430", "\u0441", "\u0434", "\u0444", "\u0433", "\u0445", "\u0458", "\u043A", + "\u043B", "\u0447", ROW2_11) + // U+045F: "џ" CYRILLIC SMALL LETTER DZHE + // U+0446: "ц" CYRILLIC SMALL LETTER TSE + // U+0432: "в" CYRILLIC SMALL LETTER VE + // U+0431: "б" CYRILLIC SMALL LETTER BE + // U+043D: "н" CYRILLIC SMALL LETTER EN + // U+043C: "м" CYRILLIC SMALL LETTER EM + // U+0436: "ж" CYRILLIC SMALL LETTER ZHE + .setLabelsOfRow(3, + ROW3_1, "\u045F", "\u0446", "\u0432", "\u0431", "\u043D", "\u043C", ROW3_8, + "\u0436") + .build(); +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Spanish.java b/tests/src/com/android/inputmethod/keyboard/layout/Spanish.java new file mode 100644 index 000000000..5ccc364ca --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/Spanish.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; + +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +public final class Spanish extends LayoutBase { + private static final String LAYOUT_NAME = "spanish"; + + public Spanish(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; } + + public static final String ROW2_10 = "ROW2_10"; + + 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"))) + .setLabelsOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l", ROW2_10) + .setLabelsOfRow(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 new file mode 100644 index 000000000..5bc45d4cb --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/Swiss.java @@ -0,0 +1,55 @@ +/* + * 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; + +public final class Swiss extends LayoutBase { + private static final String LAYOUT_NAME = "swiss"; + + public Swiss(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; } + + public static final String ROW1_11 = "ROW1_11"; + public static final String ROW2_10 = "ROW2_10"; + public static final String ROW2_11 = "ROW2_11"; + + 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(ROW1_11)) + .setLabelsOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l", ROW2_10, ROW2_11) + .setLabelsOfRow(3, "y", "x", "c", "v", "b", "n", "m") + .build(); +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Symbols.java b/tests/src/com/android/inputmethod/keyboard/layout/Symbols.java index 6fcfa0520..127d81aad 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/Symbols.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/Symbols.java @@ -16,36 +16,49 @@ package com.android.inputmethod.keyboard.layout; +import com.android.inputmethod.keyboard.layout.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.expected.AbstractLayoutBase; import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; -import com.android.inputmethod.keyboard.layout.expected.LayoutBase; -import com.android.inputmethod.latin.Constants; /** * The symbols keyboard layout. */ -public final class Symbols extends LayoutBase { - public static ExpectedKey[][] getLayout(final boolean isPhone) { - return isPhone ? toPhoneSymbol(SYMBOLS_COMMON) : toTabletSymbols(SYMBOLS_COMMON); +public class Symbols extends AbstractLayoutBase { + private final LayoutCustomizer mCustomizer; + + public Symbols(final LayoutCustomizer customizer) { + mCustomizer = customizer; } - public static ExpectedKey[][] getDefaultLayout(final boolean isPhone) { - final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(getLayout(isPhone)); - builder.replaceKeyOfLabel(CURRENCY, Symbols.CURRENCY_DOLLAR); - builder.replaceKeyOfLabel(DOUBLE_QUOTE, - key("\"", join(Symbols.DOUBLE_QUOTES_9LR, Symbols.DOUBLE_ANGLE_QUOTES_LR))); - builder.replaceKeyOfLabel(SINGLE_QUOTE, - key("'", join(Symbols.SINGLE_QUOTES_9LR, Symbols.SINGLE_ANGLE_QUOTES_LR))); + public ExpectedKey[][] getLayout(final boolean isPhone) { + 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(); } - // Functional keys. - public static final ExpectedKey ALPHABET_KEY = key("ABC", Constants.CODE_SWITCH_ALPHA_SYMBOL); - public static final ExpectedKey SYMBOLS_SHIFT_KEY = key("= \\ <", Constants.CODE_SHIFT); - public static final ExpectedKey TABLET_SYMBOLS_SHIFT_KEY = key("~ [ <", Constants.CODE_SHIFT); - // Variations of the "currency" key on the 2nd row. - public static final String CURRENCY = "currency"; + public static final String CURRENCY = "CURRENCY"; // U+00A2: "¢" CENT SIGN // U+00A3: "£" POUND SIGN // U+00A5: "¥" YEN SIGN @@ -63,13 +76,13 @@ public final class Symbols extends LayoutBase { CENT_SIGN, POUND_SIGN, DOLLAR_SIGN, YEN_SIGN, PESO_SIGN); // Variations of the "double quote" key's "more keys" on the 3rd row. - public static final String DOUBLE_QUOTE = "double_quote"; + public static final String DOUBLE_QUOTE = "DOUBLE_QUOTE"; // U+201C: "“" LEFT DOUBLE QUOTATION MARK // U+201D: "”" RIGHT DOUBLE QUOTATION MARK // U+201E: "„" DOUBLE LOW-9 QUOTATION MARK - static final ExpectedKey DQUOTE_LEFT = key("\u201C"); - static final ExpectedKey DQUOTE_RIGHT = key("\u201D"); - static final ExpectedKey DQUOTE_LOW9 = key("\u201E"); + private static final ExpectedKey DQUOTE_LEFT = key("\u201C"); + private static final ExpectedKey DQUOTE_RIGHT = key("\u201D"); + private static final ExpectedKey DQUOTE_LOW9 = key("\u201E"); public static ExpectedKey[] DOUBLE_QUOTES_9LR = { DQUOTE_LOW9, DQUOTE_LEFT, DQUOTE_RIGHT }; public static ExpectedKey[] DOUBLE_QUOTES_R9L = { DQUOTE_RIGHT, DQUOTE_LOW9, DQUOTE_LEFT }; public static ExpectedKey[] DOUBLE_QUOTES_L9R = { DQUOTE_LEFT, DQUOTE_LOW9, DQUOTE_RIGHT }; @@ -78,20 +91,17 @@ public final class Symbols extends LayoutBase { // U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK private static final ExpectedKey DAQUOTE_LEFT = key("\u00AB"); private static final ExpectedKey DAQUOTE_RIGHT = key("\u00BB"); - private static final ExpectedKey DAQUOTE_LEFT_RTL = key("\u00AB", "\u00BB"); - private static final ExpectedKey DAQUOTE_RIGHT_RTL = key("\u00BB", "\u00AB"); public static ExpectedKey[] DOUBLE_ANGLE_QUOTES_LR = { DAQUOTE_LEFT, DAQUOTE_RIGHT }; public static ExpectedKey[] DOUBLE_ANGLE_QUOTES_RL = { DAQUOTE_RIGHT, DAQUOTE_LEFT }; - public static ExpectedKey[] DOUBLE_ANGLE_QUOTES_RTL = { DAQUOTE_LEFT_RTL, DAQUOTE_RIGHT_RTL }; // Variations of the "single quote" key's "more keys" on the 3rd row. - public static final String SINGLE_QUOTE = "single_quote"; + public static final String SINGLE_QUOTE = "SINGLE_QUOTE"; // U+2018: "‘" LEFT SINGLE QUOTATION MARK // U+2019: "’" RIGHT SINGLE QUOTATION MARK // U+201A: "‚" SINGLE LOW-9 QUOTATION MARK - static final ExpectedKey SQUOTE_LEFT = key("\u2018"); - static final ExpectedKey SQUOTE_RIGHT = key("\u2019"); - static final ExpectedKey SQUOTE_LOW9 = key("\u201A"); + private static final ExpectedKey SQUOTE_LEFT = key("\u2018"); + private static final ExpectedKey SQUOTE_RIGHT = key("\u2019"); + private static final ExpectedKey SQUOTE_LOW9 = key("\u201A"); public static ExpectedKey[] SINGLE_QUOTES_9LR = { SQUOTE_LOW9, SQUOTE_LEFT, SQUOTE_RIGHT }; public static ExpectedKey[] SINGLE_QUOTES_R9L = { SQUOTE_RIGHT, SQUOTE_LOW9, SQUOTE_LEFT }; public static ExpectedKey[] SINGLE_QUOTES_L9R = { SQUOTE_LEFT, SQUOTE_LOW9, SQUOTE_RIGHT }; @@ -100,81 +110,94 @@ public final class Symbols extends LayoutBase { // U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK private static final ExpectedKey SAQUOTE_LEFT = key("\u2039"); private static final ExpectedKey SAQUOTE_RIGHT = key("\u203A"); - private static final ExpectedKey SAQUOTE_LEFT_RTL = key("\u2039", "\u203A"); - private static final ExpectedKey SAQUOTE_RIGHT_RTL = key("\u203A", "\u2039"); public static ExpectedKey[] SINGLE_ANGLE_QUOTES_LR = { SAQUOTE_LEFT, SAQUOTE_RIGHT }; public static ExpectedKey[] SINGLE_ANGLE_QUOTES_RL = { SAQUOTE_RIGHT, SAQUOTE_LEFT }; - public static ExpectedKey[] SINGLE_ANGLE_QUOTES_RTL = { SAQUOTE_LEFT_RTL, SAQUOTE_RIGHT_RTL }; // Common symbols keyboard layout. - public 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") + private static final ExpectedKey[][] SYMBOLS_COMMON = new ExpectedKeyboardBuilder() + .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 static ExpectedKey[][] toPhoneSymbol(final ExpectedKey[][] common) { - return new ExpectedKeyboardBuilder(common) - .addKeysOnTheLeftOfRow(3, Symbols.SYMBOLS_SHIFT_KEY) - .addKeysOnTheRightOfRow(3, DELETE_KEY) - .addKeysOnTheLeftOfRow(4, Symbols.ALPHABET_KEY) - .addKeysOnTheRightOfRow(4, key(ENTER_KEY, EMOJI_KEY)) - .build(); - } + public static class RtlSymbols extends Symbols { + public RtlSymbols(final LayoutCustomizer customizer) { + super(customizer); + } + + // U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK + // U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK + private static final ExpectedKey DAQUOTE_LEFT_RTL = key("\u00AB", "\u00BB"); + private static final ExpectedKey DAQUOTE_RIGHT_RTL = key("\u00BB", "\u00AB"); + public static ExpectedKey[] DOUBLE_ANGLE_QUOTES_LR_RTL = { + DAQUOTE_LEFT_RTL, DAQUOTE_RIGHT_RTL + }; + // U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK + // U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK + private static final ExpectedKey SAQUOTE_LEFT_RTL = key("\u2039", "\u203A"); + private static final ExpectedKey SAQUOTE_RIGHT_RTL = key("\u203A", "\u2039"); + public static ExpectedKey[] SINGLE_ANGLE_QUOTES_LR_RTL = { + SAQUOTE_LEFT_RTL, SAQUOTE_RIGHT_RTL + }; - private static ExpectedKey[][] toTabletSymbols(final ExpectedKey[][] common) { - return new ExpectedKeyboardBuilder(common) - .addKeysOnTheLeftOfRow(3, - key("\\"), key("=")) - .addKeysOnTheRightOfRow(1, DELETE_KEY) - .addKeysOnTheRightOfRow(2, ENTER_KEY) - .addKeysOnTheLeftOfRow(3, Symbols.TABLET_SYMBOLS_SHIFT_KEY) - .addKeysOnTheRightOfRow(3, Symbols.TABLET_SYMBOLS_SHIFT_KEY) - .addKeysOnTheLeftOfRow(4, Symbols.ALPHABET_KEY) - .addKeysOnTheRightOfRow(4, EMOJI_KEY) - .build(); + @Override + public ExpectedKey[][] getLayout(final boolean isPhone) { + return new ExpectedKeyboardBuilder(super.getLayout(isPhone)) + .replaceKeyOfLabel("(", key("(", ")", + moreKey("<", ">"), moreKey("{", "}"), moreKey("[", "]"))) + .replaceKeyOfLabel(")", key(")", "(", + moreKey(">", "<"), moreKey("}", "{"), moreKey("]", "["))) + .build(); + } } } diff --git a/tests/src/com/android/inputmethod/keyboard/layout/SymbolsShifted.java b/tests/src/com/android/inputmethod/keyboard/layout/SymbolsShifted.java index 4d9ae4348..7cbd2fbb0 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/SymbolsShifted.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/SymbolsShifted.java @@ -16,31 +16,47 @@ package com.android.inputmethod.keyboard.layout; +import com.android.inputmethod.keyboard.layout.LayoutBase.LayoutCustomizer; import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; -import com.android.inputmethod.keyboard.layout.expected.LayoutBase; -import com.android.inputmethod.latin.Constants; +import com.android.inputmethod.keyboard.layout.expected.AbstractLayoutBase; /** * The symbols shifted keyboard layout. */ -public final class SymbolsShifted extends LayoutBase { - public static ExpectedKey[][] getLayout(final boolean isPhone) { - return isPhone ? toPhoneSymbolsShifted(SYMBOLS_SHIFTED_COMMON) - : toTabletSymbolsShifted(SYMBOLS_SHIFTED_COMMON); +public class SymbolsShifted extends AbstractLayoutBase { + private final LayoutCustomizer mCustomizer; + + public SymbolsShifted(final LayoutCustomizer customizer) { + mCustomizer = customizer; } - public static ExpectedKey[][] getDefaultLayout(final boolean isPhone) { - final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(getLayout(isPhone)); - builder.replaceKeyOfLabel(OTHER_CURRENCIES, SymbolsShifted.CURRENCIES_OTHER_THAN_DOLLAR); + public ExpectedKey[][] getLayout(final boolean isPhone) { + 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(); } - // Functional key. - public static final ExpectedKey BACK_TO_SYMBOLS_KEY = key("?123", Constants.CODE_SHIFT); - // Variations of the "other currencies" keys on the 2rd row. - public static final String OTHER_CURRENCIES = "other_currencies"; + public static final String OTHER_CURRENCIES = "OTHER_CURRENCY"; public static final ExpectedKey[] CURRENCIES_OTHER_THAN_DOLLAR = { Symbols.POUND_SIGN, Symbols.CENT_SIGN, Symbols.EURO_SIGN, Symbols.YEN_SIGN }; @@ -48,91 +64,101 @@ public final class SymbolsShifted extends LayoutBase { Symbols.POUND_SIGN, Symbols.YEN_SIGN, key(Symbols.DOLLAR_SIGN, Symbols.CENT_SIGN), Symbols.CENT_SIGN }; + public static final ExpectedKey[] CURRENCIES_OTHER_GENERIC = { + Symbols.POUND_SIGN, Symbols.EURO_SIGN, key(Symbols.DOLLAR_SIGN, Symbols.CENT_SIGN), + Symbols.CENT_SIGN + }; // Common symbols shifted keyboard layout. - public 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() + .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 static ExpectedKey[][] toPhoneSymbolsShifted(final ExpectedKey[][] common) { - return new ExpectedKeyboardBuilder(common) - .addKeysOnTheLeftOfRow(3, BACK_TO_SYMBOLS_KEY) - .addKeysOnTheRightOfRow(3, DELETE_KEY) - .addKeysOnTheLeftOfRow(4, Symbols.ALPHABET_KEY) - .addKeysOnTheRightOfRow(4, key(ENTER_KEY, EMOJI_KEY)) - .build(); - } + public static class RtlSymbolsShifted extends SymbolsShifted { + public RtlSymbolsShifted(final LayoutCustomizer customizer) { + super(customizer); + } - private static 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, BACK_TO_SYMBOLS_KEY) - .addKeysOnTheRightOfRow(3, BACK_TO_SYMBOLS_KEY) - .addKeysOnTheLeftOfRow(4, Symbols.ALPHABET_KEY) - .addKeysOnTheRightOfRow(4, EMOJI_KEY) + @Override + public ExpectedKey[][] getLayout(final boolean isPhone) { + return new ExpectedKeyboardBuilder(super.getLayout(isPhone)) + .replaceKeyOfLabel("{", key("{", "}")) + .replaceKeyOfLabel("}", key("}", "{")) + .replaceKeyOfLabel("[", key("[", "]")) + .replaceKeyOfLabel("]", key("]", "[")) + // U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK + // U+2264: "≤" LESS-THAN OR EQUAL TO + // U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK + .replaceKeyOfLabel("<", key("<", ">", + moreKey("\u2039", "\u203A"), moreKey("\u2264", "\u2265"), + moreKey("\u00AB", "\u00BB"))) + // U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK + // U+2265: "≥" GREATER-THAN EQUAL TO + // U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK + .replaceKeyOfLabel(">", key(">", "<", + moreKey("\u203A", "\u2039"), moreKey("\u2265", "\u2264"), + moreKey("\u00BB", "\u00AB"))) .build(); + } } } diff --git a/tests/src/com/android/inputmethod/keyboard/layout/Thai.java b/tests/src/com/android/inputmethod/keyboard/layout/Thai.java new file mode 100644 index 000000000..747e0aa31 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/Thai.java @@ -0,0 +1,319 @@ +/* + * 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 com.android.inputmethod.latin.Constants; + +import java.util.Locale; + +/** + * The Thai alphabet keyboard. + */ +public final class Thai extends LayoutBase { + private static final String LAYOUT_NAME = "thai"; + + public Thai(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + public static class ThaiCustomizer extends LayoutCustomizer { + public ThaiCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getAlphabetKey() { return THAI_ALPHABET_KEY; } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_BAHT; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { return EMPTY_KEYS; } + + // U+0E01: "ก" THAI CHARACTER KO KAI + // U+0E02: "ข" THAI CHARACTER KHO KHAI + // U+0E04: "ค" THAI CHARACTER KHO KHWAI + private static final ExpectedKey THAI_ALPHABET_KEY = key( + "\u0E01\u0E02\u0E04", Constants.CODE_SWITCH_ALPHA_SYMBOL); + + // U+0E3F: "฿" THAI CURRENCY SYMBOL BAHT + private static final ExpectedKey CURRENCY_BAHT = key("\u0E3F", + Symbols.DOLLAR_SIGN, Symbols.CENT_SIGN, Symbols.EURO_SIGN, Symbols.POUND_SIGN, + Symbols.YEN_SIGN, Symbols.PESO_SIGN); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + if (isPhone) { + // U+0E03: "ฃ" THAI CHARACTER KHO KHUAT + builder.addKeysOnTheRightOfRow(3, key("\u0E03")); + } else { + // U+0E03: "ฃ" THAI CHARACTER KHO KHUAT + builder.addKeysOnTheRightOfRow(2, key("\u0E03")) + .addKeysOnTheRightOfRow(4, EXCLAMATION_AND_QUESTION_MARKS); + } + return builder.build(); + } + + @Override + public ExpectedKey[][] getCommonAlphabetShiftLayout(final boolean isPhone, + final int elementId) { + if (elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) { + return getCommonAlphabetLayout(isPhone); + } + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder( + ALPHABET_SHIFTED_COMMON); + if (isPhone) { + // U+0E05: "ฅ" THAI CHARACTER KHO KHON + builder.addKeysOnTheRightOfRow(3, key("\u0E05")); + } else { + // U+0E05: "ฅ" THAI CHARACTER KHO KHON + builder.addKeysOnTheRightOfRow(2, key("\u0E05")); + } + 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(); + final ExpectedKey[] spacebar = joinKeys( + customizer.getKeysLeftToSpacebar(isPhone), + customizer.getSpaceKeys(isPhone), + customizer.getKeysRightToSpacebar(isPhone)); + builder.setKeysOfRow(5, spacebar); + 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, customizer.getLeftShiftKeys(isPhone)) + .addKeysOnTheRightOfRow(4, customizer.getRightShiftKeys(isPhone)); + return builder; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0E45: "ๅ" THAI CHARACTER LAKKHANGYAO + key("\u0E45"), + // U+0E51: "๑" THAI DIGIT ONE + key("/", joinMoreKeys("1", "\u0E51")), + // U+0E52: "๒" THAI DIGIT TWO + key("_", joinMoreKeys("2", "\u0E52")), + // U+0E20: "ภ" THAI CHARACTER PHO SAMPHAO + // U+0E53: "๓" THAI DIGIT THREE + key("\u0E20", joinMoreKeys("3", "\u0E53")), + // U+0E16: "ถ" THAI CHARACTER THO THUNG + // U+0E54: "๔" THAI DIGIT FOUR + key("\u0E16", joinMoreKeys("4", "\u0E54")), + // U+0E38: " ุ" THAI CHARACTER SARA U + key(" \u0E38", "\u0E38"), + // U+0E36: " ึ" THAI CHARACTER SARA UE + key(" \u0E36", "\u0E36"), + // U+0E04: "ค" THAI CHARACTER KHO KHWAI + // U+0E55: "๕" THAI DIGIT FIVE + key("\u0E04", joinMoreKeys("5", "\u0E55")), + // U+0E15: "ต" THAI CHARACTER TO TAO + // U+0E56: "๖" THAI DIGIT SIX + key("\u0E15", joinMoreKeys("6", "\u0E56")), + // U+0E08: "จ" THAI CHARACTER CHO CHAN + // U+0E57: "๗" THAI DIGIT SEVEN + key("\u0E08", joinMoreKeys("7", "\u0E57")), + // U+0E02: "ข" THAI CHARACTER KHO KHAI + // U+0E58: "๘" THAI DIGIT EIGHT + key("\u0E02", joinMoreKeys("8", "\u0E58")), + // U+0E0A: "ช" THAI CHARACTER CHO CHANG + // U+0E59: "๙" THAI DIGIT NINE + key("\u0E0A", joinMoreKeys("9", "\u0E59"))) + .setKeysOfRow(2, + // U+0E46: "ๆ" THAI CHARACTER MAIYAMOK + // U+0E50: "๐" THAI DIGIT ZERO + key("\u0E46", joinMoreKeys("0", "\u0E50")), + // U+0E44: "ไ" THAI CHARACTER SARA AI MAIMALAI + key("\u0E44"), + // U+0E33: "ำ" THAI CHARACTER SARA AM + key("\u0E33"), + // U+0E1E: "พ" THAI CHARACTER PHO PHAN + key("\u0E1E"), + // U+0E30: "ะ" THAI CHARACTER SARA A + key("\u0E30"), + // U+0E31: " ั" THAI CHARACTER MAI HAN-AKAT + key(" \u0E31", "\u0E31"), + // U+0E35: " ี" HAI CHARACTER SARA II + key(" \u0E35", "\u0E35"), + // U+0E23: "ร" THAI CHARACTER RO RUA + key("\u0E23"), + // U+0E19: "น" THAI CHARACTER NO NU + key("\u0E19"), + // U+0E22: "ย" THAI CHARACTER YO YAK + key("\u0E22"), + // U+0E1A: "บ" THAI CHARACTER BO BAIMAI + key("\u0E1A"), + // U+0E25: "ล" THAI CHARACTER LO LING + key("\u0E25")) + .setKeysOfRow(3, + // U+0E1F: "ฟ" THAI CHARACTER FO FAN + key("\u0E1F"), + // U+0E2B: "ห" THAI CHARACTER HO HIP + key("\u0E2B"), + // U+0E01: "ก" THAI CHARACTER KO KAI + key("\u0E01"), + // U+0E14: "ด" THAI CHARACTER DO DEK + key("\u0E14"), + // U+0E40: "เ" THAI CHARACTER SARA E + key("\u0E40"), + // U+0E49: " ้" THAI CHARACTER MAI THO + key(" \u0E49", "\u0E49"), + // U+0E48: " ่" THAI CHARACTER MAI EK + key(" \u0E48", "\u0E48"), + // U+0E32: "า" THAI CHARACTER SARA AA + key("\u0E32"), + // U+0E2A: "ส" THAI CHARACTER SO SUA + key("\u0E2A"), + // U+0E27: "ว" THAI CHARACTER WO WAEN + key("\u0E27"), + // U+0E07: "ง" THAI CHARACTER NGO NGU + key("\u0E07")) + .setKeysOfRow(4, + // U+0E1C: "ผ" THAI CHARACTER PHO PHUNG + key("\u0E1C"), + // U+0E1B: "ป" THAI CHARACTER PO PLA + key("\u0E1B"), + // U+0E41: "แ" THAI CHARACTER SARA AE + key("\u0E41"), + // U+0E2D: "อ" THAI CHARACTER O ANG + key("\u0E2D"), + // U+0E34: " ิ" THAI CHARACTER SARA I + key(" \u0E34", "\u0E34"), + // U+0E37: " ื" THAI CHARACTER SARA UEE + key(" \u0E37", "\u0E37"), + // U+0E17: "ท" THAI CHARACTER THO THAHAN + key("\u0E17"), + // U+0E21: "ม" THAI CHARACTER MO MA + key("\u0E21"), + // U+0E43: "ใ" THAI CHARACTER SARA AI MAIMUAN + key("\u0E43"), + // U+0E1D: "ฝ" THAI CHARACTER FO FA + key("\u0E1D")) + .build(); + + private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + key("+"), + // U+0E51: "๑" THAI DIGIT ONE + key("\u0E51"), + // U+0E52: "๒" THAI DIGIT TWO + key("\u0E52"), + // U+0E53: "๓" THAI DIGIT THREE + key("\u0E53"), + // U+0E54: "๔" THAI DIGIT FOUR + key("\u0E54"), + // U+0E39: " ู" THAI CHARACTER SARA UU + key(" \u0E39", "\u0E39"), + // U+0E3F: "฿" THAI CURRENCY SYMBOL BAHT + key("\u0E3F"), + // U+0E55: "๕" THAI DIGIT FIVE + key("\u0E55"), + // U+0E56: "๖" THAI DIGIT SIX + key("\u0E56"), + // U+0E57: "๗" THAI DIGIT SEVEN + key("\u0E57"), + // U+0E58: "๘" THAI DIGIT EIGHT + key("\u0E58"), + // U+0E59: "๙" THAI DIGIT NINE + key("\u0E59")) + .setKeysOfRow(2, + // U+0E50: "๐" THAI DIGIT ZERO + key("\u0E50"), + key("\""), + // U+0E0E: "ฎ" THAI CHARACTER DO CHADA + key("\u0E0E"), + // U+0E11: "ฑ" THAI CHARACTER THO NANGMONTHO + key("\u0E11"), + // U+0E18: "ธ" THAI CHARACTER THO THONG + key("\u0E18"), + // U+0E4D: " ํ" THAI CHARACTER THANTHAKHAT + key(" \u0E4D", "\u0E4D"), + // U+0E4A: " ๊" THAI CHARACTER MAI TRI + key(" \u0E4A", "\u0E4A"), + // U+0E13: "ณ" THAI CHARACTER NO NEN + key("\u0E13"), + // U+0E2F: "ฯ" THAI CHARACTER PAIYANNOI + key("\u0E2F"), + // U+0E0D: "ญ" THAI CHARACTER YO YING + key("\u0E0D"), + // U+0E10: "ฐ" THAI CHARACTER THO THAN + key("\u0E10"), + key(",")) + .setKeysOfRow(3, + // U+0E24: "ฤ" THAI CHARACTER RU + key("\u0E24"), + // U+0E06: "ฆ" THAI CHARACTER KHO RAKHANG + key("\u0E06"), + // U+0E0F: "ฏ" THAI CHARACTER TO PATAK + key("\u0E0F"), + // U+0E42: "โ" THAI CHARACTER SARA O + key("\u0E42"), + // U+0E0C: "ฌ" THAI CHARACTER CHO CHOE + key("\u0E0C"), + // U+0E47: " ็" THAI CHARACTER MAITAIKHU + key(" \u0E47", "\u0E47"), + // U+0E4B: " ๋" THAI CHARACTER MAI CHATTAWA + key(" \u0E4B", "\u0E4B"), + // U+0E29: "ษ" THAI CHARACTER SO RUSI + key("\u0E29"), + // U+0E28: "ศ" THAI CHARACTER SO SALA + key("\u0E28"), + // U+0E0B: "ซ" THAI CHARACTER SO SO + key("\u0E0B"), + key(".")) + .setKeysOfRow(4, + key("("), + key(")"), + // U+0E09: "ฉ" THAI CHARACTER CHO CHING + key("\u0E09"), + // U+0E2E: "ฮ" THAI CHARACTER HO NOKHUK + key("\u0E2E"), + // U+0E3A: " ฺ" THAI CHARACTER PHINTHU + key(" \u0E3A", "\u0E3A"), + // U+0E4C: " ์" THAI CHARACTER THANTHAKHAT + key(" \u0E4C", "\u0E4C"), + key("?"), + // U+0E12: "ฒ" THAI CHARACTER THO PHUTHAO + key("\u0E12"), + // U+0E2C: "ฬ" THAI CHARACTER LO CHULA + key("\u0E2C"), + // U+0E26: "ฦ" THAI CHARACTER LU + key("\u0E26")) + .build(); +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractKeyboardBuilder.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractKeyboardBuilder.java index 682ac20a1..3365b92ec 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractKeyboardBuilder.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractKeyboardBuilder.java @@ -29,7 +29,7 @@ import java.util.Arrays; */ abstract class AbstractKeyboardBuilder<E> { // A building array of rows. - private final E[][] mRows; + private E[][] mRows; // Returns an instance of default element. abstract E defaultElement(); @@ -42,12 +42,8 @@ abstract class AbstractKeyboardBuilder<E> { * Construct a builder filled with the default element. * @param dimensions the integer array of each row's size. */ - AbstractKeyboardBuilder(final int ... dimensions) { - mRows = newArrayOfArray(dimensions.length); - for (int rowIndex = 0; rowIndex < dimensions.length; rowIndex++) { - mRows[rowIndex] = newArray(dimensions[rowIndex]); - Arrays.fill(mRows[rowIndex], defaultElement()); - } + AbstractKeyboardBuilder() { + mRows = newArrayOfArray(0); } /** @@ -102,10 +98,13 @@ abstract class AbstractKeyboardBuilder<E> { */ void setRowAt(final int row, final E[] elements) { final int rowIndex = row - 1; - if (rowIndex < 0 || rowIndex >= mRows.length) { + if (rowIndex < 0) { throw new RuntimeException("Illegal row number: " + row); } - mRows[rowIndex] = elements; + final E[][] newRows = (rowIndex < mRows.length) ? mRows + : Arrays.copyOf(mRows, rowIndex + 1); + newRows[rowIndex] = elements; + mRows = newRows; } /** @@ -120,8 +119,11 @@ abstract class AbstractKeyboardBuilder<E> { void setElementAt(final int row, final int column, final E element, final boolean insert) { final E[] elements = getRowAt(row); final int columnIndex = column - 1; + if (columnIndex < 0) { + throw new RuntimeException("Illegal column number: " + column); + } if (insert) { - if (columnIndex < 0 || columnIndex >= elements.length + 1) { + if (columnIndex >= elements.length + 1) { throw new RuntimeException("Illegal column number: " + column); } final E[] newElements = Arrays.copyOf(elements, elements.length + 1); @@ -134,9 +136,9 @@ abstract class AbstractKeyboardBuilder<E> { setRowAt(row, newElements); return; } - if (columnIndex < 0 || columnIndex >= elements.length) { - throw new RuntimeException("Illegal column number: " + column); - } - elements[columnIndex] = element; + final E[] newElements = (columnIndex < elements.length) ? elements + : Arrays.copyOf(elements, columnIndex + 1); + newElements[columnIndex] = element; + setRowAt(row, newElements); } } diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java new file mode 100644 index 000000000..61cadfcad --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java @@ -0,0 +1,132 @@ +/* + * 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.expected; + +import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; +import com.android.inputmethod.latin.Constants; +import com.android.inputmethod.latin.utils.CollectionUtils; +import com.android.inputmethod.latin.utils.StringUtils; + +import java.util.ArrayList; +import java.util.Arrays; + +/** + * Base class to create an expected keyboard for unit test. + */ +public abstract class AbstractLayoutBase { + // Those helper methods have a lower case name to be readable when defining expected keyboard + // layouts. + + // 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 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 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 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 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 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 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 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[] joinMoreKeys(final Object ... moreKeys) { + return joinKeys(moreKeys); + } + + // Helper method to create {@link ExpectedKey} array by joining {@link ExpectedKey}, + // {@link ExpectedKey} array, and {@link String}. + public static ExpectedKey[] joinKeys(final Object ... keys) { + final ArrayList<ExpectedKey> list = CollectionUtils.newArrayList(); + for (final Object key : keys) { + if (key instanceof ExpectedKey) { + list.add((ExpectedKey)key); + } else if (key instanceof ExpectedKey[]) { + list.addAll(Arrays.asList((ExpectedKey[])key)); + } else if (key instanceof String) { + list.add(key((String)key)); + } else { + throw new RuntimeException("Unknown expected key type: " + key); + } + } + return list.toArray(new ExpectedKey[list.size()]); + } + + // Icon ids. + private static final int ICON_DELETE = KeyboardIconsSet.getIconId( + KeyboardIconsSet.NAME_DELETE_KEY); + private static final int ICON_SETTINGS = KeyboardIconsSet.getIconId( + KeyboardIconsSet.NAME_SETTINGS_KEY); + private static final int ICON_ENTER = KeyboardIconsSet.getIconId( + KeyboardIconsSet.NAME_ENTER_KEY); + private static final int ICON_EMOJI = KeyboardIconsSet.getIconId( + KeyboardIconsSet.NAME_EMOJI_KEY); + + // Functional keys. + public static final ExpectedKey DELETE_KEY = key(ICON_DELETE, Constants.CODE_DELETE); + 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 SPACE_KEY = key( + StringUtils.newSingleCodePointString(Constants.CODE_SPACE)); +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java index 577f43e17..050bc4c5a 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java @@ -85,7 +85,7 @@ public final class ActualKeyboardBuilder extends AbstractKeyboardBuilder<Key> { for (int rowIndex = 0; rowIndex < dimensions.length; rowIndex++) { dimensions[rowIndex] = rows.get(rowIndex).size(); } - final ActualKeyboardBuilder builder = new ActualKeyboardBuilder(dimensions); + final ActualKeyboardBuilder builder = new ActualKeyboardBuilder(); for (int rowIndex = 0; rowIndex < rows.size(); rowIndex++) { final int row = rowIndex + 1; @@ -95,10 +95,6 @@ public final class ActualKeyboardBuilder extends AbstractKeyboardBuilder<Key> { return builder.build(); } - private ActualKeyboardBuilder(final int ... dimensions) { - super(dimensions); - } - @Override Key defaultElement() { return null; } 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 e22d75cd7..98c08aded 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKey.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKey.java @@ -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) { 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 57f842b74..176e0eb92 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java @@ -23,8 +23,8 @@ import java.util.Locale; * This class builds an expected keyboard for unit test. */ public final class ExpectedKeyboardBuilder extends AbstractKeyboardBuilder<ExpectedKey> { - public ExpectedKeyboardBuilder(final int ... dimensions) { - super(dimensions); + public ExpectedKeyboardBuilder() { + super(); } public ExpectedKeyboardBuilder(final ExpectedKey[][] rows) { @@ -121,6 +121,17 @@ public final class ExpectedKeyboardBuilder extends AbstractKeyboardBuilder<Expec } /** + * Set the row with specified keys. + * @param row the row number to set keys. + * @param keys the keys to be set at <code>row</code>. + * @return this builder. + */ + public ExpectedKeyboardBuilder setKeysOfRow(final int row, final ExpectedKey ... keys) { + setRowAt(row, keys); + return this; + } + + /** * Set the "more keys" of the key that has the specified label. * @param label the label of the key to set the "more keys". * @param moreKeys the array of labels of the "more keys" to be set. diff --git a/tests/src/com/android/inputmethod/keyboard/layout/expected/LayoutBase.java b/tests/src/com/android/inputmethod/keyboard/layout/expected/LayoutBase.java deleted file mode 100644 index 1d242d0b8..000000000 --- a/tests/src/com/android/inputmethod/keyboard/layout/expected/LayoutBase.java +++ /dev/null @@ -1,174 +0,0 @@ -/* - * 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.expected; - -import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; -import com.android.inputmethod.latin.Constants; -import com.android.inputmethod.latin.utils.CollectionUtils; - -import java.util.ArrayList; -import java.util.Arrays; - -/** - * Base class to create an expected keyboard for unit test. - */ -public class LayoutBase { - // 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. - 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. - 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. - 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. - 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". - 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. - 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. - 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. - public static ExpectedKey moreKey(final String label, final int code) { - return ExpectedKey.newInstance(label, code); - } - - // Helper method to create {@link ExpectedKey} array by joining {@link ExpectedKey}, - // {@link ExpectedKey} array, and {@link String}. - public static ExpectedKey[] join(final Object ... keys) { - final ArrayList<ExpectedKey> list = CollectionUtils.newArrayList(); - for (final Object key : keys) { - if (key instanceof ExpectedKey) { - list.add((ExpectedKey)key); - } else if (key instanceof ExpectedKey[]) { - list.addAll(Arrays.asList((ExpectedKey[])key)); - } else if (key instanceof String) { - list.add(key((String)key)); - } else { - throw new RuntimeException("Unknown expected key type: " + key); - } - } - return list.toArray(new ExpectedKey[list.size()]); - } - - // Icon ids. - private static final int ICON_SHIFT = KeyboardIconsSet.getIconId("shift_key"); - private static final int ICON_DELETE = KeyboardIconsSet.getIconId("delete_key"); - private static final int ICON_SETTINGS = KeyboardIconsSet.getIconId("settings_key"); - private static final int ICON_ENTER = KeyboardIconsSet.getIconId("enter_key"); - private static final int ICON_EMOJI = KeyboardIconsSet.getIconId("emoji_key"); - - // Functional keys. - public static final ExpectedKey CAPSLOCK_MORE_KEY = key(" ", Constants.CODE_CAPSLOCK); - public static final ExpectedKey SHIFT_KEY = key(ICON_SHIFT, Constants.CODE_SHIFT); - public static final ExpectedKey DELETE_KEY = key(ICON_DELETE, Constants.CODE_DELETE); - public static final ExpectedKey SYMBOLS_KEY = key("?123", Constants.CODE_SWITCH_ALPHA_SYMBOL); - 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); - - // Punctuation more keys for phone form factor. - public static final String[] PHONE_PUNCTUATION_MORE_KEYS = { - ";", "/", "(", ")", "#", "!", ",", "?", - "&", "%", "+", "\"", "-", ":", "'", "@" - }; - - // Punctuation more keys for tablet form factor. - public static final String[] TABLET_PUNCTUATION_MORE_KEYS = { - ";", "/", "(", ")", "#", "'", ",", - "&", "%", "+", "\"", "-", ":", "@" - }; - - // Helper method to create alphabet layout for phone by adding special function keys except - // shift key. - private static ExpectedKeyboardBuilder convertToPhoneAlphabetKeyboardBuilder( - final ExpectedKey[][] commonLayout) { - return new ExpectedKeyboardBuilder(commonLayout) - .addKeysOnTheRightOfRow(3, DELETE_KEY) - .setLabelsOfRow(4, ",", " ", ".") - .setMoreKeysOf(",", SETTINGS_KEY) - .setMoreKeysOf(".", PHONE_PUNCTUATION_MORE_KEYS) - .addKeysOnTheLeftOfRow(4, SYMBOLS_KEY) - .addKeysOnTheRightOfRow(4, key(ENTER_KEY, EMOJI_KEY)); - } - - // Helper method to create alphabet layout for tablet by adding special function keys except - // shift key. - private static ExpectedKeyboardBuilder convertToTabletAlphabetKeyboardBuilder( - final ExpectedKey[][] commonLayout) { - return new ExpectedKeyboardBuilder(commonLayout) - // U+00BF: "¿" INVERTED QUESTION MARK - // U+00A1: "¡" INVERTED EXCLAMATION MARK - .addKeysOnTheRightOfRow(3, - key("!", moreKey("\u00A1")), key("?", moreKey("\u00BF"))) - .addKeysOnTheRightOfRow(1, DELETE_KEY) - .addKeysOnTheRightOfRow(2, ENTER_KEY) - .setLabelsOfRow(4, "/", " ", ",", ".") - .setMoreKeysOf(".", TABLET_PUNCTUATION_MORE_KEYS) - .addKeysOnTheLeftOfRow(4, SYMBOLS_KEY, SETTINGS_KEY) - .addKeysOnTheRightOfRow(4, EMOJI_KEY); - } - - // Helper method to create alphabet layout by adding special function keys. - public static ExpectedKey[][] getAlphabetLayoutWithoutShiftKeys( - final ExpectedKey[][] commonLayout, final boolean isPhone) { - return isPhone ? convertToPhoneAlphabetKeyboardBuilder(commonLayout).build() - : convertToTabletAlphabetKeyboardBuilder(commonLayout).build(); - } - - // Helper method to create alphabet layout by adding special function keys. - public static ExpectedKey[][] getDefaultAlphabetLayout(final ExpectedKey[][] commonLayout, - final boolean isPhone) { - final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder( - getAlphabetLayoutWithoutShiftKeys(commonLayout, isPhone)); - if (isPhone) { - builder.addKeysOnTheLeftOfRow(3, key(SHIFT_KEY, CAPSLOCK_MORE_KEY)); - } else { - builder.addKeysOnTheLeftOfRow(3, key(SHIFT_KEY, CAPSLOCK_MORE_KEY)) - .addKeysOnTheRightOfRow(3, key(SHIFT_KEY, CAPSLOCK_MORE_KEY)); - } - return builder.build(); - } -} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/LayoutTestsBase.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/LayoutTestsBase.java index 5c51d088b..c51abc03e 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/tests/LayoutTestsBase.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/LayoutTestsBase.java @@ -24,22 +24,20 @@ import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.keyboard.KeyboardId; import com.android.inputmethod.keyboard.KeyboardLayoutSet; import com.android.inputmethod.keyboard.KeyboardLayoutSetTestsBase; -import com.android.inputmethod.keyboard.layout.AlphabetShifted; -import com.android.inputmethod.keyboard.layout.Symbols; -import com.android.inputmethod.keyboard.layout.SymbolsShifted; +import com.android.inputmethod.keyboard.layout.LayoutBase; +import com.android.inputmethod.keyboard.layout.expected.AbstractLayoutBase; import com.android.inputmethod.keyboard.layout.expected.ActualKeyboardBuilder; import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; -import com.android.inputmethod.keyboard.layout.expected.LayoutBase; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import java.util.Arrays; -import java.util.Locale; /** * Base class for keyboard layout unit test. */ abstract class LayoutTestsBase extends KeyboardLayoutSetTestsBase { + private LayoutBase mLayout; private InputMethodSubtype mSubtype; private String mLogTag; private KeyboardLayoutSet mKeyboardLayoutSet; @@ -48,7 +46,8 @@ abstract class LayoutTestsBase extends KeyboardLayoutSetTestsBase { protected void setUp() throws Exception { super.setUp(); - mSubtype = getSubtype(getTestLocale(), getTestKeyboardLayout()); + mLayout = getLayout(); + mSubtype = getSubtype(mLayout.getLocale(), mLayout.getName()); mLogTag = SubtypeLocaleUtils.getSubtypeNameForLogging(mSubtype) + "/" + (isPhone() ? "phone" : "tablet"); mKeyboardLayoutSet = createKeyboardLayoutSet(mSubtype, null /* editorInfo */); @@ -57,117 +56,85 @@ 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 LayoutBase.key(label, 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 LayoutBase.key(label, outputText, 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 LayoutBase.key(key, 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 LayoutBase.moreKey(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 LayoutBase.moreKey(label, 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[] join(final Object ... keys) { - return LayoutBase.join(keys); + static ExpectedKey[] joinMoreKeys(final Object ... moreKeys) { + return AbstractLayoutBase.joinKeys(moreKeys); } - // Locale for testing subtype. - abstract Locale getTestLocale(); - - // Keyboard layout name for testing subtype. - abstract String getTestKeyboardLayout(); - - // Alphabet keyboard for testing subtype. - abstract ExpectedKey[][] getAlphabetLayout(final boolean isPhone); - - // Alphabet automatic shifted keyboard for testing subtype. - ExpectedKey[][] getAlphabetAutomaticShiftedLayout(final boolean isPhone) { - return AlphabetShifted.getDefaultLayout(getAlphabetLayout(isPhone), getTestLocale()); - } - - // Alphabet manual shifted keyboard for testing subtype. - ExpectedKey[][] getAlphabetManualShiftedLayout(final boolean isPhone) { - return AlphabetShifted.getDefaultLayout(getAlphabetLayout(isPhone), getTestLocale()); - } - - // Alphabet shift locked keyboard for testing subtype. - ExpectedKey[][] getAlphabetShiftLockedLayout(final boolean isPhone) { - return AlphabetShifted.getDefaultLayout(getAlphabetLayout(isPhone), getTestLocale()); - } - - // Alphabet shift lock shifted keyboard for testing subtype. - ExpectedKey[][] getAlphabetShiftLockShiftedLayout(final boolean isPhone) { - return AlphabetShifted.getDefaultLayout(getAlphabetLayout(isPhone), getTestLocale()); + // Helper method to create {@link ExpectedKey} array by joining {@link ExpectedKey}, + // {@link ExpectedKey} array, and {@link String}. + static ExpectedKey[] joinKeys(final Object ... keys) { + return AbstractLayoutBase.joinKeys(keys); } - // Symbols keyboard for testing subtype. - ExpectedKey[][] getSymbolsLayout(final boolean isPhone) { - return Symbols.getDefaultLayout(isPhone); - } + // Keyboard layout for testing subtype. + abstract LayoutBase getLayout(); - // Symbols shifted keyboard for testing subtype. - ExpectedKey[][] getSymbolsShiftedLayout(final boolean isPhone) { - return SymbolsShifted.getDefaultLayout(isPhone); + ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder; } // TODO: Add phone, phone symbols, number, number password layout tests. public final void testAlphabet() { - final int elementId = KeyboardId.ELEMENT_ALPHABET; - doKeyboardTests(elementId, getAlphabetLayout(isPhone())); + doKeyboardTests(KeyboardId.ELEMENT_ALPHABET); } public final void testAlphabetAutomaticShifted() { - final int elementId = KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED; - doKeyboardTests(elementId, getAlphabetAutomaticShiftedLayout(isPhone())); + doKeyboardTests(KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED); } public final void testAlphabetManualShifted() { - final int elementId = KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED; - doKeyboardTests(elementId, getAlphabetManualShiftedLayout(isPhone())); + doKeyboardTests(KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED); } public final void testAlphabetShiftLocked() { - final int elementId = KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED; - doKeyboardTests(elementId, getAlphabetShiftLockedLayout(isPhone())); + doKeyboardTests(KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED); } public final void testAlphabetShiftLockShifted() { - final int elementId = KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED; - doKeyboardTests(elementId, getAlphabetShiftLockShiftedLayout(isPhone())); + doKeyboardTests(KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED); } public final void testSymbols() { - final int elementId = KeyboardId.ELEMENT_SYMBOLS; - doKeyboardTests(elementId, getSymbolsLayout(isPhone())); + doKeyboardTests(KeyboardId.ELEMENT_SYMBOLS); } public final void testSymbolsShifted() { - final int elementId = KeyboardId.ELEMENT_SYMBOLS_SHIFTED; - doKeyboardTests(elementId, getSymbolsShiftedLayout(isPhone())); + doKeyboardTests(KeyboardId.ELEMENT_SYMBOLS_SHIFTED); } // Comparing expected keyboard and actual keyboard. - private void doKeyboardTests(final int elementId, final ExpectedKey[][] expectedKeyboard) { + private void doKeyboardTests(final int elementId) { + final ExpectedKey[][] expectedKeyboard = mLayout.getLayout(isPhone(), elementId); // Skip test if no keyboard is defined. if (expectedKeyboard == null) { return; diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsAfrikaans.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsAfrikaans.java new file mode 100644 index 000000000..c98b4a5a9 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsAfrikaans.java @@ -0,0 +1,101 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * af: TestsAfrikaans/qwerty + */ +@SmallTest +public final class TestsAfrikaans extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("af"); + private static final LayoutBase LAYOUT = new Qwerty(new AfrikaansCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class AfrikaansCustomizer extends LayoutCustomizer { + AfrikaansCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", + "3", "\u00E9", "\u00E8", "\u00EA", "\u00EB", "\u0119", "\u0117", + "\u0113") + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FA", "\u00FB", "\u00FC", "\u00F9", "\u016B") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+0133: "ij" LATIN SMALL LIGATURE IJ + .setMoreKeysOf("y", "6", "\u00FD", "\u0133") + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + // U+0133: "ij" LATIN SMALL LIGATURE IJ + .setMoreKeysOf("i", + "8", "\u00ED", "\u00EC", "\u00EF", "\u00EE", "\u012F", "\u012B", + "\u0133") + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", + "9", "\u00F3", "\u00F4", "\u00F6", "\u00F2", "\u00F5", "\u0153", + "\u00F8", "\u014D") + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + .setMoreKeysOf("a", + "\u00E1", "\u00E2", "\u00E4", "\u00E0", "\u00E6", "\u00E3", "\u00E5", + "\u0101") + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + .setMoreKeysOf("n", "\u00F1", "\u0144"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsArabic.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsArabic.java new file mode 100644 index 000000000..7c97df5af --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsArabic.java @@ -0,0 +1,37 @@ +/* + * 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.Arabic; +import com.android.inputmethod.keyboard.layout.Arabic.ArabicCustomizer; +import com.android.inputmethod.keyboard.layout.LayoutBase; + +import java.util.Locale; + +/** + * ar: TestsArabic/arabic + */ +@SmallTest +public class TestsArabic extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("ar"); + private static final LayoutBase LAYOUT = new Arabic(new ArabicCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsAzerbaijaniAZ.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsAzerbaijaniAZ.java new file mode 100644 index 000000000..84d5a3627 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsAzerbaijaniAZ.java @@ -0,0 +1,89 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * az_AZ: Azerbaijani (Azerbaijan)/qwerty + */ +@SmallTest +public final class TestsAzerbaijaniAZ extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("az", "AZ"); + private static final LayoutBase LAYOUT = new Qwerty(new AzerbaijaniAZCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static final class AzerbaijaniAZCustomizer extends LayoutCustomizer { + public AzerbaijaniAZCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+0259: "ə" LATIN SMALL LETTER SCHWA + .setMoreKeysOf("e", "3", "\u0259") + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FC", "\u00FB", "\u00F9", "\u00FA", "\u016B") + // U+0131: "ı" LATIN SMALL LETTER DOTLESS I + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + .setMoreKeysOf("i", + "8", "\u0131", "\u00EE", "\u00EF", "\u00EC", "\u00ED", "\u012F", + "\u012B") + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", + "9", "\u00F6", "\u00F4", "\u0153", "\u00F2", "\u00F3", "\u00F5", + "\u00F8", "\u014D") + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + .setMoreKeysOf("a", "\u00E2") + // U+015F: "ş" LATIN SMALL LETTER S WITH CEDILLA + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + .setMoreKeysOf("s", "\u015F", "\u00DF", "\u015B", "\u0161") + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + .setMoreKeysOf("c", "\u00E7", "\u0107", "\u010D") + // U+011F: "ğ" LATIN SMALL LETTER G WITH BREVE + .setMoreKeysOf("g", "\u011F"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBelarusianBY.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBelarusianBY.java new file mode 100644 index 000000000..476841c23 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBelarusianBY.java @@ -0,0 +1,73 @@ +/* + * 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.EastSlavic; +import com.android.inputmethod.keyboard.layout.EastSlavic.EastSlavicCustomizer; +import com.android.inputmethod.keyboard.layout.LayoutBase; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * be_BY: Belarusian (Belarus)/east_slavic + */ +@SmallTest +public final class TestsBelarusianBY extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("be", "BY"); + private static final LayoutBase LAYOUT = new EastSlavic(new BelarusianBYCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class BelarusianBYCustomizer extends EastSlavicCustomizer { + public BelarusianBYCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { + return Symbols.DOUBLE_QUOTES_R9L; + } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { + return Symbols.SINGLE_QUOTES_R9L; + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+0435: "е" CYRILLIC SMALL LETTER IE + // U+0451: "ё" CYRILLIC SMALL LETTER IO + .setMoreKeysOf("\u0435", "5", "\u0451") + // U+045E: "ў" CYRILLIC SMALL LETTER SHORT U + .replaceKeyOfLabel(EastSlavic.ROW1_9, key("\u045E", moreKey("9"))) + // U+044B: "ы" CYRILLIC SMALL LETTER YERU + .replaceKeyOfLabel(EastSlavic.ROW2_2, key("\u044B")) + // U+044D: "э" CYRILLIC SMALL LETTER E + .replaceKeyOfLabel(EastSlavic.ROW2_11, key("\u044D")) + // U+0456: "і" CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I + .replaceKeyOfLabel(EastSlavic.ROW3_5, key("\u0456")) + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN + .setMoreKeysOf("\u044C", "\u044A"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBulgarian.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBulgarian.java new file mode 100644 index 000000000..ded8d7243 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBulgarian.java @@ -0,0 +1,37 @@ +/* + * 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.Bulgarian; +import com.android.inputmethod.keyboard.layout.Bulgarian.BulgarianCustomizer; +import com.android.inputmethod.keyboard.layout.LayoutBase; + +import java.util.Locale; + +/** + * bg: TestsBulgarian/bulgarian + */ +@SmallTest +public final class TestsBulgarian extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("bg"); + private static final LayoutBase LAYOUT = new Bulgarian(new BulgarianCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBulgarianBds.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBulgarianBds.java new file mode 100644 index 000000000..22b2011ee --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsBulgarianBds.java @@ -0,0 +1,37 @@ +/* + * 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.BulgarianBds; +import com.android.inputmethod.keyboard.layout.BulgarianBds.BulgarianBdsCustomizer; +import com.android.inputmethod.keyboard.layout.LayoutBase; + +import java.util.Locale; + +/** + * bg: Bulgarian/bulgarian_bds + */ +@SmallTest +public final class TestsBulgarianBds extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("bg"); + private static final LayoutBase LAYOUT = new BulgarianBds(new BulgarianBdsCustomizer(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 new file mode 100644 index 000000000..ec03f0d92 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsCatalan.java @@ -0,0 +1,124 @@ +/* + * 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.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Spanish; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * ca: Catalan/spanish + */ +@SmallTest +public class TestsCatalan extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("ca"); + private static final LayoutBase LAYOUT = new Spanish(new CatalanCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class CatalanCustomizer extends EuroLayoutCustomizer { + public CatalanCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { + return isPhone ? PHONE_PUNCTUATION_MORE_KEYS + : TABLET_PUNCTUATION_MORE_KEYS; + } + + // U+00B7: "·" MIDDLE DOT + private static final ExpectedKey[] PHONE_PUNCTUATION_MORE_KEYS = joinKeys( + ";", "/", "(", ")", "#", "\u00B7", "!", ",", "?", + "&", "%", "+", "\"", "-", ":", "'", "@"); + + private static final ExpectedKey[] TABLET_PUNCTUATION_MORE_KEYS = joinKeys( + ";", "/", "(", ")", "#", "\u00B7", "'", ",", + "&", "%", "+", "\"", "-", ":", "@"); + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", + "3", "\u00E8", "\u00E9", "\u00EB", "\u00EA", "\u0119", "\u0117", + "\u0113") + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FA", "\u00FC", "\u00F9", "\u00FB", "\u016B") + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + .setMoreKeysOf("i", + "8", "\u00ED", "\u00EF", "\u00EC", "\u00EE", "\u012F", "\u012B") + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + // U+00BA: "º" MASCULINE ORDINAL INDICATOR + .setMoreKeysOf("o", + "9", "\u00F2", "\u00F3", "\u00F6", "\u00F4", "\u00F5", "\u00F8", + "\u0153", "\u014D", "\u00BA") + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + // U+00AA: "ª" FEMININE ORDINAL INDICATOR + .setMoreKeysOf("a", + "\u00E0", "\u00E1", "\u00E4", "\u00E2", "\u00E3", "\u00E5", "\u0105", + "\u00E6", "\u0101", "\u00AA") + // U+00B7: "·" MIDDLE DOT + // U+0142: "ł" LATIN SMALL LETTER L WITH STROKE + .setMoreKeysOf("l", "l\u00B7l", "\u0142") + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + .replaceKeyOfLabel(Spanish.ROW2_10, key("\u00E7")) + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + .setMoreKeysOf("c", "\u00E7", "\u0107", "\u010D") + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + .setMoreKeysOf("n", "\u00F1", "\u0144"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsCroatian.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsCroatian.java new file mode 100644 index 000000000..cf76de52e --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsCroatian.java @@ -0,0 +1,78 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwertz; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * hr: Croatian/qwertz + */ +@SmallTest +public final class TestsCroatian extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("hr"); + private static final LayoutBase LAYOUT = new Qwertz(new CroatianCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class CroatianCustomizer extends LayoutCustomizer { + public CroatianCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_L9R; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_L9R; } + + @Override + public ExpectedKey[] getDoubleAngleQuoteKeys() { return Symbols.DOUBLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKey[] getSingleAngleQuoteKeys() { return Symbols.SINGLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + // U+017A: "ź" LATIN SMALL LETTER Z WITH ACUTE + // U+017C: "ż" LATIN SMALL LETTER Z WITH DOT ABOVE + .setMoreKeysOf("z", "6", "\u017E", "\u017A", "\u017C") + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + .setMoreKeysOf("s", "\u0161", "\u015B", "\u00DF") + // U+0111: "đ" LATIN SMALL LETTER D WITH STROKE + .setMoreKeysOf("d", "\u0111") + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + .setMoreKeysOf("c", "\u010D", "\u0107", "\u00E7") + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + .setMoreKeysOf("n", "\u00F1", "\u0144"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsCzech.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsCzech.java new file mode 100644 index 000000000..5cf47401d --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsCzech.java @@ -0,0 +1,135 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwertz; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * cs: Czech/qwertz + */ +@SmallTest +public final class TestsCzech extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("cs"); + private static final LayoutBase LAYOUT = new Qwertz(new CzechCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class CzechCustomizer extends LayoutCustomizer { + public CzechCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getDoubleAngleQuoteKeys() { return Symbols.DOUBLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKey[] getSingleAngleQuoteKeys() { return Symbols.SINGLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+011B: "ě" LATIN SMALL LETTER E WITH CARON + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", + "3", "\u00E9", "\u011B", "\u00E8", "\u00EA", "\u00EB", "\u0119", + "\u0117", "\u0113") + // U+0159: "ř" LATIN SMALL LETTER R WITH CARON + .setMoreKeysOf("r", "4", "\u0159") + // U+0165: "ť" LATIN SMALL LETTER T WITH CARON + .setMoreKeysOf("t", "5", "\u0165") + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + // U+017A: "ź" LATIN SMALL LETTER Z WITH ACUTE + // U+017C: "ż" LATIN SMALL LETTER Z WITH DOT ABOVE + .setMoreKeysOf("z", "6", "\u017E", "\u017A", "\u017C") + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+016F: "ů" LATIN SMALL LETTER U WITH RING ABOVE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", + "7", "\u00FA", "\u016F", "\u00FB", "\u00FC", "\u00F9", "\u016B") + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + .setMoreKeysOf("i", + "8", "\u00ED", "\u00EE", "\u00EF", "\u00EC", "\u012F", "\u012B") + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", + "9", "\u00F3", "\u00F6", "\u00F4", "\u00F2", "\u00F5", "\u0153", + "\u00F8", "\u014D") + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + .setMoreKeysOf("a", + "\u00E1", "\u00E0", "\u00E2", "\u00E4", "\u00E6", "\u00E3", "\u00E5", + "\u0101") + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + .setMoreKeysOf("s", "\u0161", "\u00DF", "\u015B") + // U+010F: "ď" LATIN SMALL LETTER D WITH CARON + .setMoreKeysOf("d", "\u010F") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "\u00FD", "\u00FF") + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + .setMoreKeysOf("c", "\u010D", "\u00E7", "\u0107") + // U+0148: "ň" LATIN SMALL LETTER N WITH CARON + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + .setMoreKeysOf("n", "\u0148", "\u00F1", "\u0144"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDanish.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDanish.java new file mode 100644 index 000000000..050a0c472 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDanish.java @@ -0,0 +1,110 @@ +/* + * 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.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Nordic; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * da: Danish/nordic + */ +@SmallTest +public final class TestsDanish extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("da"); + private static final LayoutBase LAYOUT = new Nordic(new DanishCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class DanishCustomizer extends EuroLayoutCustomizer { + public DanishCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getDoubleAngleQuoteKeys() { return Symbols.DOUBLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKey[] getSingleAngleQuoteKeys() { return Symbols.SINGLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + .setMoreKeysOf("e", "3", "\u00E9", "\u00EB") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "6", "\u00FD", "\u00FF") + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FA", "\u00FC", "\u00FB", "\u00F9", "\u016B") + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + .setMoreKeysOf("i", "8", "\u00ED", "\u00EF") + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", + "9", "\u00F3", "\u00F4", "\u00F2", "\u00F5", "\u0153", "\u014D") + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + .replaceKeyOfLabel(Nordic.ROW1_11, key("\u00E5")) + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + .replaceKeyOfLabel(Nordic.ROW2_10, key("\u00E6", moreKey("\u00E4"))) + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + .replaceKeyOfLabel(Nordic.ROW2_11, key("\u00F8", moreKey("\u00F6"))) + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + .setMoreKeysOf("a", "\u00E1", "\u00E4", "\u00E0", "\u00E2", "\u00E3", "\u0101") + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + .setMoreKeysOf("s", "\u00DF", "\u015B", "\u0161") + // U+00F0: "ð" LATIN SMALL LETTER ETH + .setMoreKeysOf("d", "\u00F0") + // U+0142: "ł" LATIN SMALL LETTER L WITH STROKE + .setMoreKeysOf("l", "\u0142") + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + .setMoreKeysOf("n", "\u00F1", "\u0144"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDutch.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDutch.java new file mode 100644 index 000000000..e6e3378a3 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDutch.java @@ -0,0 +1,108 @@ +/* + * 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.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * nl: Dutch/qwerty + */ +@SmallTest +public final class TestsDutch extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("nl"); + private static final LayoutBase LAYOUT = new Qwerty(new DutchCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class DutchCustomizer extends EuroLayoutCustomizer { + public DutchCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_L9R; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_L9R; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", + "3", "\u00E9", "\u00EB", "\u00EA", "\u00E8", "\u0119", "\u0117", + "\u0113") + // U+0133: "ij" LATIN SMALL LIGATURE IJ + .setMoreKeysOf("y", "6", "\u0133") + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FA", "\u00FC", "\u00FB", "\u00F9", "\u016B") + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + // U+0133: "ij" LATIN SMALL LIGATURE IJ + .setMoreKeysOf("i", + "8", "\u00ED", "\u00EF", "\u00EC", "\u00EE", "\u012F", "\u012B", + "\u0133") + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", + "9", "\u00F3", "\u00F6", "\u00F4", "\u00F2", "\u00F5", "\u0153", + "\u00F8", "\u014D") + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + .setMoreKeysOf("a", + "\u00E1", "\u00E4", "\u00E2", "\u00E0", "\u00E6", "\u00E3", "\u00E5", + "\u0101") + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + .setMoreKeysOf("n", "\u00F1", "\u0144"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDutchBE.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDutchBE.java new file mode 100644 index 000000000..aa706f601 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsDutchBE.java @@ -0,0 +1,108 @@ +/* + * 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.Azerty; +import com.android.inputmethod.keyboard.layout.LayoutBase; +import com.android.inputmethod.keyboard.layout.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * nl_BE: Dutch (Belgium)/azerty + */ +@SmallTest +public final class TestsDutchBE extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("nl", "BE"); + private static final LayoutBase LAYOUT = new Azerty(new DutchBECustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class DutchBECustomizer extends EuroLayoutCustomizer { + public DutchBECustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_L9R; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_L9R; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + .setMoreKeysOf("a", + "1", "\u00E1", "\u00E4", "\u00E2", "\u00E0", "\u00E6", "\u00E3", + "\u00E5", "\u0101") + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", + "3", "\u00E9", "\u00EB", "\u00EA", "\u00E8", "\u0119", "\u0117", + "\u0113") + // U+0133: "ij" LATIN SMALL LIGATURE IJ + .setMoreKeysOf("y", "6", "\u0133") + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FA", "\u00FC", "\u00FB", "\u00F9", "\u016B") + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + // U+0133: "ij" LATIN SMALL LIGATURE IJ + .setMoreKeysOf("i", + "8", "\u00ED", "\u00EF", "\u00EC", "\u00EE", "\u012F", "\u012B", + "\u0133") + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", + "9", "\u00F3", "\u00F6", "\u00F4", "\u00F2", "\u00F5", "\u0153", + "\u00F8", "\u014D") + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + .setMoreKeysOf("n", "\u00F1", "\u0144"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEnglishUK.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEnglishUK.java new file mode 100644 index 000000000..4789507d8 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEnglishUK.java @@ -0,0 +1,57 @@ +/* + * 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.Qwerty; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; + +import java.util.Locale; + +/* + * en_GB: English (Great Britain)/qwerty + */ +@SmallTest +public final class TestsEnglishUK extends TestsEnglishUS { + private static final Locale LOCALE = new Locale("en", "GB"); + private static final LayoutBase LAYOUT = new Qwerty(new EnglishUKCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class EnglishUKCustomizer extends EnglishUSCustomizer { + public EnglishUKCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_POUND; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { return CURRENCIES_OTHER_THAN_POUND; } + + private static final ExpectedKey CURRENCY_POUND = key(Symbols.POUND_SIGN, + Symbols.CENT_SIGN, Symbols.DOLLAR_SIGN, Symbols.EURO_SIGN, Symbols.YEN_SIGN, + Symbols.PESO_SIGN); + + private static final ExpectedKey[] CURRENCIES_OTHER_THAN_POUND = { + Symbols.EURO_SIGN, Symbols.YEN_SIGN, key(Symbols.DOLLAR_SIGN, Symbols.CENT_SIGN), + Symbols.CENT_SIGN + }; + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEnglishUS.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEnglishUS.java index fd1a60619..991187aab 100644 --- a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEnglishUS.java +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEnglishUS.java @@ -18,8 +18,9 @@ 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.LayoutBase.LayoutCustomizer; import com.android.inputmethod.keyboard.layout.Qwerty; -import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; import java.util.Locale; @@ -28,71 +29,65 @@ import java.util.Locale; * en_US: English (United States)/qwerty */ @SmallTest -public final class TestsEnglishUS extends LayoutTestsBase { - @Override - Locale getTestLocale() { - return new Locale("en", "US"); - } +public class TestsEnglishUS extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("en", "US"); + private static final LayoutBase LAYOUT = new Qwerty(new EnglishUSCustomizer(LOCALE)); @Override - String getTestKeyboardLayout() { - return Qwerty.LAYOUT_NAME; - } + LayoutBase getLayout() { return LAYOUT; } - @Override - ExpectedKey[][] getAlphabetLayout(final boolean isPhone) { - final ExpectedKey[][] keyboard = Qwerty.getLayout(isPhone); - final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(keyboard); - setAccentedLetters(builder); - return builder.build(); - } + // TODO: Make this as generic English customizer. + static class EnglishUSCustomizer extends LayoutCustomizer { + public EnglishUSCustomizer(final Locale locale) { super(locale); } - static ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { - return builder - // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE - // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE - // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX - // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS - // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON - .setMoreKeysOf("e", "3", "\u00E8", "\u00E9", "\u00EA", "\u00EB", "\u0113") - // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX - // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS - // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE - // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE - // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON - .setMoreKeysOf("u", "7", "\u00FB", "\u00FC", "\u00F9", "\u00FA", "\u016B") - // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX - // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS - // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE - // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON - // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE - .setMoreKeysOf("i", "8", "\u00EE", "\u00EF", "\u00ED", "\u012B", "\u00EC") - // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX - // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS - // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE - // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE - // U+0153: "œ" LATIN SMALL LIGATURE OE - // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE - // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON - // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE - .setMoreKeysOf("o", - "9", "\u00F4", "\u00F6", "\u00F2", "\u00F3", "\u0153", "\u00F8", "\u014D", - "\u00F5") - // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE - // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX - // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS - // U+00E6: "æ" LATIN SMALL LETTER AE - // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE - // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE - // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON - .setMoreKeysOf("a", - "\u00E0", "\u00E1", "\u00E2", "\u00E4", "\u00E6", "\u00E3", "\u00E5", - "\u0101") - // U+00DF: "ß" LATIN SMALL LETTER SHARP S - .setMoreKeysOf("s", "\u00DF") - // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA - .setMoreKeysOf("c", "\u00E7") - // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE - .setMoreKeysOf("n", "\u00F1"); + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", "3", "\u00E8", "\u00E9", "\u00EA", "\u00EB", "\u0113") + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FB", "\u00FC", "\u00F9", "\u00FA", "\u016B") + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + .setMoreKeysOf("i", "8", "\u00EE", "\u00EF", "\u00ED", "\u012B", "\u00EC") + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + .setMoreKeysOf("o", + "9", "\u00F4", "\u00F6", "\u00F2", "\u00F3", "\u0153", "\u00F8", + "\u014D", "\u00F5") + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + .setMoreKeysOf("a", + "\u00E0", "\u00E1", "\u00E2", "\u00E4", "\u00E6", "\u00E3", "\u00E5", + "\u0101") + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + .setMoreKeysOf("s", "\u00DF") + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + .setMoreKeysOf("c", "\u00E7") + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + .setMoreKeysOf("n", "\u00F1"); + } } } diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEsperanto.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEsperanto.java new file mode 100644 index 000000000..a54601b6b --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEsperanto.java @@ -0,0 +1,181 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Spanish; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * eo: Esperanto/spanish + */ +@SmallTest +public class TestsEsperanto extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("eo"); + private static final LayoutBase LAYOUT = new Spanish(new EsperantoCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class EsperantoCustomizer extends LayoutCustomizer { + public EsperantoCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+015D: "ŝ" LATIN SMALL LETTER S WITH CIRCUMFLEX + .replaceKeyOfLabel("q", key("\u015D", moreKey("1"), moreKey("q"))) + // U+011D: "ĝ" LATIN SMALL LETTER G WITH CIRCUMFLEX + // U+0175: "ŵ" LATIN SMALL LETTER W WITH CIRCUMFLEX + .replaceKeyOfLabel("w", key("\u011D", + moreKey("2"), moreKey("w"), moreKey("\u0175"))) + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+011B: "ě" LATIN SMALL LETTER E WITH CARON + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", + "3", "\u00E9", "\u011B", "\u00E8", "\u00EA", "\u00EB", "\u0119", + "\u0117", "\u0113") + // U+0159: "ř" LATIN SMALL LETTER R WITH CARON + // U+0155: "ŕ" LATIN SMALL LETTER R WITH ACUTE + // U+0157: "ŗ" LATIN SMALL LETTER R WITH CEDILLA + .setMoreKeysOf("r", "4", "\u0159", "\u0155", "\u0157") + // U+0165: "ť" LATIN SMALL LETTER T WITH CARON + // U+021B: "ț" LATIN SMALL LETTER T WITH COMMA BELOW + // U+0163: "ţ" LATIN SMALL LETTER T WITH CEDILLA + // U+0167: "ŧ" LATIN SMALL LETTER T WITH STROKE + .setMoreKeysOf("t", "5", "\u0165", "\u021B", "\u0163", "\u0167") + // U+016D: "ŭ" LATIN SMALL LETTER U WITH BREVE + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+0177: "ŷ" LATIN SMALL LETTER Y WITH CIRCUMFLEX + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + // U+00FE: "þ" LATIN SMALL LETTER THORN + .replaceKeyOfLabel("y", key("\u016D", + moreKey("6"), moreKey("y"), moreKey("\u00FD"), moreKey("\u0177"), + moreKey("\u00FF"), moreKey("\u00FE"))) + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+016F: "ů" LATIN SMALL LETTER U WITH RING ABOVE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + // U+0169: "ũ" LATIN SMALL LETTER U WITH TILDE + // U+0171: "ű" LATIN SMALL LETTER U WITH DOUBLE ACUTE + // U+0173: "ų" LATIN SMALL LETTER U WITH OGONEK + // U+00B5: "µ" MICRO SIGN + .setMoreKeysOf("u", + "7", "\u00FA", "\u016F", "\u00FB", "\u00FC", "\u00F9", "\u016B", + "\u0169", "\u0171", "\u0173", "\u00B5") + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+0129: "ĩ" LATIN SMALL LETTER I WITH TILDE + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + // U+0131: "ı" LATIN SMALL LETTER DOTLESS I + // U+0133: "ij" LATIN SMALL LIGATURE IJ + .setMoreKeysOf("i", + "8", "\u00ED", "\u00EE", "\u00EF", "\u0129", "\u00EC", "\u012F", + "\u012B", "\u0131", "\u0133") + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + // U+0151: "ő" LATIN SMALL LETTER O WITH DOUBLE ACUTE + // U+00BA: "º" MASCULINE ORDINAL INDICATOR + .setMoreKeysOf("o", + "9", "\u00F3", "\u00F6", "\u00F4", "\u00F2", "\u00F5", "\u0153", + "\u00F8", "\u014D", "\u0151", "\u00BA") + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + // U+0103: "ă" LATIN SMALL LETTER A WITH BREVE + // U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK + // U+00AA: "ª" FEMININE ORDINAL INDICATOR + .setMoreKeysOf("a", + "\u00E1", "\u00E0", "\u00E2", "\u00E4", "\u00E6", "\u00E3", "\u00E5", + "\u0101", "\u0103", "\u0105", "\u00AA") + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+0219: "ș" LATIN SMALL LETTER S WITH COMMA BELOW + // U+015F: "ş" LATIN SMALL LETTER S WITH CEDILLA + .setMoreKeysOf("s", "\u00DF", "\u0161", "\u015B", "\u0219", "\u015F") + // U+00F0: "ð" LATIN SMALL LETTER ETH + // U+010F: "ď" LATIN SMALL LETTER D WITH CARON + // U+0111: "đ" LATIN SMALL LETTER D WITH STROKE + .setMoreKeysOf("d", "\u00F0", "\u010F", "\u0111") + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + // U+0146: "ņ" LATIN SMALL LETTER N WITH CEDILLA + // U+0148: "ň" LATIN SMALL LETTER N WITH CARON + // U+0149: "ʼn" LATIN SMALL LETTER N PRECEDED BY APOSTROPHE + // U+014B: "ŋ" LATIN SMALL LETTER ENG + .setMoreKeysOf("n", "\u00F1", "\u0144", "\u0146", "\u0148", "\u0149", "\u014B") + // U+011F: "ğ" LATIN SMALL LETTER G WITH BREVE + // U+0121: "ġ" LATIN SMALL LETTER G WITH DOT ABOVE + // U+0123: "ģ" LATIN SMALL LETTER G WITH CEDILLA + .setMoreKeysOf("g", "\u011F", "\u0121", "\u0123") + // U+0125: "ĥ" LATIN SMALL LETTER H WITH CIRCUMFLEX + // U+0127: "ħ" LATIN SMALL LETTER H WITH STROKE + .setMoreKeysOf("h", "\u0125", "\u0127") + // U+0137: "ķ" LATIN SMALL LETTER K WITH CEDILLA + // U+0138: "ĸ" LATIN SMALL LETTER KRA + .setMoreKeysOf("k", "\u0137", "\u0138") + // U+013A: "ĺ" LATIN SMALL LETTER L WITH ACUTE + // U+013C: "ļ" LATIN SMALL LETTER L WITH CEDILLA + // U+013E: "ľ" LATIN SMALL LETTER L WITH CARON + // U+0140: "ŀ" LATIN SMALL LETTER L WITH MIDDLE DOT + // U+0142: "ł" LATIN SMALL LETTER L WITH STROKE + .setMoreKeysOf("l", "\u013A", "\u013C", "\u013E", "\u0140", "\u0142") + // U+0135: "ĵ" LATIN SMALL LETTER J WITH CIRCUMFLEX + .replaceKeyOfLabel(Spanish.ROW2_10, key("\u0135")) + // U+017A: "ź" LATIN SMALL LETTER Z WITH ACUTE + // U+017C: "ż" LATIN SMALL LETTER Z WITH DOT ABOVE + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + .setMoreKeysOf("z", "\u017A", "\u017C", "\u017E") + // U+0109: "ĉ" LATIN SMALL LETTER C WITH CIRCUMFLEX + .replaceKeyOfLabel("x", key("\u0109", moreKey("x"))) + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+010B: "ċ" LATIN SMALL LETTER C WITH DOT ABOVE + .setMoreKeysOf("c", "\u0107", "\u010D", "\u00E7", "\u010B") + // U+0175: "ŵ" LATIN SMALL LETTER W WITH CIRCUMFLEX + .setMoreKeysOf("v", "w", "\u0175"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEstonianEE.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEstonianEE.java new file mode 100644 index 000000000..be3786a32 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsEstonianEE.java @@ -0,0 +1,158 @@ +/* + * 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.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Nordic; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * et_EE: Estonian (Estonia)/nordic + */ +@SmallTest +public final class TestsEstonianEE extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("et", "EE"); + private static final LayoutBase LAYOUT = new Nordic(new EstonianEECustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class EstonianEECustomizer extends EuroLayoutCustomizer { + public EstonianEECustomizer(final Locale locale) { + super(locale); + } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_R9L; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+011B: "ě" LATIN SMALL LETTER E WITH CARON + .setMoreKeysOf("e", + "3", "\u0113", "\u00E8", "\u0117", "\u00E9", "\u00EA", "\u00EB", + "\u0119", "\u011B") + // U+0157: "ŗ" LATIN SMALL LETTER R WITH CEDILLA + // U+0159: "ř" LATIN SMALL LETTER R WITH CARON + // U+0155: "ŕ" LATIN SMALL LETTER R WITH ACUTE + .setMoreKeysOf("r", "4", "\u0157", "\u0159", "\u0155") + // U+0163: "ţ" LATIN SMALL LETTER T WITH CEDILLA + // U+0165: "ť" LATIN SMALL LETTER T WITH CARON + .setMoreKeysOf("t", "5", "\u0163", "\u0165") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "6", "\u00FD", "\u00FF") + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + // U+0173: "ų" LATIN SMALL LETTER U WITH OGONEK + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+016F: "ů" LATIN SMALL LETTER U WITH RING ABOVE + // U+0171: "ű" LATIN SMALL LETTER U WITH DOUBLE ACUTE + .setMoreKeysOf("u", + "7", "\u00FC", "\u016B", "\u0173", "\u00F9", "\u00FA", "\u00FB", + "\u016F", "\u0171") + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+0131: "ı" LATIN SMALL LETTER DOTLESS I + .setMoreKeysOf("i", + "8", "\u012B", "\u00EC", "\u012F", "\u00ED", "\u00EE", "\u00EF", + "\u0131") + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+0151: "ő" LATIN SMALL LETTER O WITH DOUBLE ACUTE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + .setMoreKeysOf("o", + "9", "\u00F6", "\u00F5", "\u00F2", "\u00F3", "\u00F4", "\u0153", + "\u0151", "\u00F8") + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + .replaceKeyOfLabel(Nordic.ROW1_11, key("\u00FC")) + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + .replaceKeyOfLabel(Nordic.ROW2_10, key("\u00F6", moreKey("\u00F5"))) + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + .replaceKeyOfLabel(Nordic.ROW2_11, key("\u00E4")) + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK + .setMoreKeysOf("a", + "\u00E4", "\u0101", "\u00E0", "\u00E1", "\u00E2", "\u00E3", "\u00E5", + "\u00E6", "\u0105") + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+015F: "ş" LATIN SMALL LETTER S WITH CEDILLA + .setMoreKeysOf("s", "\u0161", "\u00DF", "\u015B", "\u015F") + // U+010F: "ď" LATIN SMALL LETTER D WITH CARON + .setMoreKeysOf("d", "\u010F") + // U+0123: "ģ" LATIN SMALL LETTER G WITH CEDILLA + // U+011F: "ğ" LATIN SMALL LETTER G WITH BREVE + .setMoreKeysOf("g", "\u0123", "\u011F") + // U+0137: "ķ" LATIN SMALL LETTER K WITH CEDILLA + .setMoreKeysOf("k", "\u0137") + // U+013C: "ļ" LATIN SMALL LETTER L WITH CEDILLA + // U+0142: "ł" LATIN SMALL LETTER L WITH STROKE + // U+013A: "ĺ" LATIN SMALL LETTER L WITH ACUTE + // U+013E: "ľ" LATIN SMALL LETTER L WITH CARON + .setMoreKeysOf("l", "\u013C", "\u0142", "\u013A", "\u013E") + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + // U+017C: "ż" LATIN SMALL LETTER Z WITH DOT ABOVE + // U+017A: "ź" LATIN SMALL LETTER Z WITH ACUTE + .setMoreKeysOf("z", "\u017E", "\u017C", "\u017A") + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + .setMoreKeysOf("c", "\u010D", "\u00E7", "\u0107") + // U+0146: "ņ" LATIN SMALL LETTER N WITH CEDILLA + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + .setMoreKeysOf("n", "\u0146", "\u00F1", "\u0144"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsFinnish.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsFinnish.java new file mode 100644 index 000000000..20ecd5164 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsFinnish.java @@ -0,0 +1,82 @@ +/* + * 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.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Nordic; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * fi: Finnish/nordic + */ +@SmallTest +public final class TestsFinnish extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("fi"); + private static final LayoutBase LAYOUT = new Nordic(new FinnishCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class FinnishCustomizer extends EuroLayoutCustomizer { + public FinnishCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + .setMoreKeysOf("u", "7", "\u00FC") + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", + "9", "\u00F8", "\u00F4", "\u00F2", "\u00F3", "\u00F5", "\u0153", + "\u014D") + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + .replaceKeyOfLabel(Nordic.ROW1_11, key("\u00E5")) + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + .replaceKeyOfLabel(Nordic.ROW2_10, key("\u00F6", moreKey("\u00F8"))) + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E6: "æ" LATIN SMALL LETTER AE + .replaceKeyOfLabel(Nordic.ROW2_11, key("\u00E4", moreKey("\u00E6"))) + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + .setMoreKeysOf("a", "\u00E6", "\u00E0", "\u00E1", "\u00E2", "\u00E3", "\u0101") + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + .setMoreKeysOf("s", "\u0161", "\u00DF", "\u015B") + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + // U+017A: "ź" LATIN SMALL LETTER Z WITH ACUTE + // U+017C: "ż" LATIN SMALL LETTER Z WITH DOT ABOVE + .setMoreKeysOf("z", "\u017E", "\u017A", "\u017C"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsFrench.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsFrench.java new file mode 100644 index 000000000..5f8ecd6e1 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsFrench.java @@ -0,0 +1,101 @@ +/* + * 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.Azerty; +import com.android.inputmethod.keyboard.layout.LayoutBase; +import com.android.inputmethod.keyboard.layout.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * fr: French/azerty + */ +@SmallTest +public final class TestsFrench extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("fr"); + private static final LayoutBase LAYOUT = new Azerty(new FrenchCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class FrenchCustomizer extends EuroLayoutCustomizer { + public FrenchCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + // U+00AA: "ª" FEMININE ORDINAL INDICATOR + .setMoreKeysOf("a", + "\u00E0", "\u00E2", "1", "\u00E6", "\u00E1", "\u00E4", "\u00E3", + "\u00E5", "\u0101", "\u00AA") + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", + "\u00E9", "\u00E8", "\u00EA", "\u00EB", "3", "\u0119", "\u0117", + "\u0113") + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "6", "\u00FF") + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "\u00F9", "\u00FB", "7", "\u00FC", "\u00FA", "\u016B") + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + .setMoreKeysOf("i", "\u00EE", "8", "\u00EF", "\u00EC", "\u00ED", "\u012F", + "\u012B") + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + // U+00BA: "º" MASCULINE ORDINAL INDICATOR + .setMoreKeysOf("o", + "\u00F4", "\u0153", "9", "\u00F6", "\u00F2", "\u00F3", "\u00F5", + "\u00F8", "\u014D", "\u00BA") + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + .setMoreKeysOf("c", "\u00E7", "\u0107", "\u010D"); + } + } +}
\ No newline at end of file diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsFrenchCA.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsFrenchCA.java new file mode 100644 index 000000000..d6babc841 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsFrenchCA.java @@ -0,0 +1,101 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * fr_CA: French (Canada)/qwerty + */ +@SmallTest +public final class TestsFrenchCA extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("fr", "CA"); + private static final LayoutBase LAYOUT = new Qwerty(new FrenchCACustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class FrenchCACustomizer extends LayoutCustomizer { + public FrenchCACustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", + "\u00E9", "\u00E8", "\u00EA", "\u00EB", "3", "\u0119", "\u0117", + "\u0113") + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "6", "\u00FF") + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "\u00F9", "\u00FB", "7", "\u00FC", "\u00FA", "\u016B") + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + .setMoreKeysOf("i", "\u00EE", "8", "\u00EF", "\u00EC", "\u00ED", "\u012F", + "\u012B") + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + // U+00BA: "º" MASCULINE ORDINAL INDICATOR + .setMoreKeysOf("o", + "\u00F4", "\u0153", "9", "\u00F6", "\u00F2", "\u00F3", "\u00F5", + "\u00F8", "\u014D", "\u00BA") + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + // U+00AA: "ª" FEMININE ORDINAL INDICATOR + .setMoreKeysOf("a", + "\u00E0", "\u00E2", "\u00E6", "\u00E1", "\u00E4", "\u00E3", "\u00E5", + "\u0101", "\u00AA") + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + .setMoreKeysOf("c", "\u00E7", "\u0107", "\u010D"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsFrenchCH.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsFrenchCH.java new file mode 100644 index 000000000..5a56ad1d4 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsFrenchCH.java @@ -0,0 +1,110 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Swiss; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * fr_CH: French (Switzerland)/swiss + */ +@SmallTest +public final class TestsFrenchCH extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("fr", "CH"); + private static final LayoutBase LAYOUT = new Swiss(new FrenchCHCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class FrenchCHCustomizer extends LayoutCustomizer { + public FrenchCHCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", + "\u00E9", "\u00E8", "\u00EA", "\u00EB", "3", "\u0119", "\u0117", + "\u0113") + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "\u00F9", "\u00FB", "7", "\u00FC", "\u00FA", "\u016B") + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + .setMoreKeysOf("i", "\u00EE", "8", "\u00EF", "\u00EC", "\u00ED", "\u012F", + "\u012B") + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + // U+00BA: "º" MASCULINE ORDINAL INDICATOR + .setMoreKeysOf("o", + "\u00F4", "\u0153", "9", "\u00F6", "\u00F2", "\u00F3", "\u00F5", + "\u00F8", "\u014D", "\u00BA") + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + .replaceKeyOfLabel(Swiss.ROW1_11, key("\u00E8", moreKey("\u00FC"))) + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + // U+00AA: "ª" FEMININE ORDINAL INDICATOR + .setMoreKeysOf("a", + "\u00E0", "\u00E2", "\u00E6", "\u00E1", "\u00E4", "\u00E3", "\u00E5", + "\u0101", "\u00AA") + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + .replaceKeyOfLabel(Swiss.ROW2_10, key("\u00E9", moreKey("\u00F6"))) + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + .replaceKeyOfLabel(Swiss.ROW2_11, key("\u00E0", moreKey("\u00E4"))) + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "\u00FF") + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + .setMoreKeysOf("c", "\u00E7", "\u0107", "\u010D"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsFrenchQwertz.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsFrenchQwertz.java new file mode 100644 index 000000000..0582b0cf0 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsFrenchQwertz.java @@ -0,0 +1,101 @@ +/* + * 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.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwertz; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * fr: French/qwertz + */ +@SmallTest +public final class TestsFrenchQwertz extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("fr"); + private static final LayoutBase LAYOUT = new Qwertz(new FrenchQwertzCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class FrenchQwertzCustomizer extends EuroLayoutCustomizer { + public FrenchQwertzCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", + "\u00E9", "\u00E8", "\u00EA", "\u00EB", "3", "\u0119", "\u0117", + "\u0113") + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "\u00F9", "\u00FB", "7", "\u00FC", "\u00FA", "\u016B") + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + .setMoreKeysOf("i", "\u00EE", "8", "\u00EF", "\u00EC", "\u00ED", "\u012F", + "\u012B") + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + // U+00BA: "º" MASCULINE ORDINAL INDICATOR + .setMoreKeysOf("o", + "\u00F4", "\u0153", "9", "\u00F6", "\u00F2", "\u00F3", "\u00F5", + "\u00F8", "\u014D", "\u00BA") + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + // U+00AA: "ª" FEMININE ORDINAL INDICATOR + .setMoreKeysOf("a", + "\u00E0", "\u00E2", "\u00E6", "\u00E1", "\u00E4", "\u00E3", "\u00E5", + "\u0101", "\u00AA") + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "\u00FF") + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + .setMoreKeysOf("c", "\u00E7", "\u0107", "\u010D"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsGerman.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsGerman.java new file mode 100644 index 000000000..7c12b37de --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsGerman.java @@ -0,0 +1,102 @@ +/* + * 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.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwertz; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * de: German/qwertz + */ +@SmallTest +public final class TestsGerman extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("de"); + private static final LayoutBase LAYOUT = new Qwertz(new GermanCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class GermanCustomizer extends EuroLayoutCustomizer { + public GermanCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getDoubleAngleQuoteKeys() { return Symbols.DOUBLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKey[] getSingleAngleQuoteKeys() { return Symbols.SINGLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + .setMoreKeysOf("e", "3", "\u00E9", "\u00E8", "\u00EA", "\u00EB", "\u0117") + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FC", "\u00FB", "\u00F9", "\u00FA", "\u016B") + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", + "9", "\u00F6", "\u00F4", "\u00F2", "\u00F3", "\u00F5", "\u0153", + "\u00F8", "\u014D") + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + .setMoreKeysOf("a", + "\u00E4", "\u00E2", "\u00E0", "\u00E1", "\u00E6", "\u00E3", "\u00E5", + "\u0101") + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + .setMoreKeysOf("s", "\u00DF", "\u015B", "\u0161") + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + .setMoreKeysOf("n", "\u00F1", "\u0144"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsGermanCH.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsGermanCH.java new file mode 100644 index 000000000..001c3c40a --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsGermanCH.java @@ -0,0 +1,111 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Swiss; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * de_CH: German (Switzerland)/swiss + */ +@SmallTest +public final class TestsGermanCH extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("de", "CH"); + private static final LayoutBase LAYOUT = new Swiss(new GermanCHCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class GermanCHCustomizer extends LayoutCustomizer { + public GermanCHCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getDoubleAngleQuoteKeys() { return Symbols.DOUBLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKey[] getSingleAngleQuoteKeys() { return Symbols.SINGLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + .setMoreKeysOf("e", "3", "\u00E9", "\u00E8", "\u00EA", "\u00EB", "\u0117") + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FC", "\u00FB", "\u00F9", "\u00FA", "\u016B") + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", + "9", "\u00F6", "\u00F4", "\u00F2", "\u00F3", "\u00F5", "\u0153", + "\u00F8", "\u014D") + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + .replaceKeyOfLabel(Swiss.ROW1_11, key("\u00FC", moreKey("\u00E8"))) + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + .setMoreKeysOf("a", + "\u00E4", "\u00E2", "\u00E0", "\u00E1", "\u00E6", "\u00E3", "\u00E5", + "\u0101") + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + .replaceKeyOfLabel(Swiss.ROW2_10, key("\u00F6", moreKey("\u00E9"))) + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + .replaceKeyOfLabel(Swiss.ROW2_11, key("\u00E4", moreKey("\u00E0"))) + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + .setMoreKeysOf("s", "\u00DF", "\u015B", "\u0161") + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + .setMoreKeysOf("n", "\u00F1", "\u0144"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsGermanQwerty.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsGermanQwerty.java new file mode 100644 index 000000000..618485dba --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsGermanQwerty.java @@ -0,0 +1,102 @@ +/* + * 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.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * de: German/qwerty + */ +@SmallTest +public final class TestsGermanQwerty extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("de"); + private static final LayoutBase LAYOUT = new Qwerty(new GermanQwertyCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class GermanQwertyCustomizer extends EuroLayoutCustomizer { + public GermanQwertyCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getDoubleAngleQuoteKeys() { return Symbols.DOUBLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKey[] getSingleAngleQuoteKeys() { return Symbols.SINGLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + .setMoreKeysOf("e", "3", "\u00E9", "\u00E8", "\u00EA", "\u00EB", "\u0117") + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FC", "\u00FB", "\u00F9", "\u00FA", "\u016B") + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", + "9", "\u00F6", "\u00F4", "\u00F2", "\u00F3", "\u00F5", "\u0153", + "\u00F8", "\u014D") + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + .setMoreKeysOf("a", + "\u00E4", "\u00E2", "\u00E0", "\u00E1", "\u00E6", "\u00E3", "\u00E5", + "\u0101") + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + .setMoreKeysOf("s", "\u00DF", "\u015B", "\u0161") + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + .setMoreKeysOf("n", "\u00F1", "\u0144"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsGreek.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsGreek.java new file mode 100644 index 000000000..4acb119ac --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsGreek.java @@ -0,0 +1,37 @@ +/* + * 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.Greek; +import com.android.inputmethod.keyboard.layout.Greek.GreekCustomizer; +import com.android.inputmethod.keyboard.layout.LayoutBase; + +import java.util.Locale; + +/** + * el: Greek/greek + */ +@SmallTest +public class TestsGreek extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("el"); + private static final LayoutBase LAYOUT = new Greek(new GreekCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHindi.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHindi.java new file mode 100644 index 000000000..84053b5be --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHindi.java @@ -0,0 +1,37 @@ +/* + * 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.Hindi; +import com.android.inputmethod.keyboard.layout.Hindi.HindiCustomizer; +import com.android.inputmethod.keyboard.layout.LayoutBase; + +import java.util.Locale; + +/** + * hi: Hindi/hindi + */ +@SmallTest +public final class TestsHindi extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("hi"); + private static final LayoutBase LAYOUT = new Hindi(new HindiCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHungarian.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHungarian.java new file mode 100644 index 000000000..942c07a2a --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsHungarian.java @@ -0,0 +1,110 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwertz; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * hu: Hungarian/qwertz + */ +@SmallTest +public final class TestsHungarian extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("hu"); + private static final LayoutBase LAYOUT = new Qwertz(new HungarianCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class HungarianCustomizer extends LayoutCustomizer { + public HungarianCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_L9R; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_L9R; } + + @Override + public ExpectedKey[] getDoubleAngleQuoteKeys() { return Symbols.DOUBLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKey[] getSingleAngleQuoteKeys() { return Symbols.SINGLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", + "3", "\u00E9", "\u00E8", "\u00EA", "\u00EB", "\u0119", "\u0117", + "\u0113") + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+0171: "ű" LATIN SMALL LETTER U WITH DOUBLE ACUTE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FA", "\u00FC", "\u0171", "\u00FB", "\u00F9", + "\u016B") + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + .setMoreKeysOf("i", "8", "\u00ED", "\u00EE", "\u00EF", "\u00EC", "\u012F", + "\u012B") + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+0151: "ő" LATIN SMALL LETTER O WITH DOUBLE ACUTE + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", + "9", "\u00F3", "\u00F6", "\u0151", "\u00F4", "\u00F2", "\u00F5", + "\u0153", "\u00F8", "\u014D") + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + .setMoreKeysOf("a", + "\u00E1", "\u00E0", "\u00E2", "\u00E4", "\u00E6", "\u00E3", "\u00E5", + "\u0101"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsIcelandic.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsIcelandic.java new file mode 100644 index 000000000..c10c1a905 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsIcelandic.java @@ -0,0 +1,108 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * is: Icelandic/qwerty + */ +@SmallTest +public final class TestsIcelandic extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("is"); + private static final LayoutBase LAYOUT = new Qwerty(new IcelandicCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class IcelandicCustomizer extends LayoutCustomizer { + public IcelandicCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_R9L; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", + "3", "\u00E9", "\u00EB", "\u00E8", "\u00EA", "\u0119", "\u0117", + "\u0113") + // U+00FE: "þ" LATIN SMALL LETTER THORN + .setMoreKeysOf("t", "5", "\u00FE") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "6", "\u00FD", "\u00FF") + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FA", "\u00FC", "\u00FB", "\u00F9", "\u016B") + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + .setMoreKeysOf("i", "8", "\u00ED", "\u00EF", "\u00EE", "\u00EC", "\u012F", + "\u012B") + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", + "9", "\u00F3", "\u00F6", "\u00F4", "\u00F2", "\u00F5", "\u0153", + "\u00F8", "\u014D") + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + .setMoreKeysOf("a", + "\u00E1", "\u00E4", "\u00E6", "\u00E5", "\u00E0", "\u00E2", "\u00E3", + "\u0101") + // U+00F0: "ð" LATIN SMALL LETTER ETH + .setMoreKeysOf("d", "\u00F0"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsIndonesian.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsIndonesian.java new file mode 100644 index 000000000..9b23bfe2b --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsIndonesian.java @@ -0,0 +1,37 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; + +import java.util.Locale; + +/** + * in: Indonesian/qwerty # "id" is the official language code of Indonesian. + */ +@SmallTest +public final class TestsIndonesian extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("in"); + private static final LayoutBase LAYOUT = new Qwerty(new LayoutCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsItalian.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsItalian.java new file mode 100644 index 000000000..1ba54b1e3 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsItalian.java @@ -0,0 +1,95 @@ +/* + * 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.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * it: Italian/qwerty + */ +@SmallTest +public final class TestsItalian extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("it"); + private static final LayoutBase LAYOUT = new Qwerty(new ItalianCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class ItalianCustomizer extends EuroLayoutCustomizer { + public ItalianCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", + "3", "\u00E8", "\u00E9", "\u00EA", "\u00EB", "\u0119", "\u0117", + "\u0113") + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00F9", "\u00FA", "\u00FB", "\u00FC", "\u016B") + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + .setMoreKeysOf("i", "8", "\u00EC", "\u00ED", "\u00EE", "\u00EF", "\u012F", + "\u012B") + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + // U+00BA: "º" MASCULINE ORDINAL INDICATOR + .setMoreKeysOf("o", + "9", "\u00F2", "\u00F3", "\u00F4", "\u00F6", "\u00F5", "\u0153", + "\u00F8", "\u014D", "\u00BA") + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + // U+00AA: "ª" FEMININE ORDINAL INDICATOR + .setMoreKeysOf("a", + "\u00E0", "\u00E1", "\u00E2", "\u00E4", "\u00E6", "\u00E3", "\u00E5", + "\u0101", "\u00AA"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsKazakh.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsKazakh.java new file mode 100644 index 000000000..ec08a5a04 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsKazakh.java @@ -0,0 +1,82 @@ +/* + * 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.EastSlavic; +import com.android.inputmethod.keyboard.layout.EastSlavic.EastSlavicCustomizer; +import com.android.inputmethod.keyboard.layout.LayoutBase; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * kk: Kazakh/east_slavic + */ +@SmallTest +public final class TestsKazakh extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("kk"); + private static final LayoutBase LAYOUT = new EastSlavic(new KazakhCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class KazakhCustomizer extends EastSlavicCustomizer { + public KazakhCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+0443: "у" CYRILLIC SMALL LETTER U + // U+04AF: "ү" CYRILLIC SMALL LETTER STRAIGHT U + // U+04B1: "ұ" CYRILLIC SMALL LETTER STRAIGHT U WITH STROKE + .setMoreKeysOf("\u0443", "3", "\u04AF", "\u04B1") + // U+043A: "к" CYRILLIC SMALL LETTER KA + // U+049B: "қ" CYRILLIC SMALL LETTER KA WITH DESCENDER + .setMoreKeysOf("\u043A", "4", "\u049B") + // U+0435: "е" CYRILLIC SMALL LETTER IE + // U+0451: "ё" CYRILLIC SMALL LETTER IO + .setMoreKeysOf("\u0435", "5", "\u0451") + // U+043D: "н" CYRILLIC SMALL LETTER EN + // U+04A3: "ң" CYRILLIC SMALL LETTER EN WITH DESCENDER + .setMoreKeysOf("\u043D", "6", "\u04A3") + // U+0433: "г" CYRILLIC SMALL LETTER GHE + // U+0493: "ғ" CYRILLIC SMALL LETTER GHE WITH STROKE + .setMoreKeysOf("\u0433", "7", "\u0493") + // U+0449: "щ" CYRILLIC SMALL LETTER SHCHA + .replaceKeyOfLabel(EastSlavic.ROW1_9, key("\u0449", moreKey("9"))) + // U+044B: "ы" CYRILLIC SMALL LETTER YERU + // U+0456: "і" CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I + .replaceKeyOfLabel(EastSlavic.ROW2_2, key("\u044B", moreKey("\u0456"))) + // U+0430: "а" CYRILLIC SMALL LETTER A + // U+04D9: "ә" CYRILLIC SMALL LETTER SCHWA + .setMoreKeysOf("\u0430", "\u04D9") + // U+043E: "о" CYRILLIC SMALL LETTER O + // U+04E9: "ө" CYRILLIC SMALL LETTER BARRED O + .setMoreKeysOf("\u043E", "\u04E9") + // U+044D: "э" CYRILLIC SMALL LETTER E + // U+04BB: "һ" CYRILLIC SMALL LETTER SHHA + .replaceKeyOfLabel(EastSlavic.ROW2_11, key("\u044D", moreKey("\u04BB"))) + // U+0438: "и" CYRILLIC SMALL LETTER I + .replaceKeyOfLabel(EastSlavic.ROW3_5, key("\u0438")) + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN + .setMoreKeysOf("\u044C", "\u044A"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsKyrgyz.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsKyrgyz.java new file mode 100644 index 000000000..ccacf3f06 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsKyrgyz.java @@ -0,0 +1,70 @@ +/* + * 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.EastSlavic; +import com.android.inputmethod.keyboard.layout.EastSlavic.EastSlavicCustomizer; +import com.android.inputmethod.keyboard.layout.LayoutBase; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * ky: Kyrgyz/east_slavic + */ +@SmallTest +public final class TestsKyrgyz extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("ky"); + private static final LayoutBase LAYOUT = new EastSlavic(new KyrgyzCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class KyrgyzCustomizer extends EastSlavicCustomizer { + public KyrgyzCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+0443: "у" CYRILLIC SMALL LETTER U + // U+04AF: "ү" CYRILLIC SMALL LETTER STRAIGHT U + .setMoreKeysOf("\u0443", "3", "\u04AF") + // U+0435: "е" CYRILLIC SMALL LETTER IE + // U+0451: "ё" CYRILLIC SMALL LETTER IO + .setMoreKeysOf("\u0435", "5", "\u0451") + // U+043D: "н" CYRILLIC SMALL LETTER EN + // U+04A3: "ң" CYRILLIC SMALL LETTER EN WITH DESCENDER + .setMoreKeysOf("\u043D", "6", "\u04A3") + // U+0449: "щ" CYRILLIC SMALL LETTER SHCHA + .replaceKeyOfLabel(EastSlavic.ROW1_9, key("\u0449", moreKey("9"))) + // U+044B: "ы" CYRILLIC SMALL LETTER YERU + .replaceKeyOfLabel(EastSlavic.ROW2_2, key("\u044B")) + // U+043E: "о" CYRILLIC SMALL LETTER O + // U+04E9: "ө" CYRILLIC SMALL LETTER BARRED O + .setMoreKeysOf("\u043E", "\u04E9") + // U+044D: "э" CYRILLIC SMALL LETTER E + .replaceKeyOfLabel(EastSlavic.ROW2_11, key("\u044D")) + // U+0438: "и" CYRILLIC SMALL LETTER I + .replaceKeyOfLabel(EastSlavic.ROW3_5, key("\u0438")) + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN + .setMoreKeysOf("\u044C", "\u044A"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsLatvian.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsLatvian.java new file mode 100644 index 000000000..0f0785440 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsLatvian.java @@ -0,0 +1,149 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * lv: Latvian/qwerty + */ +@SmallTest +public final class TestsLatvian extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("lv"); + private static final LayoutBase LAYOUT = new Qwerty(new LatvianCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class LatvianCustomizer extends LayoutCustomizer { + public LatvianCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_R9L; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+011B: "ě" LATIN SMALL LETTER E WITH CARON + .setMoreKeysOf("e", + "3", "\u0113", "\u0117", "\u00E8", "\u00E9", "\u00EA", "\u00EB", + "\u0119", "\u011B") + // U+0157: "ŗ" LATIN SMALL LETTER R WITH CEDILLA + // U+0159: "ř" LATIN SMALL LETTER R WITH CARON + // U+0155: "ŕ" LATIN SMALL LETTER R WITH ACUTE + .setMoreKeysOf("r", "4", "\u0157", "\u0159", "\u0155") + // U+0163: "ţ" LATIN SMALL LETTER T WITH CEDILLA + // U+0165: "ť" LATIN SMALL LETTER T WITH CARON + .setMoreKeysOf("t", "5", "\u0163", "\u0165") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "6", "\u00FD", "\u00FF") + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + // U+0173: "ų" LATIN SMALL LETTER U WITH OGONEK + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+016F: "ů" LATIN SMALL LETTER U WITH RING ABOVE + // U+0171: "ű" LATIN SMALL LETTER U WITH DOUBLE ACUTE + .setMoreKeysOf("u", + "7", "\u016B", "\u0173", "\u00F9", "\u00FA", "\u00FB", "\u00FC", + "\u016F", "\u0171") + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+0131: "ı" LATIN SMALL LETTER DOTLESS I + .setMoreKeysOf("i", + "8", "\u012B", "\u012F", "\u00EC", "\u00ED", "\u00EE", "\u00EF", + "\u0131") + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+0151: "ő" LATIN SMALL LETTER O WITH DOUBLE ACUTE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + .setMoreKeysOf("o", + "9", "\u00F2", "\u00F3", "\u00F4", "\u00F5", "\u00F6", "\u0153", + "\u0151", "\u00F8") + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK + .setMoreKeysOf("a", + "\u0101", "\u00E0", "\u00E1", "\u00E2", "\u00E3", "\u00E4", "\u00E5", + "\u00E6", "\u0105") + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+015F: "ş" LATIN SMALL LETTER S WITH CEDILLA + .setMoreKeysOf("s", "\u0161", "\u00DF", "\u015B", "\u015F") + // U+010F: "ď" LATIN SMALL LETTER D WITH CARON + .setMoreKeysOf("d", "\u010F") + // U+0123: "ģ" LATIN SMALL LETTER G WITH CEDILLA + // U+011F: "ğ" LATIN SMALL LETTER G WITH BREVE + .setMoreKeysOf("g", "\u0123", "\u011F") + // U+0137: "ķ" LATIN SMALL LETTER K WITH CEDILLA + .setMoreKeysOf("k", "\u0137") + // U+013C: "ļ" LATIN SMALL LETTER L WITH CEDILLA + // U+0142: "ł" LATIN SMALL LETTER L WITH STROKE + // U+013A: "ĺ" LATIN SMALL LETTER L WITH ACUTE + // U+013E: "ľ" LATIN SMALL LETTER L WITH CARON + .setMoreKeysOf("l", "\u013C", "\u0142", "\u013A", "\u013E") + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + // U+017C: "ż" LATIN SMALL LETTER Z WITH DOT ABOVE + // U+017A: "ź" LATIN SMALL LETTER Z WITH ACUTE + .setMoreKeysOf("z", "\u017E", "\u017C", "\u017A") + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + .setMoreKeysOf("c", "\u010D", "\u00E7", "\u0107") + // U+0146: "ņ" LATIN SMALL LETTER N WITH CEDILLA + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + .setMoreKeysOf("n", "\u0146", "\u00F1", "\u0144"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsLithuanian.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsLithuanian.java new file mode 100644 index 000000000..9094db91a --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsLithuanian.java @@ -0,0 +1,150 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * lt: Lithuanian/qwerty + */ +@SmallTest +public final class TestsLithuanian extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("lt"); + private static final LayoutBase LAYOUT = new Qwerty(new LithuanianCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class LithuanianCustomizer extends LayoutCustomizer { + public LithuanianCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_R9L; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+011B: "ě" LATIN SMALL LETTER E WITH CARON + .setMoreKeysOf("e", + "3", "\u0117", "\u0119", "\u0113", "\u00E8", "\u00E9", "\u00EA", + "\u00EB", "\u011B") + // U+0157: "ŗ" LATIN SMALL LETTER R WITH CEDILLA + // U+0159: "ř" LATIN SMALL LETTER R WITH CARON + // U+0155: "ŕ" LATIN SMALL LETTER R WITH ACUTE + .setMoreKeysOf("r", "4", "\u0157", "\u0159", "\u0155") + // U+0163: "ţ" LATIN SMALL LETTER T WITH CEDILLA + // U+0165: "ť" LATIN SMALL LETTER T WITH CARON + .setMoreKeysOf("t", "5", "\u0163", "\u0165") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "6", "\u00FD", "\u00FF") + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + // U+0173: "ų" LATIN SMALL LETTER U WITH OGONEK + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+016F: "ů" LATIN SMALL LETTER U WITH RING ABOVE + // U+0171: "ű" LATIN SMALL LETTER U WITH DOUBLE ACUTE + .setMoreKeysOf("u", + "7", "\u016B", "\u0173", "\u00FC", "\u016B", "\u00F9", "\u00FA", + "\u00FB", "\u016F", "\u0171") + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+0131: "ı" LATIN SMALL LETTER DOTLESS I + .setMoreKeysOf("i", + "8", "\u012F", "\u012B", "\u00EC", "\u00ED", "\u00EE", "\u00EF", + "\u0131") + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+0151: "ő" LATIN SMALL LETTER O WITH DOUBLE ACUTE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + .setMoreKeysOf("o", + "9", "\u00F6", "\u00F5", "\u00F2", "\u00F3", "\u00F4", "\u0153", + "\u0151", "\u00F8") + // U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+00E6: "æ" LATIN SMALL LETTER AE + .setMoreKeysOf("a", + "\u0105", "\u00E4", "\u0101", "\u00E0", "\u00E1", "\u00E2", "\u00E3", + "\u00E5", "\u00E6") + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+015F: "ş" LATIN SMALL LETTER S WITH CEDILLA + .setMoreKeysOf("s", "\u0161", "\u00DF", "\u015B", "\u015F") + // U+010F: "ď" LATIN SMALL LETTER D WITH CARON + .setMoreKeysOf("d", "\u010F") + // U+0123: "ģ" LATIN SMALL LETTER G WITH CEDILLA + // U+011F: "ğ" LATIN SMALL LETTER G WITH BREVE + .setMoreKeysOf("g", "\u0123", "\u011F") + // U+0137: "ķ" LATIN SMALL LETTER K WITH CEDILLA + .setMoreKeysOf("k", "\u0137") + // U+013C: "ļ" LATIN SMALL LETTER L WITH CEDILLA + // U+0142: "ł" LATIN SMALL LETTER L WITH STROKE + // U+013A: "ĺ" LATIN SMALL LETTER L WITH ACUTE + // U+013E: "ľ" LATIN SMALL LETTER L WITH CARON + .setMoreKeysOf("l", "\u013C", "\u0142", "\u013A", "\u013E") + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + // U+017C: "ż" LATIN SMALL LETTER Z WITH DOT ABOVE + // U+017A: "ź" LATIN SMALL LETTER Z WITH ACUTE + .setMoreKeysOf("z", "\u017E", "\u017C", "\u017A") + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + .setMoreKeysOf("c", "\u010D", "\u00E7", "\u0107") + // U+0146: "ņ" LATIN SMALL LETTER N WITH CEDILLA + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + .setMoreKeysOf("n", "\u0146", "\u00F1", "\u0144"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMacedonian.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMacedonian.java new file mode 100644 index 000000000..520269830 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMacedonian.java @@ -0,0 +1,69 @@ +/* + * 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.SouthSlavic; +import com.android.inputmethod.keyboard.layout.SouthSlavic.SouthSlavicLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * mk: Macedonian/south_slavic + */ +@SmallTest +public final class TestsMacedonian extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("mk"); + private static final LayoutBase LAYOUT = new SouthSlavic(new MacedonianCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class MacedonianCustomizer extends SouthSlavicLayoutCustomizer { + public MacedonianCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_R9L; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+0435: "е" CYRILLIC SMALL LETTER IE + // U+0450: "ѐ" CYRILLIC SMALL LETTER IE WITH GRAVE + .setMoreKeysOf("\u0435", "3", "\u0450") + // U+0455: "ѕ" CYRILLIC SMALL LETTER DZE + .replaceKeyOfLabel(SouthSlavic.ROW1_6, key("\u0455", moreKey("6"))) + // U+0438: "и" CYRILLIC SMALL LETTER I + // U+045D: "ѝ" CYRILLIC SMALL LETTER I WITH GRAVE + .setMoreKeysOf("\u0438", "8", "\u045D") + // U+045C: "ќ" CYRILLIC SMALL LETTER KJE + .replaceKeyOfLabel(SouthSlavic.ROW2_11, key("\u045C")) + // U+0437: "з" CYRILLIC SMALL LETTER ZE + .replaceKeyOfLabel(SouthSlavic.ROW3_1, key("\u0437")) + // U+0453: "ѓ" CYRILLIC SMALL LETTER GJE + .replaceKeyOfLabel(SouthSlavic.ROW3_8, key("\u0453")); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMalayMY.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMalayMY.java new file mode 100644 index 000000000..9792af9d0 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsMalayMY.java @@ -0,0 +1,37 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; + +import java.util.Locale; + +/** + * ms_MY: Malay (Malaysia)/qwerty + */ +@SmallTest +public final class TestsMalayMY extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("ms", "MY"); + private static final LayoutBase LAYOUT = new Qwerty(new LayoutCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsNepaliRomanized.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsNepaliRomanized.java new file mode 100644 index 000000000..971976aec --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsNepaliRomanized.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.LayoutBase; +import com.android.inputmethod.keyboard.layout.NepaliRomanized; +import com.android.inputmethod.keyboard.layout.NepaliRomanized.NepaliRomanizedCustomizer; + +import java.util.Locale; + +/** + * ne_NP: Nepali (Nepal) Romanized/nepali_romanized + */ +@SmallTest +public final class TestsNepaliRomanized extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("ne", "NP"); + private static final LayoutBase LAYOUT = new NepaliRomanized( + new NepaliRomanizedCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsNepaliTraditional.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsNepaliTraditional.java new file mode 100644 index 000000000..724c4304f --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsNepaliTraditional.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.LayoutBase; +import com.android.inputmethod.keyboard.layout.NepaliTraditional; +import com.android.inputmethod.keyboard.layout.NepaliTraditional.NepaliTraditionalCustomizer; + +import java.util.Locale; + +/** + * ne_NP: Nepali (Nepal) Traditional/nepali_traditional + */ +@SmallTest +public final class TestsNepaliTraditional extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("ne", "NP"); + private static final LayoutBase LAYOUT = new NepaliTraditional( + new NepaliTraditionalCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsNoLanguage.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsNoLanguage.java new file mode 100644 index 000000000..76a3d4df4 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsNoLanguage.java @@ -0,0 +1,175 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * zz: QWERTY/qwerty + */ +@SmallTest +public final class TestsNoLanguage extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("zz"); + private static final LayoutBase LAYOUT = new Qwerty(new NoLanguageCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class NoLanguageCustomizer extends LayoutCustomizer { + public NoLanguageCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+0175: "ŵ" LATIN SMALL LETTER W WITH CIRCUMFLEX + .setMoreKeysOf("w", "2", "\u0175") + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + // U+0115: "ĕ" LATIN SMALL LETTER E WITH BREVE + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+011B: "ě" LATIN SMALL LETTER E WITH CARON + .setMoreKeysOf("e", + "3", "\u00E8", "\u00E9", "\u00EA", "\u00EB", "\u0113", "\u0115", + "\u0117", "\u0119", "\u011B") + // U+0155: "ŕ" LATIN SMALL LETTER R WITH ACUTE + // U+0157: "ŗ" LATIN SMALL LETTER R WITH CEDILLA + // U+0159: "ř" LATIN SMALL LETTER R WITH CARON + .setMoreKeysOf("r", "4", "\u0155", "\u0157", "\u0159") + // U+00FE: "þ" LATIN SMALL LETTER THORN + // U+0163: "ţ" LATIN SMALL LETTER T WITH CEDILLA + // U+0165: "ť" LATIN SMALL LETTER T WITH CARON + // U+0167: "ŧ" LATIN SMALL LETTER T WITH STROKE + .setMoreKeysOf("t", "5", "\u00FE", "\u0163", "\u0165", "\u0167") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+0177: "ŷ" LATIN SMALL LETTER Y WITH CIRCUMFLEX + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + // U+0133: "ij" LATIN SMALL LIGATURE IJ + .setMoreKeysOf("y", "6", "\u00FD", "\u0177", "\u00FF", "\u0133") + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+0169: "ũ" LATIN SMALL LETTER U WITH TILDE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + // U+016D: "ŭ" LATIN SMALL LETTER U WITH BREVE + // U+016F: "ů" LATIN SMALL LETTER U WITH RING ABOVE + // U+0171: "ű" LATIN SMALL LETTER U WITH DOUBLE ACUTE + // U+0173: "ų" LATIN SMALL LETTER U WITH OGONEK + .setMoreKeysOf("u", + "7", "\u00F9", "\u00FA", "\u00FB", "\u00FC", "\u0169", "\u016B", + "\u016D", "\u016F", "\u0171", "\u0173") + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+0129: "ĩ" LATIN SMALL LETTER I WITH TILDE + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + // U+012D: "ĭ" LATIN SMALL LETTER I WITH BREVE + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+0131: "ı" LATIN SMALL LETTER DOTLESS I + // U+0133: "ij" LATIN SMALL LIGATURE IJ + .setMoreKeysOf("i", + "8", "\u00EC", "\u00ED", "\u00EE", "\u00EF", "\u0129", "\u012B", + "\u012D", "\u012F", "\u0131", "\u0133") + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + // U+014F: "ŏ" LATIN SMALL LETTER O WITH BREVE + // U+0151: "ő" LATIN SMALL LETTER O WITH DOUBLE ACUTE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00BA: "º" MASCULINE ORDINAL INDICATOR + .setMoreKeysOf("o", + "9", "\u00F2", "\u00F3", "\u00F4", "\u00F5", "\u00F6", "\u00F8", + "\u014D", "\u014F", "\u0151", "\u0153", "\u00BA") + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + // U+0103: "ă" LATIN SMALL LETTER A WITH BREVE + // U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK + // U+00AA: "ª" FEMININE ORDINAL INDICATOR + .setMoreKeysOf("a", + "\u00E0", "\u00E1", "\u00E2", "\u00E3", "\u00E4", "\u00E5", "\u00E6", + "\u0101", "\u0103", "\u0105", "\u00AA") + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+015D: "ŝ" LATIN SMALL LETTER S WITH CIRCUMFLEX + // U+015F: "ş" LATIN SMALL LETTER S WITH CEDILLA + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + // U+017F: "ſ" LATIN SMALL LETTER LONG S + .setMoreKeysOf("s", "\u00DF", "\u015B", "\u015D", "\u015F", "\u0161", "\u017F") + // U+010F: "ď" LATIN SMALL LETTER D WITH CARON + // U+0111: "đ" LATIN SMALL LETTER D WITH STROKE + // U+00F0: "ð" LATIN SMALL LETTER ETH + .setMoreKeysOf("d", "\u010F", "\u0111", "\u00F0") + // U+011D: "ĝ" LATIN SMALL LETTER G WITH CIRCUMFLEX + // U+011F: "ğ" LATIN SMALL LETTER G WITH BREVE + // U+0121: "ġ" LATIN SMALL LETTER G WITH DOT ABOVE + // U+0123: "ģ" LATIN SMALL LETTER G WITH CEDILLA + .setMoreKeysOf("g", "\u011D", "\u011F", "\u0121", "\u0123") + // U+0125: "ĥ" LATIN SMALL LETTER H WITH CIRCUMFLEX + .setMoreKeysOf("h", "\u0125") + // U+0135: "ĵ" LATIN SMALL LETTER J WITH CIRCUMFLEX + .setMoreKeysOf("j", "\u0135") + // U+0137: "ķ" LATIN SMALL LETTER K WITH CEDILLA + // U+0138: "ĸ" LATIN SMALL LETTER KRA + .setMoreKeysOf("k", "\u0137", "\u0138") + // U+013A: "ĺ" LATIN SMALL LETTER L WITH ACUTE + // U+013C: "ļ" LATIN SMALL LETTER L WITH CEDILLA + // U+013E: "ľ" LATIN SMALL LETTER L WITH CARON + // U+0140: "ŀ" LATIN SMALL LETTER L WITH MIDDLE DOT + // U+0142: "ł" LATIN SMALL LETTER L WITH STROKE + .setMoreKeysOf("l", "\u013A", "\u013C", "\u013E", "\u0140", "\u0142") + // U+017A: "ź" LATIN SMALL LETTER Z WITH ACUTE + // U+017C: "ż" LATIN SMALL LETTER Z WITH DOT ABOVE + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + .setMoreKeysOf("z", "\u017A", "\u017C", "\u017E") + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + // U+0109: "ĉ" LATIN SMALL LETTER C WITH CIRCUMFLEX + // U+010B: "ċ" LATIN SMALL LETTER C WITH DOT ABOVE + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + .setMoreKeysOf("c", "\u00E7", "\u0107", "\u0109", "\u010B", "\u010D") + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + // U+0146: "ņ" LATIN SMALL LETTER N WITH CEDILLA + // U+0148: "ň" LATIN SMALL LETTER N WITH CARON + // U+0149: "ʼn" LATIN SMALL LETTER N PRECEDED BY APOSTROPHE + // U+014B: "ŋ" LATIN SMALL LETTER ENG + .setMoreKeysOf("n", "\u00F1", "\u0144", "\u0146", "\u0148", "\u0149", "\u014B"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsNorwegian.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsNorwegian.java new file mode 100644 index 000000000..d5b904c5f --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsNorwegian.java @@ -0,0 +1,96 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Nordic; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * nb: Norwegian Bokmål/nordic + */ +@SmallTest +public final class TestsNorwegian extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("nb"); + private static final LayoutBase LAYOUT = new Nordic(new NorwegianCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class NorwegianCustomizer extends LayoutCustomizer { + public NorwegianCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_L9R; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_L9R; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", + "3", "\u00E9", "\u00E8", "\u00EA", "\u00EB", "\u0119", "\u0117", + "\u0113") + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FC", "\u00FB", "\u00F9", "\u00FA", "\u016B") + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", + "9", "\u00F4", "\u00F2", "\u00F3", "\u00F6", "\u00F5", "\u0153", + "\u014D") + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + .replaceKeyOfLabel(Nordic.ROW1_11, key("\u00E5")) + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + .replaceKeyOfLabel(Nordic.ROW2_10, key("\u00F8", moreKey("\u00F6"))) + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + .replaceKeyOfLabel(Nordic.ROW2_11, key("\u00E6", moreKey("\u00E4"))) + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + .setMoreKeysOf("a", "\u00E0", "\u00E4", "\u00E1", "\u00E2", "\u00E3", "\u0101"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsPolish.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsPolish.java new file mode 100644 index 000000000..7d8f62963 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsPolish.java @@ -0,0 +1,105 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * pl: Polish/qwerty + */ +@SmallTest +public final class TestsPolish extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("pl"); + private static final LayoutBase LAYOUT = new Qwerty(new PolishCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class PolishCustomizer extends LayoutCustomizer { + public PolishCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_L9R; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_L9R; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", + "3", "\u0119", "\u00E8", "\u00E9", "\u00EA", "\u00EB", "\u0117", + "\u0113") + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", + "9", "\u00F3", "\u00F6", "\u00F4", "\u00F2", "\u00F5", "\u0153", + "\u00F8", "\u014D") + // U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + .setMoreKeysOf("a", + "\u0105", "\u00E1", "\u00E0", "\u00E2", "\u00E4", "\u00E6", "\u00E3", + "\u00E5", "\u0101") + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + .setMoreKeysOf("s", "\u015B", "\u00DF", "\u0161") + // U+0142: "ł" LATIN SMALL LETTER L WITH STROKE + .setMoreKeysOf("l", "\u0142") + // U+017C: "ż" LATIN SMALL LETTER Z WITH DOT ABOVE + // U+017A: "ź" LATIN SMALL LETTER Z WITH ACUTE + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + .setMoreKeysOf("z", "\u017C", "\u017A", "\u017E") + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + .setMoreKeysOf("c", "\u0107", "\u00E7", "\u010D") + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + .setMoreKeysOf("n", "\u0144", "\u00F1"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsPortugueseBR.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsPortugueseBR.java new file mode 100644 index 000000000..00ee6981f --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsPortugueseBR.java @@ -0,0 +1,99 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * pt_BR: Portuguese (Brazil)/qwerty + */ +@SmallTest +public class TestsPortugueseBR extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("pt", "BR"); + private static final LayoutBase LAYOUT = new Qwerty(new PortugueseBRCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + // TODO: Make this as generic Portuguese customizer. + static class PortugueseBRCustomizer extends LayoutCustomizer { + public PortugueseBRCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + .setMoreKeysOf("e", + "3", "\u00E9", "\u00EA", "\u00E8", "\u0119", "\u0117", "\u0113", + "\u00EB") + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FA", "\u00FC", "\u00F9", "\u00FB", "\u016B") + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + .setMoreKeysOf("i", "8", "\u00ED", "\u00EE", "\u00EC", "\u00EF", "\u012F", + "\u012B") + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + // U+00BA: "º" MASCULINE ORDINAL INDICATOR + .setMoreKeysOf("o", + "9", "\u00F3", "\u00F5", "\u00F4", "\u00F2", "\u00F6", "\u0153", + "\u00F8", "\u014D", "\u00BA") + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00AA: "ª" FEMININE ORDINAL INDICATOR + .setMoreKeysOf("a", + "\u00E1", "\u00E3", "\u00E0", "\u00E2", "\u00E4", "\u00E5", "\u00E6", + "\u00AA") + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + .setMoreKeysOf("c", "\u00E7", "\u010D", "\u0107"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsPortuguesePT.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsPortuguesePT.java new file mode 100644 index 000000000..836542ea9 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsPortuguesePT.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.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * pt_PT: Portuguese (Portugal)/qwerty + */ +@SmallTest +public final class TestsPortuguesePT extends TestsPortugueseBR { + private static final Locale LOCALE = new Locale("pt", "PT"); + private static final LayoutBase LAYOUT = new Qwerty(new PortuguesePTCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class PortuguesePTCustomizer extends EuroLayoutCustomizer { + private final PortugueseBRCustomizer mPortugueseCustomizer; + + public PortuguesePTCustomizer(final Locale locale) { + super(locale); + mPortugueseCustomizer = new PortugueseBRCustomizer(locale); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return mPortugueseCustomizer.setAccentedLetters(builder); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsRomanian.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsRomanian.java new file mode 100644 index 000000000..59b328d07 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsRomanian.java @@ -0,0 +1,82 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * ro: Romanian/qwerty + */ +@SmallTest +public final class TestsRomanian extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("ro"); + private static final LayoutBase LAYOUT = new Qwerty(new RomanianCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class RomanianCustomizer extends LayoutCustomizer { + public RomanianCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_L9R; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_L9R; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+021B: "ț" LATIN SMALL LETTER T WITH COMMA BELOW + .setMoreKeysOf("t", "5", "\u021B") + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + .setMoreKeysOf("i", "8", "\u00EE", "\u00EF", "\u00EC", "\u00ED", "\u012F", + "\u012B") + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+0103: "ă" LATIN SMALL LETTER A WITH BREVE + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + .setMoreKeysOf("a", + "\u00E2", "\u00E3", "\u0103", "\u00E0", "\u00E1", "\u00E4", "\u00E6", + "\u00E5", "\u0101") + // U+0219: "ș" LATIN SMALL LETTER S WITH COMMA BELOW + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + .setMoreKeysOf("s", "\u0219", "\u00DF", "\u015B", "\u0161"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsRussian.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsRussian.java new file mode 100644 index 000000000..14f950160 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsRussian.java @@ -0,0 +1,69 @@ +/* + * 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.EastSlavic; +import com.android.inputmethod.keyboard.layout.EastSlavic.EastSlavicCustomizer; +import com.android.inputmethod.keyboard.layout.LayoutBase; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * ru: Russian/east_slavic + */ +@SmallTest +public final class TestsRussian extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("ru"); + private static final LayoutBase LAYOUT = new EastSlavic(new RussianCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class RussianCustomizer extends EastSlavicCustomizer { + public RussianCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_R9L; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+0435: "е" CYRILLIC SMALL LETTER IE + // U+0451: "ё" CYRILLIC SMALL LETTER IO + .setMoreKeysOf("\u0435", "5", "\u0451") + // U+0449: "щ" CYRILLIC SMALL LETTER SHCHA + .replaceKeyOfLabel(EastSlavic.ROW1_9, key("\u0449", moreKey("9"))) + // U+044B: "ы" CYRILLIC SMALL LETTER YERU + .replaceKeyOfLabel(EastSlavic.ROW2_2, key("\u044B")) + // U+044D: "э" CYRILLIC SMALL LETTER E + .replaceKeyOfLabel(EastSlavic.ROW2_11, key("\u044D")) + // U+0438: "и" CYRILLIC SMALL LETTER I + .replaceKeyOfLabel(EastSlavic.ROW3_5, key("\u0438")) + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN + .setMoreKeysOf("\u044C", "\u044A"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSerbian.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSerbian.java new file mode 100644 index 000000000..119ea142c --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSerbian.java @@ -0,0 +1,75 @@ +/* + * 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.SouthSlavic; +import com.android.inputmethod.keyboard.layout.SouthSlavic.SouthSlavicLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * sr: Serbian/south_slavic + */ +@SmallTest +public final class TestsSerbian extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("sr"); + private static final LayoutBase LAYOUT = new SouthSlavic(new SerbianCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class SerbianCustomizer extends SouthSlavicLayoutCustomizer { + public SerbianCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getDoubleAngleQuoteKeys() { return Symbols.DOUBLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKey[] getSingleAngleQuoteKeys() { return Symbols.SINGLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+0435: "е" CYRILLIC SMALL LETTER IE + // U+0450: "ѐ" CYRILLIC SMALL LETTER IE WITH GRAVE + .setMoreKeysOf("\u0435", "3", "\u0450") + // U+0437: "з" CYRILLIC SMALL LETTER ZE + .replaceKeyOfLabel(SouthSlavic.ROW1_6, key("\u0437", moreKey("6"))) + // U+0438: "и" CYRILLIC SMALL LETTER I + // U+045D: "ѝ" CYRILLIC SMALL LETTER I WITH GRAVE + .setMoreKeysOf("\u0438", "8", "\u045D") + // U+045B: "ћ" CYRILLIC SMALL LETTER TSHE + .replaceKeyOfLabel(SouthSlavic.ROW2_11, key("\u045B")) + // U+0455: "ѕ" CYRILLIC SMALL LETTER DZE + .replaceKeyOfLabel(SouthSlavic.ROW3_1, key("\u0455")) + // U+0452: "ђ" CYRILLIC SMALL LETTER DJE + .replaceKeyOfLabel(SouthSlavic.ROW3_8, key("\u0452")); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSlovak.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSlovak.java new file mode 100644 index 000000000..3d7825b13 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSlovak.java @@ -0,0 +1,156 @@ +/* + * 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.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * sk: Slovak/qwerty + */ +@SmallTest +public final class TestsSlovak extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("sk"); + private static final LayoutBase LAYOUT = new Qwerty(new SlovakCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class SlovakCustomizer extends EuroLayoutCustomizer { + public SlovakCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getDoubleAngleQuoteKeys() { return Symbols.DOUBLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKey[] getSingleAngleQuoteKeys() { return Symbols.SINGLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+011B: "ě" LATIN SMALL LETTER E WITH CARON + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + .setMoreKeysOf("e", + "3", "\u00E9", "\u011B", "\u0113", "\u0117", "\u00E8", "\u00EA", + "\u00EB", "\u0119") + // U+0155: "ŕ" LATIN SMALL LETTER R WITH ACUTE + // U+0159: "ř" LATIN SMALL LETTER R WITH CARON + // U+0157: "ŗ" LATIN SMALL LETTER R WITH CEDILLA + .setMoreKeysOf("r", "4", "\u0155", "\u0159", "\u0157") + // U+0165: "ť" LATIN SMALL LETTER T WITH CARON + // U+0163: "ţ" LATIN SMALL LETTER T WITH CEDILLA + .setMoreKeysOf("t", "5", "\u0165", "\u0163") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "6", "\u00FD", "\u00FF") + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+016F: "ů" LATIN SMALL LETTER U WITH RING ABOVE + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + // U+0173: "ų" LATIN SMALL LETTER U WITH OGONEK + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+0171: "ű" LATIN SMALL LETTER U WITH DOUBLE ACUTE + .setMoreKeysOf("u", + "7", "\u00FA", "\u016F", "\u00FC", "\u016B", "\u0173", "\u00F9", + "\u00FB", "\u0171") + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+0131: "ı" LATIN SMALL LETTER DOTLESS I + .setMoreKeysOf("i", + "8", "\u00ED", "\u012B", "\u012F", "\u00EC", "\u00EE", "\u00EF", + "\u0131") + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+0151: "ő" LATIN SMALL LETTER O WITH DOUBLE ACUTE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + .setMoreKeysOf("o", + "9", "\u00F4", "\u00F3", "\u00F6", "\u00F2", "\u00F5", "\u0153", + "\u0151", "\u00F8") + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK + .setMoreKeysOf("a", + "\u00E1", "\u00E4", "\u0101", "\u00E0", "\u00E2", "\u00E3", "\u00E5", + "\u00E6", "\u0105") + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+015F: "ş" LATIN SMALL LETTER S WITH CEDILLA + .setMoreKeysOf("s", "\u0161", "\u00DF", "\u015B", "\u015F") + // U+010F: "ď" LATIN SMALL LETTER D WITH CARON + .setMoreKeysOf("d", "\u010F") + // U+0123: "ģ" LATIN SMALL LETTER G WITH CEDILLA + // U+011F: "ğ" LATIN SMALL LETTER G WITH BREVE + .setMoreKeysOf("g", "\u0123", "\u011F") + // U+0137: "ķ" LATIN SMALL LETTER K WITH CEDILLA + .setMoreKeysOf("k", "\u0137") + // U+013E: "ľ" LATIN SMALL LETTER L WITH CARON + // U+013A: "ĺ" LATIN SMALL LETTER L WITH ACUTE + // U+013C: "ļ" LATIN SMALL LETTER L WITH CEDILLA + // U+0142: "ł" LATIN SMALL LETTER L WITH STROKE + .setMoreKeysOf("l", "\u013E", "\u013A", "\u013C", "\u0142") + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + // U+017C: "ż" LATIN SMALL LETTER Z WITH DOT ABOVE + // U+017A: "ź" LATIN SMALL LETTER Z WITH ACUTE + .setMoreKeysOf("z", "\u017E", "\u017C", "\u017A") + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + .setMoreKeysOf("c", "\u010D", "\u00E7", "\u0107") + // U+0148: "ň" LATIN SMALL LETTER N WITH CARON + // U+0146: "ņ" LATIN SMALL LETTER N WITH CEDILLA + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + .setMoreKeysOf("n", "\u0148", "\u0146", "\u00F1", "\u0144"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSlovenian.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSlovenian.java new file mode 100644 index 000000000..88a23ba07 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSlovenian.java @@ -0,0 +1,70 @@ +/* + * 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.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * sl: Slovenian/qwerty + */ +@SmallTest +public final class TestsSlovenian extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("sl"); + private static final LayoutBase LAYOUT = new Qwerty(new SlovenianCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class SlovenianCustomizer extends EuroLayoutCustomizer { + public SlovenianCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getDoubleAngleQuoteKeys() { return Symbols.DOUBLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKey[] getSingleAngleQuoteKeys() { return Symbols.SINGLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + .setMoreKeysOf("s", "\u0161") + // U+0111: "đ" LATIN SMALL LETTER D WITH STROKE + .setMoreKeysOf("d", "\u0111") + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + .setMoreKeysOf("z", "\u017E") + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + .setMoreKeysOf("c", "\u010D", "\u0107"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSpanish.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSpanish.java new file mode 100644 index 000000000..cc5a64c69 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSpanish.java @@ -0,0 +1,59 @@ +/* + * 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.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Spanish; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import com.android.inputmethod.keyboard.layout.tests.TestsSpanishUS.SpanishUSCustomizer; + +import java.util.Locale; + +/** + * es: Spanish/spanish + */ +@SmallTest +public class TestsSpanish extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("es"); + private static final LayoutBase LAYOUT = new Spanish(new SpanishESCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class SpanishESCustomizer extends EuroLayoutCustomizer { + private final SpanishUSCustomizer mSpanishUSCustomizer; + + public SpanishESCustomizer(final Locale locale) { + super(locale); + mSpanishUSCustomizer = new SpanishUSCustomizer(locale); + } + + @Override + public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { + return mSpanishUSCustomizer.getPunctuationMoreKeys(isPhone); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return mSpanishUSCustomizer.setAccentedLetters(builder); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSpanishUS.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSpanishUS.java new file mode 100644 index 000000000..517db9d9f --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSpanishUS.java @@ -0,0 +1,120 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Spanish; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * es_US: Spanish (United States)/spanish + */ +@SmallTest +public class TestsSpanishUS extends TestsSpanish { + private static final Locale LOCALE = new Locale("es", "US"); + private static final LayoutBase LAYOUT = new Spanish(new SpanishUSCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + // Make this as generic Spanish customizer. + static class SpanishUSCustomizer extends LayoutCustomizer { + public SpanishUSCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { + return isPhone ? PHONE_PUNCTUATION_MORE_KEYS + : LayoutBase.TABLET_PUNCTUATION_MORE_KEYS; + } + + // Punctuation more keys for phone form factor. + private static final ExpectedKey[] PHONE_PUNCTUATION_MORE_KEYS = joinKeys( + // U+00A1: "¡" INVERTED EXCLAMATION MARK + // U+00BF: "¿" INVERTED QUESTION MARK + "\u00A1", ";", "/", "(", ")", "#", "!", ",", "?", + "\u00BF", "&", "%", "+", "\"", "-", ":", "'", "@"); + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + // U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", + "3", "\u00E9", "\u00E8", "\u00EB", "\u00EA", "\u0119", "\u0117", + "\u0113") + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FA", "\u00FC", "\u00F9", "\u00FB", "\u016B") + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + .setMoreKeysOf("i", "8", "\u00ED", "\u00EF", "\u00EC", "\u00EE", "\u012F", + "\u012B") + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + // U+00BA: "º" MASCULINE ORDINAL INDICATOR + .setMoreKeysOf("o", + "9", "\u00F3", "\u00F2", "\u00F6", "\u00F4", "\u00F5", "\u00F8", + "\u0153", "\u014D", "\u00BA") + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + // U+00AA: "ª" FEMININE ORDINAL INDICATOR + .setMoreKeysOf("a", + "\u00E1", "\u00E0", "\u00E4", "\u00E2", "\u00E3", "\u00E5", "\u0105", + "\u00E6", "\u0101", "\u00AA") + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + .replaceKeyOfLabel(Spanish.ROW2_10, key("\u00F1")) + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + .setMoreKeysOf("c", "\u00E7", "\u0107", "\u010D") + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + .setMoreKeysOf("n", "\u00F1", "\u0144"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSwahili.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSwahili.java new file mode 100644 index 000000000..49e1912ee --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSwahili.java @@ -0,0 +1,93 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * sw: Swahili/qwerty + */ +@SmallTest +public final class TestsSwahili extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("sw"); + private static final LayoutBase LAYOUT = new Qwerty(new SwahiliCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class SwahiliCustomizer extends LayoutCustomizer { + public SwahiliCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", "3", "\u00E8", "\u00E9", "\u00EA", "\u00EB", "\u0113") + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FB", "\u00FC", "\u00F9", "\u00FA", "\u016B") + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + .setMoreKeysOf("i", "8", "\u00EE", "\u00EF", "\u00ED", "\u012B", "\u00EC") + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + .setMoreKeysOf("o", + "9", "\u00F4", "\u00F6", "\u00F2", "\u00F3", "\u0153", "\u00F8", + "\u014D", "\u00F5") + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+0101: "ā" LATIN SMALL LETTER A WITH MACRON + .setMoreKeysOf("a", + "\u00E0", "\u00E1", "\u00E2", "\u00E4", "\u00E6", "\u00E3", "\u00E5", + "\u0101") + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + .setMoreKeysOf("s", "\u00DF") + .setMoreKeysOf("g", "g'") + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + .setMoreKeysOf("c", "\u00E7") + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + .setMoreKeysOf("n", "\u00F1"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSwedish.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSwedish.java new file mode 100644 index 000000000..14155cb0e --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsSwedish.java @@ -0,0 +1,124 @@ +/* + * 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.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Nordic; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * sv: Swedish/nordic + */ +@SmallTest +public final class TestsSwedish extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("sv"); + private static final LayoutBase LAYOUT = new Nordic(new SwedishCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class SwedishCustomizer extends EuroLayoutCustomizer { + public SwedishCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getDoubleAngleQuoteKeys() { return Symbols.DOUBLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKey[] getSingleAngleQuoteKeys() { return Symbols.SINGLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + // U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK + .setMoreKeysOf("e", "3", "\u00E9", "\u00E8", "\u00EA", "\u00EB", "\u0119") + // U+0159: "ř" LATIN SMALL LETTER R WITH CARON + .setMoreKeysOf("r", "4", "\u0159") + // U+0165: "ť" LATIN SMALL LETTER T WITH CARON + // U+00FE: "þ" LATIN SMALL LETTER THORN + .setMoreKeysOf("t", "5", "\u0165", "\u00FE") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "6", "\u00FD", "\u00FF") + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FC", "\u00FA", "\u00F9", "\u00FB", "\u016B") + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + .setMoreKeysOf("i", "8", "\u00ED", "\u00EC", "\u00EE", "\u00EF") + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", "9", "\u00F3", "\u00F2", "\u00F4", "\u00F5", "\u014D") + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + .replaceKeyOfLabel(Nordic.ROW1_11, key("\u00E5")) + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+0153: "œ" LATIN SMALL LIGATURE OE + .replaceKeyOfLabel(Nordic.ROW2_10, key("\u00F6", + moreKey("\u00F8"), moreKey("\u0153"))) + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E6: "æ" LATIN SMALL LETTER AE + .replaceKeyOfLabel(Nordic.ROW2_11, key("\u00E4", moreKey("\u00E6"))) + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + .setMoreKeysOf("a", "\u00E1", "\u00E0", "\u00E2", "\u0105", "\u00E3") + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + // U+015F: "ş" LATIN SMALL LETTER S WITH CEDILLA + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + .setMoreKeysOf("s", "\u015B", "\u0161", "\u015F", "\u00DF") + // U+00F0: "ð" LATIN SMALL LETTER ETH + // U+010F: "ď" LATIN SMALL LETTER D WITH CARON + .setMoreKeysOf("d", "\u00F0", "\u010F") + // U+0142: "ł" LATIN SMALL LETTER L WITH STROKE + .setMoreKeysOf("l", "\u0142") + // U+017A: "ź" LATIN SMALL LETTER Z WITH ACUTE + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + // U+017C: "ż" LATIN SMALL LETTER Z WITH DOT ABOVE + .setMoreKeysOf("z", "\u017A", "\u017E", "\u017C") + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + .setMoreKeysOf("c", "\u00E7", "\u0107", "\u010D") + // U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + // U+0148: "ň" LATIN SMALL LETTER N WITH CARON + .setMoreKeysOf("n", "\u0144", "\u00F1", "\u0148"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsTagalog.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsTagalog.java new file mode 100644 index 000000000..72e435a24 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsTagalog.java @@ -0,0 +1,53 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Spanish; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import com.android.inputmethod.keyboard.layout.tests.TestsSpanishUS.SpanishUSCustomizer; + +import java.util.Locale; + +/** + * tl: Tagalog/spanish + */ +@SmallTest +public class TestsTagalog extends TestsSpanish { + private static final Locale LOCALE = new Locale("tl"); + private static final LayoutBase LAYOUT = new Spanish(new TagalogCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class TagalogCustomizer extends LayoutCustomizer { + private final SpanishUSCustomizer mSpanishUSCustomizer; + + public TagalogCustomizer(final Locale locale) { + super(locale); + mSpanishUSCustomizer = new SpanishUSCustomizer(locale); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return mSpanishUSCustomizer.setAccentedLetters(builder); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsThai.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsThai.java new file mode 100644 index 000000000..3c8727290 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsThai.java @@ -0,0 +1,37 @@ +/* + * 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.Thai; +import com.android.inputmethod.keyboard.layout.Thai.ThaiCustomizer; + +import java.util.Locale; + +/** + * th: Thai/thai + */ +@SmallTest +public final class TestsThai extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("th"); + private static final LayoutBase LAYOUT = new Thai(new ThaiCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsTurkish.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsTurkish.java new file mode 100644 index 000000000..ab67ae90d --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsTurkish.java @@ -0,0 +1,86 @@ +/* + * 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.LayoutBase.EuroLayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * tr: Turkish/qwerty + */ +@SmallTest +public final class TestsTurkish extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("tr"); + private static final LayoutBase LAYOUT = new Qwerty(new TurkishCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class TurkishCustomizer extends EuroLayoutCustomizer { + public TurkishCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + // U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+016B: "ū" LATIN SMALL LETTER U WITH MACRON + .setMoreKeysOf("u", "7", "\u00FC", "\u00FB", "\u00F9", "\u00FA", "\u016B") + // U+0131: "ı" LATIN SMALL LETTER DOTLESS I + // U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+012F: "į" LATIN SMALL LETTER I WITH OGONEK + // U+012B: "ī" LATIN SMALL LETTER I WITH MACRON + .setMoreKeysOf("i", "8", + "\u0131", "\u00EE", "\u00EF", "\u00EC", "\u00ED", "\u012F", "\u012B") + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+0153: "œ" LATIN SMALL LIGATURE OE + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", + "9", "\u00F6", "\u00F4", "\u0153", "\u00F2", "\u00F3", "\u00F5", + "\u00F8", "\u014D") + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + .setMoreKeysOf("a", "\u00E2") + // U+015F: "ş" LATIN SMALL LETTER S WITH CEDILLA + // U+00DF: "ß" LATIN SMALL LETTER SHARP S + // U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + .setMoreKeysOf("s", "\u015F", "\u00DF", "\u015B", "\u0161") + // U+011F: "ğ" LATIN SMALL LETTER G WITH BREVE + .setMoreKeysOf("g", "\u011F") + // U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + .setMoreKeysOf("c", "\u00E7", "\u0107", "\u010D"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsUkrainian.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsUkrainian.java new file mode 100644 index 000000000..20749d675 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsUkrainian.java @@ -0,0 +1,84 @@ +/* + * 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.EastSlavic; +import com.android.inputmethod.keyboard.layout.EastSlavic.EastSlavicCustomizer; +import com.android.inputmethod.keyboard.layout.LayoutBase; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.SymbolsShifted; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * uk: Ukrainian/east_slavic + */ +@SmallTest +public final class TestsUkrainian extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("uk"); + private static final LayoutBase LAYOUT = new EastSlavic(new UkrainianCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class UkrainianCustomizer extends EastSlavicCustomizer { + public UkrainianCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_HRYVNIA; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_R9L; } + + // U+20B4: "₴" HRYVNIA SIGN + private static final ExpectedKey CURRENCY_HRYVNIA = key("\u20B4", + Symbols.DOLLAR_SIGN, Symbols.CENT_SIGN, Symbols.EURO_SIGN, Symbols.POUND_SIGN, + Symbols.YEN_SIGN, Symbols.PESO_SIGN); + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+0433: "г" CYRILLIC SMALL LETTER GHE + // U+0491: "ґ" CYRILLIC SMALL LETTER GHE WITH UPTURN + .setMoreKeysOf("\u0433", "7", "\u0491") + // U+0449: "щ" CYRILLIC SMALL LETTER SHCHA + .replaceKeyOfLabel(EastSlavic.ROW1_9, key("\u0449", moreKey("9"))) + // U+0456: "і" CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I + // U+0457: "ї" CYRILLIC SMALL LETTER YI + .replaceKeyOfLabel(EastSlavic.ROW2_2, key("\u0456", moreKey("\u0457"))) + // U+0454: "є" CYRILLIC SMALL LETTER UKRAINIAN IE + .replaceKeyOfLabel(EastSlavic.ROW2_11, key("\u0454")) + // U+0438: "и" CYRILLIC SMALL LETTER I + .replaceKeyOfLabel(EastSlavic.ROW3_5, key("\u0438")) + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN + .setMoreKeysOf("\u044C", "\u044A"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsVietnamese.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsVietnamese.java new file mode 100644 index 000000000..94b0c1f3b --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsVietnamese.java @@ -0,0 +1,149 @@ +/* + * 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.LayoutBase.LayoutCustomizer; +import com.android.inputmethod.keyboard.layout.Qwerty; +import com.android.inputmethod.keyboard.layout.Symbols; +import com.android.inputmethod.keyboard.layout.SymbolsShifted; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKey; +import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * vi: Vietnamese/qwerty + */ +@SmallTest +public final class TestsVietnamese extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("vi"); + private static final LayoutBase LAYOUT = new Qwerty(new VietnameseCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class VietnameseCustomizer extends LayoutCustomizer { + public VietnameseCustomizer(final Locale locale) { + super(locale); + } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_DONG; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + // U+20AB: "₫" DONG SIGN + private static final ExpectedKey CURRENCY_DONG = key("\u20AB", + Symbols.DOLLAR_SIGN, Symbols.CENT_SIGN, Symbols.EURO_SIGN, Symbols.POUND_SIGN, + Symbols.YEN_SIGN, Symbols.PESO_SIGN); + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+1EBB: "ẻ" LATIN SMALL LETTER E WITH HOOK ABOVE + // U+1EBD: "ẽ" LATIN SMALL LETTER E WITH TILDE + // U+1EB9: "ẹ" LATIN SMALL LETTER E WITH DOT BELOW + // U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX + // U+1EC1: "ề" LATIN SMALL LETTER E WITH CIRCUMFLEX AND GRAVE + // U+1EBF: "ế" LATIN SMALL LETTER E WITH CIRCUMFLEX AND ACUTE + // U+1EC3: "ể" LATIN SMALL LETTER E WITH CIRCUMFLEX AND HOOK ABOVE + // U+1EC5: "ễ" LATIN SMALL LETTER E WITH CIRCUMFLEX AND TILDE + // U+1EC7: "ệ" LATIN SMALL LETTER E WITH CIRCUMFLEX AND DOT BELOW + .setMoreKeysOf("e", + "3", "\u00E8", "\u00E9", "\u1EBB", "\u1EBD", "\u1EB9", "\u00EA", + "\u1EC1", "\u1EBF", "\u1EC3", "\u1EC5", "\u1EC7") + // U+1EF3: "ỳ" LATIN SMALL LETTER Y WITH GRAVE + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+1EF7: "ỷ" LATIN SMALL LETTER Y WITH HOOK ABOVE + // U+1EF9: "ỹ" LATIN SMALL LETTER Y WITH TILDE + // U+1EF5: "ỵ" LATIN SMALL LETTER Y WITH DOT BELOW + .setMoreKeysOf("y", "6", "\u1EF3", "\u00FD", "\u1EF7", "\u1EF9", "\u1EF5") + // U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE + // U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE + // U+1EE7: "ủ" LATIN SMALL LETTER U WITH HOOK ABOVE + // U+0169: "ũ" LATIN SMALL LETTER U WITH TILDE + // U+1EE5: "ụ" LATIN SMALL LETTER U WITH DOT BELOW + // U+01B0: "ư" LATIN SMALL LETTER U WITH HORN + // U+1EEB: "ừ" LATIN SMALL LETTER U WITH HORN AND GRAVE + // U+1EE9: "ứ" LATIN SMALL LETTER U WITH HORN AND ACUTE + // U+1EED: "ử" LATIN SMALL LETTER U WITH HORN AND HOOK ABOVE + // U+1EEF: "ữ" LATIN SMALL LETTER U WITH HORN AND TILDE + // U+1EF1: "ự" LATIN SMALL LETTER U WITH HORN AND DOT BELOW + .setMoreKeysOf("u", + "7", "\u00F9", "\u00FA", "\u1EE7", "\u0169", "\u1EE5", "\u01B0", + "\u1EEB", "\u1EE9", "\u1EED", "\u1EEF", "\u1EF1") + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+1EC9: "ỉ" LATIN SMALL LETTER I WITH HOOK ABOVE + // U+0129: "ĩ" LATIN SMALL LETTER I WITH TILDE + // U+1ECB: "ị" LATIN SMALL LETTER I WITH DOT BELOW + .setMoreKeysOf("i", "8", "\u00EC", "\u00ED", "\u1EC9", "\u0129", "\u1ECB") + // U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE + // U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE + // U+1ECF: "ỏ" LATIN SMALL LETTER O WITH HOOK ABOVE + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + // U+1ECD: "ọ" LATIN SMALL LETTER O WITH DOT BELOW + // U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX + // U+1ED3: "ồ" LATIN SMALL LETTER O WITH CIRCUMFLEX AND GRAVE + // U+1ED1: "ố" LATIN SMALL LETTER O WITH CIRCUMFLEX AND ACUTE + // U+1ED5: "ổ" LATIN SMALL LETTER O WITH CIRCUMFLEX AND HOOK ABOVE + // U+1ED7: "ỗ" LATIN SMALL LETTER O WITH CIRCUMFLEX AND TILDE + // U+1ED9: "ộ" LATIN SMALL LETTER O WITH CIRCUMFLEX AND DOT BELOW + // U+01A1: "ơ" LATIN SMALL LETTER O WITH HORN + // U+1EDD: "ờ" LATIN SMALL LETTER O WITH HORN AND GRAVE + // U+1EDB: "ớ" LATIN SMALL LETTER O WITH HORN AND ACUTE + // U+1EDF: "ở" LATIN SMALL LETTER O WITH HORN AND HOOK ABOVE + // U+1EE1: "ỡ" LATIN SMALL LETTER O WITH HORN AND TILDE + // U+1EE3: "ợ" LATIN SMALL LETTER O WITH HORN AND DOT BELOW + .setMoreKeysOf("o", + "9", "\u00F2", "\u00F3", "\u1ECF", "\u00F5", "\u1ECD", "\u00F4", + "\u1ED3", "\u1ED1", "\u1ED5", "\u1ED7", "\u1ED9", "\u01A1", "\u1EDD", + "\u1EDB", "\u1EDF", "\u1EE1", "\u1EE3") + // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + // U+1EA3: "ả" LATIN SMALL LETTER A WITH HOOK ABOVE + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // U+1EA1: "ạ" LATIN SMALL LETTER A WITH DOT BELOW + // U+0103: "ă" LATIN SMALL LETTER A WITH BREVE + // U+1EB1: "ằ" LATIN SMALL LETTER A WITH BREVE AND GRAVE + // U+1EAF: "ắ" LATIN SMALL LETTER A WITH BREVE AND ACUTE + // U+1EB3: "ẳ" LATIN SMALL LETTER A WITH BREVE AND HOOK ABOVE + // U+1EB5: "ẵ" LATIN SMALL LETTER A WITH BREVE AND TILDE + // U+1EB7: "ặ" LATIN SMALL LETTER A WITH BREVE AND DOT BELOW + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+1EA7: "ầ" LATIN SMALL LETTER A WITH CIRCUMFLEX AND GRAVE + // U+1EA5: "ấ" LATIN SMALL LETTER A WITH CIRCUMFLEX AND ACUTE + // U+1EA9: "ẩ" LATIN SMALL LETTER A WITH CIRCUMFLEX AND HOOK ABOVE + // U+1EAB: "ẫ" LATIN SMALL LETTER A WITH CIRCUMFLEX AND TILDE + // U+1EAD: "ậ" LATIN SMALL LETTER A WITH CIRCUMFLEX AND DOT BELOW + .setMoreKeysOf("a", + "\u00E0", "\u00E1", "\u1EA3", "\u00E3", "\u1EA1", "\u0103", "\u1EB1", + "\u1EAF", "\u1EB3", "\u1EB5", "\u1EB7", "\u00E2", "\u1EA7", "\u1EA5", + "\u1EA9", "\u1EAB", "\u1EAD") + // U+0111: "đ" LATIN SMALL LETTER D WITH STROKE + .setMoreKeysOf("d", "\u0111"); + } + } +} diff --git a/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsZulu.java b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsZulu.java new file mode 100644 index 000000000..04e89be55 --- /dev/null +++ b/tests/src/com/android/inputmethod/keyboard/layout/tests/TestsZulu.java @@ -0,0 +1,36 @@ +/* + * 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.Qwerty; + +import java.util.Locale; + +/** + * zu: Zulu/qwerty + */ +@SmallTest +public final class TestsZulu extends TestsEnglishUS { + private static final Locale LOCALE = new Locale("zu"); + private static final LayoutBase LAYOUT = new Qwerty(new EnglishUSCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java b/tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java index 69420d6ac..918f09067 100644 --- a/tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java +++ b/tests/src/com/android/inputmethod/latin/BinaryDictionaryDecayingTests.java @@ -75,16 +75,16 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase { } private void forcePassingShortTime(final BinaryDictionary binaryDictionary) { - // 4 days. - final int timeToElapse = (int)TimeUnit.SECONDS.convert(4, TimeUnit.DAYS); + // 30 days. + final int timeToElapse = (int)TimeUnit.SECONDS.convert(30, TimeUnit.DAYS); mCurrentTime += timeToElapse; setCurrentTimeForTestMode(mCurrentTime); binaryDictionary.flushWithGC(); } private void forcePassingLongTime(final BinaryDictionary binaryDictionary) { - // 60 days. - final int timeToElapse = (int)TimeUnit.SECONDS.convert(60, TimeUnit.DAYS); + // 365 days. + final int timeToElapse = (int)TimeUnit.SECONDS.convert(365, TimeUnit.DAYS); mCurrentTime += timeToElapse; setCurrentTimeForTestMode(mCurrentTime); binaryDictionary.flushWithGC(); @@ -210,9 +210,6 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase { addUnigramWord(binaryDictionary, "a", Dictionary.NOT_A_PROBABILITY); assertFalse(binaryDictionary.isValidWord("a")); addUnigramWord(binaryDictionary, "a", Dictionary.NOT_A_PROBABILITY); - assertFalse(binaryDictionary.isValidWord("a")); - addUnigramWord(binaryDictionary, "a", Dictionary.NOT_A_PROBABILITY); - assertFalse(binaryDictionary.isValidWord("a")); addUnigramWord(binaryDictionary, "a", Dictionary.NOT_A_PROBABILITY); assertTrue(binaryDictionary.isValidWord("a")); @@ -222,10 +219,6 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase { addBigramWords(binaryDictionary, "a", "b", Dictionary.NOT_A_PROBABILITY); assertFalse(binaryDictionary.isValidBigram("a", "b")); addBigramWords(binaryDictionary, "a", "b", Dictionary.NOT_A_PROBABILITY); - assertFalse(binaryDictionary.isValidBigram("a", "b")); - addBigramWords(binaryDictionary, "a", "b", Dictionary.NOT_A_PROBABILITY); - assertFalse(binaryDictionary.isValidBigram("a", "b")); - addBigramWords(binaryDictionary, "a", "b", Dictionary.NOT_A_PROBABILITY); assertTrue(binaryDictionary.isValidBigram("a", "b")); addUnigramWord(binaryDictionary, "c", DUMMY_PROBABILITY); @@ -265,8 +258,6 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase { addUnigramWord(binaryDictionary, "a", DUMMY_PROBABILITY); addUnigramWord(binaryDictionary, "a", DUMMY_PROBABILITY); addUnigramWord(binaryDictionary, "a", DUMMY_PROBABILITY); - addUnigramWord(binaryDictionary, "a", DUMMY_PROBABILITY); - addUnigramWord(binaryDictionary, "a", DUMMY_PROBABILITY); assertTrue(binaryDictionary.isValidWord("a")); forcePassingShortTime(binaryDictionary); assertTrue(binaryDictionary.isValidWord("a")); @@ -289,12 +280,6 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase { addUnigramWord(binaryDictionary, "a", DUMMY_PROBABILITY); addUnigramWord(binaryDictionary, "b", DUMMY_PROBABILITY); addBigramWords(binaryDictionary, "a", "b", DUMMY_PROBABILITY); - addUnigramWord(binaryDictionary, "a", DUMMY_PROBABILITY); - addUnigramWord(binaryDictionary, "b", DUMMY_PROBABILITY); - addBigramWords(binaryDictionary, "a", "b", DUMMY_PROBABILITY); - addUnigramWord(binaryDictionary, "a", DUMMY_PROBABILITY); - addUnigramWord(binaryDictionary, "b", DUMMY_PROBABILITY); - addBigramWords(binaryDictionary, "a", "b", DUMMY_PROBABILITY); assertTrue(binaryDictionary.isValidBigram("a", "b")); forcePassingShortTime(binaryDictionary); assertTrue(binaryDictionary.isValidBigram("a", "b")); @@ -370,7 +355,7 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase { private void testOverflowUnigrams(final int formatVersion) { final int unigramCount = 20000; - final int eachUnigramTypedCount = 5; + final int eachUnigramTypedCount = 2; final int strongUnigramTypedCount = 20; final int weakUnigramTypedCount = 1; final int codePointSetSize = 50; @@ -505,7 +490,7 @@ public class BinaryDictionaryDecayingTests extends AndroidTestCase { final int bigramCount = 20000; final int unigramCount = 1000; final int unigramTypedCount = 20; - final int eachBigramTypedCount = 5; + final int eachBigramTypedCount = 2; final int strongBigramTypedCount = 20; final int weakBigramTypedCount = 1; final int codePointSetSize = 50; diff --git a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java index 4d44135e6..b47662719 100644 --- a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java +++ b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java @@ -948,16 +948,15 @@ public class BinaryDictionaryTests extends AndroidTestCase { final HashSet<String> bigramWord1s = bigrams.get(word0); final WordProperty wordProperty = binaryDictionary.getWordProperty(word0); assertEquals(bigramWord1s.size(), wordProperty.mBigrams.size()); - final int unigramProbability = wordProperty.getProbability(); for (int j = 0; j < wordProperty.mBigrams.size(); j++) { final String word1 = wordProperty.mBigrams.get(j).mWord; assertTrue(bigramWord1s.contains(word1)); - final int bigramProbability = wordProperty.mBigrams.get(j).getProbability(); - final int probability = binaryDictionary.calculateProbability( - unigramProbability, bigramProbability); - assertEquals((int)bigramProbabilities.get(new Pair<String, String>(word0, word1)), - probability); - assertEquals(wordProperty.mBigrams.get(j).getProbability(), probability); + final int bigramProbabilityDelta = bigramProbabilities.get( + new Pair<String, String>(word0, word1)); + final int unigramProbability = wordProbabilities.get(word1); + final int bigramProbablity = binaryDictionary.calculateProbability( + unigramProbability, bigramProbabilityDelta); + assertEquals(wordProperty.mBigrams.get(j).getProbability(), bigramProbablity); } } } @@ -1040,16 +1039,16 @@ public class BinaryDictionaryTests extends AndroidTestCase { assertEquals((int)wordProbabilitiesToCheckLater.get(word0), wordProperty.mProbabilityInfo.mProbability); wordSet.remove(word0); - final int unigramProbability = wordProperty.getProbability(); final HashSet<String> bigramWord1s = bigrams.get(word0); for (int j = 0; j < wordProperty.mBigrams.size(); j++) { final String word1 = wordProperty.mBigrams.get(j).mWord; assertTrue(bigramWord1s.contains(word1)); - final int bigramProbability = wordProperty.mBigrams.get(j).getProbability(); - final int probability = binaryDictionary.calculateProbability( - unigramProbability, bigramProbability); + final int unigramProbability = wordProbabilitiesToCheckLater.get(word1); final Pair<String, String> bigram = new Pair<String, String>(word0, word1); - assertEquals((int)bigramProbabilitiesToCheckLater.get(bigram), probability); + final int bigramProbabilityDelta = bigramProbabilitiesToCheckLater.get(bigram); + final int bigramProbablity = binaryDictionary.calculateProbability( + unigramProbability, bigramProbabilityDelta); + assertEquals(wordProperty.mBigrams.get(j).getProbability(), bigramProbablity); bigramSet.remove(bigram); } token = result.mNextToken; diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java index ab9751380..ab6245635 100644 --- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java +++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java @@ -356,7 +356,7 @@ public class InputLogicTests extends InputTestsBase { final String NOT_CORRECTED_RESULT = "qpmx "; final String DESIRED_WORD = "qpmz"; final String CORRECTED_RESULT = "qpmz "; - final int typeCountNotToAutocorrect = 3; + final int typeCountNotToAutocorrect = 1; final int typeCountToAutoCorrect = 16; int startIndex = 0; int endIndex = 0; diff --git a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java index 04840d667..60599f66d 100644 --- a/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java +++ b/tests/src/com/android/inputmethod/latin/personalization/UserHistoryDictionaryTests.java @@ -72,8 +72,8 @@ public class UserHistoryDictionaryTests extends AndroidTestCase { } private void forcePassingLongTime() { - // 60 days. - final int timeToElapse = (int)TimeUnit.DAYS.toSeconds(60); + // 365 days. + final int timeToElapse = (int)TimeUnit.DAYS.toSeconds(365); mCurrentTime += timeToElapse; setCurrentTimeForTestMode(mCurrentTime); } diff --git a/tools/dicttool/Android.mk b/tools/dicttool/Android.mk index c0a55626a..948c03b4f 100644 --- a/tools/dicttool/Android.mk +++ b/tools/dicttool/Android.mk @@ -29,32 +29,34 @@ include $(CLEAR_VARS) LATINIME_LOCAL_DIR := ../.. LATINIME_BASE_SOURCE_DIRECTORY := $(LATINIME_LOCAL_DIR)/java/src/com/android/inputmethod LATINIME_ANNOTATIONS_SOURCE_DIRECTORY := $(LATINIME_BASE_SOURCE_DIRECTORY)/annotations -LATINIME_CORE_SOURCE_DIRECTORY := $(LATINIME_BASE_SOURCE_DIRECTORY)/latin -MAKEDICT_CORE_SOURCE_DIRECTORY := $(LATINIME_CORE_SOURCE_DIRECTORY)/makedict +MAKEDICT_CORE_SOURCE_DIRECTORY := $(LATINIME_BASE_SOURCE_DIRECTORY)/latin/makedict # Dependencies for Dicttool. Most of these files are needed by BinaryDictionary.java. Note that # a significant part of the dependencies are mocked in the compat/ directory, with empty or # nearly-empty implementations, for parts that we don't use in Dicttool. -USED_TARGETTED_UTILS := \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/BinaryDictionary.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/DicTraverseSession.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/Dictionary.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/InputPointers.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/LastComposedWord.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/LatinImeLogger.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/SuggestedWords.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/WordComposer.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/settings/NativeSuggestOptions.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/utils/BinaryDictionaryUtils.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/utils/ByteArrayDictBuffer.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/utils/CollectionUtils.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/utils/CombinedFormatUtils.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/utils/CoordinateUtils.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/utils/FileUtils.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/utils/JniUtils.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/utils/LocaleUtils.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/utils/ResizableIntArray.java \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/utils/StringUtils.java +LATINIME_SRCS_FOR_DICTTOOL := \ + event/Event.java \ + latin/BinaryDictionary.java \ + latin/DicTraverseSession.java \ + latin/Dictionary.java \ + latin/InputPointers.java \ + latin/LastComposedWord.java \ + latin/LatinImeLogger.java \ + latin/SuggestedWords.java \ + latin/WordComposer.java \ + latin/settings/NativeSuggestOptions.java \ + latin/utils/BinaryDictionaryUtils.java \ + latin/utils/ByteArrayDictBuffer.java \ + latin/utils/CollectionUtils.java \ + latin/utils/CombinedFormatUtils.java \ + latin/utils/CoordinateUtils.java \ + latin/utils/FileUtils.java \ + latin/utils/JniUtils.java \ + latin/utils/LocaleUtils.java \ + latin/utils/ResizableIntArray.java \ + latin/utils/StringUtils.java +USED_TARGETED_SRCS := $(addprefix $(LATINIME_BASE_SOURCE_DIRECTORY)/, \ + $(LATINIME_SRCS_FOR_DICTTOOL)) DICTTOOL_ONDEVICE_TESTS_DIRECTORY := \ $(LATINIME_LOCAL_DIR)/tests/src/com/android/inputmethod/latin/makedict/ @@ -68,11 +70,11 @@ LOCAL_ANNOTATIONS_SRC_FILES := \ LOCAL_SRC_FILES := $(LOCAL_TOOL_SRC_FILES) \ $(filter-out $(addprefix %/, $(notdir $(LOCAL_TOOL_SRC_FILES))), $(LOCAL_MAIN_SRC_FILES)) \ $(LOCAL_ANNOTATIONS_SRC_FILES) \ - $(LATINIME_CORE_SOURCE_DIRECTORY)/Constants.java \ + $(LATINIME_BASE_SOURCE_DIRECTORY)/latin/Constants.java \ $(call all-java-files-under, tests) \ $(call all-java-files-under, $(DICTTOOL_ONDEVICE_TESTS_DIRECTORY)) \ $(call all-java-files-under, $(DICTTOOL_COMPAT_TESTS_DIRECTORY)) \ - $(USED_TARGETTED_UTILS) + $(USED_TARGETED_SRCS) LOCAL_JAVA_LIBRARIES := junit LOCAL_ADDITIONAL_DEPENDENCIES := $(LATINIME_HOST_NATIVE_LIBNAME) |