diff options
Diffstat (limited to 'tests/src/org/kelar/inputmethod/keyboard')
224 files changed, 31242 insertions, 0 deletions
diff --git a/tests/src/org/kelar/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysBase.java b/tests/src/org/kelar/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysBase.java new file mode 100644 index 000000000..5ba44c73e --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysBase.java @@ -0,0 +1,337 @@ +/* + * 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 org.kelar.inputmethod.keyboard; + +import android.text.InputType; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.keyboard.internal.MoreKeySpec; +import org.kelar.inputmethod.latin.R; +import org.kelar.inputmethod.latin.RichInputMethodManager; +import org.kelar.inputmethod.latin.common.Constants; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +import java.util.Arrays; +import java.util.Locale; + +abstract class KeyboardLayoutSetNavigateMoreKeysBase extends KeyboardLayoutSetTestsBase { + private ExpectedMoreKey mExpectedNavigateNextMoreKey; + private ExpectedMoreKey mExpectedNavigatePreviousMoreKey; + private ExpectedMoreKey mExpectedEmojiMoreKey; + + protected ExpectedMoreKey getExpectedNavigateNextMoreKey() { + return new ExpectedMoreKey(R.string.label_next_key); + } + + protected ExpectedMoreKey getExpectedNavigatePreviousMoreKey() { + return new ExpectedMoreKey(R.string.label_previous_key); + } + + protected ExpectedMoreKey getExpectedEmojiMoreKey() { + return new ExpectedMoreKey(KeyboardIconsSet.NAME_EMOJI_ACTION_KEY); + } + + @Override + protected void setUp() throws Exception { + super.setUp(); + mExpectedNavigateNextMoreKey = getExpectedNavigateNextMoreKey(); + mExpectedNavigatePreviousMoreKey = getExpectedNavigatePreviousMoreKey(); + mExpectedEmojiMoreKey = getExpectedEmojiMoreKey(); + } + + /** + * This class represents an expected more key. + */ + protected static class ExpectedMoreKey { + public static final int NO_LABEL = 0; + public static final ExpectedMoreKey[] EMPTY_MORE_KEYS = new ExpectedMoreKey[0]; + + public final int mLabelResId; + public final int mIconId; + + public ExpectedMoreKey(final String iconName) { + mLabelResId = NO_LABEL; + mIconId = KeyboardIconsSet.getIconId(iconName); + } + + public ExpectedMoreKey(final int labelResId) { + mLabelResId = labelResId; + mIconId = KeyboardIconsSet.ICON_UNDEFINED; + } + } + + private void doTestMoreKeysOf(final int code, final InputMethodSubtype subtype, + final int elementId, final int inputType, final int imeOptions, + final ExpectedMoreKey ... expectedMoreKeys) { + final EditorInfo editorInfo = new EditorInfo(); + editorInfo.inputType = inputType; + editorInfo.imeOptions = imeOptions; + final KeyboardLayoutSet layoutSet = createKeyboardLayoutSet(subtype, editorInfo); + final Keyboard keyboard = layoutSet.getKeyboard(elementId); + + final Key actualKey = keyboard.getKey(code); + final MoreKeySpec[] actualMoreKeys = actualKey.getMoreKeys(); + final String tag = actualKey.toString() + " moreKeys=" + Arrays.toString(actualMoreKeys); + if (expectedMoreKeys.length == 0) { + assertEquals(tag, null, actualMoreKeys); + return; + } + if (expectedMoreKeys.length == 1) { + assertEquals(tag + " fixedOrder", false, actualKey.isMoreKeysFixedOrder()); + assertEquals(tag + " fixedColumn", false, actualKey.isMoreKeysFixedColumn()); + } else { + assertEquals(tag + " fixedOrder", true, actualKey.isMoreKeysFixedOrder()); + assertEquals(tag + " fixedColumn", true, actualKey.isMoreKeysFixedColumn()); + // TODO: Can't handle multiple rows of more keys. + assertEquals(tag + " column", + expectedMoreKeys.length, actualKey.getMoreKeysColumnNumber()); + } + assertNotNull(tag + " moreKeys", actualMoreKeys); + assertEquals(tag, expectedMoreKeys.length, actualMoreKeys.length); + for (int index = 0; index < actualMoreKeys.length; index++) { + final int expectedLabelResId = expectedMoreKeys[index].mLabelResId; + if (expectedLabelResId == ExpectedMoreKey.NO_LABEL) { + assertEquals(tag + " label " + index, null, actualMoreKeys[index].mLabel); + } else { + final CharSequence expectedLabel = getContext().getText(expectedLabelResId); + assertEquals(tag + " label " + index, expectedLabel, actualMoreKeys[index].mLabel); + } + final int expectedIconId = expectedMoreKeys[index].mIconId; + assertEquals(tag + " icon " + index, expectedIconId, actualMoreKeys[index].mIconId); + } + } + + private void doTestNavigationMoreKeysOf(final int code, final InputMethodSubtype subtype, + final int elementId, final int inputType) { + // No navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_NULL, + ExpectedMoreKey.EMPTY_MORE_KEYS); + // With next navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_FLAG_NAVIGATE_NEXT, + mExpectedNavigateNextMoreKey); + // With previous navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + mExpectedNavigatePreviousMoreKey); + // With next and previous naviagte flags. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_FLAG_NAVIGATE_NEXT | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + mExpectedNavigatePreviousMoreKey, mExpectedNavigateNextMoreKey); + // Action next. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_NEXT, + ExpectedMoreKey.EMPTY_MORE_KEYS); + // Action next with next navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NAVIGATE_NEXT, + ExpectedMoreKey.EMPTY_MORE_KEYS); + // Action next with previous navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + mExpectedNavigatePreviousMoreKey); + // Action next with next and previous navigate flags. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NAVIGATE_NEXT + | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + mExpectedNavigatePreviousMoreKey); + // Action previous. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_PREVIOUS, + ExpectedMoreKey.EMPTY_MORE_KEYS); + // Action previous with next navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_PREVIOUS | EditorInfo.IME_FLAG_NAVIGATE_NEXT, + mExpectedNavigateNextMoreKey); + // Action previous with previous navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_PREVIOUS | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + ExpectedMoreKey.EMPTY_MORE_KEYS); + // Action previous with next and previous navigate flags. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_PREVIOUS | EditorInfo.IME_FLAG_NAVIGATE_NEXT + | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + mExpectedNavigateNextMoreKey); + } + + private void doTestNavigationWithEmojiMoreKeysOf(final int code, + final InputMethodSubtype subtype, final int elementId, final int inputType) { + // No navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_NULL, + mExpectedEmojiMoreKey); + // With next navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_FLAG_NAVIGATE_NEXT, + mExpectedEmojiMoreKey, mExpectedNavigateNextMoreKey); + // With previous navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + mExpectedEmojiMoreKey, mExpectedNavigatePreviousMoreKey); + // With next and previous naviagte flags. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_FLAG_NAVIGATE_NEXT | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + mExpectedEmojiMoreKey, mExpectedNavigatePreviousMoreKey, + mExpectedNavigateNextMoreKey); + // Action next. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_NEXT, + mExpectedEmojiMoreKey); + // Action next with next navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NAVIGATE_NEXT, + mExpectedEmojiMoreKey); + // Action next with previous navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + mExpectedEmojiMoreKey, mExpectedNavigatePreviousMoreKey); + // Action next with next and previous navigate flags. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NAVIGATE_NEXT + | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + mExpectedEmojiMoreKey, mExpectedNavigatePreviousMoreKey); + // Action previous. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_PREVIOUS, + mExpectedEmojiMoreKey); + // Action previous with next navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_PREVIOUS | EditorInfo.IME_FLAG_NAVIGATE_NEXT, + mExpectedEmojiMoreKey, mExpectedNavigateNextMoreKey); + // Action previous with previous navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_PREVIOUS | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + mExpectedEmojiMoreKey); + // Action previous with next and previous navigate flags. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_PREVIOUS | EditorInfo.IME_FLAG_NAVIGATE_NEXT + | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + mExpectedEmojiMoreKey, mExpectedNavigateNextMoreKey); + } + + private void doTestNoNavigationMoreKeysOf(final int code, final InputMethodSubtype subtype, + final int elementId, final int inputType) { + // No navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_NULL, + ExpectedMoreKey.EMPTY_MORE_KEYS); + // With next navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_FLAG_NAVIGATE_NEXT, + ExpectedMoreKey.EMPTY_MORE_KEYS); + // With previous navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + ExpectedMoreKey.EMPTY_MORE_KEYS); + // With next and previous naviagte flags. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_FLAG_NAVIGATE_NEXT | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + ExpectedMoreKey.EMPTY_MORE_KEYS); + // Action next. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_NEXT, + ExpectedMoreKey.EMPTY_MORE_KEYS); + // Action next with next navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NAVIGATE_NEXT, + ExpectedMoreKey.EMPTY_MORE_KEYS); + // Action next with previous navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + ExpectedMoreKey.EMPTY_MORE_KEYS); + // Action next with next and previous navigate flags. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_NEXT | EditorInfo.IME_FLAG_NAVIGATE_NEXT + | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + ExpectedMoreKey.EMPTY_MORE_KEYS); + // Action previous. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_PREVIOUS, + ExpectedMoreKey.EMPTY_MORE_KEYS); + // Action previous with next navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_PREVIOUS | EditorInfo.IME_FLAG_NAVIGATE_NEXT, + ExpectedMoreKey.EMPTY_MORE_KEYS); + // Action previous with previous navigate flag. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_PREVIOUS | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + ExpectedMoreKey.EMPTY_MORE_KEYS); + // Action previous with next and previous navigate flags. + doTestMoreKeysOf(code, subtype, elementId, inputType, + EditorInfo.IME_ACTION_PREVIOUS | EditorInfo.IME_FLAG_NAVIGATE_NEXT + | EditorInfo.IME_FLAG_NAVIGATE_PREVIOUS, + ExpectedMoreKey.EMPTY_MORE_KEYS); + } + + public void testMoreKeysOfEnterKey() { + final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); + final InputMethodSubtype subtype = richImm.findSubtypeByLocaleAndKeyboardLayoutSet( + Locale.US.toString(), SubtypeLocaleUtils.QWERTY); + + // Password field. + doTestNavigationMoreKeysOf(Constants.CODE_ENTER, subtype, KeyboardId.ELEMENT_ALPHABET, + InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); + // Email field. + doTestNavigationMoreKeysOf(Constants.CODE_ENTER, subtype, KeyboardId.ELEMENT_ALPHABET, + InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS); + // Url field. + doTestNavigationMoreKeysOf(Constants.CODE_ENTER, subtype, KeyboardId.ELEMENT_ALPHABET, + InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI); + // Phone number field. + doTestNavigationMoreKeysOf(Constants.CODE_ENTER, subtype, KeyboardId.ELEMENT_PHONE, + InputType.TYPE_CLASS_PHONE); + // Number field. + doTestNavigationMoreKeysOf(Constants.CODE_ENTER, subtype, KeyboardId.ELEMENT_NUMBER, + InputType.TYPE_CLASS_NUMBER); + // Date-time field. + doTestNavigationMoreKeysOf(Constants.CODE_ENTER, subtype, KeyboardId.ELEMENT_NUMBER, + InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_NORMAL); + // Date field. + doTestNavigationMoreKeysOf(Constants.CODE_ENTER, subtype, KeyboardId.ELEMENT_NUMBER, + InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_DATE); + // Time field. + doTestNavigationMoreKeysOf(Constants.CODE_ENTER, subtype, KeyboardId.ELEMENT_NUMBER, + InputType.TYPE_CLASS_DATETIME | InputType.TYPE_DATETIME_VARIATION_TIME); + // Text field. + if (isPhone()) { + // The enter key has an Emoji key as one of more keys. + doTestNavigationWithEmojiMoreKeysOf(Constants.CODE_ENTER, subtype, + KeyboardId.ELEMENT_ALPHABET, + InputType.TYPE_CLASS_TEXT); + } else { + // Tablet has a dedicated Emoji key, so the Enter key has no Emoji more key. + doTestNavigationMoreKeysOf(Constants.CODE_ENTER, subtype, + KeyboardId.ELEMENT_ALPHABET, + InputType.TYPE_CLASS_TEXT); + } + // Short message field. + if (isPhone()) { + // Enter key is switched to Emoji key on a short message field. + // Emoji key has no navigation more keys. + doTestNoNavigationMoreKeysOf(Constants.CODE_EMOJI, subtype, + KeyboardId.ELEMENT_ALPHABET, + InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE); + } else { + doTestNavigationMoreKeysOf(Constants.CODE_ENTER, subtype, + KeyboardId.ELEMENT_ALPHABET, + InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysKlpTests.java b/tests/src/org/kelar/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysKlpTests.java new file mode 100644 index 000000000..c257e3dee --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysKlpTests.java @@ -0,0 +1,28 @@ +/* + * 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 org.kelar.inputmethod.keyboard; + +import androidx.test.filters.SmallTest; + +@SmallTest +public class KeyboardLayoutSetNavigateMoreKeysKlpTests + extends KeyboardLayoutSetNavigateMoreKeysBase { + @Override + protected int getKeyboardThemeForTests() { + return KeyboardTheme.THEME_ID_KLP; + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysLxxTests.java b/tests/src/org/kelar/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysLxxTests.java new file mode 100644 index 000000000..fadbba0fd --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysLxxTests.java @@ -0,0 +1,40 @@ +/* + * 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 org.kelar.inputmethod.keyboard; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; + +@SmallTest +public class KeyboardLayoutSetNavigateMoreKeysLxxTests + extends KeyboardLayoutSetNavigateMoreKeysBase { + @Override + protected int getKeyboardThemeForTests() { + return KeyboardTheme.THEME_ID_LXX_LIGHT; + } + + @Override + protected ExpectedMoreKey getExpectedNavigateNextMoreKey() { + return new ExpectedMoreKey(KeyboardIconsSet.NAME_NEXT_KEY); + } + + @Override + protected ExpectedMoreKey getExpectedNavigatePreviousMoreKey() { + return new ExpectedMoreKey(KeyboardIconsSet.NAME_PREVIOUS_KEY); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java b/tests/src/org/kelar/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java new file mode 100644 index 000000000..122caea85 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java @@ -0,0 +1,168 @@ +/* + * 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 org.kelar.inputmethod.keyboard; + +import android.content.Context; +import android.content.res.Resources; +import android.test.AndroidTestCase; +import android.view.ContextThemeWrapper; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodInfo; +import android.view.inputmethod.InputMethodSubtype; + +import org.kelar.inputmethod.compat.InputMethodSubtypeCompatUtils; +import org.kelar.inputmethod.keyboard.KeyboardLayoutSet.Builder; +import org.kelar.inputmethod.latin.R; +import org.kelar.inputmethod.latin.RichInputMethodManager; +import org.kelar.inputmethod.latin.RichInputMethodSubtype; +import org.kelar.inputmethod.latin.common.Constants; +import org.kelar.inputmethod.latin.settings.Settings; +import org.kelar.inputmethod.latin.utils.AdditionalSubtypeUtils; +import org.kelar.inputmethod.latin.utils.ResourceUtils; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +import java.util.ArrayList; +import java.util.Locale; + +public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase { + // All input method subtypes of LatinIME. + private final ArrayList<InputMethodSubtype> mAllSubtypesList = new ArrayList<>(); + + public interface SubtypeFilter { + public boolean accept(final InputMethodSubtype subtype); + } + + public static final SubtypeFilter FILTER_IS_ASCII_CAPABLE = new SubtypeFilter() { + @Override + public boolean accept(InputMethodSubtype subtype) { + return InputMethodSubtypeCompatUtils.isAsciiCapable(subtype); + } + }; + + public static final SubtypeFilter FILTER_IS_ADDITIONAL_SUBTYPE = new SubtypeFilter() { + @Override + public boolean accept(InputMethodSubtype subtype) { + return AdditionalSubtypeUtils.isAdditionalSubtype(subtype); + } + }; + + private RichInputMethodManager mRichImm; + private InputMethodSubtype[] mSavedAdditionalSubtypes; + private int mScreenMetrics; + + protected abstract int getKeyboardThemeForTests(); + + @Override + protected void setUp() throws Exception { + super.setUp(); + final Context context = getContext(); + final Resources res = context.getResources(); + RichInputMethodManager.init(context); + mRichImm = RichInputMethodManager.getInstance(); + + // Save and reset additional subtypes preference. + mSavedAdditionalSubtypes = mRichImm.getAdditionalSubtypes(); + final InputMethodSubtype[] predefinedAdditionalSubtypes = + AdditionalSubtypeUtils.createAdditionalSubtypesArray( + AdditionalSubtypeUtils.createPrefSubtypes( + res.getStringArray(R.array.predefined_subtypes))); + mRichImm.setAdditionalInputMethodSubtypes(predefinedAdditionalSubtypes); + + final KeyboardTheme keyboardTheme = KeyboardTheme.searchKeyboardThemeById( + getKeyboardThemeForTests(), KeyboardTheme.KEYBOARD_THEMES); + setContext(new ContextThemeWrapper(getContext(), keyboardTheme.mStyleId)); + KeyboardLayoutSet.onKeyboardThemeChanged(); + + mScreenMetrics = Settings.readScreenMetrics(res); + + final InputMethodInfo imi = mRichImm.getInputMethodInfoOfThisIme(); + final int subtypeCount = imi.getSubtypeCount(); + for (int index = 0; index < subtypeCount; index++) { + mAllSubtypesList.add(imi.getSubtypeAt(index)); + } + } + + @Override + protected void tearDown() throws Exception { + // Restore additional subtypes preference. + mRichImm.setAdditionalInputMethodSubtypes(mSavedAdditionalSubtypes); + super.tearDown(); + } + + protected final ArrayList<InputMethodSubtype> getAllSubtypesList() { + return mAllSubtypesList; + } + + protected final ArrayList<InputMethodSubtype> getSubtypesFilteredBy( + final SubtypeFilter filter) { + final ArrayList<InputMethodSubtype> list = new ArrayList<>(); + for (final InputMethodSubtype subtype : mAllSubtypesList) { + if (filter.accept(subtype)) { + list.add(subtype); + } + } + return list; + } + + protected final boolean isPhone() { + return Constants.isPhone(mScreenMetrics); + } + + protected final InputMethodSubtype getSubtype(final Locale locale, + final String keyboardLayout) { + for (final InputMethodSubtype subtype : mAllSubtypesList) { + final Locale subtypeLocale = SubtypeLocaleUtils.getSubtypeLocale(subtype); + final String subtypeLayout = SubtypeLocaleUtils.getKeyboardLayoutSetName(subtype); + if (locale.equals(subtypeLocale) && keyboardLayout.equals(subtypeLayout)) { + // Found subtype that matches locale and keyboard layout. + return subtype; + } + } + for (final InputMethodSubtype subtype : getSubtypesFilteredBy(FILTER_IS_ASCII_CAPABLE)) { + final Locale subtypeLocale = SubtypeLocaleUtils.getSubtypeLocale(subtype); + if (locale.equals(subtypeLocale)) { + // Create additional subtype. + return AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype( + locale.toString(), keyboardLayout); + } + } + throw new RuntimeException( + "Unknown subtype: locale=" + locale + " keyboardLayout=" + keyboardLayout); + } + + protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype, + final EditorInfo editorInfo) { + return createKeyboardLayoutSet(subtype, editorInfo, false /* voiceInputKeyEnabled */, + false /* languageSwitchKeyEnabled */, false /* splitLayoutEnabled */); + } + + protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype, + final EditorInfo editorInfo, final boolean voiceInputKeyEnabled, + final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) { + final Context context = getContext(); + final Resources res = context.getResources(); + final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(context); + final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res); + final Builder builder = new Builder(context, editorInfo); + builder.setKeyboardGeometry(keyboardWidth, keyboardHeight) + .setSubtype(RichInputMethodSubtype.getRichInputMethodSubtype(subtype)) + .setVoiceInputKeyEnabled(voiceInputKeyEnabled) + .setLanguageSwitchKeyEnabled(languageSwitchKeyEnabled) + .setSplitLayoutEnabledByUser(splitLayoutEnabled); + return builder.build(); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/KeyboardLayoutTest.java b/tests/src/org/kelar/inputmethod/keyboard/KeyboardLayoutTest.java new file mode 100644 index 000000000..eb0754a60 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/KeyboardLayoutTest.java @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2015 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 org.kelar.inputmethod.keyboard; + +import static org.junit.Assert.assertEquals; + +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.ArrayList; + +@SmallTest +@RunWith(AndroidJUnit4.class) +public class KeyboardLayoutTest { + @Test + public void testNewKeyboardLayout() { + KeyboardLayout keyboardLayout = KeyboardLayout + .newKeyboardLayout(new ArrayList<Key>(), 11, 12, 13, 14); + + assertEquals(11, keyboardLayout.mMostCommonKeyWidth); + assertEquals(12, keyboardLayout.mMostCommonKeyHeight); + assertEquals(13, keyboardLayout.mKeyboardWidth); + assertEquals(14, keyboardLayout.mKeyboardHeight); + + assertEquals(0, keyboardLayout.getKeyCodes().length); + assertEquals(0, keyboardLayout.getKeyWidths().length); + assertEquals(0, keyboardLayout.getKeyHeights().length); + assertEquals(0, keyboardLayout.getKeyXCoordinates().length); + assertEquals(0, keyboardLayout.getKeyYCoordinates().length); + + Key key1 = new Key("label1", 101, 102, "101", "101hint", 103, 104, 105, 106, 1100, 1101, + 10, 10); + Key key2 = new Key("label2", 201, 103, "201", "201hint", 203, 204, 205, 206, 2100, 2101, + 10, 10); + + ArrayList<Key> sortedKeys = new ArrayList<>(2); + sortedKeys.add(key1); + sortedKeys.add(key2); + keyboardLayout = KeyboardLayout.newKeyboardLayout(sortedKeys, 11, 12, 13, 14); + assertEquals(2, keyboardLayout.getKeyCodes().length); + assertEquals(2, keyboardLayout.getKeyWidths().length); + assertEquals(2, keyboardLayout.getKeyHeights().length); + assertEquals(2, keyboardLayout.getKeyXCoordinates().length); + assertEquals(2, keyboardLayout.getKeyYCoordinates().length); + + assertEquals(102, keyboardLayout.getKeyCodes()[0]); + // xCo + horizontalGap/2 + assertEquals(105 + 5, keyboardLayout.getKeyXCoordinates()[0]); + assertEquals(106, keyboardLayout.getKeyYCoordinates()[0]); + // width - horizontalGap + assertEquals(1100 - 10, keyboardLayout.getKeyWidths()[0]); + // height - verticalGap + assertEquals(1101 - 10, keyboardLayout.getKeyHeights()[0]); + + assertEquals(103, keyboardLayout.getKeyCodes()[1]); + // xCo + horizontalGap/2 + assertEquals(205 + 5, keyboardLayout.getKeyXCoordinates()[1]); + assertEquals(206, keyboardLayout.getKeyYCoordinates()[1]); + // width - horizontalGap + assertEquals(2100 - 10, keyboardLayout.getKeyWidths()[1]); + // height - verticalGap + assertEquals(2101 - 10, keyboardLayout.getKeyHeights()[1]); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/KeyboardThemeTests.java b/tests/src/org/kelar/inputmethod/keyboard/KeyboardThemeTests.java new file mode 100644 index 000000000..ffc5cc9ed --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/KeyboardThemeTests.java @@ -0,0 +1,461 @@ +/* + * 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 org.kelar.inputmethod.keyboard; + +import static org.kelar.inputmethod.keyboard.KeyboardTheme.THEME_ID_ICS; +import static org.kelar.inputmethod.keyboard.KeyboardTheme.THEME_ID_KLP; +import static org.kelar.inputmethod.keyboard.KeyboardTheme.THEME_ID_LXX_DARK; +import static org.kelar.inputmethod.keyboard.KeyboardTheme.THEME_ID_LXX_LIGHT; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +import android.content.Context; +import android.content.SharedPreferences; +import android.os.Build; +import android.os.Build.VERSION_CODES; +import android.preference.PreferenceManager; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.Arrays; + +@SmallTest +@RunWith(AndroidJUnit4.class) +public class KeyboardThemeTests { + private SharedPreferences mPrefs; + + private static final int THEME_ID_NULL = -1; + private static final int THEME_ID_UNKNOWN = -2; + private static final int THEME_ID_ILLEGAL = -3; + private static final String ILLEGAL_THEME_ID_STRING = "ThisCausesNumberFormatExecption"; + + private Context getContext() { + return InstrumentationRegistry.getTargetContext(); + } + + @Before + public void setUp() throws Exception { + mPrefs = PreferenceManager.getDefaultSharedPreferences(getContext()); + } + + /* + * Helper functions. + */ + + private static boolean isValidKeyboardThemeId(final int themeId) { + switch (themeId) { + case THEME_ID_ICS: + case THEME_ID_KLP: + case THEME_ID_LXX_LIGHT: + case THEME_ID_LXX_DARK: + return true; + default: + return false; + } + } + + private void setKeyboardThemePreference(final String prefKey, final int themeId) { + final String themeIdString = Integer.toString(themeId); + if (isValidKeyboardThemeId(themeId) || themeId == THEME_ID_UNKNOWN) { + // Set valid theme id to preference. + mPrefs.edit().putString(prefKey, themeIdString).apply(); + return; + } + if (themeId == THEME_ID_NULL) { + // Simulate undefined preference. + mPrefs.edit().remove(prefKey).apply(); + return; + } + // themeId == THEME_ID_ILLEGAL + // Simulate illegal format theme id in preference. + mPrefs.edit().putString(prefKey, ILLEGAL_THEME_ID_STRING).apply(); + } + + private void assertKeyboardTheme(final int sdkVersion, final int expectedThemeId) { + final KeyboardTheme actualTheme = KeyboardTheme.getKeyboardTheme( + mPrefs, sdkVersion, KeyboardTheme.KEYBOARD_THEMES); + assertEquals(expectedThemeId, actualTheme.mThemeId); + } + + /* + * Test keyboard theme preference on the same platform version and the same keyboard version. + */ + + private void assertKeyboardThemePreference(final int sdkVersion, final int previousThemeId, + final int expectedThemeId) { + // Clear preferences before testing. + setKeyboardThemePreference(KeyboardTheme.KLP_KEYBOARD_THEME_KEY, THEME_ID_NULL); + setKeyboardThemePreference(KeyboardTheme.LXX_KEYBOARD_THEME_KEY, THEME_ID_NULL); + // Set the preference of the sdkVersion to previousThemeId. + final String prefKey = KeyboardTheme.getPreferenceKey(sdkVersion); + setKeyboardThemePreference(prefKey, previousThemeId); + assertKeyboardTheme(sdkVersion, expectedThemeId); + } + + private void assertKeyboardThemePreferenceOnKlp(final int sdkVersion) { + final int defaultThemeId = THEME_ID_KLP; + assertKeyboardThemePreference(sdkVersion, THEME_ID_NULL, defaultThemeId); + assertKeyboardThemePreference(sdkVersion, THEME_ID_ICS, THEME_ID_ICS); + assertKeyboardThemePreference(sdkVersion, THEME_ID_KLP, THEME_ID_KLP); + assertKeyboardThemePreference(sdkVersion, THEME_ID_LXX_LIGHT, THEME_ID_LXX_LIGHT); + assertKeyboardThemePreference(sdkVersion, THEME_ID_LXX_DARK, THEME_ID_LXX_DARK); + assertKeyboardThemePreference(sdkVersion, THEME_ID_UNKNOWN, defaultThemeId); + assertKeyboardThemePreference(sdkVersion, THEME_ID_ILLEGAL, defaultThemeId); + } + + @Test + public void testKeyboardThemePreferenceOnKlp() { + assertKeyboardThemePreferenceOnKlp(VERSION_CODES.ICE_CREAM_SANDWICH); + assertKeyboardThemePreferenceOnKlp(VERSION_CODES.ICE_CREAM_SANDWICH_MR1); + assertKeyboardThemePreferenceOnKlp(VERSION_CODES.JELLY_BEAN); + assertKeyboardThemePreferenceOnKlp(VERSION_CODES.JELLY_BEAN_MR1); + assertKeyboardThemePreferenceOnKlp(VERSION_CODES.JELLY_BEAN_MR2); + assertKeyboardThemePreferenceOnKlp(VERSION_CODES.KITKAT); + } + + private void assertKeyboardThemePreferenceOnLxx(final int sdkVersion) { + final int defaultThemeId = THEME_ID_LXX_LIGHT; + assertKeyboardThemePreference(sdkVersion, THEME_ID_NULL, defaultThemeId); + assertKeyboardThemePreference(sdkVersion, THEME_ID_ICS, THEME_ID_ICS); + assertKeyboardThemePreference(sdkVersion, THEME_ID_KLP, THEME_ID_KLP); + assertKeyboardThemePreference(sdkVersion, THEME_ID_LXX_LIGHT, THEME_ID_LXX_LIGHT); + assertKeyboardThemePreference(sdkVersion, THEME_ID_LXX_DARK, THEME_ID_LXX_DARK); + assertKeyboardThemePreference(sdkVersion, THEME_ID_UNKNOWN, defaultThemeId); + assertKeyboardThemePreference(sdkVersion, THEME_ID_ILLEGAL, defaultThemeId); + } + + @Test + public void testKeyboardThemePreferenceOnLxx() { + assertKeyboardThemePreferenceOnLxx(Build.VERSION_CODES.LOLLIPOP); + } + + /* + * Test default keyboard theme based on the platform version. + */ + + private void assertDefaultKeyboardTheme(final int sdkVersion, final int previousThemeId, + final int expectedThemeId) { + final String oldPrefKey = KeyboardTheme.KLP_KEYBOARD_THEME_KEY; + setKeyboardThemePreference(oldPrefKey, previousThemeId); + + final KeyboardTheme defaultTheme = KeyboardTheme.getDefaultKeyboardTheme( + mPrefs, sdkVersion, KeyboardTheme.KEYBOARD_THEMES); + + assertNotNull(defaultTheme); + assertEquals(expectedThemeId, defaultTheme.mThemeId); + if (sdkVersion <= VERSION_CODES.KITKAT) { + // Old preference must be retained if it is valid. Otherwise it must be pruned. + assertEquals(isValidKeyboardThemeId(previousThemeId), mPrefs.contains(oldPrefKey)); + return; + } + // Old preference must be removed. + assertFalse(mPrefs.contains(oldPrefKey)); + } + + private void assertDefaultKeyboardThemeOnKlp(final int sdkVersion) { + assertDefaultKeyboardTheme(sdkVersion, THEME_ID_NULL, THEME_ID_KLP); + assertDefaultKeyboardTheme(sdkVersion, THEME_ID_ICS, THEME_ID_ICS); + assertDefaultKeyboardTheme(sdkVersion, THEME_ID_KLP, THEME_ID_KLP); + assertDefaultKeyboardTheme(sdkVersion, THEME_ID_UNKNOWN, THEME_ID_KLP); + assertDefaultKeyboardTheme(sdkVersion, THEME_ID_ILLEGAL, THEME_ID_KLP); + } + + @Test + public void testDefaultKeyboardThemeOnKlp() { + assertDefaultKeyboardThemeOnKlp(VERSION_CODES.ICE_CREAM_SANDWICH); + assertDefaultKeyboardThemeOnKlp(VERSION_CODES.ICE_CREAM_SANDWICH_MR1); + assertDefaultKeyboardThemeOnKlp(VERSION_CODES.JELLY_BEAN); + assertDefaultKeyboardThemeOnKlp(VERSION_CODES.JELLY_BEAN_MR1); + assertDefaultKeyboardThemeOnKlp(VERSION_CODES.JELLY_BEAN_MR2); + assertDefaultKeyboardThemeOnKlp(VERSION_CODES.KITKAT); + } + + private void assertDefaultKeyboardThemeOnLxx(final int sdkVersion) { + // Forced to switch to LXX theme. + assertDefaultKeyboardTheme(sdkVersion, THEME_ID_NULL, THEME_ID_LXX_LIGHT); + assertDefaultKeyboardTheme(sdkVersion, THEME_ID_ICS, THEME_ID_LXX_LIGHT); + assertDefaultKeyboardTheme(sdkVersion, THEME_ID_KLP, THEME_ID_LXX_LIGHT); + assertDefaultKeyboardTheme(sdkVersion, THEME_ID_UNKNOWN, THEME_ID_LXX_LIGHT); + assertDefaultKeyboardTheme(sdkVersion, THEME_ID_ILLEGAL, THEME_ID_LXX_LIGHT); + } + + @Test + public void testDefaultKeyboardThemeOnLxx() { + assertDefaultKeyboardThemeOnLxx(Build.VERSION_CODES.LOLLIPOP); + } + + /* + * Test keyboard theme preference while upgrading the keyboard that doesn't support LXX theme + * to the keyboard that supports LXX theme. + */ + + private void assertUpgradeKeyboardToLxxOn(final int sdkVersion, final int previousThemeId, + final int expectedThemeId) { + setKeyboardThemePreference(KeyboardTheme.KLP_KEYBOARD_THEME_KEY, previousThemeId); + // Clean up new keyboard theme preference to simulate "upgrade to LXX keyboard". + setKeyboardThemePreference(KeyboardTheme.LXX_KEYBOARD_THEME_KEY, THEME_ID_NULL); + + final KeyboardTheme theme = KeyboardTheme.getKeyboardTheme( + mPrefs, sdkVersion, KeyboardTheme.KEYBOARD_THEMES); + + assertNotNull(theme); + assertEquals(expectedThemeId, theme.mThemeId); + if (sdkVersion <= VERSION_CODES.KITKAT) { + // New preference must not exist. + assertFalse(mPrefs.contains(KeyboardTheme.LXX_KEYBOARD_THEME_KEY)); + // Old preference must be retained if it is valid. Otherwise it must be pruned. + assertEquals(isValidKeyboardThemeId(previousThemeId), + mPrefs.contains(KeyboardTheme.KLP_KEYBOARD_THEME_KEY)); + if (isValidKeyboardThemeId(previousThemeId)) { + // Old preference must have an expected value. + assertEquals(mPrefs.getString(KeyboardTheme.KLP_KEYBOARD_THEME_KEY, null), + Integer.toString(expectedThemeId)); + } + return; + } + // Old preference must be removed. + assertFalse(mPrefs.contains(KeyboardTheme.KLP_KEYBOARD_THEME_KEY)); + // New preference must not exist. + assertFalse(mPrefs.contains(KeyboardTheme.LXX_KEYBOARD_THEME_KEY)); + } + + private void assertUpgradeKeyboardToLxxOnKlp(final int sdkVersion) { + assertUpgradeKeyboardToLxxOn(sdkVersion, THEME_ID_NULL, THEME_ID_KLP); + assertUpgradeKeyboardToLxxOn(sdkVersion, THEME_ID_ICS, THEME_ID_ICS); + assertUpgradeKeyboardToLxxOn(sdkVersion, THEME_ID_KLP, THEME_ID_KLP); + assertUpgradeKeyboardToLxxOn(sdkVersion, THEME_ID_UNKNOWN, THEME_ID_KLP); + assertUpgradeKeyboardToLxxOn(sdkVersion, THEME_ID_ILLEGAL, THEME_ID_KLP); + } + + // Upgrading keyboard on I,J and K. + @Test + public void testUpgradeKeyboardToLxxOnKlp() { + assertUpgradeKeyboardToLxxOnKlp(VERSION_CODES.ICE_CREAM_SANDWICH); + assertUpgradeKeyboardToLxxOnKlp(VERSION_CODES.ICE_CREAM_SANDWICH_MR1); + assertUpgradeKeyboardToLxxOnKlp(VERSION_CODES.JELLY_BEAN); + assertUpgradeKeyboardToLxxOnKlp(VERSION_CODES.JELLY_BEAN_MR1); + assertUpgradeKeyboardToLxxOnKlp(VERSION_CODES.JELLY_BEAN_MR2); + assertUpgradeKeyboardToLxxOnKlp(VERSION_CODES.KITKAT); + } + + private void assertUpgradeKeyboardToLxxOnLxx(final int sdkVersion) { + // Forced to switch to LXX theme. + assertUpgradeKeyboardToLxxOn(sdkVersion, THEME_ID_NULL, THEME_ID_LXX_LIGHT); + assertUpgradeKeyboardToLxxOn(sdkVersion, THEME_ID_ICS, THEME_ID_LXX_LIGHT); + assertUpgradeKeyboardToLxxOn(sdkVersion, THEME_ID_KLP, THEME_ID_LXX_LIGHT); + assertUpgradeKeyboardToLxxOn(sdkVersion, THEME_ID_UNKNOWN, THEME_ID_LXX_LIGHT); + assertUpgradeKeyboardToLxxOn(sdkVersion, THEME_ID_ILLEGAL, THEME_ID_LXX_LIGHT); + } + + // Upgrading keyboard on L. + @Test + public void testUpgradeKeyboardToLxxOnLxx() { + assertUpgradeKeyboardToLxxOnLxx(Build.VERSION_CODES.LOLLIPOP); + } + + /* + * Test keyboard theme preference while upgrading platform version. + */ + + private void assertUpgradePlatformFromTo(final int oldSdkVersion, final int newSdkVersion, + final int previousThemeId, final int expectedThemeId) { + if (newSdkVersion < oldSdkVersion) { + // No need to test. + return; + } + // Clean up preferences. + setKeyboardThemePreference(KeyboardTheme.KLP_KEYBOARD_THEME_KEY, THEME_ID_NULL); + setKeyboardThemePreference(KeyboardTheme.LXX_KEYBOARD_THEME_KEY, THEME_ID_NULL); + + final String oldPrefKey = KeyboardTheme.getPreferenceKey(oldSdkVersion); + setKeyboardThemePreference(oldPrefKey, previousThemeId); + + assertKeyboardTheme(newSdkVersion, expectedThemeId); + } + + private void assertUpgradePlatformFromKlpToKlp(final int oldSdkVersion, + final int newSdkVersion) { + assertUpgradePlatformFromTo(oldSdkVersion, newSdkVersion, THEME_ID_NULL, THEME_ID_KLP); + assertUpgradePlatformFromTo(oldSdkVersion, newSdkVersion, THEME_ID_ICS, THEME_ID_ICS); + assertUpgradePlatformFromTo(oldSdkVersion, newSdkVersion, THEME_ID_KLP, THEME_ID_KLP); + assertUpgradePlatformFromTo(oldSdkVersion, newSdkVersion, THEME_ID_UNKNOWN, THEME_ID_KLP); + assertUpgradePlatformFromTo(oldSdkVersion, newSdkVersion, THEME_ID_ILLEGAL, THEME_ID_KLP); + } + + private void assertUpgradePlatformToKlpFrom(final int oldSdkVersion) { + assertUpgradePlatformFromKlpToKlp(oldSdkVersion, VERSION_CODES.ICE_CREAM_SANDWICH); + assertUpgradePlatformFromKlpToKlp(oldSdkVersion, VERSION_CODES.ICE_CREAM_SANDWICH_MR1); + assertUpgradePlatformFromKlpToKlp(oldSdkVersion, VERSION_CODES.JELLY_BEAN); + assertUpgradePlatformFromKlpToKlp(oldSdkVersion, VERSION_CODES.JELLY_BEAN_MR1); + assertUpgradePlatformFromKlpToKlp(oldSdkVersion, VERSION_CODES.JELLY_BEAN_MR2); + assertUpgradePlatformFromKlpToKlp(oldSdkVersion, VERSION_CODES.KITKAT); + } + + // Update platform from I,J, and K to I,J, and K + @Test + public void testUpgradePlatformToKlpFromKlp() { + assertUpgradePlatformToKlpFrom(VERSION_CODES.ICE_CREAM_SANDWICH); + assertUpgradePlatformToKlpFrom(VERSION_CODES.ICE_CREAM_SANDWICH_MR1); + assertUpgradePlatformToKlpFrom(VERSION_CODES.JELLY_BEAN); + assertUpgradePlatformToKlpFrom(VERSION_CODES.JELLY_BEAN_MR1); + assertUpgradePlatformToKlpFrom(VERSION_CODES.JELLY_BEAN_MR2); + assertUpgradePlatformToKlpFrom(VERSION_CODES.KITKAT); + } + + private void assertUpgradePlatformToLxxFrom(final int oldSdkVersion) { + // Forced to switch to LXX theme. + final int newSdkVersion = Build.VERSION_CODES.LOLLIPOP; + assertUpgradePlatformFromTo( + oldSdkVersion, newSdkVersion, THEME_ID_NULL, THEME_ID_LXX_LIGHT); + assertUpgradePlatformFromTo( + oldSdkVersion, newSdkVersion, THEME_ID_ICS, THEME_ID_LXX_LIGHT); + assertUpgradePlatformFromTo( + oldSdkVersion, newSdkVersion, THEME_ID_KLP, THEME_ID_LXX_LIGHT); + assertUpgradePlatformFromTo( + oldSdkVersion, newSdkVersion, THEME_ID_UNKNOWN, THEME_ID_LXX_LIGHT); + assertUpgradePlatformFromTo( + oldSdkVersion, newSdkVersion, THEME_ID_ILLEGAL, THEME_ID_LXX_LIGHT); + } + + // Update platform from I,J, and K to L + @Test + public void testUpgradePlatformToLxx() { + assertUpgradePlatformToLxxFrom(VERSION_CODES.ICE_CREAM_SANDWICH); + assertUpgradePlatformToLxxFrom(VERSION_CODES.ICE_CREAM_SANDWICH_MR1); + assertUpgradePlatformToLxxFrom(VERSION_CODES.JELLY_BEAN); + assertUpgradePlatformToLxxFrom(VERSION_CODES.JELLY_BEAN_MR1); + assertUpgradePlatformToLxxFrom(VERSION_CODES.JELLY_BEAN_MR2); + assertUpgradePlatformToLxxFrom(VERSION_CODES.KITKAT); + } + + // Update platform from L to L. + @Test + public void testUpgradePlatformToLxxFromLxx() { + final int oldSdkVersion = Build.VERSION_CODES.LOLLIPOP; + final int newSdkVersion = Build.VERSION_CODES.LOLLIPOP; + assertUpgradePlatformFromTo( + oldSdkVersion, newSdkVersion, THEME_ID_NULL, THEME_ID_LXX_LIGHT); + assertUpgradePlatformFromTo( + oldSdkVersion, newSdkVersion, THEME_ID_ICS, THEME_ID_ICS); + assertUpgradePlatformFromTo( + oldSdkVersion, newSdkVersion, THEME_ID_KLP, THEME_ID_KLP); + assertUpgradePlatformFromTo( + oldSdkVersion, newSdkVersion, THEME_ID_LXX_LIGHT, THEME_ID_LXX_LIGHT); + assertUpgradePlatformFromTo( + oldSdkVersion, newSdkVersion, THEME_ID_LXX_DARK, THEME_ID_LXX_DARK); + assertUpgradePlatformFromTo( + oldSdkVersion, newSdkVersion, THEME_ID_UNKNOWN, THEME_ID_LXX_LIGHT); + assertUpgradePlatformFromTo( + oldSdkVersion, newSdkVersion, THEME_ID_ILLEGAL, THEME_ID_LXX_LIGHT); + } + + /* + * Test that KeyboardTheme array should be sorted by descending order of + * {@link KeyboardTheme#mMinApiVersion}. + */ + private static void assertSortedKeyboardThemeArray(final KeyboardTheme[] array) { + assertNotNull(array); + final int length = array.length; + assertTrue("array length=" + length, length > 0); + for (int index = 0; index < length - 1; index++) { + final KeyboardTheme theme = array[index]; + final KeyboardTheme nextTheme = array[index + 1]; + assertTrue("sorted MinApiVersion: " + + theme.mThemeName + ": minApiVersion=" + theme.mMinApiVersion, + theme.mMinApiVersion >= nextTheme.mMinApiVersion); + } + } + + @Test + public void testSortedKeyboardTheme() { + assertSortedKeyboardThemeArray(KeyboardTheme.KEYBOARD_THEMES); + } + + @Test + public void testSortedAvailableKeyboardTheme() { + assertSortedKeyboardThemeArray(KeyboardTheme.getAvailableThemeArray(getContext())); + } + + /* + * Test for missing selected theme. + */ + private static KeyboardTheme[] LIMITED_THEMES = { + KeyboardTheme.searchKeyboardThemeById(THEME_ID_ICS, KeyboardTheme.KEYBOARD_THEMES), + KeyboardTheme.searchKeyboardThemeById(THEME_ID_KLP, KeyboardTheme.KEYBOARD_THEMES) + }; + static { + Arrays.sort(LIMITED_THEMES); + assertSortedKeyboardThemeArray(LIMITED_THEMES); + } + + @Test + public void testMissingSelectedThemeIcs() { + // Clean up preferences. + setKeyboardThemePreference(KeyboardTheme.KLP_KEYBOARD_THEME_KEY, THEME_ID_NULL); + setKeyboardThemePreference(KeyboardTheme.LXX_KEYBOARD_THEME_KEY, THEME_ID_NULL); + + final int sdkVersion = VERSION_CODES.ICE_CREAM_SANDWICH; + final String oldPrefKey = KeyboardTheme.getPreferenceKey(sdkVersion); + setKeyboardThemePreference(oldPrefKey, THEME_ID_LXX_LIGHT); + + final KeyboardTheme actualTheme = KeyboardTheme.getKeyboardTheme( + mPrefs, sdkVersion, LIMITED_THEMES); + // LXX_LIGHT is missing, fall-back to KLP. + assertEquals(THEME_ID_KLP, actualTheme.mThemeId); + } + + @Test + public void testMissingSelectedThemeKlp() { + // Clean up preferences. + setKeyboardThemePreference(KeyboardTheme.KLP_KEYBOARD_THEME_KEY, THEME_ID_NULL); + setKeyboardThemePreference(KeyboardTheme.LXX_KEYBOARD_THEME_KEY, THEME_ID_NULL); + + final int sdkVersion = VERSION_CODES.KITKAT; + final String oldPrefKey = KeyboardTheme.getPreferenceKey(sdkVersion); + setKeyboardThemePreference(oldPrefKey, THEME_ID_LXX_LIGHT); + + final KeyboardTheme actualTheme = KeyboardTheme.getKeyboardTheme( + mPrefs, sdkVersion, LIMITED_THEMES); + // LXX_LIGHT is missing, fall-back to KLP. + assertEquals(THEME_ID_KLP, actualTheme.mThemeId); + } + + @Test + public void testMissingSelectedThemeLxx() { + // Clean up preferences. + setKeyboardThemePreference(KeyboardTheme.KLP_KEYBOARD_THEME_KEY, THEME_ID_NULL); + setKeyboardThemePreference(KeyboardTheme.LXX_KEYBOARD_THEME_KEY, THEME_ID_NULL); + + final int sdkVersion = Build.VERSION_CODES.LOLLIPOP; + final String oldPrefKey = KeyboardTheme.getPreferenceKey(sdkVersion); + setKeyboardThemePreference(oldPrefKey, THEME_ID_LXX_DARK); + + final KeyboardTheme actualTheme = KeyboardTheme.getKeyboardTheme( + mPrefs, sdkVersion, LIMITED_THEMES); + // LXX_DARK is missing, fall-back to KLP. + assertEquals(THEME_ID_KLP, actualTheme.mThemeId); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/MoreKeysKeyboardBuilderAutoOrderTests.java b/tests/src/org/kelar/inputmethod/keyboard/MoreKeysKeyboardBuilderAutoOrderTests.java new file mode 100644 index 000000000..15d594daa --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/MoreKeysKeyboardBuilderAutoOrderTests.java @@ -0,0 +1,2604 @@ +/* + * 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 org.kelar.inputmethod.keyboard; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import androidx.test.filters.MediumTest; +import androidx.test.runner.AndroidJUnit4; + +import org.kelar.inputmethod.keyboard.MoreKeysKeyboard.MoreKeysKeyboardParams; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@MediumTest +@RunWith(AndroidJUnit4.class) +public class MoreKeysKeyboardBuilderAutoOrderTests { + private static final int WIDTH = 10; + private static final int HEIGHT = 10; + + private static final int KEYBOARD_WIDTH = WIDTH * 10; + private static final int XPOS_L0 = WIDTH * 0 + WIDTH / 2; + private static final int XPOS_L1 = WIDTH * 1 + WIDTH / 2; + private static final int XPOS_L2 = WIDTH * 2 + WIDTH / 2; + private static final int XPOS_L3 = WIDTH * 3 + WIDTH / 2; + private static final int XPOS_M0 = WIDTH * 4 + WIDTH / 2; + private static final int XPOS_M1 = WIDTH * 5 + WIDTH / 2; + private static final int XPOS_R3 = WIDTH * 6 + WIDTH / 2; + private static final int XPOS_R2 = WIDTH * 7 + WIDTH / 2; + private static final int XPOS_R1 = WIDTH * 8 + WIDTH / 2; + private static final int XPOS_R0 = WIDTH * 9 + WIDTH / 2; + + private static MoreKeysKeyboardParams createParams(final int numKeys, final int columnNum, + final int coordXInParent) { + final MoreKeysKeyboardParams params = new MoreKeysKeyboardParams(); + params.setParameters(numKeys, columnNum, WIDTH, HEIGHT, coordXInParent, KEYBOARD_WIDTH, + true /* isMoreKeysFixedColumn */, false /* isMoreKeysFixedOrder */, + 0 /* dividerWidth */); + return params; + } + + @Test + public void testLayoutError() { + MoreKeysKeyboardParams params = null; + try { + final int maxColumns = KEYBOARD_WIDTH / WIDTH; + params = createParams(maxColumns + 1, maxColumns + 1, HEIGHT); + fail("Should throw IllegalArgumentException"); + } catch (IllegalArgumentException e) { + // Too small keyboard to hold more keys keyboard. + } + assertNull("Too small keyboard to hold more keys keyboard", params); + } + + // More keys keyboard layout test. + // "[n]" represents n-th key position in more keys keyboard. + // "<1>" is the default key. + + // <1> + @Test + public void testLayout1KeyAuto5M0() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_M0); + assertEquals("1 key auto 5 M0 columns", 1, params.mNumColumns); + assertEquals("1 key auto 5 M0 rows", 1, params.mNumRows); + assertEquals("1 key auto 5 M0 left", 0, params.mLeftKeys); + assertEquals("1 key auto 5 M0 right", 1, params.mRightKeys); + assertEquals("1 key auto 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key auto 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key auto 5 M0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |<1> + @Test + public void testLayout1KeyAuto5L0() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L0); + assertEquals("1 key auto 5 L0 columns", 1, params.mNumColumns); + assertEquals("1 key auto 5 L0 rows", 1, params.mNumRows); + assertEquals("1 key auto 5 L0 left", 0, params.mLeftKeys); + assertEquals("1 key auto 5 L0 right", 1, params.mRightKeys); + assertEquals("1 key auto 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key auto 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key auto 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> + @Test + public void testLayout1KeyAuto5L1() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L1); + assertEquals("1 key auto 5 L1 columns", 1, params.mNumColumns); + assertEquals("1 key auto 5 L1 rows", 1, params.mNumRows); + assertEquals("1 key auto 5 L1 left", 0, params.mLeftKeys); + assertEquals("1 key auto 5 L1 right", 1, params.mRightKeys); + assertEquals("1 key auto 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key auto 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key auto 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ ___ <1> + @Test + public void testLayout1KeyAuto5L2() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L2); + assertEquals("1 key auto 5 L2 columns", 1, params.mNumColumns); + assertEquals("1 key auto 5 L2 rows", 1, params.mNumRows); + assertEquals("1 key auto 5 L2 left", 0, params.mLeftKeys); + assertEquals("1 key auto 5 L2 right", 1, params.mRightKeys); + assertEquals("1 key auto 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key auto 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key auto 5 L2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // <1>| + @Test + public void testLayout1KeyAuto5R0() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R0); + assertEquals("1 key auto 5 R0 columns", 1, params.mNumColumns); + assertEquals("1 key auto 5 R0 rows", 1, params.mNumRows); + assertEquals("1 key auto 5 R0 left", 0, params.mLeftKeys); + assertEquals("1 key auto 5 R0 right", 1, params.mRightKeys); + assertEquals("1 key auto 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key auto 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key auto 5 R0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // <1> ___| + @Test + public void testLayout1KeyAuto5R1() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R1); + assertEquals("1 key auto 5 R1 columns", 1, params.mNumColumns); + assertEquals("1 key auto 5 R1 rows", 1, params.mNumRows); + assertEquals("1 key auto 5 R1 left", 0, params.mLeftKeys); + assertEquals("1 key auto 5 R1 right", 1, params.mRightKeys); + assertEquals("1 key auto 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key auto 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key auto 5 R1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // <1> ___ ___| + @Test + public void testLayout1KeyAuto5R2() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R2); + assertEquals("1 key auto 5 R2 columns", 1, params.mNumColumns); + assertEquals("1 key auto 5 R2 rows", 1, params.mNumRows); + assertEquals("1 key auto 5 R2 left", 0, params.mLeftKeys); + assertEquals("1 key auto 5 R2 right", 1, params.mRightKeys); + assertEquals("1 key auto 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key auto 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key auto 5 R2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // <1> [2] + @Test + public void testLayout2KeyAuto5M0() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_M0); + assertEquals("2 key auto 5 M0 columns", 2, params.mNumColumns); + assertEquals("2 key auto 5 M0 rows", 1, params.mNumRows); + assertEquals("2 key auto 5 M0 left", 0, params.mLeftKeys); + assertEquals("2 key auto 5 M0 right", 2, params.mRightKeys); + assertEquals("2 key auto 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key auto 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("2 key auto 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key auto 5 M0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |<1> [2] + @Test + public void testLayout2KeyAuto5L0() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L0); + assertEquals("2 key auto 5 L0 columns", 2, params.mNumColumns); + assertEquals("2 key auto 5 L0 rows", 1, params.mNumRows); + assertEquals("2 key auto 5 L0 left", 0, params.mLeftKeys); + assertEquals("2 key auto 5 L0 right", 2, params.mRightKeys); + assertEquals("2 key auto 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key auto 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("2 key auto 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key auto 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] + @Test + public void testLayout2KeyAuto5L1() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L1); + assertEquals("2 key auto 5 L1 columns", 2, params.mNumColumns); + assertEquals("2 key auto 5 L1 rows", 1, params.mNumRows); + assertEquals("2 key auto 5 L1 left", 0, params.mLeftKeys); + assertEquals("2 key auto 5 L1 right", 2, params.mRightKeys); + assertEquals("2 key auto 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key auto 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("2 key auto 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key auto 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ ___ <1> [2] + @Test + public void testLayout2KeyAuto5L2() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L2); + assertEquals("2 key auto 5 L2 columns", 2, params.mNumColumns); + assertEquals("2 key auto 5 L2 rows", 1, params.mNumRows); + assertEquals("2 key auto 5 L2 left", 0, params.mLeftKeys); + assertEquals("2 key auto 5 L2 right", 2, params.mRightKeys); + assertEquals("2 key auto 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key auto 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("2 key auto 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key auto 5 L2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // [2] <1>| + @Test + public void testLayout2KeyAuto5R0() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R0); + assertEquals("2 key auto 5 R0 columns", 2, params.mNumColumns); + assertEquals("2 key auto 5 R0 rows", 1, params.mNumRows); + assertEquals("2 key auto 5 R0 left", 1, params.mLeftKeys); + assertEquals("2 key auto 5 R0 right", 1, params.mRightKeys); + assertEquals("2 key auto 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key auto 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("2 key auto 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key auto 5 R0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [2] <1> ___| + @Test + public void testLayout2KeyAuto5R1() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R1); + assertEquals("2 key auto 5 R1 columns", 2, params.mNumColumns); + assertEquals("2 key auto 5 R1 rows", 1, params.mNumRows); + assertEquals("2 key auto 5 R1 left", 1, params.mLeftKeys); + assertEquals("2 key auto 5 R1 right", 1, params.mRightKeys); + assertEquals("2 key auto 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key auto 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("2 key auto 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key auto 5 R1 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // <1> [2] ___| + @Test + public void testLayout2KeyAuto5R2() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R2); + assertEquals("2 key auto 5 R2 columns", 2, params.mNumColumns); + assertEquals("2 key auto 5 R2 rows", 1, params.mNumRows); + assertEquals("2 key auto 5 R2 left", 0, params.mLeftKeys); + assertEquals("2 key auto 5 R2 right", 2, params.mRightKeys); + assertEquals("2 key auto 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key auto 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("2 key auto 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key auto 5 R2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // [3] <1> [2] + @Test + public void testLayout3KeyAuto5M0() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_M0); + assertEquals("3 key auto 5 M0 columns", 3, params.mNumColumns); + assertEquals("3 key auto 5 M0 rows", 1, params.mNumRows); + assertEquals("3 key auto 5 M0 left", 1, params.mLeftKeys); + assertEquals("3 key auto 5 M0 right", 2, params.mRightKeys); + assertEquals("3 key auto 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key auto 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key auto 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("3 key auto 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key auto 5 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |<1> [2] [3] + @Test + public void testLayout3KeyAuto5L0() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L0); + assertEquals("3 key auto 5 L0 columns", 3, params.mNumColumns); + assertEquals("3 key auto 5 L0 rows", 1, params.mNumRows); + assertEquals("3 key auto 5 L0 left", 0, params.mLeftKeys); + assertEquals("3 key auto 5 L0 right", 3, params.mRightKeys); + assertEquals("3 key auto 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key auto 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key auto 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("3 key auto 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key auto 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] [3] + @Test + public void testLayout3KeyAuto5L1() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L1); + assertEquals("3 key auto 5 L1 columns", 3, params.mNumColumns); + assertEquals("3 key auto 5 L1 rows", 1, params.mNumRows); + assertEquals("3 key auto 5 L1 left", 0, params.mLeftKeys); + assertEquals("3 key auto 5 L1 right", 3, params.mRightKeys); + assertEquals("3 key auto 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key auto 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key auto 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("3 key auto 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key auto 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [3] <1> [2] + @Test + public void testLayout3KeyAuto5L2() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L2); + assertEquals("3 key auto 5 L2 columns", 3, params.mNumColumns); + assertEquals("3 key auto 5 L2 rows", 1, params.mNumRows); + assertEquals("3 key auto 5 L2 left", 1, params.mLeftKeys); + assertEquals("3 key auto 5 L2 right", 2, params.mRightKeys); + assertEquals("3 key auto 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key auto 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key auto 5 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("3 key auto 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key auto 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [3] [2] <1>| + @Test + public void testLayout3KeyAuto5R0() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R0); + assertEquals("3 key auto 5 R0 columns", 3, params.mNumColumns); + assertEquals("3 key auto 5 R0 rows", 1, params.mNumRows); + assertEquals("3 key auto 5 R0 left", 2, params.mLeftKeys); + assertEquals("3 key auto 5 R0 right", 1, params.mRightKeys); + assertEquals("3 key auto 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key auto 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("3 key auto 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("3 key auto 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key auto 5 R0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [3] [2] <1> ___| + @Test + public void testLayout3KeyAuto5R1() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R1); + assertEquals("3 key auto 5 R1 columns", 3, params.mNumColumns); + assertEquals("3 key auto 5 R1 rows", 1, params.mNumRows); + assertEquals("3 key auto 5 R1 left", 2, params.mLeftKeys); + assertEquals("3 key auto 5 R1 right", 1, params.mRightKeys); + assertEquals("3 key auto 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key auto 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("3 key auto 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("3 key auto 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key auto 5 R1 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [3] <1> [2] ___| + @Test + public void testLayout3KeyAuto5R2() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R2); + assertEquals("3 key auto 5 R2 columns", 3, params.mNumColumns); + assertEquals("3 key auto 5 R2 rows", 1, params.mNumRows); + assertEquals("3 key auto 5 R2 left", 1, params.mLeftKeys); + assertEquals("3 key auto 5 R2 right", 2, params.mRightKeys); + assertEquals("3 key auto 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key auto 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key auto 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("3 key auto 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key auto 5 R2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [3] + // <1> [2] + @Test + public void testLayout3KeyAuto2M0() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_M0); + assertEquals("3 key auto 2 M0 columns", 2, params.mNumColumns); + assertEquals("3 key auto 2 M0 rows", 2, params.mNumRows); + assertEquals("3 key auto 2 M0 left", 0, params.mLeftKeys); + assertEquals("3 key auto 2 M0 right", 2, params.mRightKeys); + assertEquals("3 key auto 2 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key auto 2 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key auto 2 M0 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key auto 2 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key auto 2 M0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |[3] + // |<1> [2] + @Test + public void testLayout3KeyAuto2L0() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L0); + assertEquals("3 key auto 2 L0 columns", 2, params.mNumColumns); + assertEquals("3 key auto 2 L0 rows", 2, params.mNumRows); + assertEquals("3 key auto 2 L0 left", 0, params.mLeftKeys); + assertEquals("3 key auto 2 L0 right", 2, params.mRightKeys); + assertEquals("3 key auto 2 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key auto 2 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key auto 2 L0 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key auto 2 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key auto 2 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [3] + // |___ <1> [2] + @Test + public void testLayout3KeyAuto2L1() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L1); + assertEquals("3 key auto 2 L1 columns", 2, params.mNumColumns); + assertEquals("3 key auto 2 L1 rows", 2, params.mNumRows); + assertEquals("3 key auto 2 L1 left", 0, params.mLeftKeys); + assertEquals("3 key auto 2 L1 right", 2, params.mRightKeys); + assertEquals("3 key auto 2 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key auto 2 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key auto 2 L1 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key auto 2 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key auto 2 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // | [3] + // |___ ___ <1> [2] + @Test + public void testLayout3KeyAuto2L2() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L2); + assertEquals("3 key auto 2 L2 columns", 2, params.mNumColumns); + assertEquals("3 key auto 2 L2 rows", 2, params.mNumRows); + assertEquals("3 key auto 2 L2 left", 0, params.mLeftKeys); + assertEquals("3 key auto 2 L2 right", 2, params.mRightKeys); + assertEquals("3 key auto 2 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key auto 2 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key auto 2 L2 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key auto 2 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key auto 2 L2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // [3]| + // [2] <1>| + @Test + public void testLayout3KeyAuto2R0() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R0); + assertEquals("3 key auto 2 R0 columns", 2, params.mNumColumns); + assertEquals("3 key auto 2 R0 rows", 2, params.mNumRows); + assertEquals("3 key auto 2 R0 left", 1, params.mLeftKeys); + assertEquals("3 key auto 2 R0 right", 1, params.mRightKeys); + assertEquals("3 key auto 2 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key auto 2 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("3 key auto 2 R0 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key auto 2 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key auto 2 R0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [3] | + // [2] <1> ___| + @Test + public void testLayout3KeyAuto2R1() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R1); + assertEquals("3 key auto 2 R1 columns", 2, params.mNumColumns); + assertEquals("3 key auto 2 R1 rows", 2, params.mNumRows); + assertEquals("3 key auto 2 R1 left", 1, params.mLeftKeys); + assertEquals("3 key auto 2 R1 right", 1, params.mRightKeys); + assertEquals("3 key auto 2 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key auto 2 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("3 key auto 2 R1 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key auto 2 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key auto 2 R1 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [3] | + // <1> [2] ___| + @Test + public void testLayout3KeyAuto2R2() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R2); + assertEquals("3 key auto 2 R2 columns", 2, params.mNumColumns); + assertEquals("3 key auto 2 R2 rows", 2, params.mNumRows); + assertEquals("3 key auto 2 R2 left", 0, params.mLeftKeys); + assertEquals("3 key auto 2 R2 right", 2, params.mRightKeys); + assertEquals("3 key auto 2 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key auto 2 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key auto 2 R2 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key auto 2 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key auto 2 R2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // [4] + // [3] <1> [2] + @Test + public void testLayout4KeyAuto3M0() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_M0); + assertEquals("4 key auto 3 M0 columns", 3, params.mNumColumns); + assertEquals("4 key auto 3 M0 rows", 2, params.mNumRows); + assertEquals("4 key auto 3 M0 left", 1, params.mLeftKeys); + assertEquals("4 key auto 3 M0 right", 2, params.mRightKeys); + assertEquals("4 key auto 3 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 3 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key auto 3 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key auto 3 M0 [4]", 0, params.getColumnPos(3)); + assertEquals("4 key auto 3 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 3 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[4] + // |<1> [2] [3] + @Test + public void testLayout4KeyAuto3L0() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L0); + assertEquals("4 key auto 3 L0 columns", 3, params.mNumColumns); + assertEquals("4 key auto 3 L0 rows", 2, params.mNumRows); + assertEquals("4 key auto 3 L0 left", 0, params.mLeftKeys); + assertEquals("4 key auto 3 L0 right", 3, params.mRightKeys); + assertEquals("4 key auto 3 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 3 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key auto 3 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("4 key auto 3 L0 [4]", 0, params.getColumnPos(3)); + assertEquals("4 key auto 3 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 3 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [4] + // |___ <1> [2] [3] + @Test + public void testLayout4KeyAuto3L1() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L1); + assertEquals("4 key auto 3 L1 columns", 3, params.mNumColumns); + assertEquals("4 key auto 3 L1 rows", 2, params.mNumRows); + assertEquals("4 key auto 3 L1 left", 0, params.mLeftKeys); + assertEquals("4 key auto 3 L1 right", 3, params.mRightKeys); + assertEquals("4 key auto 3 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 3 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key auto 3 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("4 key auto 3 L1 [4]", 0, params.getColumnPos(3)); + assertEquals("4 key auto 3 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 3 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ ___ [4] + // |___ [3] <1> [2] + @Test + public void testLayout4KeyAuto3L2() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L2); + assertEquals("4 key auto 3 L2 columns", 3, params.mNumColumns); + assertEquals("4 key auto 3 L2 rows", 2, params.mNumRows); + assertEquals("4 key auto 3 L2 left", 1, params.mLeftKeys); + assertEquals("4 key auto 3 L2 right", 2, params.mRightKeys); + assertEquals("4 key auto 3 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 3 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key auto 3 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key auto 3 L2 [4]", 0, params.getColumnPos(3)); + assertEquals("4 key auto 3 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 3 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [4]| + // [3] [2] <1>| + @Test + public void testLayout4KeyAuto3R0() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R0); + assertEquals("4 key auto 3 R0 columns", 3, params.mNumColumns); + assertEquals("4 key auto 3 R0 rows", 2, params.mNumRows); + assertEquals("4 key auto 3 R0 left", 2, params.mLeftKeys); + assertEquals("4 key auto 3 R0 right", 1, params.mRightKeys); + assertEquals("4 key auto 3 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 3 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("4 key auto 3 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("4 key auto 3 R0 [4]", 0, params.getColumnPos(3)); + assertEquals("4 key auto 3 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 3 R0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [4] ___| + // [3] [2] <1> ___| + @Test + public void testLayout4KeyAuto3R1() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R1); + assertEquals("4 key auto 3 R1 columns", 3, params.mNumColumns); + assertEquals("4 key auto 3 R1 rows", 2, params.mNumRows); + assertEquals("4 key auto 3 R1 left", 2, params.mLeftKeys); + assertEquals("4 key auto 3 R1 right", 1, params.mRightKeys); + assertEquals("4 key auto 3 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 3 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("4 key auto 3 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("4 key auto 3 R1 [4]", 0, params.getColumnPos(3)); + assertEquals("4 key auto 3 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 3 R1 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [4] ___| + // [3] <1> [2] ___| + @Test + public void testLayout4KeyAuto3R2() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R2); + assertEquals("4 key auto 3 R2 columns", 3, params.mNumColumns); + assertEquals("4 key auto 3 R2 rows", 2, params.mNumRows); + assertEquals("4 key auto 3 R2 left", 1, params.mLeftKeys); + assertEquals("4 key auto 3 R2 right", 2, params.mRightKeys); + assertEquals("4 key auto 3 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 3 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key auto 3 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key auto 3 R2 [4]", 0, params.getColumnPos(3)); + assertEquals("4 key auto 3 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 3 R2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [3] <1> [2] [4] + @Test + public void testLayout4KeyAuto4M0() { + MoreKeysKeyboardParams params = createParams(4, 4, XPOS_M0); + assertEquals("4 key auto 4 M0 columns", 4, params.mNumColumns); + assertEquals("4 key auto 4 M0 rows", 1, params.mNumRows); + assertEquals("4 key auto 4 M0 left", 1, params.mLeftKeys); + assertEquals("4 key auto 4 M0 right", 3, params.mRightKeys); + assertEquals("4 key auto 4 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 4 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key auto 4 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key auto 4 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("4 key auto 4 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 4 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |<1> [2] [3] [4] + @Test + public void testLayout4KeyAuto4L0() { + MoreKeysKeyboardParams params = createParams(4, 4, XPOS_L0); + assertEquals("4 key auto 4 L0 columns", 4, params.mNumColumns); + assertEquals("4 key auto 4 L0 rows", 1, params.mNumRows); + assertEquals("4 key auto 4 L0 left", 0, params.mLeftKeys); + assertEquals("4 key auto 4 L0 right", 4, params.mRightKeys); + assertEquals("4 key auto 4 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 4 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key auto 4 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("4 key auto 4 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("4 key auto 4 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 4 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] [3] [4] + @Test + public void testLayout4KeyAuto4L1() { + MoreKeysKeyboardParams params = createParams(4, 4, XPOS_L1); + assertEquals("4 key auto 4 L1 columns", 4, params.mNumColumns); + assertEquals("4 key auto 4 L1 rows", 1, params.mNumRows); + assertEquals("4 key auto 4 L1 left", 0, params.mLeftKeys); + assertEquals("4 key auto 4 L1 right", 4, params.mRightKeys); + assertEquals("4 key auto 4 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 4 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key auto 4 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("4 key auto 4 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("4 key auto 4 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 4 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [3] <1> [2] [4] + @Test + public void testLayout4KeyAuto4L2() { + MoreKeysKeyboardParams params = createParams(4, 4, XPOS_L2); + assertEquals("4 key auto 4 L2 columns", 4, params.mNumColumns); + assertEquals("4 key auto 4 L2 rows", 1, params.mNumRows); + assertEquals("4 key auto 4 L2 left", 1, params.mLeftKeys); + assertEquals("4 key auto 4 L2 right", 3, params.mRightKeys); + assertEquals("4 key auto 4 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 4 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key auto 4 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key auto 4 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("4 key auto 4 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 4 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [4] [3] [2] <1>| + @Test + public void testLayout4KeyAuto4R0() { + MoreKeysKeyboardParams params = createParams(4, 4, XPOS_R0); + assertEquals("4 key auto 4 R0 columns", 4, params.mNumColumns); + assertEquals("4 key auto 4 R0 rows", 1, params.mNumRows); + assertEquals("4 key auto 4 R0 left", 3, params.mLeftKeys); + assertEquals("4 key auto 4 R0 right", 1, params.mRightKeys); + assertEquals("4 key auto 4 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 4 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("4 key auto 4 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("4 key auto 4 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("4 key auto 4 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 4 R0 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [4] [3] [2] <1> ___| + @Test + public void testLayout4KeyAuto4R1() { + MoreKeysKeyboardParams params = createParams(4, 4, XPOS_R1); + assertEquals("4 key auto 4 R1 columns", 4, params.mNumColumns); + assertEquals("4 key auto 4 R1 rows", 1, params.mNumRows); + assertEquals("4 key auto 4 R1 left", 3, params.mLeftKeys); + assertEquals("4 key auto 4 R1 right", 1, params.mRightKeys); + assertEquals("4 key auto 4 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 4 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("4 key auto 4 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("4 key auto 4 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("4 key auto 4 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 4 R1 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [4] [3] <1> [2] ___| + @Test + public void testLayout4KeyAuto4R2() { + MoreKeysKeyboardParams params = createParams(4, 4, XPOS_R2); + assertEquals("4 key auto 4 R2 columns", 4, params.mNumColumns); + assertEquals("4 key auto 4 R2 rows", 1, params.mNumRows); + assertEquals("4 key auto 4 R2 left", 2, params.mLeftKeys); + assertEquals("4 key auto 4 R2 right", 2, params.mRightKeys); + assertEquals("4 key auto 4 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 4 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key auto 4 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key auto 4 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("4 key auto 4 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 4 R2 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [3] <1> [2] [4] + @Test + public void testLayout4KeyAuto5M0() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_M0); + assertEquals("4 key auto 5 M0 columns", 4, params.mNumColumns); + assertEquals("4 key auto 5 M0 rows", 1, params.mNumRows); + assertEquals("4 key auto 5 M0 left", 1, params.mLeftKeys); + assertEquals("4 key auto 5 M0 right", 3, params.mRightKeys); + assertEquals("4 key auto 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key auto 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key auto 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("4 key auto 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 5 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |<1> [2] [3] [4] + @Test + public void testLayout4KeyAuto5L0() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L0); + assertEquals("4 key auto 5 L0 columns", 4, params.mNumColumns); + assertEquals("4 key auto 5 L0 rows", 1, params.mNumRows); + assertEquals("4 key auto 5 L0 left", 0, params.mLeftKeys); + assertEquals("4 key auto 5 L0 right", 4, params.mRightKeys); + assertEquals("4 key auto 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key auto 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("4 key auto 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("4 key auto 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] [3] [4] + @Test + public void testLayout4KeyAuto5L1() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L1); + assertEquals("4 key auto 5 L1 columns", 4, params.mNumColumns); + assertEquals("4 key auto 5 L1 rows", 1, params.mNumRows); + assertEquals("4 key auto 5 L1 left", 0, params.mLeftKeys); + assertEquals("4 key auto 5 L1 right", 4, params.mRightKeys); + assertEquals("4 key auto 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key auto 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("4 key auto 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("4 key auto 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [3] <1> [2] [4] + @Test + public void testLayout4KeyAuto5L2() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L2); + assertEquals("4 key auto 5 L2 columns", 4, params.mNumColumns); + assertEquals("4 key auto 5 L2 rows", 1, params.mNumRows); + assertEquals("4 key auto 5 L2 left", 1, params.mLeftKeys); + assertEquals("4 key auto 5 L2 right", 3, params.mRightKeys); + assertEquals("4 key auto 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key auto 5 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key auto 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("4 key auto 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [4] [3] [2] <1>| + @Test + public void testLayout4KeyAuto5R0() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R0); + assertEquals("4 key auto 5 R0 columns", 4, params.mNumColumns); + assertEquals("4 key auto 5 R0 rows", 1, params.mNumRows); + assertEquals("4 key auto 5 R0 left", 3, params.mLeftKeys); + assertEquals("4 key auto 5 R0 right", 1, params.mRightKeys); + assertEquals("4 key auto 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("4 key auto 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("4 key auto 5 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("4 key auto 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 5 R0 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [4] [3] [2] <1> ___| + @Test + public void testLayout4KeyAuto5R1() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R1); + assertEquals("4 key auto 5 R1 columns", 4, params.mNumColumns); + assertEquals("4 key auto 5 R1 rows", 1, params.mNumRows); + assertEquals("4 key auto 5 R1 left", 3, params.mLeftKeys); + assertEquals("4 key auto 5 R1 right", 1, params.mRightKeys); + assertEquals("4 key auto 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("4 key auto 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("4 key auto 5 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("4 key auto 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 5 R1 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [4] [3] <1> [2] ___| + @Test + public void testLayout4KeyAuto5R2() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R2); + assertEquals("4 key auto 5 R2 columns", 4, params.mNumColumns); + assertEquals("4 key auto 5 R2 rows", 1, params.mNumRows); + assertEquals("4 key auto 5 R2 left", 2, params.mLeftKeys); + assertEquals("4 key auto 5 R2 right", 2, params.mRightKeys); + assertEquals("4 key auto 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key auto 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key auto 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key auto 5 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("4 key auto 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key auto 5 R2 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [4] [5] + // [3] <1> [2] + @Test + public void testLayout5KeyAuto3M0() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_M0); + assertEquals("5 key auto 3 M0 columns", 3, params.mNumColumns); + assertEquals("5 key auto 3 M0 rows", 2, params.mNumRows); + assertEquals("5 key auto 3 M0 left", 1, params.mLeftKeys); + assertEquals("5 key auto 3 M0 right", 2, params.mRightKeys); + assertEquals("5 key auto 3 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 3 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key auto 3 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key auto 3 M0 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key auto 3 M0 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key auto 3 M0 adjust", -1, params.mTopRowAdjustment); + assertEquals("5 key auto 3 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[4] [5] + // |<1> [2] [3] + @Test + public void testLayout5KeyAuto3L0() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L0); + assertEquals("5 key auto 3 L0 columns", 3, params.mNumColumns); + assertEquals("5 key auto 3 L0 rows", 2, params.mNumRows); + assertEquals("5 key auto 3 L0 left", 0, params.mLeftKeys); + assertEquals("5 key auto 3 L0 right", 3, params.mRightKeys); + assertEquals("5 key auto 3 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 3 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key auto 3 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key auto 3 L0 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key auto 3 L0 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key auto 3 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 3 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [4] [5] + // |___ <1> [2] [3] + @Test + public void testLayout5KeyAuto3L1() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L1); + assertEquals("5 key auto 3 L1 columns", 3, params.mNumColumns); + assertEquals("5 key auto 3 L1 rows", 2, params.mNumRows); + assertEquals("5 key auto 3 L1 left", 0, params.mLeftKeys); + assertEquals("5 key auto 3 L1 right", 3, params.mRightKeys); + assertEquals("5 key auto 3 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 3 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key auto 3 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key auto 3 L1 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key auto 3 L1 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key auto 3 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 3 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [4] [5] + // |___ [3] <1> [2] + @Test + public void testLayout5KeyAuto3L2() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L2); + assertEquals("5 key auto 3 L2 columns", 3, params.mNumColumns); + assertEquals("5 key auto 3 L2 rows", 2, params.mNumRows); + assertEquals("5 key auto 3 L2 left", 1, params.mLeftKeys); + assertEquals("5 key auto 3 L2 right", 2, params.mRightKeys); + assertEquals("5 key auto 3 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 3 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key auto 3 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key auto 3 L2 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key auto 3 L2 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key auto 3 L2 adjust", -1, params.mTopRowAdjustment); + assertEquals("5 key auto 3 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [5] [4]| + // [3] [2] <1>| + @Test + public void testLayout5KeyAuto3R0() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R0); + assertEquals("5 key auto 3 R0 columns", 3, params.mNumColumns); + assertEquals("5 key auto 3 R0 rows", 2, params.mNumRows); + assertEquals("5 key auto 3 R0 left", 2, params.mLeftKeys); + assertEquals("5 key auto 3 R0 right", 1, params.mRightKeys); + assertEquals("5 key auto 3 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 3 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("5 key auto 3 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("5 key auto 3 R0 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key auto 3 R0 [5]", -1, params.getColumnPos(4)); + assertEquals("5 key auto 3 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 3 R0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [5] [4] ___| + // [3] [2] <1> ___| + @Test + public void testLayout5KeyAuto3R1() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R1); + assertEquals("5 key auto 3 R1 columns", 3, params.mNumColumns); + assertEquals("5 key auto 3 R1 rows", 2, params.mNumRows); + assertEquals("5 key auto 3 R1 left", 2, params.mLeftKeys); + assertEquals("5 key auto 3 R1 right", 1, params.mRightKeys); + assertEquals("5 key auto 3 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 3 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("5 key auto 3 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("5 key auto 3 R1 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key auto 3 R1 [5]", -1, params.getColumnPos(4)); + assertEquals("5 key auto 3 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 3 R1 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [4] [5] ___| + // [3] <1> [2] ___| + @Test + public void testLayout5KeyAuto3R2() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R2); + assertEquals("5 key auto 3 R2 columns", 3, params.mNumColumns); + assertEquals("5 key auto 3 R2 rows", 2, params.mNumRows); + assertEquals("5 key auto 3 R2 left", 1, params.mLeftKeys); + assertEquals("5 key auto 3 R2 right", 2, params.mRightKeys); + assertEquals("5 key auto 3 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 3 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key auto 3 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key auto 3 R2 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key auto 3 R2 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key auto 3 R2 adjust", -1, params.mTopRowAdjustment); + assertEquals("5 key auto 3 R2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [5] + // [3] <1> [2] [4] + @Test + public void testLayout5KeyAuto4M0() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_M0); + assertEquals("5 key auto 4 M0 columns", 4, params.mNumColumns); + assertEquals("5 key auto 4 M0 rows", 2, params.mNumRows); + assertEquals("5 key auto 4 M0 left", 1, params.mLeftKeys); + assertEquals("5 key auto 4 M0 right", 3, params.mRightKeys); + assertEquals("5 key auto 4 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 4 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key auto 4 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key auto 4 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("5 key auto 4 M0 [5]", 0, params.getColumnPos(4)); + assertEquals("5 key auto 4 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 4 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[5] + // |<1> [2] [3] [4] + @Test + public void testLayout5KeyAuto4L0() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L0); + assertEquals("5 key auto 4 L0 columns", 4, params.mNumColumns); + assertEquals("5 key auto 4 L0 rows", 2, params.mNumRows); + assertEquals("5 key auto 4 L0 left", 0, params.mLeftKeys); + assertEquals("5 key auto 4 L0 right", 4, params.mRightKeys); + assertEquals("5 key auto 4 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 4 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key auto 4 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key auto 4 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("5 key auto 4 L0 [5]", 0, params.getColumnPos(4)); + assertEquals("5 key auto 4 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 4 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [5] + // |___ <1> [2] [3] [4] + @Test + public void testLayout5KeyAuto4L1() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L1); + assertEquals("5 key auto 4 L1 columns", 4, params.mNumColumns); + assertEquals("5 key auto 4 L1 rows", 2, params.mNumRows); + assertEquals("5 key auto 4 L1 left", 0, params.mLeftKeys); + assertEquals("5 key auto 4 L1 right", 4, params.mRightKeys); + assertEquals("5 key auto 4 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 4 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key auto 4 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key auto 4 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("5 key auto 4 L1 [5]", 0, params.getColumnPos(4)); + assertEquals("5 key auto 4 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 4 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [5] + // |___ [3] <1> [2] [4] + @Test + public void testLayout5KeyAuto4L2() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L2); + assertEquals("5 key auto 4 L2 columns", 4, params.mNumColumns); + assertEquals("5 key auto 4 L2 rows", 2, params.mNumRows); + assertEquals("5 key auto 4 L2 left", 1, params.mLeftKeys); + assertEquals("5 key auto 4 L2 right", 3, params.mRightKeys); + assertEquals("5 key auto 4 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 4 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key auto 4 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key auto 4 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("5 key auto 4 L2 [5]", 0, params.getColumnPos(4)); + assertEquals("5 key auto 4 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 4 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [5]| + // [4] [3] [2] <1>| + @Test + public void testLayout5KeyAuto4R0() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R0); + assertEquals("5 key auto 4 R0 columns", 4, params.mNumColumns); + assertEquals("5 key auto 4 R0 rows", 2, params.mNumRows); + assertEquals("5 key auto 4 R0 left", 3, params.mLeftKeys); + assertEquals("5 key auto 4 R0 right", 1, params.mRightKeys); + assertEquals("5 key auto 4 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 4 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("5 key auto 4 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("5 key auto 4 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("5 key auto 4 R0 [5]", 0, params.getColumnPos(4)); + assertEquals("5 key auto 4 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 4 R0 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [5] ___| + // [4] [3] [2] <1> ___| + @Test + public void testLayout5KeyAuto4R1() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R1); + assertEquals("5 key auto 4 R1 columns", 4, params.mNumColumns); + assertEquals("5 key auto 4 R1 rows", 2, params.mNumRows); + assertEquals("5 key auto 4 R1 left", 3, params.mLeftKeys); + assertEquals("5 key auto 4 R1 right", 1, params.mRightKeys); + assertEquals("5 key auto 4 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 4 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("5 key auto 4 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("5 key auto 4 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("5 key auto 4 R1 [5]", 0, params.getColumnPos(4)); + assertEquals("5 key auto 4 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 4 R1 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [5] ___| + // [4] [3] <1> [2] ___| + @Test + public void testLayout5KeyAuto4R2() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R2); + assertEquals("5 key auto 4 R2 columns", 4, params.mNumColumns); + assertEquals("5 key auto 4 R2 rows", 2, params.mNumRows); + assertEquals("5 key auto 4 R2 left", 2, params.mLeftKeys); + assertEquals("5 key auto 4 R2 right", 2, params.mRightKeys); + assertEquals("5 key auto 4 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 4 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key auto 4 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key auto 4 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("5 key auto 4 R2 [5]", 0, params.getColumnPos(4)); + assertEquals("5 key auto 4 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 4 R2 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [5] [3] <1> [2] [4] + @Test + public void testLayout5KeyAuto5M0() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_M0); + assertEquals("5 key auto 5 M0 columns", 5, params.mNumColumns); + assertEquals("5 key auto 5 M0 rows", 1, params.mNumRows); + assertEquals("5 key auto 5 M0 left", 2, params.mLeftKeys); + assertEquals("5 key auto 5 M0 right", 3, params.mRightKeys); + assertEquals("5 key auto 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key auto 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key auto 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("5 key auto 5 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("5 key auto 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |<1> [2] [3] [4] [5] + @Test + public void testLayout5KeyAuto5L0() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L0); + assertEquals("5 key auto 5 L0 columns", 5, params.mNumColumns); + assertEquals("5 key auto 5 L0 rows", 1, params.mNumRows); + assertEquals("5 key auto 5 L0 left", 0, params.mLeftKeys); + assertEquals("5 key auto 5 L0 right", 5, params.mRightKeys); + assertEquals("5 key auto 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key auto 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key auto 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("5 key auto 5 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("5 key auto 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] [3] [4] [5] + @Test + public void testLayout5KeyAuto5L1() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L1); + assertEquals("5 key auto 5 L1 columns", 5, params.mNumColumns); + assertEquals("5 key auto 5 L1 rows", 1, params.mNumRows); + assertEquals("5 key auto 5 L1 left", 0, params.mLeftKeys); + assertEquals("5 key auto 5 L1 right", 5, params.mRightKeys); + assertEquals("5 key auto 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key auto 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key auto 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("5 key auto 5 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("5 key auto 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [3] <1> [2] [4] [5] + @Test + public void testLayout5KeyAuto5L2() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L2); + assertEquals("5 key auto 5 L2 columns", 5, params.mNumColumns); + assertEquals("5 key auto 5 L2 rows", 1, params.mNumRows); + assertEquals("5 key auto 5 L2 left", 1, params.mLeftKeys); + assertEquals("5 key auto 5 L2 right", 4, params.mRightKeys); + assertEquals("5 key auto 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key auto 5 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key auto 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("5 key auto 5 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("5 key auto 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [5] [4] [3] [2] <1>| + @Test + public void testLayout5KeyAuto5R0() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R0); + assertEquals("5 key auto 5 R0 columns", 5, params.mNumColumns); + assertEquals("5 key auto 5 R0 rows", 1, params.mNumRows); + assertEquals("5 key auto 5 R0 left", 4, params.mLeftKeys); + assertEquals("5 key auto 5 R0 right", 1, params.mRightKeys); + assertEquals("5 key auto 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("5 key auto 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("5 key auto 5 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("5 key auto 5 R0 [5]", -4, params.getColumnPos(4)); + assertEquals("5 key auto 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 5 R0 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [5] [4] [3] [2] <1> ___| + @Test + public void testLayout5KeyAuto5R1() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R1); + assertEquals("5 key auto 5 R1 columns", 5, params.mNumColumns); + assertEquals("5 key auto 5 R1 rows", 1, params.mNumRows); + assertEquals("5 key auto 5 R1 left", 4, params.mLeftKeys); + assertEquals("5 key auto 5 R1 right", 1, params.mRightKeys); + assertEquals("5 key auto 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("5 key auto 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("5 key auto 5 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("5 key auto 5 R1 [5]", -4, params.getColumnPos(4)); + assertEquals("5 key auto 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 5 R1 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [5] [4] [3] <1> [2] ___| + @Test + public void testLayout5KeyAuto5R2() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R2); + assertEquals("5 key auto 5 R2 columns", 5, params.mNumColumns); + assertEquals("5 key auto 5 R2 rows", 1, params.mNumRows); + assertEquals("5 key auto 5 R2 left", 3, params.mLeftKeys); + assertEquals("5 key auto 5 R2 right", 2, params.mRightKeys); + assertEquals("5 key auto 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key auto 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key auto 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key auto 5 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("5 key auto 5 R2 [5]", -3, params.getColumnPos(4)); + assertEquals("5 key auto 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key auto 5 R2 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [5] [6] + // [3] <1> [2] [4] + @Test + public void testLayout6KeyAuto4M0() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_M0); + assertEquals("6 key auto 4 M0 columns", 4, params.mNumColumns); + assertEquals("6 key auto 4 M0 rows", 2, params.mNumRows); + assertEquals("6 key auto 4 M0 left", 1, params.mLeftKeys); + assertEquals("6 key auto 4 M0 right", 3, params.mRightKeys); + assertEquals("6 key auto 4 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key auto 4 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key auto 4 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("6 key auto 4 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("6 key auto 4 M0 [5]", 0, params.getColumnPos(4)); + assertEquals("6 key auto 4 M0 [6]", 1, params.getColumnPos(5)); + assertEquals("6 key auto 4 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key auto 4 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[5] [6] + // |<1> [2] [3] [4] + @Test + public void testLayout6KeyAuto4L0() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L0); + assertEquals("6 key auto 4 L0 columns", 4, params.mNumColumns); + assertEquals("6 key auto 4 L0 rows", 2, params.mNumRows); + assertEquals("6 key auto 4 L0 left", 0, params.mLeftKeys); + assertEquals("6 key auto 4 L0 right", 4, params.mRightKeys); + assertEquals("6 key auto 4 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key auto 4 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key auto 4 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("6 key auto 4 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("6 key auto 4 L0 [5]", 0, params.getColumnPos(4)); + assertEquals("6 key auto 4 L0 [6]", 1, params.getColumnPos(5)); + assertEquals("6 key auto 4 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key auto 4 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [5] [6] + // |___ <1> [2] [3] [4] + @Test + public void testLayout6KeyAuto4L1() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L1); + assertEquals("6 key auto 4 L1 columns", 4, params.mNumColumns); + assertEquals("6 key auto 4 L1 rows", 2, params.mNumRows); + assertEquals("6 key auto 4 L1 left", 0, params.mLeftKeys); + assertEquals("6 key auto 4 L1 right", 4, params.mRightKeys); + assertEquals("6 key auto 4 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key auto 4 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key auto 4 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("6 key auto 4 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("6 key auto 4 L1 [5]", 0, params.getColumnPos(4)); + assertEquals("6 key auto 4 L1 [6]", 1, params.getColumnPos(5)); + assertEquals("6 key auto 4 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key auto 4 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [5] [6] + // |___ [3] <1> [2] [4] + @Test + public void testLayout6KeyAuto4L2() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L2); + assertEquals("6 key auto 4 L2 columns", 4, params.mNumColumns); + assertEquals("6 key auto 4 L2 rows", 2, params.mNumRows); + assertEquals("6 key auto 4 L2 left", 1, params.mLeftKeys); + assertEquals("6 key auto 4 L2 right", 3, params.mRightKeys); + assertEquals("6 key auto 4 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key auto 4 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key auto 4 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("6 key auto 4 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("6 key auto 4 L2 [5]", 0, params.getColumnPos(4)); + assertEquals("6 key auto 4 L2 [6]", 1, params.getColumnPos(5)); + assertEquals("6 key auto 4 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key auto 4 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [6] [5]| + // [4] [3] [2] <1>| + @Test + public void testLayout6KeyAuto4R0() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R0); + assertEquals("6 key auto 4 R0 columns", 4, params.mNumColumns); + assertEquals("6 key auto 4 R0 rows", 2, params.mNumRows); + assertEquals("6 key auto 4 R0 left", 3, params.mLeftKeys); + assertEquals("6 key auto 4 R0 right", 1, params.mRightKeys); + assertEquals("6 key auto 4 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key auto 4 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("6 key auto 4 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("6 key auto 4 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("6 key auto 4 R0 [5]", 0, params.getColumnPos(4)); + assertEquals("6 key auto 4 R0 [6]", -1, params.getColumnPos(5)); + assertEquals("6 key auto 4 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key auto 4 R0 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [6] [5] ___| + // [4] [3] [2] <1> ___| + @Test + public void testLayout6KeyAuto4R1() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R1); + assertEquals("6 key auto 4 R1 columns", 4, params.mNumColumns); + assertEquals("6 key auto 4 R1 rows", 2, params.mNumRows); + assertEquals("6 key auto 4 R1 left", 3, params.mLeftKeys); + assertEquals("6 key auto 4 R1 right", 1, params.mRightKeys); + assertEquals("6 key auto 4 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key auto 4 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("6 key auto 4 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("6 key auto 4 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("6 key auto 4 R1 [5]", 0, params.getColumnPos(4)); + assertEquals("6 key auto 4 R1 [6]", -1, params.getColumnPos(5)); + assertEquals("6 key auto 4 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key auto 4 R1 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [5] [6] ___| + // [4] [3] <1> [2] ___| + @Test + public void testLayout6KeyAuto4R2() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R2); + assertEquals("6 key auto 4 R2 columns", 4, params.mNumColumns); + assertEquals("6 key auto 4 R2 rows", 2, params.mNumRows); + assertEquals("6 key auto 4 R2 left", 2, params.mLeftKeys); + assertEquals("6 key auto 4 R2 right", 2, params.mRightKeys); + assertEquals("6 key auto 4 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key auto 4 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key auto 4 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("6 key auto 4 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("6 key auto 4 R2 [5]", 0, params.getColumnPos(4)); + assertEquals("6 key auto 4 R2 [6]", 1, params.getColumnPos(5)); + assertEquals("6 key auto 4 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key auto 4 R2 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [6] + // [5] [3] <1> [2] [4] + @Test + public void testLayout6KeyAuto5M0() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_M0); + assertEquals("6 key auto 5 M0 columns", 5, params.mNumColumns); + assertEquals("6 key auto 5 M0 rows", 2, params.mNumRows); + assertEquals("6 key auto 5 M0 left", 2, params.mLeftKeys); + assertEquals("6 key auto 5 M0 right", 3, params.mRightKeys); + assertEquals("6 key auto 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key auto 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key auto 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("6 key auto 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("6 key auto 5 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("6 key auto 5 M0 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key auto 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key auto 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |[6] + // |<1> [2] [3] [4] [5] + @Test + public void testLayout6KeyAuto5L0() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L0); + assertEquals("6 key auto 5 L0 columns", 5, params.mNumColumns); + assertEquals("6 key auto 5 L0 rows", 2, params.mNumRows); + assertEquals("6 key auto 5 L0 left", 0, params.mLeftKeys); + assertEquals("6 key auto 5 L0 right", 5, params.mRightKeys); + assertEquals("6 key auto 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key auto 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key auto 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("6 key auto 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("6 key auto 5 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("6 key auto 5 L0 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key auto 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key auto 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] + // |___ <1> [2] [3] [4] [5] + @Test + public void testLayout6KeyAuto5L1() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L1); + assertEquals("6 key auto 5 L1 columns", 5, params.mNumColumns); + assertEquals("6 key auto 5 L1 rows", 2, params.mNumRows); + assertEquals("6 key auto 5 L1 left", 0, params.mLeftKeys); + assertEquals("6 key auto 5 L1 right", 5, params.mRightKeys); + assertEquals("6 key auto 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key auto 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key auto 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("6 key auto 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("6 key auto 5 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("6 key auto 5 L1 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key auto 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key auto 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] + // |___ [3] <1> [2] [4] [5] + @Test + public void testLayout6KeyAuto5L2() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L2); + assertEquals("6 key auto 5 L2 columns", 5, params.mNumColumns); + assertEquals("6 key auto 5 L2 rows", 2, params.mNumRows); + assertEquals("6 key auto 5 L2 left", 1, params.mLeftKeys); + assertEquals("6 key auto 5 L2 right", 4, params.mRightKeys); + assertEquals("6 key auto 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key auto 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key auto 5 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("6 key auto 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("6 key auto 5 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("6 key auto 5 L2 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key auto 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key auto 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [6]| + // [5] [4] [3] [2] <1>| + @Test + public void testLayout6KeyAuto5R0() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R0); + assertEquals("6 key auto 5 R0 columns", 5, params.mNumColumns); + assertEquals("6 key auto 5 R0 rows", 2, params.mNumRows); + assertEquals("6 key auto 5 R0 left", 4, params.mLeftKeys); + assertEquals("6 key auto 5 R0 right", 1, params.mRightKeys); + assertEquals("6 key auto 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key auto 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("6 key auto 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("6 key auto 5 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("6 key auto 5 R0 [5]", -4, params.getColumnPos(4)); + assertEquals("6 key auto 5 R0 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key auto 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key auto 5 R0 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [6] ___| + // [5] [4] [3] [2] <1> ___| + @Test + public void testLayout6KeyAuto5R1() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R1); + assertEquals("6 key auto 5 R1 columns", 5, params.mNumColumns); + assertEquals("6 key auto 5 R1 rows", 2, params.mNumRows); + assertEquals("6 key auto 5 R1 left", 4, params.mLeftKeys); + assertEquals("6 key auto 5 R1 right", 1, params.mRightKeys); + assertEquals("6 key auto 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key auto 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("6 key auto 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("6 key auto 5 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("6 key auto 5 R1 [5]", -4, params.getColumnPos(4)); + assertEquals("6 key auto 5 R1 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key auto 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key auto 5 R1 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [6] ___| + // [5] [4] [3] <1> [2] ___| + @Test + public void testLayout6KeyAuto5R2() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R2); + assertEquals("6 key auto 5 R2 columns", 5, params.mNumColumns); + assertEquals("6 key auto 5 R2 rows", 2, params.mNumRows); + assertEquals("6 key auto 5 R2 left", 3, params.mLeftKeys); + assertEquals("6 key auto 5 R2 right", 2, params.mRightKeys); + assertEquals("6 key auto 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key auto 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key auto 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("6 key auto 5 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("6 key auto 5 R2 [5]", -3, params.getColumnPos(4)); + assertEquals("6 key auto 5 R2 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key auto 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key auto 5 R2 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // |<1> [2] [3] [4] [5] [6] [7] ___ ___ ___| + @Test + public void testLayout7KeyAuto7L0() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L0); + assertEquals("7 key auto 7 L0 columns", 7, params.mNumColumns); + assertEquals("7 key auto 7 L0 rows", 1, params.mNumRows); + assertEquals("7 key auto 7 L0 left", 0, params.mLeftKeys); + assertEquals("7 key auto 7 L0 right", 7, params.mRightKeys); + assertEquals("7 key auto 7 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 7 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 7 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key auto 7 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("7 key auto 7 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("7 key auto 7 L0 [6]", 5, params.getColumnPos(5)); + assertEquals("7 key auto 7 L0 [7]", 6, params.getColumnPos(6)); + assertEquals("7 key auto 7 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 7 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] [3] [4] [5] [6] [7] ___ ___| + @Test + public void testLayout7KeyAuto7L1() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L1); + assertEquals("7 key auto 7 L1 columns", 7, params.mNumColumns); + assertEquals("7 key auto 7 L1 rows", 1, params.mNumRows); + assertEquals("7 key auto 7 L1 left", 0, params.mLeftKeys); + assertEquals("7 key auto 7 L1 right", 7, params.mRightKeys); + assertEquals("7 key auto 7 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 7 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 7 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key auto 7 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("7 key auto 7 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("7 key auto 7 L1 [6]", 5, params.getColumnPos(5)); + assertEquals("7 key auto 7 L1 [7]", 6, params.getColumnPos(6)); + assertEquals("7 key auto 7 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 7 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [3] <1> [2] [4] [5] [6] [7] ___ ___| + @Test + public void testLayout7KeyAuto7L2() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L2); + assertEquals("7 key auto 7 L2 columns", 7, params.mNumColumns); + assertEquals("7 key auto 7 L2 rows", 1, params.mNumRows); + assertEquals("7 key auto 7 L2 left", 1, params.mLeftKeys); + assertEquals("7 key auto 7 L2 right", 6, params.mRightKeys); + assertEquals("7 key auto 7 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 7 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 7 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key auto 7 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key auto 7 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("7 key auto 7 L2 [6]", 4, params.getColumnPos(5)); + assertEquals("7 key auto 7 L2 [7]", 5, params.getColumnPos(6)); + assertEquals("7 key auto 7 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 7 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |___ [5] [3] <1> [2] [4] [6] [7] ___ ___| + @Test + public void testLayout7KeyAuto7L3() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L3); + assertEquals("7 key auto 7 L3 columns", 7, params.mNumColumns); + assertEquals("7 key auto 7 L3 rows", 1, params.mNumRows); + assertEquals("7 key auto 7 L3 left", 2, params.mLeftKeys); + assertEquals("7 key auto 7 L3 right", 5, params.mRightKeys); + assertEquals("7 key auto 7 L3 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 7 L3 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 7 L3 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key auto 7 L3 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key auto 7 L3 [5]", -2, params.getColumnPos(4)); + assertEquals("7 key auto 7 L3 [6]", 3, params.getColumnPos(5)); + assertEquals("7 key auto 7 L3 [7]", 4, params.getColumnPos(6)); + assertEquals("7 key auto 7 L3 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 7 L3 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |___ [7] [5] [3] <1> [2] [4] [6] ___ ___| + @Test + public void testLayout7KeyAuto7M0() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_M0); + assertEquals("7 key auto 7 M0 columns", 7, params.mNumColumns); + assertEquals("7 key auto 7 M0 rows", 1, params.mNumRows); + assertEquals("7 key auto 7 M0 left", 3, params.mLeftKeys); + assertEquals("7 key auto 7 M0 right", 4, params.mRightKeys); + assertEquals("7 key auto 7 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 7 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 7 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key auto 7 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key auto 7 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("7 key auto 7 M0 [6]", 3, params.getColumnPos(5)); + assertEquals("7 key auto 7 M0 [7]", -3, params.getColumnPos(6)); + assertEquals("7 key auto 7 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 7 M0 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // |___ ___ [7] [5] [3] <1> [2] [4] [6] ___| + @Test + public void testLayout7KeyAuto7M1() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_M1); + assertEquals("7 key auto 7 M1 columns", 7, params.mNumColumns); + assertEquals("7 key auto 7 M1 rows", 1, params.mNumRows); + assertEquals("7 key auto 7 M1 left", 3, params.mLeftKeys); + assertEquals("7 key auto 7 M1 right", 4, params.mRightKeys); + assertEquals("7 key auto 7 M1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 7 M1 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 7 M1 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key auto 7 M1 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key auto 7 M1 [5]", -2, params.getColumnPos(4)); + assertEquals("7 key auto 7 M1 [6]", 3, params.getColumnPos(5)); + assertEquals("7 key auto 7 M1 [7]", -3, params.getColumnPos(6)); + assertEquals("7 key auto 7 M1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 7 M1 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // |___ ___ [7] [6] [5] [3] <1> [2] [4] ___| + @Test + public void testLayout7KeyAuto7R3() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R3); + assertEquals("7 key auto 7 R3 columns", 7, params.mNumColumns); + assertEquals("7 key auto 7 R3 rows", 1, params.mNumRows); + assertEquals("7 key auto 7 R3 left", 4, params.mLeftKeys); + assertEquals("7 key auto 7 R3 right", 3, params.mRightKeys); + assertEquals("7 key auto 7 R3 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 7 R3 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 7 R3 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key auto 7 R3 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key auto 7 R3 [5]", -2, params.getColumnPos(4)); + assertEquals("7 key auto 7 R3 [6]", -3, params.getColumnPos(5)); + assertEquals("7 key auto 7 R3 [7]", -4, params.getColumnPos(6)); + assertEquals("7 key auto 7 R3 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 7 R3 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // |___ ___ [7] [6] [5] [4] [3] <1> [2] ___| + @Test + public void testLayout7KeyAuto7R2() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R2); + assertEquals("7 key auto 7 R2 columns", 7, params.mNumColumns); + assertEquals("7 key auto 7 R2 rows", 1, params.mNumRows); + assertEquals("7 key auto 7 R2 left", 5, params.mLeftKeys); + assertEquals("7 key auto 7 R2 right", 2, params.mRightKeys); + assertEquals("7 key auto 7 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 7 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 7 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key auto 7 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("7 key auto 7 R2 [5]", -3, params.getColumnPos(4)); + assertEquals("7 key auto 7 R2 [6]", -4, params.getColumnPos(5)); + assertEquals("7 key auto 7 R2 [7]", -5, params.getColumnPos(6)); + assertEquals("7 key auto 7 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 7 R2 default", WIDTH * 5, params.getDefaultKeyCoordX()); + } + + // |___ ___ [7] [6] [5] [4] [3] [2] <1> ___| + @Test + public void testLayout7KeyAuto7R1() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R1); + assertEquals("7 key auto 7 R1 columns", 7, params.mNumColumns); + assertEquals("7 key auto 7 R1 rows", 1, params.mNumRows); + assertEquals("7 key auto 7 R1 left", 6, params.mLeftKeys); + assertEquals("7 key auto 7 R1 right", 1, params.mRightKeys); + assertEquals("7 key auto 7 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 7 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("7 key auto 7 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("7 key auto 7 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("7 key auto 7 R1 [5]", -4, params.getColumnPos(4)); + assertEquals("7 key auto 7 R1 [6]", -5, params.getColumnPos(5)); + assertEquals("7 key auto 7 R1 [7]", -6, params.getColumnPos(6)); + assertEquals("7 key auto 7 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 7 R1 default", WIDTH * 6, params.getDefaultKeyCoordX()); + } + + // |___ ___ [7] [6] [5] [4] [3] [2] <1>| + @Test + public void testLayout7KeyAuto7R0() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R0); + assertEquals("7 key auto 7 R0 columns", 7, params.mNumColumns); + assertEquals("7 key auto 7 R0 rows", 1, params.mNumRows); + assertEquals("7 key auto 7 R0 left", 6, params.mLeftKeys); + assertEquals("7 key auto 7 R0 right", 1, params.mRightKeys); + assertEquals("7 key auto 7 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 7 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("7 key auto 7 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("7 key auto 7 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("7 key auto 7 R0 [5]", -4, params.getColumnPos(4)); + assertEquals("7 key auto 7 R0 [6]", -5, params.getColumnPos(5)); + assertEquals("7 key auto 7 R0 [7]", -6, params.getColumnPos(6)); + assertEquals("7 key auto 7 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 7 R0 default", WIDTH * 6, params.getDefaultKeyCoordX()); + } + + // [6] [7] + // [5] [3] <1> [2] [4] + @Test + public void testLayout7KeyAuto5M0() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_M0); + assertEquals("7 key auto 5 M0 columns", 5, params.mNumColumns); + assertEquals("7 key auto 5 M0 rows", 2, params.mNumRows); + assertEquals("7 key auto 5 M0 left", 2, params.mLeftKeys); + assertEquals("7 key auto 5 M0 right", 3, params.mRightKeys); + assertEquals("7 key auto 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key auto 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key auto 5 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("7 key auto 5 M0 [6]", 0, params.getColumnPos(5)); + assertEquals("7 key auto 5 M0 [7]", 1, params.getColumnPos(6)); + assertEquals("7 key auto 5 M0 adjust", -1, params.mTopRowAdjustment); + assertEquals("7 key auto 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |[6] [7] + // |<1> [2] [3] [4] [5] + @Test + public void testLayout7KeyAuto5L0() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L0); + assertEquals("7 key auto 5 L0 columns", 5, params.mNumColumns); + assertEquals("7 key auto 5 L0 rows", 2, params.mNumRows); + assertEquals("7 key auto 5 L0 left", 0, params.mLeftKeys); + assertEquals("7 key auto 5 L0 right", 5, params.mRightKeys); + assertEquals("7 key auto 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key auto 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("7 key auto 5 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("7 key auto 5 L0 [6]", 0, params.getColumnPos(5)); + assertEquals("7 key auto 5 L0 [7]", 1, params.getColumnPos(6)); + assertEquals("7 key auto 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] + // |___ <1> [2] [3] [4] [5] + @Test + public void testLayout7KeyAuto5L1() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L1); + assertEquals("7 key auto 5 L1 columns", 5, params.mNumColumns); + assertEquals("7 key auto 5 L1 rows", 2, params.mNumRows); + assertEquals("7 key auto 5 L1 left", 0, params.mLeftKeys); + assertEquals("7 key auto 5 L1 right", 5, params.mRightKeys); + assertEquals("7 key auto 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key auto 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("7 key auto 5 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("7 key auto 5 L1 [6]", 0, params.getColumnPos(5)); + assertEquals("7 key auto 5 L1 [7]", 1, params.getColumnPos(6)); + assertEquals("7 key auto 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] + // |___ [3] <1> [2] [4] [5] + @Test + public void testLayout7KeyAuto5L2() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L2); + assertEquals("7 key auto 5 L2 columns", 5, params.mNumColumns); + assertEquals("7 key auto 5 L2 rows", 2, params.mNumRows); + assertEquals("7 key auto 5 L2 left", 1, params.mLeftKeys); + assertEquals("7 key auto 5 L2 right", 4, params.mRightKeys); + assertEquals("7 key auto 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 5 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key auto 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key auto 5 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("7 key auto 5 L2 [6]", 0, params.getColumnPos(5)); + assertEquals("7 key auto 5 L2 [7]", 1, params.getColumnPos(6)); + assertEquals("7 key auto 5 L2 adjust", -1, params.mTopRowAdjustment); + assertEquals("7 key auto 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [7] [6]| + // [5] [4] [3] [2] <1>| + @Test + public void testLayout7KeyAuto5R0() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R0); + assertEquals("7 key auto 5 R0 columns", 5, params.mNumColumns); + assertEquals("7 key auto 5 R0 rows", 2, params.mNumRows); + assertEquals("7 key auto 5 R0 left", 4, params.mLeftKeys); + assertEquals("7 key auto 5 R0 right", 1, params.mRightKeys); + assertEquals("7 key auto 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("7 key auto 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("7 key auto 5 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("7 key auto 5 R0 [5]", -4, params.getColumnPos(4)); + assertEquals("7 key auto 5 R0 [6]", 0, params.getColumnPos(5)); + assertEquals("7 key auto 5 R0 [7]", -1, params.getColumnPos(6)); + assertEquals("7 key auto 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 5 R0 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [7] [6] ___| + // [5] [4] [3] [2] <1> ___| + @Test + public void testLayout7KeyAuto5R1() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R1); + assertEquals("7 key auto 5 R1 columns", 5, params.mNumColumns); + assertEquals("7 key auto 5 R1 rows", 2, params.mNumRows); + assertEquals("7 key auto 5 R1 left", 4, params.mLeftKeys); + assertEquals("7 key auto 5 R1 right", 1, params.mRightKeys); + assertEquals("7 key auto 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("7 key auto 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("7 key auto 5 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("7 key auto 5 R1 [5]", -4, params.getColumnPos(4)); + assertEquals("7 key auto 5 R1 [6]", 0, params.getColumnPos(5)); + assertEquals("7 key auto 5 R1 [7]", -1, params.getColumnPos(6)); + assertEquals("7 key auto 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 5 R1 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [6] [7] ___| + // [5] [4] [3] <1> [2] ___| + @Test + public void testLayout7KeyAuto5R2() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R2); + assertEquals("7 key auto 5 R2 columns", 5, params.mNumColumns); + assertEquals("7 key auto 5 R2 rows", 2, params.mNumRows); + assertEquals("7 key auto 5 R2 left", 3, params.mLeftKeys); + assertEquals("7 key auto 5 R2 right", 2, params.mRightKeys); + assertEquals("7 key auto 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key auto 5 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("7 key auto 5 R2 [5]", -3, params.getColumnPos(4)); + assertEquals("7 key auto 5 R2 [6]", 0, params.getColumnPos(5)); + assertEquals("7 key auto 5 R2 [7]", 1, params.getColumnPos(6)); + assertEquals("7 key auto 5 R2 adjust", -1, params.mTopRowAdjustment); + assertEquals("7 key auto 5 R2 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [7] + // [6] [4] [5] + // [3] <1> [2] + @Test + public void testLayout7KeyAuto3M0() { + MoreKeysKeyboardParams params = createParams(7, 3, XPOS_M0); + assertEquals("7 key auto 3 M0 columns", 3, params.mNumColumns); + assertEquals("7 key auto 3 M0 rows", 3, params.mNumRows); + assertEquals("7 key auto 3 M0 left", 1, params.mLeftKeys); + assertEquals("7 key auto 3 M0 right", 2, params.mRightKeys); + assertEquals("7 key auto 3 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 3 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 3 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key auto 3 M0 [4]", 0, params.getColumnPos(3)); + assertEquals("7 key auto 3 M0 [5]", 1, params.getColumnPos(4)); + assertEquals("7 key auto 3 M0 [6]", -1, params.getColumnPos(5)); + assertEquals("7 key auto 3 M0 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key auto 3 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 3 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[7] + // |[4] [5] [6] + // |<1> [2] [3] + @Test + public void testLayout7KeyAuto3L0() { + MoreKeysKeyboardParams params = createParams(7, 3, XPOS_L0); + assertEquals("7 key auto 3 L0 columns", 3, params.mNumColumns); + assertEquals("7 key auto 3 L0 rows", 3, params.mNumRows); + assertEquals("7 key auto 3 L0 left", 0, params.mLeftKeys); + assertEquals("7 key auto 3 L0 right", 3, params.mRightKeys); + assertEquals("7 key auto 3 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 3 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 3 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key auto 3 L0 [4]", 0, params.getColumnPos(3)); + assertEquals("7 key auto 3 L0 [5]", 1, params.getColumnPos(4)); + assertEquals("7 key auto 3 L0 [6]", 2, params.getColumnPos(5)); + assertEquals("7 key auto 3 L0 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key auto 3 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 3 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [7] + // |___ [4] [5] [6] + // |___ <1> [2] [3] + @Test + public void testLayout7KeyAuto3L1() { + MoreKeysKeyboardParams params = createParams(7, 3, XPOS_L1); + assertEquals("7 key auto 3 L1 columns", 3, params.mNumColumns); + assertEquals("7 key auto 3 L1 rows", 3, params.mNumRows); + assertEquals("7 key auto 3 L1 left", 0, params.mLeftKeys); + assertEquals("7 key auto 3 L1 right", 3, params.mRightKeys); + assertEquals("7 key auto 3 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 3 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 3 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key auto 3 L1 [4]", 0, params.getColumnPos(3)); + assertEquals("7 key auto 3 L1 [5]", 1, params.getColumnPos(4)); + assertEquals("7 key auto 3 L1 [6]", 2, params.getColumnPos(5)); + assertEquals("7 key auto 3 L1 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key auto 3 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 3 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [7] + // |___ [6] [4] [5] + // |___ [3] <1> [2] + @Test + public void testLayout7KeyAuto3L2() { + MoreKeysKeyboardParams params = createParams(7, 3, XPOS_L2); + assertEquals("7 key auto 3 L2 columns", 3, params.mNumColumns); + assertEquals("7 key auto 3 L2 rows", 3, params.mNumRows); + assertEquals("7 key auto 3 L2 left", 1, params.mLeftKeys); + assertEquals("7 key auto 3 L2 right", 2, params.mRightKeys); + assertEquals("7 key auto 3 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 3 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 3 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key auto 3 L2 [4]", 0, params.getColumnPos(3)); + assertEquals("7 key auto 3 L2 [5]", 1, params.getColumnPos(4)); + assertEquals("7 key auto 3 L2 [6]", -1, params.getColumnPos(5)); + assertEquals("7 key auto 3 L2 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key auto 3 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 3 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [7]| + // [6] [5] [4]| + // [3] [2] <1>| + @Test + public void testLayout7KeyAuto3R0() { + MoreKeysKeyboardParams params = createParams(7, 3, XPOS_R0); + assertEquals("7 key auto 3 R0 columns", 3, params.mNumColumns); + assertEquals("7 key auto 3 R0 rows", 3, params.mNumRows); + assertEquals("7 key auto 3 R0 left", 2, params.mLeftKeys); + assertEquals("7 key auto 3 R0 right", 1, params.mRightKeys); + assertEquals("7 key auto 3 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 3 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("7 key auto 3 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("7 key auto 3 R0 [4]", 0, params.getColumnPos(3)); + assertEquals("7 key auto 3 R0 [5]", -1, params.getColumnPos(4)); + assertEquals("7 key auto 3 R0 [6]", -2, params.getColumnPos(5)); + assertEquals("7 key auto 3 R0 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key auto 3 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 3 R0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [7] ___| + // [6] [5] [4] ___| + // [3] [2] <1> ___| + @Test + public void testLayout7KeyAuto3R1() { + MoreKeysKeyboardParams params = createParams(7, 3, XPOS_R1); + assertEquals("7 key auto 3 R1 columns", 3, params.mNumColumns); + assertEquals("7 key auto 3 R1 rows", 3, params.mNumRows); + assertEquals("7 key auto 3 R1 left", 2, params.mLeftKeys); + assertEquals("7 key auto 3 R1 right", 1, params.mRightKeys); + assertEquals("7 key auto 3 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 3 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("7 key auto 3 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("7 key auto 3 R1 [4]", 0, params.getColumnPos(3)); + assertEquals("7 key auto 3 R1 [5]", -1, params.getColumnPos(4)); + assertEquals("7 key auto 3 R1 [6]", -2, params.getColumnPos(5)); + assertEquals("7 key auto 3 R1 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key auto 3 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 3 R1 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [7] ___| + // [6] [4] [5] ___| + // [3] <1> [2] ___| + @Test + public void testLayout7KeyAuto3R2() { + MoreKeysKeyboardParams params = createParams(7, 3, XPOS_R2); + assertEquals("7 key auto 3 R2 columns", 3, params.mNumColumns); + assertEquals("7 key auto 3 R2 rows", 3, params.mNumRows); + assertEquals("7 key auto 3 R2 left", 1, params.mLeftKeys); + assertEquals("7 key auto 3 R2 right", 2, params.mRightKeys); + assertEquals("7 key auto 3 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key auto 3 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key auto 3 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key auto 3 R2 [4]", 0, params.getColumnPos(3)); + assertEquals("7 key auto 3 R2 [5]", 1, params.getColumnPos(4)); + assertEquals("7 key auto 3 R2 [6]", -1, params.getColumnPos(5)); + assertEquals("7 key auto 3 R2 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key auto 3 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key auto 3 R2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [8] [6] [7] + // [5] [3] <1> [2] [4] + @Test + public void testLayout8KeyAuto5M0() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_M0); + assertEquals("8 key auto 5 M0 columns", 5, params.mNumColumns); + assertEquals("8 key auto 5 M0 rows", 2, params.mNumRows); + assertEquals("8 key auto 5 M0 left", 2, params.mLeftKeys); + assertEquals("8 key auto 5 M0 right", 3, params.mRightKeys); + assertEquals("8 key auto 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key auto 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("8 key auto 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("8 key auto 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("8 key auto 5 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("8 key auto 5 M0 [6]", 0, params.getColumnPos(5)); + assertEquals("8 key auto 5 M0 [7]", 1, params.getColumnPos(6)); + assertEquals("8 key auto 5 M0 [8]", -1, params.getColumnPos(7)); + assertEquals("8 key auto 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key auto 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |[6] [7] [8] + // |<1> [2] [3] [4] [5] + @Test + public void testLayout8KeyAuto5L0() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L0); + assertEquals("8 key auto 5 L0 columns", 5, params.mNumColumns); + assertEquals("8 key auto 5 L0 rows", 2, params.mNumRows); + assertEquals("8 key auto 5 L0 left", 0, params.mLeftKeys); + assertEquals("8 key auto 5 L0 right", 5, params.mRightKeys); + assertEquals("8 key auto 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key auto 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("8 key auto 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("8 key auto 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("8 key auto 5 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("8 key auto 5 L0 [6]", 0, params.getColumnPos(5)); + assertEquals("8 key auto 5 L0 [7]", 1, params.getColumnPos(6)); + assertEquals("8 key auto 5 L0 [8]", 2, params.getColumnPos(7)); + assertEquals("8 key auto 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key auto 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] [8] + // |___ <1> [2] [3] [4] [5] + @Test + public void testLayout8KeyAuto5L1() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L1); + assertEquals("8 key auto 5 L1 columns", 5, params.mNumColumns); + assertEquals("8 key auto 5 L1 rows", 2, params.mNumRows); + assertEquals("8 key auto 5 L1 left", 0, params.mLeftKeys); + assertEquals("8 key auto 5 L1 right", 5, params.mRightKeys); + assertEquals("8 key auto 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key auto 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("8 key auto 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("8 key auto 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("8 key auto 5 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("8 key auto 5 L1 [6]", 0, params.getColumnPos(5)); + assertEquals("8 key auto 5 L1 [7]", 1, params.getColumnPos(6)); + assertEquals("8 key auto 5 L1 [8]", 2, params.getColumnPos(7)); + assertEquals("8 key auto 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key auto 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [8] [6] [7] + // |___ [3] <1> [2] [4] [5] + @Test + public void testLayout8KeyAuto5L2() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L2); + assertEquals("8 key auto 5 L2 columns", 5, params.mNumColumns); + assertEquals("8 key auto 5 L2 rows", 2, params.mNumRows); + assertEquals("8 key auto 5 L2 left", 1, params.mLeftKeys); + assertEquals("8 key auto 5 L2 right", 4, params.mRightKeys); + assertEquals("8 key auto 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key auto 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("8 key auto 5 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("8 key auto 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("8 key auto 5 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("8 key auto 5 L2 [6]", 0, params.getColumnPos(5)); + assertEquals("8 key auto 5 L2 [7]", 1, params.getColumnPos(6)); + assertEquals("8 key auto 5 L2 [8]", -1, params.getColumnPos(7)); + assertEquals("8 key auto 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key auto 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [8] [7] [6]| + // [5] [4] [3] [2] <1>| + @Test + public void testLayout8KeyAuto5R0() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R0); + assertEquals("8 key auto 5 R0 columns", 5, params.mNumColumns); + assertEquals("8 key auto 5 R0 rows", 2, params.mNumRows); + assertEquals("8 key auto 5 R0 left", 4, params.mLeftKeys); + assertEquals("8 key auto 5 R0 right", 1, params.mRightKeys); + assertEquals("8 key auto 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key auto 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("8 key auto 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("8 key auto 5 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("8 key auto 5 R0 [5]", -4, params.getColumnPos(4)); + assertEquals("8 key auto 5 R0 [6]", 0, params.getColumnPos(5)); + assertEquals("8 key auto 5 R0 [7]", -1, params.getColumnPos(6)); + assertEquals("8 key auto 5 R0 [8]", -2, params.getColumnPos(7)); + assertEquals("8 key auto 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key auto 5 R0 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [8] [7] [6] ___| + // [5] [4] [3] [2] <1> ___| + @Test + public void testLayout8KeyAuto5R1() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R1); + assertEquals("8 key auto 5 R1 columns", 5, params.mNumColumns); + assertEquals("8 key auto 5 R1 rows", 2, params.mNumRows); + assertEquals("8 key auto 5 R1 left", 4, params.mLeftKeys); + assertEquals("8 key auto 5 R1 right", 1, params.mRightKeys); + assertEquals("8 key auto 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key auto 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("8 key auto 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("8 key auto 5 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("8 key auto 5 R1 [5]", -4, params.getColumnPos(4)); + assertEquals("8 key auto 5 R1 [6]", 0, params.getColumnPos(5)); + assertEquals("8 key auto 5 R1 [7]", -1, params.getColumnPos(6)); + assertEquals("8 key auto 5 R1 [8]", -2, params.getColumnPos(7)); + assertEquals("8 key auto 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key auto 5 R1 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [8] [6] [7] ___| + // [5] [4] [3] <1> [2] ___| + @Test + public void testLayout8KeyAuto5R2() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R2); + assertEquals("8 key auto 5 R2 columns", 5, params.mNumColumns); + assertEquals("8 key auto 5 R2 rows", 2, params.mNumRows); + assertEquals("8 key auto 5 R2 left", 3, params.mLeftKeys); + assertEquals("8 key auto 5 R2 right", 2, params.mRightKeys); + assertEquals("8 key auto 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key auto 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("8 key auto 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("8 key auto 5 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("8 key auto 5 R2 [5]", -3, params.getColumnPos(4)); + assertEquals("8 key auto 5 R2 [6]", 0, params.getColumnPos(5)); + assertEquals("8 key auto 5 R2 [7]", 1, params.getColumnPos(6)); + assertEquals("8 key auto 5 R2 [8]", -1, params.getColumnPos(7)); + assertEquals("8 key auto 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key auto 5 R2 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [8] [6] [7] [9] + // [5] [3] <1> [2] [4] + @Test + public void testLayout9KeyAuto5M0() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_M0); + assertEquals("9 key auto 5 M0 columns", 5, params.mNumColumns); + assertEquals("9 key auto 5 M0 rows", 2, params.mNumRows); + assertEquals("9 key auto 5 M0 left", 2, params.mLeftKeys); + assertEquals("9 key auto 5 M0 right", 3, params.mRightKeys); + assertEquals("9 key auto 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("9 key auto 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("9 key auto 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("9 key auto 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("9 key auto 5 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("9 key auto 5 M0 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key auto 5 M0 [7]", 1, params.getColumnPos(6)); + assertEquals("9 key auto 5 M0 [8]", -1, params.getColumnPos(7)); + assertEquals("9 key auto 5 M0 [9]", 2, params.getColumnPos(8)); + assertEquals("9 key auto 5 M0 adjust", -1, params.mTopRowAdjustment); + assertEquals("9 key auto 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |[6] [7] [8] [9] + // |<1> [2] [3] [4] [5] + @Test + public void testLayout9KeyAuto5L0() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L0); + assertEquals("9 key auto 5 L0 columns", 5, params.mNumColumns); + assertEquals("9 key auto 5 L0 rows", 2, params.mNumRows); + assertEquals("9 key auto 5 L0 left", 0, params.mLeftKeys); + assertEquals("9 key auto 5 L0 right", 5, params.mRightKeys); + assertEquals("9 key auto 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("9 key auto 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("9 key auto 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("9 key auto 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("9 key auto 5 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("9 key auto 5 L0 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key auto 5 L0 [7]", 1, params.getColumnPos(6)); + assertEquals("9 key auto 5 L0 [8]", 2, params.getColumnPos(7)); + assertEquals("9 key auto 5 L0 [9]", 3, params.getColumnPos(8)); + assertEquals("9 key auto 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("9 key auto 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] [8] [9] + // |___ <1> [2] [3] [4] [5] + @Test + public void testLayout9KeyAuto5L1() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L1); + assertEquals("9 key auto 5 L1 columns", 5, params.mNumColumns); + assertEquals("9 key auto 5 L1 rows", 2, params.mNumRows); + assertEquals("9 key auto 5 L1 left", 0, params.mLeftKeys); + assertEquals("9 key auto 5 L1 right", 5, params.mRightKeys); + assertEquals("9 key auto 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("9 key auto 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("9 key auto 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("9 key auto 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("9 key auto 5 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("9 key auto 5 L1 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key auto 5 L1 [7]", 1, params.getColumnPos(6)); + assertEquals("9 key auto 5 L1 [8]", 2, params.getColumnPos(7)); + assertEquals("9 key auto 5 L1 [9]", 3, params.getColumnPos(8)); + assertEquals("9 key auto 5 L1 adjust",0, params.mTopRowAdjustment); + assertEquals("9 key auto 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] [8] [9] + // |___ [3] <1> [2] [4] [5] + @Test + public void testLayout9KeyAuto5L2() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L2); + assertEquals("9 key auto 5 L2 columns", 5, params.mNumColumns); + assertEquals("9 key auto 5 L2 rows", 2, params.mNumRows); + assertEquals("9 key auto 5 L2 left", 1, params.mLeftKeys); + assertEquals("9 key auto 5 L2 right", 4, params.mRightKeys); + assertEquals("9 key auto 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("9 key auto 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("9 key auto 5 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("9 key auto 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("9 key auto 5 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("9 key auto 5 L2 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key auto 5 L2 [7]", 1, params.getColumnPos(6)); + assertEquals("9 key auto 5 L2 [8]", 2, params.getColumnPos(7)); + assertEquals("9 key auto 5 L2 [9]", 3, params.getColumnPos(8)); + assertEquals("9 key auto 5 L2 adjust", -1, params.mTopRowAdjustment); + assertEquals("9 key auto 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [9] [8] [7] [6]| + // [5] [4] [3] [2] <1>| + @Test + public void testLayout9KeyAuto5R0() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R0); + assertEquals("9 key auto 5 R0 columns", 5, params.mNumColumns); + assertEquals("9 key auto 5 R0 rows", 2, params.mNumRows); + assertEquals("9 key auto 5 R0 left", 4, params.mLeftKeys); + assertEquals("9 key auto 5 R0 right", 1, params.mRightKeys); + assertEquals("9 key auto 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("9 key auto 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("9 key auto 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("9 key auto 5 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("9 key auto 5 R0 [5]", -4, params.getColumnPos(4)); + assertEquals("9 key auto 5 R0 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key auto 5 R0 [7]", -1, params.getColumnPos(6)); + assertEquals("9 key auto 5 R0 [8]", -2, params.getColumnPos(7)); + assertEquals("9 key auto 5 R0 [9]", -3, params.getColumnPos(8)); + assertEquals("9 key auto 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("9 key auto 5 R0 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [9] [8] [7] [6] ___| + // [5] [4] [3] [2] <1> ___| + @Test + public void testLayout9KeyAuto5R1() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R1); + assertEquals("9 key auto 5 R1 columns", 5, params.mNumColumns); + assertEquals("9 key auto 5 R1 rows", 2, params.mNumRows); + assertEquals("9 key auto 5 R1 left", 4, params.mLeftKeys); + assertEquals("9 key auto 5 R1 right", 1, params.mRightKeys); + assertEquals("9 key auto 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("9 key auto 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("9 key auto 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("9 key auto 5 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("9 key auto 5 R1 [5]", -4, params.getColumnPos(4)); + assertEquals("9 key auto 5 R1 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key auto 5 R1 [7]", -1, params.getColumnPos(6)); + assertEquals("9 key auto 5 R1 [8]", -2, params.getColumnPos(7)); + assertEquals("9 key auto 5 R1 [9]", -3, params.getColumnPos(8)); + assertEquals("9 key auto 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("9 key auto 5 R1 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [9] [8] [6] [7] ___| + // [5] [4] [3] <1> [2] ___| + @Test + public void testLayout9KeyAuto5R2() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R2); + assertEquals("9 key auto 5 R2 columns", 5, params.mNumColumns); + assertEquals("9 key auto 5 R2 rows", 2, params.mNumRows); + assertEquals("9 key auto 5 R2 left", 3, params.mLeftKeys); + assertEquals("9 key auto 5 R2 right", 2, params.mRightKeys); + assertEquals("9 key auto 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("9 key auto 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("9 key auto 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("9 key auto 5 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("9 key auto 5 R2 [5]", -3, params.getColumnPos(4)); + assertEquals("9 key auto 5 R2 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key auto 5 R2 [7]", 1, params.getColumnPos(6)); + assertEquals("9 key auto 5 R2 [8]", -1, params.getColumnPos(7)); + assertEquals("9 key auto 5 R2 [9]", -2, params.getColumnPos(8)); + assertEquals("9 key auto 5 R2 adjust", -1, params.mTopRowAdjustment); + assertEquals("9 key auto 5 R2 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [A] [8] [6] [7] [9] + // [5] [3] <1> [2] [4] + @Test + public void testLayout10KeyAuto5M0() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_M0); + assertEquals("10 key auto 5 M0 columns", 5, params.mNumColumns); + assertEquals("10 key auto 5 M0 rows", 2, params.mNumRows); + assertEquals("10 key auto 5 M0 left", 2, params.mLeftKeys); + assertEquals("10 key auto 5 M0 right", 3, params.mRightKeys); + assertEquals("10 key auto 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("10 key auto 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("10 key auto 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("10 key auto 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("10 key auto 5 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("10 key auto 5 M0 [6]", 0, params.getColumnPos(5)); + assertEquals("10 key auto 5 M0 [7]", 1, params.getColumnPos(6)); + assertEquals("10 key auto 5 M0 [8]", -1, params.getColumnPos(7)); + assertEquals("10 key auto 5 M0 [9]", 2, params.getColumnPos(8)); + assertEquals("10 key auto 5 M0 [A]", -2, params.getColumnPos(9)); + assertEquals("10 key auto 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key auto 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |[6] [7] [8] [9] [A] + // |<1> [2] [3] [4] [5] + @Test + public void testLayout10KeyAuto5L0() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L0); + assertEquals("10 key auto 5 L0 columns", 5, params.mNumColumns); + assertEquals("10 key auto 5 L0 rows", 2, params.mNumRows); + assertEquals("10 key auto 5 L0 left", 0, params.mLeftKeys); + assertEquals("10 key auto 5 L0 right", 5, params.mRightKeys); + assertEquals("10 key auto 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("10 key auto 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("10 key auto 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("10 key auto 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("10 key auto 5 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("10 key auto 5 L0 [6]", 0, params.getColumnPos(5)); + assertEquals("10 key auto 5 L0 [7]", 1, params.getColumnPos(6)); + assertEquals("10 key auto 5 L0 [8]", 2, params.getColumnPos(7)); + assertEquals("10 key auto 5 L0 [9]", 3, params.getColumnPos(8)); + assertEquals("10 key auto 5 L0 [A]", 4, params.getColumnPos(9)); + assertEquals("10 key auto 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key auto 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] [8] [9] [A] + // |___ <1> [2] [3] [4] [5] + @Test + public void testLayout10KeyAuto5L1() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L1); + assertEquals("10 key auto 5 L1 columns", 5, params.mNumColumns); + assertEquals("10 key auto 5 L1 rows", 2, params.mNumRows); + assertEquals("10 key auto 5 L1 left", 0, params.mLeftKeys); + assertEquals("10 key auto 5 L1 right", 5, params.mRightKeys); + assertEquals("10 key auto 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("10 key auto 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("10 key auto 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("10 key auto 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("10 key auto 5 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("10 key auto 5 L1 [6]", 0, params.getColumnPos(5)); + assertEquals("10 key auto 5 L1 [7]", 1, params.getColumnPos(6)); + assertEquals("10 key auto 5 L1 [8]", 2, params.getColumnPos(7)); + assertEquals("10 key auto 5 L1 [9]", 3, params.getColumnPos(8)); + assertEquals("10 key auto 5 L1 [A]", 4, params.getColumnPos(9)); + assertEquals("10 key auto 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key auto 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [8] [6] [7] [9] [A] + // |___ [3] <1> [2] [4] [5] + @Test + public void testLayout10KeyAuto5L2() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L2); + assertEquals("10 key auto 5 L2 columns", 5, params.mNumColumns); + assertEquals("10 key auto 5 L2 rows", 2, params.mNumRows); + assertEquals("10 key auto 5 L2 left", 1, params.mLeftKeys); + assertEquals("10 key auto 5 L2 right", 4, params.mRightKeys); + assertEquals("10 key auto 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("10 key auto 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("10 key auto 5 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("10 key auto 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("10 key auto 5 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("10 key auto 5 L2 [6]", 0, params.getColumnPos(5)); + assertEquals("10 key auto 5 L2 [7]", 1, params.getColumnPos(6)); + assertEquals("10 key auto 5 L2 [8]", -1, params.getColumnPos(7)); + assertEquals("10 key auto 5 L2 [9]", 2, params.getColumnPos(8)); + assertEquals("10 key auto 5 L2 [A]", 3, params.getColumnPos(9)); + assertEquals("10 key auto 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key auto 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [A] [9] [8] [7] [6]| + // [5] [4] [3] [2] <1>| + @Test + public void testLayout10KeyAuto5R0() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R0); + assertEquals("10 key auto 5 R0 columns", 5, params.mNumColumns); + assertEquals("10 key auto 5 R0 rows", 2, params.mNumRows); + assertEquals("10 key auto 5 R0 left", 4, params.mLeftKeys); + assertEquals("10 key auto 5 R0 right", 1, params.mRightKeys); + assertEquals("10 key auto 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("10 key auto 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("10 key auto 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("10 key auto 5 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("10 key auto 5 R0 [5]", -4, params.getColumnPos(4)); + assertEquals("10 key auto 5 R0 [6]", 0, params.getColumnPos(5)); + assertEquals("10 key auto 5 R0 [7]", -1, params.getColumnPos(6)); + assertEquals("10 key auto 5 R0 [8]", -2, params.getColumnPos(7)); + assertEquals("10 key auto 5 R0 [9]", -3, params.getColumnPos(8)); + assertEquals("10 key auto 5 R0 [A]", -4, params.getColumnPos(9)); + assertEquals("10 key auto 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key auto 5 R0 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [A] [9] [8] [7] [6] ___| + // [5] [4] [3] [2] <1> ___| + @Test + public void testLayout10KeyAuto5R1() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R1); + assertEquals("10 key auto 5 R1 columns", 5, params.mNumColumns); + assertEquals("10 key auto 5 R1 rows", 2, params.mNumRows); + assertEquals("10 key auto 5 R1 left", 4, params.mLeftKeys); + assertEquals("10 key auto 5 R1 right", 1, params.mRightKeys); + assertEquals("10 key auto 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("10 key auto 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("10 key auto 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("10 key auto 5 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("10 key auto 5 R1 [5]", -4, params.getColumnPos(4)); + assertEquals("10 key auto 5 R1 [6]", 0, params.getColumnPos(5)); + assertEquals("10 key auto 5 R1 [7]", -1, params.getColumnPos(6)); + assertEquals("10 key auto 5 R1 [8]", -2, params.getColumnPos(7)); + assertEquals("10 key auto 5 R1 [9]", -3, params.getColumnPos(8)); + assertEquals("10 key auto 5 R1 [A]", -4, params.getColumnPos(9)); + assertEquals("10 key auto 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key auto 5 R1 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [A] [9] [8] [6] [7] ___| + // [5] [4] [3] <1> [2] ___| + @Test + public void testLayout10KeyAuto5R2() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R2); + assertEquals("10 key auto 5 R2 columns", 5, params.mNumColumns); + assertEquals("10 key auto 5 R2 rows", 2, params.mNumRows); + assertEquals("10 key auto 5 R2 left", 3, params.mLeftKeys); + assertEquals("10 key auto 5 R2 right", 2, params.mRightKeys); + assertEquals("10 key auto 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("10 key auto 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("10 key auto 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("10 key auto 5 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("10 key auto 5 R2 [5]", -3, params.getColumnPos(4)); + assertEquals("10 key auto 5 R2 [6]", 0, params.getColumnPos(5)); + assertEquals("10 key auto 5 R2 [7]", 1, params.getColumnPos(6)); + assertEquals("10 key auto 5 R2 [8]", -1, params.getColumnPos(7)); + assertEquals("10 key auto 5 R2 [9]", -2, params.getColumnPos(8)); + assertEquals("10 key auto 5 R2 [A]", -3, params.getColumnPos(9)); + assertEquals("10 key auto 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key auto 5 R2 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [B] + // [A] [8] [6] [7] [9] + // [5] [3] <1> [2] [4] + @Test + public void testLayout11KeyAuto5M0() { + MoreKeysKeyboardParams params = createParams(11, 5, XPOS_M0); + assertEquals("11 key auto 5 M0 columns", 5, params.mNumColumns); + assertEquals("11 key auto 5 M0 rows", 3, params.mNumRows); + assertEquals("11 key auto 5 M0 left", 2, params.mLeftKeys); + assertEquals("11 key auto 5 M0 right", 3, params.mRightKeys); + assertEquals("11 key auto 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("11 key auto 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("11 key auto 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("11 key auto 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("11 key auto 5 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("11 key auto 5 M0 [6]", 0, params.getColumnPos(5)); + assertEquals("11 key auto 5 M0 [7]", 1, params.getColumnPos(6)); + assertEquals("11 key auto 5 M0 [8]", -1, params.getColumnPos(7)); + assertEquals("11 key auto 5 M0 [9]", 2, params.getColumnPos(8)); + assertEquals("11 key auto 5 M0 [A]", -2, params.getColumnPos(9)); + assertEquals("11 key auto 5 M0 [B]", 0, params.getColumnPos(10)); + assertEquals("11 key auto 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("11 key auto 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [B] [C] + // [A] [8] [6] [7] [9] + // [5] [3] <1> [2] [4] + @Test + public void testLayout12KeyAuto5M0() { + MoreKeysKeyboardParams params = createParams(12, 5, XPOS_M0); + assertEquals("12 key auto 5 M0 columns", 5, params.mNumColumns); + assertEquals("12 key auto 5 M0 rows", 3, params.mNumRows); + assertEquals("12 key auto 5 M0 left", 2, params.mLeftKeys); + assertEquals("12 key auto 5 M0 right", 3, params.mRightKeys); + assertEquals("12 key auto 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("12 key auto 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("12 key auto 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("12 key auto 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("12 key auto 5 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("12 key auto 5 M0 [6]", 0, params.getColumnPos(5)); + assertEquals("12 key auto 5 M0 [7]", 1, params.getColumnPos(6)); + assertEquals("12 key auto 5 M0 [8]", -1, params.getColumnPos(7)); + assertEquals("12 key auto 5 M0 [9]", 2, params.getColumnPos(8)); + assertEquals("12 key auto 5 M0 [A]", -2, params.getColumnPos(9)); + assertEquals("12 key auto 5 M0 [B]", 0, params.getColumnPos(10)); + assertEquals("12 key auto 5 M0 [C]", 1, params.getColumnPos(11)); + assertEquals("12 key auto 5 M0 adjust", -1, params.mTopRowAdjustment); + assertEquals("12 key auto 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [D] [B] [C] + // [A] [8] [6] [7] [9] + // [5] [3] <1> [2] [4] + @Test + public void testLayout13KeyAuto5M0() { + MoreKeysKeyboardParams params = createParams(13, 5, XPOS_M0); + assertEquals("13 key auto 5 M0 columns", 5, params.mNumColumns); + assertEquals("13 key auto 5 M0 rows", 3, params.mNumRows); + assertEquals("13 key auto 5 M0 left", 2, params.mLeftKeys); + assertEquals("13 key auto 5 M0 right", 3, params.mRightKeys); + assertEquals("13 key auto 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("13 key auto 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("13 key auto 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("13 key auto 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("13 key auto 5 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("13 key auto 5 M0 [6]", 0, params.getColumnPos(5)); + assertEquals("13 key auto 5 M0 [7]", 1, params.getColumnPos(6)); + assertEquals("13 key auto 5 M0 [8]", -1, params.getColumnPos(7)); + assertEquals("13 key auto 5 M0 [9]", 2, params.getColumnPos(8)); + assertEquals("13 key auto 5 M0 [A]", -2, params.getColumnPos(9)); + assertEquals("13 key auto 5 M0 [B]", 0, params.getColumnPos(10)); + assertEquals("13 key auto 5 M0 [C]", 1, params.getColumnPos(11)); + assertEquals("13 key auto 5 M0 [D]", -1, params.getColumnPos(12)); + assertEquals("13 key auto 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("13 key auto 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [D] [B] [C] [E] + // [A] [8] [6] [7] [9] + // [5] [3] <1> [2] [4] + @Test + public void testLayout14KeyAuto5M0() { + MoreKeysKeyboardParams params = createParams(14, 5, XPOS_M0); + assertEquals("13 key auto 5 M0 columns", 5, params.mNumColumns); + assertEquals("13 key auto 5 M0 rows", 3, params.mNumRows); + assertEquals("13 key auto 5 M0 left", 2, params.mLeftKeys); + assertEquals("13 key auto 5 M0 right", 3, params.mRightKeys); + assertEquals("13 key auto 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("13 key auto 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("13 key auto 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("13 key auto 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("13 key auto 5 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("13 key auto 5 M0 [6]", 0, params.getColumnPos(5)); + assertEquals("13 key auto 5 M0 [7]", 1, params.getColumnPos(6)); + assertEquals("13 key auto 5 M0 [8]", -1, params.getColumnPos(7)); + assertEquals("13 key auto 5 M0 [9]", 2, params.getColumnPos(8)); + assertEquals("13 key auto 5 M0 [A]", -2, params.getColumnPos(9)); + assertEquals("13 key auto 5 M0 [B]", 0, params.getColumnPos(10)); + assertEquals("13 key auto 5 M0 [C]", 1, params.getColumnPos(11)); + assertEquals("13 key auto 5 M0 [D]", -1, params.getColumnPos(12)); + assertEquals("13 key auto 5 M0 [E]", 2, params.getColumnPos(13)); + assertEquals("13 key auto 5 M0 adjust", -1, params.mTopRowAdjustment); + assertEquals("13 key auto 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [J] [I] [H] ___| + // [G] [F] [E] [D] [C] [B] [A] [9] ___| + // [8] [7] [6] [5] [4] [3] [2] <1> ___| + @Test + public void testLayout19KeyAuto8R1() { + MoreKeysKeyboardParams params = createParams(19, 8, XPOS_R1); + assertEquals("19 key auto 8 R1 columns", 8, params.mNumColumns); + assertEquals("19 key auto 8 R1 rows", 3, params.mNumRows); + assertEquals("19 key auto 8 R1 left", 7, params.mLeftKeys); + assertEquals("19 key auto 8 R1 right", 1, params.mRightKeys); + assertEquals("19 key auto 8 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("19 key auto 8 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("19 key auto 8 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("19 key auto 8 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("19 key auto 8 R1 [5]", -4, params.getColumnPos(4)); + assertEquals("19 key auto 8 R1 [6]", -5, params.getColumnPos(5)); + assertEquals("19 key auto 8 R1 [7]", -6, params.getColumnPos(6)); + assertEquals("19 key auto 8 R1 [8]", -7, params.getColumnPos(7)); + assertEquals("19 key auto 8 R1 [9]", 0, params.getColumnPos(8)); + assertEquals("19 key auto 8 R1 [A]", -1, params.getColumnPos(9)); + assertEquals("19 key auto 8 R1 [B]", -2, params.getColumnPos(10)); + assertEquals("19 key auto 8 R1 [C]", -3, params.getColumnPos(11)); + assertEquals("19 key auto 8 R1 [D]", -4, params.getColumnPos(12)); + assertEquals("19 key auto 8 R1 [E]", -5, params.getColumnPos(13)); + assertEquals("19 key auto 8 R1 [F]", -6, params.getColumnPos(14)); + assertEquals("19 key auto 8 R1 [G]", -7, params.getColumnPos(15)); + assertEquals("19 key auto 8 R1 [H]", 0, params.getColumnPos(16)); + assertEquals("19 key auto 8 R1 [I]", -1, params.getColumnPos(17)); + assertEquals("19 key auto 8 R1 [J]", -2, params.getColumnPos(18)); + assertEquals("19 key auto 8 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("19 key auto 8 R1 default", WIDTH * 7, params.getDefaultKeyCoordX()); + } + + // [J] [H] [I] ___| + // [G] [F] [E] [D] [C] [B] [9] [A] ___| + // [8] [7] [6] [5] [4] [3] <1> [2] ___| + @Test + public void testLayout19KeyAuto8R2() { + MoreKeysKeyboardParams params = createParams(19, 8, XPOS_R2); + assertEquals("19 key auto 8 R2 columns", 8, params.mNumColumns); + assertEquals("19 key auto 8 R2 rows", 3, params.mNumRows); + assertEquals("19 key auto 8 R2 left", 6, params.mLeftKeys); + assertEquals("19 key auto 8 R2 right", 2, params.mRightKeys); + assertEquals("19 key auto 8 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("19 key auto 8 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("19 key auto 8 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("19 key auto 8 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("19 key auto 8 R2 [5]", -3, params.getColumnPos(4)); + assertEquals("19 key auto 8 R2 [6]", -4, params.getColumnPos(5)); + assertEquals("19 key auto 8 R2 [7]", -5, params.getColumnPos(6)); + assertEquals("19 key auto 8 R2 [8]", -6, params.getColumnPos(7)); + assertEquals("19 key auto 8 R2 [9]", 0, params.getColumnPos(8)); + assertEquals("19 key auto 8 R2 [A]", 1, params.getColumnPos(9)); + assertEquals("19 key auto 8 R2 [B]", -1, params.getColumnPos(10)); + assertEquals("19 key auto 8 R2 [C]", -2, params.getColumnPos(11)); + assertEquals("19 key auto 8 R2 [D]", -3, params.getColumnPos(12)); + assertEquals("19 key auto 8 R2 [E]", -4, params.getColumnPos(13)); + assertEquals("19 key auto 8 R2 [F]", -5, params.getColumnPos(14)); + assertEquals("19 key auto 8 R2 [G]", -6, params.getColumnPos(15)); + assertEquals("19 key auto 8 R2 [H]", 0, params.getColumnPos(16)); + assertEquals("19 key auto 8 R2 [I]", 1, params.getColumnPos(17)); + assertEquals("19 key auto 8 R2 [J]", -1, params.getColumnPos(18)); + assertEquals("19 key auto 8 R2 adjust", -1, params.mTopRowAdjustment); + assertEquals("19 key auto 8 R2 default", WIDTH * 6, params.getDefaultKeyCoordX()); + } + + // [J] [H] [I] ___| + // [G] [F] [E] [D] [B] [9] [A] [C] ___| + // [8] [7] [6] [5] [3] <1> [2] [4] ___| + @Test + public void testLayout19KeyAuto8R3() { + MoreKeysKeyboardParams params = createParams(19, 8, XPOS_R3); + assertEquals("19 key auto 8 R3 columns", 8, params.mNumColumns); + assertEquals("19 key auto 8 R3 rows", 3, params.mNumRows); + assertEquals("19 key auto 8 R3 left", 5, params.mLeftKeys); + assertEquals("19 key auto 8 R3 right", 3, params.mRightKeys); + assertEquals("19 key auto 8 R3 <1>", 0, params.getColumnPos(0)); + assertEquals("19 key auto 8 R3 [2]", 1, params.getColumnPos(1)); + assertEquals("19 key auto 8 R3 [3]", -1, params.getColumnPos(2)); + assertEquals("19 key auto 8 R3 [4]", 2, params.getColumnPos(3)); + assertEquals("19 key auto 8 R3 [5]", -2, params.getColumnPos(4)); + assertEquals("19 key auto 8 R3 [6]", -3, params.getColumnPos(5)); + assertEquals("19 key auto 8 R3 [7]", -4, params.getColumnPos(6)); + assertEquals("19 key auto 8 R3 [8]", -5, params.getColumnPos(7)); + assertEquals("19 key auto 8 R3 [9]", 0, params.getColumnPos(8)); + assertEquals("19 key auto 8 R3 [A]", 1, params.getColumnPos(9)); + assertEquals("19 key auto 8 R3 [B]", -1, params.getColumnPos(10)); + assertEquals("19 key auto 8 R3 [C]", 2, params.getColumnPos(11)); + assertEquals("19 key auto 8 R3 [D]", -2, params.getColumnPos(12)); + assertEquals("19 key auto 8 R3 [E]", -3, params.getColumnPos(13)); + assertEquals("19 key auto 8 R3 [F]", -4, params.getColumnPos(14)); + assertEquals("19 key auto 8 R3 [G]", -5, params.getColumnPos(15)); + assertEquals("19 key auto 8 R3 [H]", 0, params.getColumnPos(16)); + assertEquals("19 key auto 8 R3 [I]", 1, params.getColumnPos(17)); + assertEquals("19 key auto 8 R3 [J]", -1, params.getColumnPos(18)); + assertEquals("19 key auto 8 R3 adjust", -1, params.mTopRowAdjustment); + assertEquals("19 key auto 8 R3 default", WIDTH * 5, params.getDefaultKeyCoordX()); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/MoreKeysKeyboardBuilderFixedOrderTests.java b/tests/src/org/kelar/inputmethod/keyboard/MoreKeysKeyboardBuilderFixedOrderTests.java new file mode 100644 index 000000000..2184ef63e --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/MoreKeysKeyboardBuilderFixedOrderTests.java @@ -0,0 +1,2785 @@ +/* + * Copyright (C) 2012 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 org.kelar.inputmethod.keyboard; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import androidx.test.filters.MediumTest; +import androidx.test.runner.AndroidJUnit4; + +import org.kelar.inputmethod.keyboard.MoreKeysKeyboard.MoreKeysKeyboardParams; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@MediumTest +@RunWith(AndroidJUnit4.class) +public class MoreKeysKeyboardBuilderFixedOrderTests { + private static final int WIDTH = 10; + private static final int HEIGHT = 10; + + private static final int KEYBOARD_WIDTH = WIDTH * 10; + private static final int XPOS_L0 = WIDTH * 0 + WIDTH / 2; + private static final int XPOS_L1 = WIDTH * 1 + WIDTH / 2; + private static final int XPOS_L2 = WIDTH * 2 + WIDTH / 2; + private static final int XPOS_L3 = WIDTH * 3 + WIDTH / 2; + private static final int XPOS_M0 = WIDTH * 4 + WIDTH / 2; + private static final int XPOS_M1 = WIDTH * 5 + WIDTH / 2; + private static final int XPOS_R3 = WIDTH * 6 + WIDTH / 2; + private static final int XPOS_R2 = WIDTH * 7 + WIDTH / 2; + private static final int XPOS_R1 = WIDTH * 8 + WIDTH / 2; + private static final int XPOS_R0 = WIDTH * 9 + WIDTH / 2; + + private static MoreKeysKeyboardParams createParams(final int numKeys, final int columnNum, + final int coordXInParent) { + final MoreKeysKeyboardParams params = new MoreKeysKeyboardParams(); + params.setParameters(numKeys, columnNum, WIDTH, HEIGHT, coordXInParent, KEYBOARD_WIDTH, + true /* isMoreKeysFixedColumn */, true /* isMoreKeysFixedOrder */, + 0 /* dividerWidth */); + return params; + } + + @Test + public void testLayoutError() { + MoreKeysKeyboardParams params = null; + try { + final int fixColumns = KEYBOARD_WIDTH / WIDTH; + params = createParams(fixColumns + 1, fixColumns + 1, HEIGHT); + fail("Should throw IllegalArgumentException"); + } catch (IllegalArgumentException e) { + // Too small keyboard to hold more keys keyboard. + } + assertNull("Too small keyboard to hold more keys keyboard", params); + } + + // More keys keyboard layout test. + // "[n]" represents n-th key position in more keys keyboard. + // "<m>" is the default key. + + // <1> + @Test + public void testLayout1KeyFix5M0() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_M0); + assertEquals("1 key fix 5 M0 columns", 1, params.mNumColumns); + assertEquals("1 key fix 5 M0 rows", 1, params.mNumRows); + assertEquals("1 key fix 5 M0 left", 0, params.mLeftKeys); + assertEquals("1 key fix 5 M0 right", 1, params.mRightKeys); + assertEquals("1 key fix 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key fix 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key fix 5 M0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |<1> + @Test + public void testLayout1KeyFix5L0() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L0); + assertEquals("1 key fix 5 L0 columns", 1, params.mNumColumns); + assertEquals("1 key fix 5 L0 rows", 1, params.mNumRows); + assertEquals("1 key fix 5 L0 left", 0, params.mLeftKeys); + assertEquals("1 key fix 5 L0 right", 1, params.mRightKeys); + assertEquals("1 key fix 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key fix 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key fix 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> + @Test + public void testLayout1KeyFix5L1() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L1); + assertEquals("1 key fix 5 L1 columns", 1, params.mNumColumns); + assertEquals("1 key fix 5 L1 rows", 1, params.mNumRows); + assertEquals("1 key fix 5 L1 left", 0, params.mLeftKeys); + assertEquals("1 key fix 5 L1 right", 1, params.mRightKeys); + assertEquals("1 key fix 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key fix 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key fix 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ ___ <1> + @Test + public void testLayout1KeyFix5L2() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L2); + assertEquals("1 key fix 5 L2 columns", 1, params.mNumColumns); + assertEquals("1 key fix 5 L2 rows", 1, params.mNumRows); + assertEquals("1 key fix 5 L2 left", 0, params.mLeftKeys); + assertEquals("1 key fix 5 L2 right", 1, params.mRightKeys); + assertEquals("1 key fix 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key fix 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key fix 5 L2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // <1>| + @Test + public void testLayout1KeyFix5R0() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R0); + assertEquals("1 key fix 5 R0 columns", 1, params.mNumColumns); + assertEquals("1 key fix 5 R0 rows", 1, params.mNumRows); + assertEquals("1 key fix 5 R0 left", 0, params.mLeftKeys); + assertEquals("1 key fix 5 R0 right", 1, params.mRightKeys); + assertEquals("1 key fix 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key fix 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key fix 5 R0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // <1> ___| + @Test + public void testLayout1KeyFix5R1() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R1); + assertEquals("1 key fix 5 R1 columns", 1, params.mNumColumns); + assertEquals("1 key fix 5 R1 rows", 1, params.mNumRows); + assertEquals("1 key fix 5 R1 left", 0, params.mLeftKeys); + assertEquals("1 key fix 5 R1 right", 1, params.mRightKeys); + assertEquals("1 key fix 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key fix 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key fix 5 R1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // <1> ___ ___| + @Test + public void testLayout1KeyFix5R2() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R2); + assertEquals("1 key fix 5 R2 columns", 1, params.mNumColumns); + assertEquals("1 key fix 5 R2 rows", 1, params.mNumRows); + assertEquals("1 key fix 5 R2 left", 0, params.mLeftKeys); + assertEquals("1 key fix 5 R2 right", 1, params.mRightKeys); + assertEquals("1 key fix 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key fix 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key fix 5 R2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // <1> [2] + @Test + public void testLayout2KeyFix5M0() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_M0); + assertEquals("2 key fix 5 M0 columns", 2, params.mNumColumns); + assertEquals("2 key fix 5 M0 rows", 1, params.mNumRows); + assertEquals("2 key fix 5 M0 left", 0, params.mLeftKeys); + assertEquals("2 key fix 5 M0 right", 2, params.mRightKeys); + assertEquals("2 key fix 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key fix 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("2 key fix 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key fix 5 M0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |<1> [2] + @Test + public void testLayout2KeyFix5L0() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L0); + assertEquals("2 key fix 5 L0 columns", 2, params.mNumColumns); + assertEquals("2 key fix 5 L0 rows", 1, params.mNumRows); + assertEquals("2 key fix 5 L0 left", 0, params.mLeftKeys); + assertEquals("2 key fix 5 L0 right", 2, params.mRightKeys); + assertEquals("2 key fix 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key fix 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("2 key fix 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key fix 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] + @Test + public void testLayout2KeyFix5L1() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L1); + assertEquals("2 key fix 5 L1 columns", 2, params.mNumColumns); + assertEquals("2 key fix 5 L1 rows", 1, params.mNumRows); + assertEquals("2 key fix 5 L1 left", 0, params.mLeftKeys); + assertEquals("2 key fix 5 L1 right", 2, params.mRightKeys); + assertEquals("2 key fix 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key fix 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("2 key fix 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key fix 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ ___ <1> [2] + @Test + public void testLayout2KeyFix5L2() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L2); + assertEquals("2 key fix 5 L2 columns", 2, params.mNumColumns); + assertEquals("2 key fix 5 L2 rows", 1, params.mNumRows); + assertEquals("2 key fix 5 L2 left", 0, params.mLeftKeys); + assertEquals("2 key fix 5 L2 right", 2, params.mRightKeys); + assertEquals("2 key fix 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key fix 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("2 key fix 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key fix 5 L2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // [1] <2>| + @Test + public void testLayout2KeyFix5R0() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R0); + assertEquals("2 key fix 5 R0 columns", 2, params.mNumColumns); + assertEquals("2 key fix 5 R0 rows", 1, params.mNumRows); + assertEquals("2 key fix 5 R0 left", 1, params.mLeftKeys); + assertEquals("2 key fix 5 R0 right", 1, params.mRightKeys); + assertEquals("2 key fix 5 R0 [1]", -1, params.getColumnPos(0)); + assertEquals("2 key fix 5 R0 <2>", 0, params.getColumnPos(1)); + assertEquals("2 key fix 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key fix 5 R0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [1] <2> ___| + @Test + public void testLayout2KeyFix5R1() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R1); + assertEquals("2 key fix 5 R1 columns", 2, params.mNumColumns); + assertEquals("2 key fix 5 R1 rows", 1, params.mNumRows); + assertEquals("2 key fix 5 R1 left", 1, params.mLeftKeys); + assertEquals("2 key fix 5 R1 right", 1, params.mRightKeys); + assertEquals("2 key fix 5 R1 [1]", -1, params.getColumnPos(0)); + assertEquals("2 key fix 5 R1 <2>", 0, params.getColumnPos(1)); + assertEquals("2 key fix 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key fix 5 R1 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // <1> [2] ___| + @Test + public void testLayout2KeyFix5R2() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R2); + assertEquals("2 key fix 5 R2 columns", 2, params.mNumColumns); + assertEquals("2 key fix 5 R2 rows", 1, params.mNumRows); + assertEquals("2 key fix 5 R2 left", 0, params.mLeftKeys); + assertEquals("2 key fix 5 R2 right", 2, params.mRightKeys); + assertEquals("2 key fix 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key fix 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("2 key fix 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key fix 5 R2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // [3] + // <1> [2] + @Test + public void testLayout3KeyFix2M0() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_M0); + assertEquals("3 key fix 2 M0 columns", 2, params.mNumColumns); + assertEquals("3 key fix 2 M0 rows", 2, params.mNumRows); + assertEquals("3 key fix 2 M0 left", 0, params.mLeftKeys); + assertEquals("3 key fix 2 M0 right", 2, params.mRightKeys); + assertEquals("3 key fix 2 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key fix 2 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key fix 2 M0 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key fix 2 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 2 M0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |[3] + // |<1> [2] + @Test + public void testLayout3KeyFix2L0() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L0); + assertEquals("3 key fix 2 L0 columns", 2, params.mNumColumns); + assertEquals("3 key fix 2 L0 rows", 2, params.mNumRows); + assertEquals("3 key fix 2 L0 left", 0, params.mLeftKeys); + assertEquals("3 key fix 2 L0 right", 2, params.mRightKeys); + assertEquals("3 key fix 2 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key fix 2 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key fix 2 L0 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key fix 2 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 2 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [3] + // |___ <1> [2] + @Test + public void testLayout3KeyFix2L1() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L1); + assertEquals("3 key fix 2 L1 columns", 2, params.mNumColumns); + assertEquals("3 key fix 2 L1 rows", 2, params.mNumRows); + assertEquals("3 key fix 2 L1 left", 0, params.mLeftKeys); + assertEquals("3 key fix 2 L1 right", 2, params.mRightKeys); + assertEquals("3 key fix 2 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key fix 2 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key fix 2 L1 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key fix 2 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 2 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // | [3] + // |___ ___ <1> [2] + @Test + public void testLayout3KeyFix2L2() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L2); + assertEquals("3 key fix 2 L2 columns", 2, params.mNumColumns); + assertEquals("3 key fix 2 L2 rows", 2, params.mNumRows); + assertEquals("3 key fix 2 L2 left", 0, params.mLeftKeys); + assertEquals("3 key fix 2 L2 right", 2, params.mRightKeys); + assertEquals("3 key fix 2 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key fix 2 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key fix 2 L2 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key fix 2 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 2 L2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // [3]| + // [1] <2>| + @Test + public void testLayout3KeyFix2R0() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R0); + assertEquals("3 key fix 2 R0 columns", 2, params.mNumColumns); + assertEquals("3 key fix 2 R0 rows", 2, params.mNumRows); + assertEquals("3 key fix 2 R0 left", 1, params.mLeftKeys); + assertEquals("3 key fix 2 R0 right", 1, params.mRightKeys); + assertEquals("3 key fix 2 R0 [1]", -1, params.getColumnPos(0)); + assertEquals("3 key fix 2 R0 <2>", 0, params.getColumnPos(1)); + assertEquals("3 key fix 2 R0 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key fix 2 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 2 R0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [3] ___| + // [1] <2> ___| + @Test + public void testLayout3KeyFix2R1() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R1); + assertEquals("3 key fix 2 R1 columns", 2, params.mNumColumns); + assertEquals("3 key fix 2 R1 rows", 2, params.mNumRows); + assertEquals("3 key fix 2 R1 left", 1, params.mLeftKeys); + assertEquals("3 key fix 2 R1 right", 1, params.mRightKeys); + assertEquals("3 key fix 2 R1 [1]", -1, params.getColumnPos(0)); + assertEquals("3 key fix 2 R1 <2>", 0, params.getColumnPos(1)); + assertEquals("3 key fix 2 R1 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key fix 2 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 2 R1 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [3] ___| + // <1> [2] ___| + @Test + public void testLayout3KeyFix2R2() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R2); + assertEquals("3 key fix 2 R2 columns", 2, params.mNumColumns); + assertEquals("3 key fix 2 R2 rows", 2, params.mNumRows); + assertEquals("3 key fix 2 R2 left", 0, params.mLeftKeys); + assertEquals("3 key fix 2 R2 right", 2, params.mRightKeys); + assertEquals("3 key fix 2 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key fix 2 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key fix 2 R2 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key fix 2 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 2 R2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // [3] [4] + // <1> [2] + @Test + public void testLayout4KeyFix2M0() { + MoreKeysKeyboardParams params = createParams(4, 2, XPOS_M0); + assertEquals("3 key fix 2 M0 columns", 2, params.mNumColumns); + assertEquals("3 key fix 2 M0 rows", 2, params.mNumRows); + assertEquals("3 key fix 2 M0 left", 0, params.mLeftKeys); + assertEquals("3 key fix 2 M0 right", 2, params.mRightKeys); + assertEquals("3 key fix 2 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key fix 2 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key fix 2 M0 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key fix 2 M0 [4]", 1, params.getColumnPos(3)); + assertEquals("3 key fix 2 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 2 M0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |[3] [4] + // |<1> [2] + @Test + public void testLayout4KeyFix2L0() { + MoreKeysKeyboardParams params = createParams(4, 2, XPOS_L0); + assertEquals("3 key fix 2 L0 columns", 2, params.mNumColumns); + assertEquals("3 key fix 2 L0 rows", 2, params.mNumRows); + assertEquals("3 key fix 2 L0 left", 0, params.mLeftKeys); + assertEquals("3 key fix 2 L0 right", 2, params.mRightKeys); + assertEquals("3 key fix 2 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key fix 2 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key fix 2 L0 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key fix 2 L0 [4]", 1, params.getColumnPos(3)); + assertEquals("3 key fix 2 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 2 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [3] [4] + // |___ <1> [2] + @Test + public void testLayout4KeyFix2L1() { + MoreKeysKeyboardParams params = createParams(4, 2, XPOS_L1); + assertEquals("3 key fix 2 L1 columns", 2, params.mNumColumns); + assertEquals("3 key fix 2 L1 rows", 2, params.mNumRows); + assertEquals("3 key fix 2 L1 left", 0, params.mLeftKeys); + assertEquals("3 key fix 2 L1 right", 2, params.mRightKeys); + assertEquals("3 key fix 2 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key fix 2 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key fix 2 L1 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key fix 2 L1 [4]", 1, params.getColumnPos(3)); + assertEquals("3 key fix 2 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 2 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // | [3] [4] + // |___ ___ <1> [2] + @Test + public void testLayout4KeyFix2L2() { + MoreKeysKeyboardParams params = createParams(4, 2, XPOS_L2); + assertEquals("3 key fix 2 L2 columns", 2, params.mNumColumns); + assertEquals("3 key fix 2 L2 rows", 2, params.mNumRows); + assertEquals("3 key fix 2 L2 left", 0, params.mLeftKeys); + assertEquals("3 key fix 2 L2 right", 2, params.mRightKeys); + assertEquals("3 key fix 2 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key fix 2 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key fix 2 L2 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key fix 2 L2 [4]", 1, params.getColumnPos(3)); + assertEquals("3 key fix 2 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 2 L2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // [3] [4]| + // [1] <2>| + @Test + public void testLayout4KeyFix2R0() { + MoreKeysKeyboardParams params = createParams(4, 2, XPOS_R0); + assertEquals("3 key fix 2 R0 columns", 2, params.mNumColumns); + assertEquals("3 key fix 2 R0 rows", 2, params.mNumRows); + assertEquals("3 key fix 2 R0 left", 1, params.mLeftKeys); + assertEquals("3 key fix 2 R0 right", 1, params.mRightKeys); + assertEquals("3 key fix 2 R0 [1]", -1, params.getColumnPos(0)); + assertEquals("3 key fix 2 R0 <2>", 0, params.getColumnPos(1)); + assertEquals("3 key fix 2 R0 [3]", -1, params.getColumnPos(2)); + assertEquals("3 key fix 2 R0 [4]", 0, params.getColumnPos(3)); + assertEquals("3 key fix 2 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 2 R0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [3] [4] ___| + // [1] <2> ___| + @Test + public void testLayout4KeyFix2R1() { + MoreKeysKeyboardParams params = createParams(4, 2, XPOS_R1); + assertEquals("3 key fix 2 R1 columns", 2, params.mNumColumns); + assertEquals("3 key fix 2 R1 rows", 2, params.mNumRows); + assertEquals("3 key fix 2 R1 left", 1, params.mLeftKeys); + assertEquals("3 key fix 2 R1 right", 1, params.mRightKeys); + assertEquals("3 key fix 2 R1 [1]", -1, params.getColumnPos(0)); + assertEquals("3 key fix 2 R1 <2>", 0, params.getColumnPos(1)); + assertEquals("3 key fix 2 R1 [3]", -1, params.getColumnPos(2)); + assertEquals("3 key fix 2 R1 [4]", 0, params.getColumnPos(3)); + assertEquals("3 key fix 2 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 2 R1 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [3] [4] ___| + // <1> [2] ___| + @Test + public void testLayout4KeyFix2R2() { + MoreKeysKeyboardParams params = createParams(4, 2, XPOS_R2); + assertEquals("3 key fix 2 R2 columns", 2, params.mNumColumns); + assertEquals("3 key fix 2 R2 rows", 2, params.mNumRows); + assertEquals("3 key fix 2 R2 left", 0, params.mLeftKeys); + assertEquals("3 key fix 2 R2 right", 2, params.mRightKeys); + assertEquals("3 key fix 2 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key fix 2 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key fix 2 R2 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key fix 2 R2 [4]", 1, params.getColumnPos(3)); + assertEquals("3 key fix 2 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 2 R2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // [1] <2> [3] + @Test + public void testLayout3KeyFix5M0() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_M0); + assertEquals("3 key fix 5 columns", 3, params.mNumColumns); + assertEquals("3 key fix 5 rows", 1, params.mNumRows); + assertEquals("3 key fix 5 left", 1, params.mLeftKeys); + assertEquals("3 key fix 5 right", 2, params.mRightKeys); + assertEquals("3 key fix 5 [1]", -1, params.getColumnPos(0)); + assertEquals("3 key fix 5 <2>", 0, params.getColumnPos(1)); + assertEquals("3 key fix 5 [3]", 1, params.getColumnPos(2)); + assertEquals("3 key fix 5 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 5 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |<1> [2] [3] + @Test + public void testLayout3KeyFix5L0() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L0); + assertEquals("3 key fix 5 L0 columns", 3, params.mNumColumns); + assertEquals("3 key fix 5 L0 rows", 1, params.mNumRows); + assertEquals("3 key fix 5 L0 left", 0, params.mLeftKeys); + assertEquals("3 key fix 5 L0 right", 3, params.mRightKeys); + assertEquals("3 key fix 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key fix 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key fix 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("3 key fix 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] [3] + @Test + public void testLayout3KeyFix5L1() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L1); + assertEquals("3 key fix 5 L1 columns", 3, params.mNumColumns); + assertEquals("3 key fix 5 L1 rows", 1, params.mNumRows); + assertEquals("3 key fix 5 L1 left", 0, params.mLeftKeys); + assertEquals("3 key fix 5 L1 right", 3, params.mRightKeys); + assertEquals("3 key fix 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key fix 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key fix 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("3 key fix 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [1] <2> [3] + @Test + public void testLayout3KeyFix5L2() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L2); + assertEquals("3 key fix 5 L2 columns", 3, params.mNumColumns); + assertEquals("3 key fix 5 L2 rows", 1, params.mNumRows); + assertEquals("3 key fix 5 L2 left", 1, params.mLeftKeys); + assertEquals("3 key fix 5 L2 right", 2, params.mRightKeys); + assertEquals("3 key fix 5 L2 [1]", -1, params.getColumnPos(0)); + assertEquals("3 key fix 5 L2 <2>", 0, params.getColumnPos(1)); + assertEquals("3 key fix 5 L2 [3]", 1, params.getColumnPos(2)); + assertEquals("3 key fix 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [1] [2] <3>| + @Test + public void testLayout3KeyFix5R0() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R0); + assertEquals("3 key fix 5 R0 columns", 3, params.mNumColumns); + assertEquals("3 key fix 5 R0 rows", 1, params.mNumRows); + assertEquals("3 key fix 5 R0 left", 2, params.mLeftKeys); + assertEquals("3 key fix 5 R0 right", 1, params.mRightKeys); + assertEquals("3 key fix 5 R0 [1]", -2, params.getColumnPos(0)); + assertEquals("3 key fix 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("3 key fix 5 R0 <3>", 0, params.getColumnPos(2)); + assertEquals("3 key fix 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 5 R0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [1] [2] <3> ___| + @Test + public void testLayout3KeyFix5R1() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R1); + assertEquals("3 key fix 5 R1 columns", 3, params.mNumColumns); + assertEquals("3 key fix 5 R1 rows", 1, params.mNumRows); + assertEquals("3 key fix 5 R1 left", 2, params.mLeftKeys); + assertEquals("3 key fix 5 R1 right", 1, params.mRightKeys); + assertEquals("3 key fix 5 R1 [1]", -2, params.getColumnPos(0)); + assertEquals("3 key fix 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("3 key fix 5 R1 <3>", 0, params.getColumnPos(2)); + assertEquals("3 key fix 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 5 R1 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [1] <2> [3] ___| + @Test + public void testLayout3KeyFix5R2() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R2); + assertEquals("3 key fix 5 R2 columns", 3, params.mNumColumns); + assertEquals("3 key fix 5 R2 rows", 1, params.mNumRows); + assertEquals("3 key fix 5 R2 left", 1, params.mLeftKeys); + assertEquals("3 key fix 5 R2 right", 2, params.mRightKeys); + assertEquals("3 key fix 5 R2 [1]", -1, params.getColumnPos(0)); + assertEquals("3 key fix 5 R2 <2>", 0, params.getColumnPos(1)); + assertEquals("3 key fix 5 R2 [3]", 1, params.getColumnPos(2)); + assertEquals("3 key fix 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key fix 5 R2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [4] + // [1] <2> [3] + @Test + public void testLayout4KeyFix3M0() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_M0); + assertEquals("4 key fix 3 M0 columns", 3, params.mNumColumns); + assertEquals("4 key fix 3 M0 rows", 2, params.mNumRows); + assertEquals("4 key fix 3 M0 left", 1, params.mLeftKeys); + assertEquals("4 key fix 3 M0 right", 2, params.mRightKeys); + assertEquals("4 key fix 3 M0 [1]", -1, params.getColumnPos(0)); + assertEquals("4 key fix 3 M0 <2>", 0, params.getColumnPos(1)); + assertEquals("4 key fix 3 M0 [3]", 1, params.getColumnPos(2)); + assertEquals("4 key fix 3 M0 [4]", 0, params.getColumnPos(3)); + assertEquals("4 key fix 3 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key fix 3 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[4] + // |<1> [2] [3] + @Test + public void testLayout4KeyFix3L0() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L0); + assertEquals("4 key fix 3 L0 columns", 3, params.mNumColumns); + assertEquals("4 key fix 3 L0 rows", 2, params.mNumRows); + assertEquals("4 key fix 3 L0 left", 0, params.mLeftKeys); + assertEquals("4 key fix 3 L0 right", 3, params.mRightKeys); + assertEquals("4 key fix 3 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key fix 3 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key fix 3 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("4 key fix 3 L0 [4]", 0, params.getColumnPos(3)); + assertEquals("4 key fix 3 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key fix 3 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [4] + // |___ <1> [2] [3] + @Test + public void testLayout4KeyFix3L1() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L1); + assertEquals("4 key fix 3 L1 columns", 3, params.mNumColumns); + assertEquals("4 key fix 3 L1 rows", 2, params.mNumRows); + assertEquals("4 key fix 3 L1 left", 0, params.mLeftKeys); + assertEquals("4 key fix 3 L1 right", 3, params.mRightKeys); + assertEquals("4 key fix 3 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key fix 3 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key fix 3 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("4 key fix 3 L1 [4]", 0, params.getColumnPos(3)); + assertEquals("4 key fix 3 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key fix 3 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ ___ [4] + // |___ ___ [1] <2> [3] + @Test + public void testLayout4KeyFix3L2() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L2); + assertEquals("4 key fix 3 L2 columns", 3, params.mNumColumns); + assertEquals("4 key fix 3 L2 rows", 2, params.mNumRows); + assertEquals("4 key fix 3 L2 left", 1, params.mLeftKeys); + assertEquals("4 key fix 3 L2 right", 2, params.mRightKeys); + assertEquals("4 key fix 3 L2 [1]", -1, params.getColumnPos(0)); + assertEquals("4 key fix 3 L2 <2>", 0, params.getColumnPos(1)); + assertEquals("4 key fix 3 L2 [3]", 1, params.getColumnPos(2)); + assertEquals("4 key fix 3 L2 [4]", 0, params.getColumnPos(3)); + assertEquals("4 key fix 3 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key fix 3 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [4]| + // [1] [2] <3>| + @Test + public void testLayout4KeyFix3R0() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R0); + assertEquals("4 key fix 3 R0 columns", 3, params.mNumColumns); + assertEquals("4 key fix 3 R0 rows", 2, params.mNumRows); + assertEquals("4 key fix 3 R0 left", 2, params.mLeftKeys); + assertEquals("4 key fix 3 R0 right", 1, params.mRightKeys); + assertEquals("4 key fix 3 R0 [1]", -2, params.getColumnPos(0)); + assertEquals("4 key fix 3 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("4 key fix 3 R0 <3>", 0, params.getColumnPos(2)); + assertEquals("4 key fix 3 R0 [4]", 0, params.getColumnPos(3)); + assertEquals("4 key fix 3 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key fix 3 R0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [4] ___| + // [1] [2] <3> ___| + @Test + public void testLayout4KeyFix3R1() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R1); + assertEquals("4 key fix 3 R1 columns", 3, params.mNumColumns); + assertEquals("4 key fix 3 R1 rows", 2, params.mNumRows); + assertEquals("4 key fix 3 R1 left", 2, params.mLeftKeys); + assertEquals("4 key fix 3 R1 right", 1, params.mRightKeys); + assertEquals("4 key fix 3 R1 [1]", -2, params.getColumnPos(0)); + assertEquals("4 key fix 3 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("4 key fix 3 R1 <3>", 0, params.getColumnPos(2)); + assertEquals("4 key fix 3 R1 [4]", 0, params.getColumnPos(3)); + assertEquals("4 key fix 3 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key fix 3 R1 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [4] ___| + // [1] <2> [3] ___| + @Test + public void testLayout4KeyFix3R2() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R2); + assertEquals("4 key fix 3 R2 columns", 3, params.mNumColumns); + assertEquals("4 key fix 3 R2 rows", 2, params.mNumRows); + assertEquals("4 key fix 3 R2 left", 1, params.mLeftKeys); + assertEquals("4 key fix 3 R2 right", 2, params.mRightKeys); + assertEquals("4 key fix 3 R2 [1]", -1, params.getColumnPos(0)); + assertEquals("4 key fix 3 R2 <2>", 0, params.getColumnPos(1)); + assertEquals("4 key fix 3 R2 [3]", 1, params.getColumnPos(2)); + assertEquals("4 key fix 3 R2 [4]", 0, params.getColumnPos(3)); + assertEquals("4 key fix 3 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key fix 3 R2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [4] [5] + // [1] <2> [3] + @Test + public void testLayout5KeyFix3M0() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_M0); + assertEquals("5 key fix 3 M0 columns", 3, params.mNumColumns); + assertEquals("5 key fix 3 M0 rows", 2, params.mNumRows); + assertEquals("5 key fix 3 M0 left", 1, params.mLeftKeys); + assertEquals("5 key fix 3 M0 right", 2, params.mRightKeys); + assertEquals("5 key fix 3 M0 [1]", -1, params.getColumnPos(0)); + assertEquals("5 key fix 3 M0 <2>", 0, params.getColumnPos(1)); + assertEquals("5 key fix 3 M0 [3]", 1, params.getColumnPos(2)); + assertEquals("5 key fix 3 M0 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key fix 3 M0 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key fix 3 M0 adjust", -1, params.mTopRowAdjustment); + assertEquals("5 key fix 3 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[4] [5] + // |<1> [2] [3] + @Test + public void testLayout5KeyFix3L0() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L0); + assertEquals("5 key fix 3 L0 columns", 3, params.mNumColumns); + assertEquals("5 key fix 3 L0 rows", 2, params.mNumRows); + assertEquals("5 key fix 3 L0 left", 0, params.mLeftKeys); + assertEquals("5 key fix 3 L0 right", 3, params.mRightKeys); + assertEquals("5 key fix 3 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key fix 3 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key fix 3 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key fix 3 L0 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key fix 3 L0 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key fix 3 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 3 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [4] [5] + // |___ <1> [2] [3] + @Test + public void testLayout5KeyFix3L1() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L1); + assertEquals("5 key fix 3 L1 columns", 3, params.mNumColumns); + assertEquals("5 key fix 3 L1 rows", 2, params.mNumRows); + assertEquals("5 key fix 3 L1 left", 0, params.mLeftKeys); + assertEquals("5 key fix 3 L1 right", 3, params.mRightKeys); + assertEquals("5 key fix 3 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key fix 3 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key fix 3 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key fix 3 L1 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key fix 3 L1 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key fix 3 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 3 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [4] [5] + // |___ [1] <2> [3] + @Test + public void testLayout5KeyFix3L2() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L2); + assertEquals("5 key fix 3 L2 columns", 3, params.mNumColumns); + assertEquals("5 key fix 3 L2 rows", 2, params.mNumRows); + assertEquals("5 key fix 3 L2 left", 1, params.mLeftKeys); + assertEquals("5 key fix 3 L2 right", 2, params.mRightKeys); + assertEquals("5 key fix 3 L2 [1]", -1, params.getColumnPos(0)); + assertEquals("5 key fix 3 L2 <2>", 0, params.getColumnPos(1)); + assertEquals("5 key fix 3 L2 [3]", 1, params.getColumnPos(2)); + assertEquals("5 key fix 3 L2 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key fix 3 L2 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key fix 3 L2 adjust", -1, params.mTopRowAdjustment); + assertEquals("5 key fix 3 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [4] [5]| + // [1] [2] <3>| + @Test + public void testLayout5KeyFix3R0() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R0); + assertEquals("5 key fix 3 R0 columns", 3, params.mNumColumns); + assertEquals("5 key fix 3 R0 rows", 2, params.mNumRows); + assertEquals("5 key fix 3 R0 left", 2, params.mLeftKeys); + assertEquals("5 key fix 3 R0 right", 1, params.mRightKeys); + assertEquals("5 key fix 3 R0 [1]", -2, params.getColumnPos(0)); + assertEquals("5 key fix 3 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("5 key fix 3 R0 <3>", 0, params.getColumnPos(2)); + assertEquals("5 key fix 3 R0 [4]", -1, params.getColumnPos(3)); + assertEquals("5 key fix 3 R0 [5]", 0, params.getColumnPos(4)); + assertEquals("5 key fix 3 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 3 R0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [4] [5] ___| + // [1] [2] <3> ___| + @Test + public void testLayout5KeyFix3R1() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R1); + assertEquals("5 key fix 3 R1 columns", 3, params.mNumColumns); + assertEquals("5 key fix 3 R1 rows", 2, params.mNumRows); + assertEquals("5 key fix 3 R1 left", 2, params.mLeftKeys); + assertEquals("5 key fix 3 R1 right", 1, params.mRightKeys); + assertEquals("5 key fix 3 R1 [1]", -2, params.getColumnPos(0)); + assertEquals("5 key fix 3 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("5 key fix 3 R1 <3>", 0, params.getColumnPos(2)); + assertEquals("5 key fix 3 R1 [4]", -1, params.getColumnPos(3)); + assertEquals("5 key fix 3 R1 [5]", 0, params.getColumnPos(4)); + assertEquals("5 key fix 3 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 3 R1 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [4] [5] ___| + // [1] <2> [3] ___| + @Test + public void testLayout5KeyFix3R2() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R2); + assertEquals("5 key fix 3 R2 columns", 3, params.mNumColumns); + assertEquals("5 key fix 3 R2 rows", 2, params.mNumRows); + assertEquals("5 key fix 3 R2 left", 1, params.mLeftKeys); + assertEquals("5 key fix 3 R2 right", 2, params.mRightKeys); + assertEquals("5 key fix 3 R2 [1]", -1, params.getColumnPos(0)); + assertEquals("5 key fix 3 R2 <2>", 0, params.getColumnPos(1)); + assertEquals("5 key fix 3 R2 [3]", 1, params.getColumnPos(2)); + assertEquals("5 key fix 3 R2 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key fix 3 R2 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key fix 3 R2 adjust", -1, params.mTopRowAdjustment); + assertEquals("5 key fix 3 R2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [4] [5] [6] + // [1] <2> [3] + @Test + public void testLayout6KeyFix3M0() { + MoreKeysKeyboardParams params = createParams(6, 3, XPOS_M0); + assertEquals("6 key fix 3 M0 columns", 3, params.mNumColumns); + assertEquals("6 key fix 3 M0 rows", 2, params.mNumRows); + assertEquals("6 key fix 3 M0 left", 1, params.mLeftKeys); + assertEquals("6 key fix 3 M0 right", 2, params.mRightKeys); + assertEquals("6 key fix 3 M0 [1]", -1, params.getColumnPos(0)); + assertEquals("6 key fix 3 M0 <2>", 0, params.getColumnPos(1)); + assertEquals("6 key fix 3 M0 [3]", 1, params.getColumnPos(2)); + assertEquals("6 key fix 3 M0 [4]", -1, params.getColumnPos(3)); + assertEquals("6 key fix 3 M0 [5]", 0, params.getColumnPos(4)); + assertEquals("6 key fix 3 M0 [6]", 1, params.getColumnPos(5)); + assertEquals("6 key fix 3 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 3 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[4] [5] [6] + // |<1> [2] [3] + @Test + public void testLayout6KeyFix3L0() { + MoreKeysKeyboardParams params = createParams(6, 3, XPOS_L0); + assertEquals("6 key fix 3 L0 columns", 3, params.mNumColumns); + assertEquals("6 key fix 3 L0 rows", 2, params.mNumRows); + assertEquals("6 key fix 3 L0 left", 0, params.mLeftKeys); + assertEquals("6 key fix 3 L0 right", 3, params.mRightKeys); + assertEquals("6 key fix 3 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key fix 3 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key fix 3 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("6 key fix 3 L0 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key fix 3 L0 [5]", 1, params.getColumnPos(4)); + assertEquals("6 key fix 3 L0 [6]", 2, params.getColumnPos(5)); + assertEquals("6 key fix 3 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 3 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [4] [5] [6] + // |___ <1> [2] [3] + @Test + public void testLayout6KeyFix3L1() { + MoreKeysKeyboardParams params = createParams(6, 3, XPOS_L1); + assertEquals("6 key fix 3 L1 columns", 3, params.mNumColumns); + assertEquals("6 key fix 3 L1 rows", 2, params.mNumRows); + assertEquals("6 key fix 3 L1 left", 0, params.mLeftKeys); + assertEquals("6 key fix 3 L1 right", 3, params.mRightKeys); + assertEquals("6 key fix 3 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key fix 3 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key fix 3 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("6 key fix 3 L1 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key fix 3 L1 [5]", 1, params.getColumnPos(4)); + assertEquals("6 key fix 3 L1 [6]", 2, params.getColumnPos(5)); + assertEquals("6 key fix 3 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 3 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [4] [5] [6] + // |___ [1] <2> [3] + @Test + public void testLayout6KeyFix3L2() { + MoreKeysKeyboardParams params = createParams(6, 3, XPOS_L2); + assertEquals("6 key fix 3 L2 columns", 3, params.mNumColumns); + assertEquals("6 key fix 3 L2 rows", 2, params.mNumRows); + assertEquals("6 key fix 3 L2 left", 1, params.mLeftKeys); + assertEquals("6 key fix 3 L2 right", 2, params.mRightKeys); + assertEquals("6 key fix 3 L2 [1]", -1, params.getColumnPos(0)); + assertEquals("6 key fix 3 L2 <2>", 0, params.getColumnPos(1)); + assertEquals("6 key fix 3 L2 [3]", 1, params.getColumnPos(2)); + assertEquals("6 key fix 3 L2 [4]", -1, params.getColumnPos(3)); + assertEquals("6 key fix 3 L2 [5]", 0, params.getColumnPos(4)); + assertEquals("6 key fix 3 L2 [6]", 1, params.getColumnPos(5)); + assertEquals("6 key fix 3 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 3 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [4] [5] [6]| + // [1] [2] <3>| + @Test + public void testLayout6KeyFix3R0() { + MoreKeysKeyboardParams params = createParams(6, 3, XPOS_R0); + assertEquals("6 key fix 3 R0 columns", 3, params.mNumColumns); + assertEquals("6 key fix 3 R0 rows", 2, params.mNumRows); + assertEquals("6 key fix 3 R0 left", 2, params.mLeftKeys); + assertEquals("6 key fix 3 R0 right", 1, params.mRightKeys); + assertEquals("6 key fix 3 R0 [1]", -2, params.getColumnPos(0)); + assertEquals("6 key fix 3 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("6 key fix 3 R0 <3>", 0, params.getColumnPos(2)); + assertEquals("6 key fix 3 R0 [4]", -2, params.getColumnPos(3)); + assertEquals("6 key fix 3 R0 [5]", -1, params.getColumnPos(4)); + assertEquals("6 key fix 3 R0 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key fix 3 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 3 R0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [4] [5] [6] ___| + // [1] [2] <3> ___| + @Test + public void testLayout6KeyFix3R1() { + MoreKeysKeyboardParams params = createParams(6, 3, XPOS_R1); + assertEquals("6 key fix 3 R1 columns", 3, params.mNumColumns); + assertEquals("6 key fix 3 R1 rows", 2, params.mNumRows); + assertEquals("6 key fix 3 R1 left", 2, params.mLeftKeys); + assertEquals("6 key fix 3 R1 right", 1, params.mRightKeys); + assertEquals("6 key fix 3 R1 [1]", -2, params.getColumnPos(0)); + assertEquals("6 key fix 3 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("6 key fix 3 R1 <3>", 0, params.getColumnPos(2)); + assertEquals("6 key fix 3 R1 [4]", -2, params.getColumnPos(3)); + assertEquals("6 key fix 3 R1 [5]", -1, params.getColumnPos(4)); + assertEquals("6 key fix 3 R1 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key fix 3 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 3 R1 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [4] [5] [6] ___| + // [1] <2> [3] ___| + @Test + public void testLayout6KeyFix3R2() { + MoreKeysKeyboardParams params = createParams(6, 3, XPOS_R2); + assertEquals("6 key fix 3 R2 columns", 3, params.mNumColumns); + assertEquals("6 key fix 3 R2 rows", 2, params.mNumRows); + assertEquals("6 key fix 3 R2 left", 1, params.mLeftKeys); + assertEquals("6 key fix 3 R2 right", 2, params.mRightKeys); + assertEquals("6 key fix 3 R2 [1]", -1, params.getColumnPos(0)); + assertEquals("6 key fix 3 R2 <2>", 0, params.getColumnPos(1)); + assertEquals("6 key fix 3 R2 [1]", 1, params.getColumnPos(2)); + assertEquals("6 key fix 3 R2 [4]", -1, params.getColumnPos(3)); + assertEquals("6 key fix 3 R2 [5]", 0, params.getColumnPos(4)); + assertEquals("6 key fix 3 R2 [6]", 1, params.getColumnPos(5)); + assertEquals("6 key fix 3 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 3 R2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // <1> [2] [3] [4] + @Test + public void testLayout4KeyFix5M0() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_M0); + assertEquals("4 key fix 5 columns", 4, params.mNumColumns); + assertEquals("4 key fix 5 rows", 1, params.mNumRows); + assertEquals("4 key fix 5 left", 1, params.mLeftKeys); + assertEquals("4 key fix 5 right", 3, params.mRightKeys); + assertEquals("4 key fix 5 <1>", -1, params.getColumnPos(0)); + assertEquals("4 key fix 5 [2]", 0, params.getColumnPos(1)); + assertEquals("4 key fix 5 [3]", 1, params.getColumnPos(2)); + assertEquals("4 key fix 5 [4]", 2, params.getColumnPos(3)); + assertEquals("4 key fix 5 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key fix 5 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |<1> [2] [3] [4] + @Test + public void testLayout4KeyFix5L0() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L0); + assertEquals("4 key fix 5 L0 columns", 4, params.mNumColumns); + assertEquals("4 key fix 5 L0 rows", 1, params.mNumRows); + assertEquals("4 key fix 5 L0 left", 0, params.mLeftKeys); + assertEquals("4 key fix 5 L0 right", 4, params.mRightKeys); + assertEquals("4 key fix 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key fix 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key fix 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("4 key fix 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("4 key fix 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key fix 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] [3] [4] + @Test + public void testLayout4KeyFix5L1() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L1); + assertEquals("4 key fix 5 L1 columns", 4, params.mNumColumns); + assertEquals("4 key fix 5 L1 rows", 1, params.mNumRows); + assertEquals("4 key fix 5 L1 left", 0, params.mLeftKeys); + assertEquals("4 key fix 5 L1 right", 4, params.mRightKeys); + assertEquals("4 key fix 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key fix 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key fix 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("4 key fix 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("4 key fix 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key fix 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [1] <2> [3] [4] + @Test + public void testLayout4KeyFix5L2() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L2); + assertEquals("4 key fix 5 L2 columns", 4, params.mNumColumns); + assertEquals("4 key fix 5 L2 rows", 1, params.mNumRows); + assertEquals("4 key fix 5 L2 left", 1, params.mLeftKeys); + assertEquals("4 key fix 5 L2 right", 3, params.mRightKeys); + assertEquals("4 key fix 5 L2 [1]", -1, params.getColumnPos(0)); + assertEquals("4 key fix 5 L2 <2>", 0, params.getColumnPos(1)); + assertEquals("4 key fix 5 L2 [3]", 1, params.getColumnPos(2)); + assertEquals("4 key fix 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("4 key fix 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key fix 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [1] [2] [3] <4>| + @Test + public void testLayout4KeyFix5R0() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R0); + assertEquals("4 key fix 5 R0 columns", 4, params.mNumColumns); + assertEquals("4 key fix 5 R0 rows", 1, params.mNumRows); + assertEquals("4 key fix 5 R0 left", 3, params.mLeftKeys); + assertEquals("4 key fix 5 R0 right", 1, params.mRightKeys); + assertEquals("4 key fix 5 R0 [1]", -3, params.getColumnPos(0)); + assertEquals("4 key fix 5 R0 [2]", -2, params.getColumnPos(1)); + assertEquals("4 key fix 5 R0 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key fix 5 R0 <4>", 0, params.getColumnPos(3)); + assertEquals("4 key fix 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key fix 5 R0 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [1] [2] [3] <4> ___| + @Test + public void testLayout4KeyFix5R1() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R1); + assertEquals("4 key fix 5 R1 columns", 4, params.mNumColumns); + assertEquals("4 key fix 5 R1 rows", 1, params.mNumRows); + assertEquals("4 key fix 5 R1 left", 3, params.mLeftKeys); + assertEquals("4 key fix 5 R1 right", 1, params.mRightKeys); + assertEquals("4 key fix 5 R1 [1]", -3, params.getColumnPos(0)); + assertEquals("4 key fix 5 R1 [2]", -2, params.getColumnPos(1)); + assertEquals("4 key fix 5 R1 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key fix 5 R1 <4>", 0, params.getColumnPos(3)); + assertEquals("4 key fix 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key fix 5 R1 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [1] [2] <3> [4] ___| + @Test + public void testLayout4KeyFix5R2() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R2); + assertEquals("4 key fix 5 R2 columns", 4, params.mNumColumns); + assertEquals("4 key fix 5 R2 rows", 1, params.mNumRows); + assertEquals("4 key fix 5 R2 left", 2, params.mLeftKeys); + assertEquals("4 key fix 5 R2 right", 2, params.mRightKeys); + assertEquals("4 key fix 5 R2 [1]", -2, params.getColumnPos(0)); + assertEquals("4 key fix 5 R2 [2]", -1, params.getColumnPos(1)); + assertEquals("4 key fix 5 R2 <3>", 0, params.getColumnPos(2)); + assertEquals("4 key fix 5 R2 [4]", 1, params.getColumnPos(3)); + assertEquals("4 key fix 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key fix 5 R2 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [5] + // [1] <2> [3] [4] + @Test + public void testLayout5KeyFix4M0() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_M0); + assertEquals("5 key fix 4 M0 columns", 4, params.mNumColumns); + assertEquals("5 key fix 4 M0 rows", 2, params.mNumRows); + assertEquals("5 key fix 4 M0 left", 1, params.mLeftKeys); + assertEquals("5 key fix 4 M0 right", 3, params.mRightKeys); + assertEquals("5 key fix 4 M0 [1]", -1, params.getColumnPos(0)); + assertEquals("5 key fix 4 M0 <2>", 0, params.getColumnPos(1)); + assertEquals("5 key fix 4 M0 [3]", 1, params.getColumnPos(2)); + assertEquals("5 key fix 4 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("5 key fix 4 M0 [5]", 0, params.getColumnPos(4)); + assertEquals("5 key fix 4 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 4 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[5] + // |<1> [2] [3] [4] + @Test + public void testLayout5KeyFix4L0() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L0); + assertEquals("5 key fix 4 L0 columns", 4, params.mNumColumns); + assertEquals("5 key fix 4 L0 rows", 2, params.mNumRows); + assertEquals("5 key fix 4 L0 left", 0, params.mLeftKeys); + assertEquals("5 key fix 4 L0 right", 4, params.mRightKeys); + assertEquals("5 key fix 4 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key fix 4 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key fix 4 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key fix 4 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("5 key fix 4 L0 [5]", 0, params.getColumnPos(4)); + assertEquals("5 key fix 4 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 4 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [5] + // |___ <1> [2] [3] [4] + @Test + public void testLayout5KeyFix4L1() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L1); + assertEquals("5 key fix 4 L1 columns", 4, params.mNumColumns); + assertEquals("5 key fix 4 L1 rows", 2, params.mNumRows); + assertEquals("5 key fix 4 L1 left", 0, params.mLeftKeys); + assertEquals("5 key fix 4 L1 right", 4, params.mRightKeys); + assertEquals("5 key fix 4 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key fix 4 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key fix 4 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key fix 4 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("5 key fix 4 L1 [5]", 0, params.getColumnPos(4)); + assertEquals("5 key fix 4 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 4 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [5] + // |___ [1] <2> [3] [4] + @Test + public void testLayout5KeyFix4L2() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L2); + assertEquals("5 key fix 4 L2 columns", 4, params.mNumColumns); + assertEquals("5 key fix 4 L2 rows", 2, params.mNumRows); + assertEquals("5 key fix 4 L2 left", 1, params.mLeftKeys); + assertEquals("5 key fix 4 L2 right", 3, params.mRightKeys); + assertEquals("5 key fix 4 L2 [1]", -1, params.getColumnPos(0)); + assertEquals("5 key fix 4 L2 <2>", 0, params.getColumnPos(1)); + assertEquals("5 key fix 4 L2 [3]", 1, params.getColumnPos(2)); + assertEquals("5 key fix 4 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("5 key fix 4 L2 [5]", 0, params.getColumnPos(4)); + assertEquals("5 key fix 4 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 4 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [5]| + // [1] [2] [3] <4>| + @Test + public void testLayout5KeyFix4R0() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R0); + assertEquals("5 key fix 4 R0 columns", 4, params.mNumColumns); + assertEquals("5 key fix 4 R0 rows", 2, params.mNumRows); + assertEquals("5 key fix 4 R0 left", 3, params.mLeftKeys); + assertEquals("5 key fix 4 R0 right", 1, params.mRightKeys); + assertEquals("5 key fix 4 R0 [1]", -3, params.getColumnPos(0)); + assertEquals("5 key fix 4 R0 [2]", -2, params.getColumnPos(1)); + assertEquals("5 key fix 4 R0 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key fix 4 R0 <4>", 0, params.getColumnPos(3)); + assertEquals("5 key fix 4 R0 [5]", 0, params.getColumnPos(4)); + assertEquals("5 key fix 4 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 4 R0 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [5] ___| + // [1] [2] [3] <4> ___| + @Test + public void testLayout5KeyFix4R1() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R1); + assertEquals("5 key fix 4 R1 columns", 4, params.mNumColumns); + assertEquals("5 key fix 4 R1 rows", 2, params.mNumRows); + assertEquals("5 key fix 4 R1 left", 3, params.mLeftKeys); + assertEquals("5 key fix 4 R1 right", 1, params.mRightKeys); + assertEquals("5 key fix 4 R1 [1]", -3, params.getColumnPos(0)); + assertEquals("5 key fix 4 R1 [2]", -2, params.getColumnPos(1)); + assertEquals("5 key fix 4 R1 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key fix 4 R1 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key fix 4 R1 [5]", 0, params.getColumnPos(4)); + assertEquals("5 key fix 4 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 4 R1 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [5] ___| + // [1] [2] <3> [4] ___| + @Test + public void testLayout5KeyFix4R2() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R2); + assertEquals("5 key fix 4 R2 columns", 4, params.mNumColumns); + assertEquals("5 key fix 4 R2 rows", 2, params.mNumRows); + assertEquals("5 key fix 4 R2 left", 2, params.mLeftKeys); + assertEquals("5 key fix 4 R2 right", 2, params.mRightKeys); + assertEquals("5 key fix 4 R2 [1]", -2, params.getColumnPos(0)); + assertEquals("5 key fix 4 R2 [2]", -1, params.getColumnPos(1)); + assertEquals("5 key fix 4 R2 <3>", 0, params.getColumnPos(2)); + assertEquals("5 key fix 4 R2 [4]", 1, params.getColumnPos(3)); + assertEquals("5 key fix 4 R2 [5]", 0, params.getColumnPos(4)); + assertEquals("5 key fix 4 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 4 R2 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [5] [6] + // [1] <2> [3] [4] + @Test + public void testLayout6KeyFix4M0() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_M0); + assertEquals("6 key fix 4 M0 columns", 4, params.mNumColumns); + assertEquals("6 key fix 4 M0 rows", 2, params.mNumRows); + assertEquals("6 key fix 4 M0 left", 1, params.mLeftKeys); + assertEquals("6 key fix 4 M0 right", 3, params.mRightKeys); + assertEquals("6 key fix 4 M0 [1]", -1, params.getColumnPos(0)); + assertEquals("6 key fix 4 M0 <2>", 0, params.getColumnPos(1)); + assertEquals("6 key fix 4 M0 [3]", 1, params.getColumnPos(2)); + assertEquals("6 key fix 4 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("6 key fix 4 M0 [5]", 0, params.getColumnPos(4)); + assertEquals("6 key fix 4 M0 [6]", 1, params.getColumnPos(5)); + assertEquals("6 key fix 4 M0 adjust", -1, params.mTopRowAdjustment); + assertEquals("6 key fix 4 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[5] [6] + // |<1> [2] [3] [4] + @Test + public void testLayout6KeyFix4L0() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L0); + assertEquals("6 key fix 4 L0 columns", 4, params.mNumColumns); + assertEquals("6 key fix 4 L0 rows", 2, params.mNumRows); + assertEquals("6 key fix 4 L0 left", 0, params.mLeftKeys); + assertEquals("6 key fix 4 L0 right", 4, params.mRightKeys); + assertEquals("6 key fix 4 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key fix 4 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key fix 4 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("6 key fix 4 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("6 key fix 4 L0 [5]", 0, params.getColumnPos(4)); + assertEquals("6 key fix 4 L0 [6]", 1, params.getColumnPos(5)); + assertEquals("6 key fix 4 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 4 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [5] [6] + // |___ <1> [2] [3] [4] + @Test + public void testLayout6KeyFix4L1() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L1); + assertEquals("6 key fix 4 L1 columns", 4, params.mNumColumns); + assertEquals("6 key fix 4 L1 rows", 2, params.mNumRows); + assertEquals("6 key fix 4 L1 left", 0, params.mLeftKeys); + assertEquals("6 key fix 4 L1 right", 4, params.mRightKeys); + assertEquals("6 key fix 4 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key fix 4 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key fix 4 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("6 key fix 4 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("6 key fix 4 L1 [5]", 0, params.getColumnPos(4)); + assertEquals("6 key fix 4 L1 [6]", 1, params.getColumnPos(5)); + assertEquals("6 key fix 4 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 4 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [5] [6] + // |___ [1] <2> [3] [4] + @Test + public void testLayout6KeyFix4L2() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L2); + assertEquals("6 key fix 4 L2 columns", 4, params.mNumColumns); + assertEquals("6 key fix 4 L2 rows", 2, params.mNumRows); + assertEquals("6 key fix 4 L2 left", 1, params.mLeftKeys); + assertEquals("6 key fix 4 L2 right", 3, params.mRightKeys); + assertEquals("6 key fix 4 L2 [1]", -1, params.getColumnPos(0)); + assertEquals("6 key fix 4 L2 <2>", 0, params.getColumnPos(1)); + assertEquals("6 key fix 4 L2 [3]", 1, params.getColumnPos(2)); + assertEquals("6 key fix 4 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("6 key fix 4 L2 [5]", 0, params.getColumnPos(4)); + assertEquals("6 key fix 4 L2 [6]", 1, params.getColumnPos(5)); + assertEquals("6 key fix 4 L2 adjust", -1, params.mTopRowAdjustment); + assertEquals("6 key fix 4 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [5] [6]| + // [1] [2] [3] <4>| + @Test + public void testLayout6KeyFix4R0() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R0); + assertEquals("6 key fix 4 R0 columns", 4, params.mNumColumns); + assertEquals("6 key fix 4 R0 rows", 2, params.mNumRows); + assertEquals("6 key fix 4 R0 left", 3, params.mLeftKeys); + assertEquals("6 key fix 4 R0 right", 1, params.mRightKeys); + assertEquals("6 key fix 4 R0 [1]", -3, params.getColumnPos(0)); + assertEquals("6 key fix 4 R0 [2]", -2, params.getColumnPos(1)); + assertEquals("6 key fix 4 R0 [3]", -1, params.getColumnPos(2)); + assertEquals("6 key fix 4 R0 <4>", 0, params.getColumnPos(3)); + assertEquals("6 key fix 4 R0 [5]", -1, params.getColumnPos(4)); + assertEquals("6 key fix 4 R0 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key fix 4 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 4 R0 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [5] [6] ___| + // [1] [2] [3] <4> ___| + @Test + public void testLayout6KeyFix4R1() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R1); + assertEquals("6 key fix 4 R1 columns", 4, params.mNumColumns); + assertEquals("6 key fix 4 R1 rows", 2, params.mNumRows); + assertEquals("6 key fix 4 R1 left", 3, params.mLeftKeys); + assertEquals("6 key fix 4 R1 right", 1, params.mRightKeys); + assertEquals("6 key fix 4 R1 [1]", -3, params.getColumnPos(0)); + assertEquals("6 key fix 4 R1 [2]", -2, params.getColumnPos(1)); + assertEquals("6 key fix 4 R1 [3]", -1, params.getColumnPos(2)); + assertEquals("6 key fix 4 R1 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key fix 4 R1 [5]", -1, params.getColumnPos(4)); + assertEquals("6 key fix 4 R1 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key fix 4 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 4 R1 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [5] [6] ___| + // [1] [2] <3> [4] ___| + @Test + public void testLayout6KeyFix4R2() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R2); + assertEquals("6 key fix 4 R2 columns", 4, params.mNumColumns); + assertEquals("6 key fix 4 R2 rows", 2, params.mNumRows); + assertEquals("6 key fix 4 R2 left", 2, params.mLeftKeys); + assertEquals("6 key fix 4 R2 right", 2, params.mRightKeys); + assertEquals("6 key fix 4 R2 [1]", -2, params.getColumnPos(0)); + assertEquals("6 key fix 4 R2 [2]", -1, params.getColumnPos(1)); + assertEquals("6 key fix 4 R2 <3>", 0, params.getColumnPos(2)); + assertEquals("6 key fix 4 R2 [4]", 1, params.getColumnPos(3)); + assertEquals("6 key fix 4 R2 [5]", 0, params.getColumnPos(4)); + assertEquals("6 key fix 4 R2 [6]", 1, params.getColumnPos(5)); + assertEquals("6 key fix 4 R2 adjust", -1, params.mTopRowAdjustment); + assertEquals("6 key fix 4 R2 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [5] [6] [7] + // [1] <2> [3] [4] + @Test + public void testLayout7KeyFix4M0() { + MoreKeysKeyboardParams params = createParams(7, 4, XPOS_M0); + assertEquals("7 key fix 4 M0 columns", 4, params.mNumColumns); + assertEquals("7 key fix 4 M0 rows", 2, params.mNumRows); + assertEquals("7 key fix 4 M0 left", 1, params.mLeftKeys); + assertEquals("7 key fix 4 M0 right", 3, params.mRightKeys); + assertEquals("7 key fix 4 M0 [1]", -1, params.getColumnPos(0)); + assertEquals("7 key fix 4 M0 <2>", 0, params.getColumnPos(1)); + assertEquals("7 key fix 4 M0 [3]", 1, params.getColumnPos(2)); + assertEquals("7 key fix 4 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key fix 4 M0 [5]", -1, params.getColumnPos(4)); + assertEquals("7 key fix 4 M0 [6]", 0, params.getColumnPos(5)); + assertEquals("7 key fix 4 M0 [7]", 1, params.getColumnPos(6)); + assertEquals("7 key fix 4 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 4 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[5] [6] [7] + // |<1> [2] [3] [4] + @Test + public void testLayout7KeyFix4L0() { + MoreKeysKeyboardParams params = createParams(7, 4, XPOS_L0); + assertEquals("7 key fix 4 L0 columns", 4, params.mNumColumns); + assertEquals("7 key fix 4 L0 rows", 2, params.mNumRows); + assertEquals("7 key fix 4 L0 left", 0, params.mLeftKeys); + assertEquals("7 key fix 4 L0 right", 4, params.mRightKeys); + assertEquals("7 key fix 4 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key fix 4 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key fix 4 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key fix 4 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("7 key fix 4 L0 [5]", 0, params.getColumnPos(4)); + assertEquals("7 key fix 4 L0 [6]", 1, params.getColumnPos(5)); + assertEquals("7 key fix 4 L0 [7]", 2, params.getColumnPos(6)); + assertEquals("7 key fix 4 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 4 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [5] [6] [7] + // |___ <1> [2] [3] [4] + @Test + public void testLayout7KeyFix4L1() { + MoreKeysKeyboardParams params = createParams(7, 4, XPOS_L1); + assertEquals("7 key fix 4 L1 columns", 4, params.mNumColumns); + assertEquals("7 key fix 4 L1 rows", 2, params.mNumRows); + assertEquals("7 key fix 4 L1 left", 0, params.mLeftKeys); + assertEquals("7 key fix 4 L1 right", 4, params.mRightKeys); + assertEquals("7 key fix 4 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key fix 4 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key fix 4 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key fix 4 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("7 key fix 4 L1 [5]", 0, params.getColumnPos(4)); + assertEquals("7 key fix 4 L1 [6]", 1, params.getColumnPos(5)); + assertEquals("7 key fix 4 l1 [7]", 2, params.getColumnPos(6)); + assertEquals("7 key fix 4 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 4 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [5] [6] [7] + // |___ [1] <2> [3] [4] + @Test + public void testLayout7KeyFix4L2() { + MoreKeysKeyboardParams params = createParams(7, 4, XPOS_L2); + assertEquals("7 key fix 4 L2 columns", 4, params.mNumColumns); + assertEquals("7 key fix 4 L2 rows", 2, params.mNumRows); + assertEquals("7 key fix 4 L2 left", 1, params.mLeftKeys); + assertEquals("7 key fix 4 L2 right", 3, params.mRightKeys); + assertEquals("7 key fix 4 L2 [1]", -1, params.getColumnPos(0)); + assertEquals("7 key fix 4 L2 <2>", 0, params.getColumnPos(1)); + assertEquals("7 key fix 4 L2 [3]", 1, params.getColumnPos(2)); + assertEquals("7 key fix 4 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key fix 4 L2 [5]", -1, params.getColumnPos(4)); + assertEquals("7 key fix 4 L2 [6]", 0, params.getColumnPos(5)); + assertEquals("7 key fix 4 L2 [7]", 1, params.getColumnPos(6)); + assertEquals("7 key fix 4 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 4 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [5] [6] [7]| + // [1] [2] [3] <4>| + @Test + public void testLayout7KeyFix4R0() { + MoreKeysKeyboardParams params = createParams(7, 4, XPOS_R0); + assertEquals("7 key fix 4 R0 columns", 4, params.mNumColumns); + assertEquals("7 key fix 4 R0 rows", 2, params.mNumRows); + assertEquals("7 key fix 4 R0 left", 3, params.mLeftKeys); + assertEquals("7 key fix 4 R0 right", 1, params.mRightKeys); + assertEquals("7 key fix 4 R0 [1]", -3, params.getColumnPos(0)); + assertEquals("7 key fix 4 R0 [2]", -2, params.getColumnPos(1)); + assertEquals("7 key fix 4 R0 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key fix 4 R0 <4>", 0, params.getColumnPos(3)); + assertEquals("7 key fix 4 R0 [5]", -2, params.getColumnPos(4)); + assertEquals("7 key fix 4 R0 [6]", -1, params.getColumnPos(5)); + assertEquals("7 key fix 4 R0 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key fix 4 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 4 R0 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [5] [6] [7] ___| + // [1] [2] [3] <4> ___| + @Test + public void testLayout7KeyFix4R1() { + MoreKeysKeyboardParams params = createParams(7, 4, XPOS_R1); + assertEquals("7 key fix 4 R1 columns", 4, params.mNumColumns); + assertEquals("7 key fix 4 R1 rows", 2, params.mNumRows); + assertEquals("7 key fix 4 R1 left", 3, params.mLeftKeys); + assertEquals("7 key fix 4 R1 right", 1, params.mRightKeys); + assertEquals("7 key fix 4 R1 [1]", -3, params.getColumnPos(0)); + assertEquals("7 key fix 4 R1 [2]", -2, params.getColumnPos(1)); + assertEquals("7 key fix 4 R1 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key fix 4 R1 <4>", 0, params.getColumnPos(3)); + assertEquals("7 key fix 4 R1 [5]", -2, params.getColumnPos(4)); + assertEquals("7 key fix 4 R1 [6]", -1, params.getColumnPos(5)); + assertEquals("7 key fix 4 R1 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key fix 4 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 4 R1 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [5] [6] [7] ___| + // [1] [2] <3> [4] ___| + @Test + public void testLayout7KeyFix4R2() { + MoreKeysKeyboardParams params = createParams(7, 4, XPOS_R2); + assertEquals("7 key fix 4 R2 columns", 4, params.mNumColumns); + assertEquals("7 key fix 4 R2 rows", 2, params.mNumRows); + assertEquals("7 key fix 4 R2 left", 2, params.mLeftKeys); + assertEquals("7 key fix 4 R2 right", 2, params.mRightKeys); + assertEquals("7 key fix 4 R2 [1]", -2, params.getColumnPos(0)); + assertEquals("7 key fix 4 R2 [2]", -1, params.getColumnPos(1)); + assertEquals("7 key fix 4 R2 <3>", 0, params.getColumnPos(2)); + assertEquals("7 key fix 4 R2 [4]", 1, params.getColumnPos(3)); + assertEquals("7 key fix 4 R2 [5]", -1, params.getColumnPos(4)); + assertEquals("7 key fix 4 R2 [6]", 0, params.getColumnPos(5)); + assertEquals("7 key fix 4 R2 [7]", 1, params.getColumnPos(6)); + assertEquals("7 key fix 4 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 4 R2 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [5] [6] [7] [8] + // [1] <2> [3] [4] + @Test + public void testLayout8KeyFix4M0() { + MoreKeysKeyboardParams params = createParams(8, 4, XPOS_M0); + assertEquals("8 key fix 4 M0 columns", 4, params.mNumColumns); + assertEquals("8 key fix 4 M0 rows", 2, params.mNumRows); + assertEquals("8 key fix 4 M0 left", 1, params.mLeftKeys); + assertEquals("8 key fix 4 M0 right", 3, params.mRightKeys); + assertEquals("8 key fix 4 M0 [1]", -1, params.getColumnPos(0)); + assertEquals("8 key fix 4 M0 <2>", 0, params.getColumnPos(1)); + assertEquals("8 key fix 4 M0 [3]", 1, params.getColumnPos(2)); + assertEquals("8 key fix 4 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("8 key fix 4 M0 [5]", -1, params.getColumnPos(4)); + assertEquals("8 key fix 4 M0 [6]", 0, params.getColumnPos(5)); + assertEquals("8 key fix 4 M0 [7]", 1, params.getColumnPos(6)); + assertEquals("8 key fix 4 M0 [8]", 2, params.getColumnPos(7)); + assertEquals("8 key fix 4 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key fix 4 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[5] [6] [7] [8] + // |<1> [2] [3] [4] + @Test + public void testLayout8KeyFix4L0() { + MoreKeysKeyboardParams params = createParams(8, 4, XPOS_L0); + assertEquals("8 key fix 4 L0 columns", 4, params.mNumColumns); + assertEquals("8 key fix 4 L0 rows", 2, params.mNumRows); + assertEquals("8 key fix 4 L0 left", 0, params.mLeftKeys); + assertEquals("8 key fix 4 L0 right", 4, params.mRightKeys); + assertEquals("8 key fix 4 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key fix 4 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("8 key fix 4 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("8 key fix 4 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("8 key fix 4 L0 [5]", 0, params.getColumnPos(4)); + assertEquals("8 key fix 4 L0 [6]", 1, params.getColumnPos(5)); + assertEquals("8 key fix 4 L0 [7]", 2, params.getColumnPos(6)); + assertEquals("8 key fix 4 L0 [8]", 3, params.getColumnPos(7)); + assertEquals("8 key fix 4 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key fix 4 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [5] [6] [7] [8] + // |___ <1> [2] [3] [4] + @Test + public void testLayout8KeyFix4L1() { + MoreKeysKeyboardParams params = createParams(8, 4, XPOS_L1); + assertEquals("8 key fix 4 L1 columns", 4, params.mNumColumns); + assertEquals("8 key fix 4 L1 rows", 2, params.mNumRows); + assertEquals("8 key fix 4 L1 left", 0, params.mLeftKeys); + assertEquals("8 key fix 4 L1 right", 4, params.mRightKeys); + assertEquals("8 key fix 4 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key fix 4 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("8 key fix 4 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("8 key fix 4 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("8 key fix 4 L1 [5]", 0, params.getColumnPos(4)); + assertEquals("8 key fix 4 L1 [6]", 1, params.getColumnPos(5)); + assertEquals("8 key fix 4 L1 [7]", 2, params.getColumnPos(6)); + assertEquals("8 key fix 4 L1 [8]", 3, params.getColumnPos(7)); + assertEquals("8 key fix 4 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key fix 4 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [5] [6] [7] [8] + // |___ [1] <2> [3] [4] + @Test + public void testLayout8KeyFix4L2() { + MoreKeysKeyboardParams params = createParams(8, 4, XPOS_L2); + assertEquals("8 key fix 4 L2 columns", 4, params.mNumColumns); + assertEquals("8 key fix 4 L2 rows", 2, params.mNumRows); + assertEquals("8 key fix 4 L2 left", 1, params.mLeftKeys); + assertEquals("8 key fix 4 L2 right", 3, params.mRightKeys); + assertEquals("8 key fix 4 L2 [1]", -1, params.getColumnPos(0)); + assertEquals("8 key fix 4 L2 <2>", 0, params.getColumnPos(1)); + assertEquals("8 key fix 4 L2 [3]", 1, params.getColumnPos(2)); + assertEquals("8 key fix 4 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("8 key fix 4 L2 [5]", -1, params.getColumnPos(4)); + assertEquals("8 key fix 4 L2 [6]", 0, params.getColumnPos(5)); + assertEquals("8 key fix 4 L2 [7]", 1, params.getColumnPos(6)); + assertEquals("8 key fix 4 L2 [8]", 2, params.getColumnPos(7)); + assertEquals("8 key fix 4 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key fix 4 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [5] [6] [7] [8]| + // [1] [2] [3] <4>| + @Test + public void testLayout8KeyFix4R0() { + MoreKeysKeyboardParams params = createParams(8, 4, XPOS_R0); + assertEquals("8 key fix 4 R0 columns", 4, params.mNumColumns); + assertEquals("8 key fix 4 R0 rows", 2, params.mNumRows); + assertEquals("8 key fix 4 R0 left", 3, params.mLeftKeys); + assertEquals("8 key fix 4 R0 right", 1, params.mRightKeys); + assertEquals("8 key fix 4 R0 [1]", -3, params.getColumnPos(0)); + assertEquals("8 key fix 4 R0 [2]", -2, params.getColumnPos(1)); + assertEquals("8 key fix 4 R0 [3]", -1, params.getColumnPos(2)); + assertEquals("8 key fix 4 R0 <4>", 0, params.getColumnPos(3)); + assertEquals("8 key fix 4 R0 [5]", -3, params.getColumnPos(4)); + assertEquals("8 key fix 4 R0 [6]", -2, params.getColumnPos(5)); + assertEquals("8 key fix 4 R0 [7]", -1, params.getColumnPos(6)); + assertEquals("8 key fix 4 R0 [8]", 0, params.getColumnPos(7)); + assertEquals("8 key fix 4 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key fix 4 R0 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [5] [6] [7] [8] ___| + // [1] [2] [3] <4> ___| + @Test + public void testLayout8KeyFix4R1() { + MoreKeysKeyboardParams params = createParams(8, 4, XPOS_R1); + assertEquals("8 key fix 4 R1 columns", 4, params.mNumColumns); + assertEquals("8 key fix 4 R1 rows", 2, params.mNumRows); + assertEquals("8 key fix 4 R1 left", 3, params.mLeftKeys); + assertEquals("8 key fix 4 R1 right", 1, params.mRightKeys); + assertEquals("8 key fix 4 R1 [1]", -3, params.getColumnPos(0)); + assertEquals("8 key fix 4 R1 [2]", -2, params.getColumnPos(1)); + assertEquals("8 key fix 4 R1 [3]", -1, params.getColumnPos(2)); + assertEquals("8 key fix 4 R1 <4>", 0, params.getColumnPos(3)); + assertEquals("8 key fix 4 R1 [5]", -3, params.getColumnPos(4)); + assertEquals("8 key fix 4 R1 [6]", -2, params.getColumnPos(5)); + assertEquals("8 key fix 4 R1 [7]", -1, params.getColumnPos(6)); + assertEquals("8 key fix 4 R1 [8]", 0, params.getColumnPos(7)); + assertEquals("8 key fix 4 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key fix 4 R1 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [5] [6] [7] [8] ___| + // [1] [2] <3> [4] ___| + @Test + public void testLayout8KeyFix4R2() { + MoreKeysKeyboardParams params = createParams(8, 4, XPOS_R2); + assertEquals("8 key fix 4 R2 columns", 4, params.mNumColumns); + assertEquals("8 key fix 4 R2 rows", 2, params.mNumRows); + assertEquals("8 key fix 4 R2 left", 2, params.mLeftKeys); + assertEquals("8 key fix 4 R2 right", 2, params.mRightKeys); + assertEquals("8 key fix 4 R2 [1]", -2, params.getColumnPos(0)); + assertEquals("8 key fix 4 R2 [2]", -1, params.getColumnPos(1)); + assertEquals("8 key fix 4 R2 <3>", 0, params.getColumnPos(2)); + assertEquals("8 key fix 4 R2 [4]", 1, params.getColumnPos(3)); + assertEquals("8 key fix 4 R2 [5]", -2, params.getColumnPos(4)); + assertEquals("8 key fix 4 R2 [6]", -1, params.getColumnPos(5)); + assertEquals("8 key fix 4 R2 [7]", 0, params.getColumnPos(6)); + assertEquals("8 key fix 4 R2 [8]", 1, params.getColumnPos(7)); + assertEquals("8 key fix 4 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key fix 4 R2 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [1] [2] <3> [4] [5] + @Test + public void testLayout5KeyFix5M0() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_M0); + assertEquals("5 key fix 5 columns", 5, params.mNumColumns); + assertEquals("5 key fix 5 rows", 1, params.mNumRows); + assertEquals("5 key fix 5 left", 2, params.mLeftKeys); + assertEquals("5 key fix 5 right", 3, params.mRightKeys); + assertEquals("5 key fix 5 [1]", -2, params.getColumnPos(0)); + assertEquals("5 key fix 5 [2]", -1, params.getColumnPos(1)); + assertEquals("5 key fix 5 <3>", 0, params.getColumnPos(2)); + assertEquals("5 key fix 5 [4]", 1, params.getColumnPos(3)); + assertEquals("5 key fix 5 [5]", 2, params.getColumnPos(4)); + assertEquals("5 key fix 5 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 5 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |<1> [2] [3] [4] [5] + @Test + public void testLayout5KeyFix5L0() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L0); + assertEquals("5 key fix 5 L0 columns", 5, params.mNumColumns); + assertEquals("5 key fix 5 L0 rows", 1, params.mNumRows); + assertEquals("5 key fix 5 L0 left", 0, params.mLeftKeys); + assertEquals("5 key fix 5 L0 right", 5, params.mRightKeys); + assertEquals("5 key fix 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key fix 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key fix 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key fix 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("5 key fix 5 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("5 key fix 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] [3] [4] [5] + @Test + public void testLayout5KeyFix5L1() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L1); + assertEquals("5 key fix 5 L1 columns", 5, params.mNumColumns); + assertEquals("5 key fix 5 L1 rows", 1, params.mNumRows); + assertEquals("5 key fix 5 L1 left", 0, params.mLeftKeys); + assertEquals("5 key fix 5 L1 right", 5, params.mRightKeys); + assertEquals("5 key fix 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key fix 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key fix 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key fix 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("5 key fix 5 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("5 key fix 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [1] <2> [3] [4] [5] + @Test + public void testLayout5KeyFix5L2() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L2); + assertEquals("5 key fix 5 L2 columns", 5, params.mNumColumns); + assertEquals("5 key fix 5 L2 rows", 1, params.mNumRows); + assertEquals("5 key fix 5 L2 left", 1, params.mLeftKeys); + assertEquals("5 key fix 5 L2 right", 4, params.mRightKeys); + assertEquals("5 key fix 5 L2 [1]", -1, params.getColumnPos(0)); + assertEquals("5 key fix 5 L2 <2>", 0, params.getColumnPos(1)); + assertEquals("5 key fix 5 L2 [3]", 1, params.getColumnPos(2)); + assertEquals("5 key fix 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("5 key fix 5 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("5 key fix 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [1] [2] [3] [4] <5>| + @Test + public void testLayout5KeyFix5R0() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R0); + assertEquals("5 key fix 5 R0 columns", 5, params.mNumColumns); + assertEquals("5 key fix 5 R0 rows", 1, params.mNumRows); + assertEquals("5 key fix 5 R0 left", 4, params.mLeftKeys); + assertEquals("5 key fix 5 R0 right", 1, params.mRightKeys); + assertEquals("5 key fix 5 R0 [1]", -4, params.getColumnPos(0)); + assertEquals("5 key fix 5 R0 [2]", -3, params.getColumnPos(1)); + assertEquals("5 key fix 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("5 key fix 5 R0 [4]", -1, params.getColumnPos(3)); + assertEquals("5 key fix 5 R0 <5>", 0, params.getColumnPos(4)); + assertEquals("5 key fix 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 5 R0 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [1] [2] [3] [4] <5> ___| + @Test + public void testLayout5KeyFix5R1() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R1); + assertEquals("5 key fix 5 R1 columns", 5, params.mNumColumns); + assertEquals("5 key fix 5 R1 rows", 1, params.mNumRows); + assertEquals("5 key fix 5 R1 left", 4, params.mLeftKeys); + assertEquals("5 key fix 5 R1 right", 1, params.mRightKeys); + assertEquals("5 key fix 5 R1 [1]", -4, params.getColumnPos(0)); + assertEquals("5 key fix 5 R1 [2]", -3, params.getColumnPos(1)); + assertEquals("5 key fix 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("5 key fix 5 R1 [4]", -1, params.getColumnPos(3)); + assertEquals("5 key fix 5 R1 <5>", 0, params.getColumnPos(4)); + assertEquals("5 key fix 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 5 R1 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [1] [2] [3] <4> [5] ___| + @Test + public void testLayout5KeyFix5R2() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R2); + assertEquals("5 key fix 5 R2 columns", 5, params.mNumColumns); + assertEquals("5 key fix 5 R2 rows", 1, params.mNumRows); + assertEquals("5 key fix 5 R2 left", 3, params.mLeftKeys); + assertEquals("5 key fix 5 R2 right", 2, params.mRightKeys); + assertEquals("5 key fix 5 R2 [1]", -3, params.getColumnPos(0)); + assertEquals("5 key fix 5 R2 [2]", -2, params.getColumnPos(1)); + assertEquals("5 key fix 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key fix 5 R2 <4>", 0, params.getColumnPos(3)); + assertEquals("5 key fix 5 R2 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key fix 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key fix 5 R2 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [6] + // [1] [2] <3> [4] [5] + @Test + public void testLayout6KeyFix5M0() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_M0); + assertEquals("6 key fix 5 columns", 5, params.mNumColumns); + assertEquals("6 key fix 5 rows", 2, params.mNumRows); + assertEquals("6 key fix 5 left", 2, params.mLeftKeys); + assertEquals("6 key fix 5 right", 3, params.mRightKeys); + assertEquals("6 key fix 5 [1]", -2, params.getColumnPos(0)); + assertEquals("6 key fix 5 [2]", -1, params.getColumnPos(1)); + assertEquals("6 key fix 5 <3>", 0, params.getColumnPos(2)); + assertEquals("6 key fix 5 [4]", 1, params.getColumnPos(3)); + assertEquals("6 key fix 5 [5]", 2, params.getColumnPos(4)); + assertEquals("6 key fix 5 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key fix 5 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 5 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |[6] + // |<1> [2] [3] [4] [5] + @Test + public void testLayout6KeyFix5L0() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L0); + assertEquals("6 key fix 5 L0 columns", 5, params.mNumColumns); + assertEquals("6 key fix 5 L0 rows", 2, params.mNumRows); + assertEquals("6 key fix 5 L0 left", 0, params.mLeftKeys); + assertEquals("6 key fix 5 L0 right", 5, params.mRightKeys); + assertEquals("6 key fix 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key fix 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key fix 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("6 key fix 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("6 key fix 5 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("6 key fix 5 L0 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key fix 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] + // |___ <1> [2] [3] [4] [5] + @Test + public void testLayout6KeyFix5L1() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L1); + assertEquals("6 key fix 5 L1 columns", 5, params.mNumColumns); + assertEquals("6 key fix 5 L1 rows", 2, params.mNumRows); + assertEquals("6 key fix 5 L1 left", 0, params.mLeftKeys); + assertEquals("6 key fix 5 L1 right", 5, params.mRightKeys); + assertEquals("6 key fix 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key fix 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key fix 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("6 key fix 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("6 key fix 5 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("6 key fix 5 L1 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key fix 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] + // |___ [1] <2> [3] [4] [5] + @Test + public void testLayout6KeyFix5L2() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L2); + assertEquals("6 key fix 5 L2 columns", 5, params.mNumColumns); + assertEquals("6 key fix 5 L2 rows", 2, params.mNumRows); + assertEquals("6 key fix 5 L2 left", 1, params.mLeftKeys); + assertEquals("6 key fix 5 L2 right", 4, params.mRightKeys); + assertEquals("6 key fix 5 L2 [1]", -1, params.getColumnPos(0)); + assertEquals("6 key fix 5 L2 <2>", 0, params.getColumnPos(1)); + assertEquals("6 key fix 5 L2 [3]", 1, params.getColumnPos(2)); + assertEquals("6 key fix 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("6 key fix 5 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("6 key fix 5 L2 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key fix 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [6]| + // [1] [2] [3] [4] <5>| + @Test + public void testLayout6KeyFix5R0() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R0); + assertEquals("6 key fix 5 R0 columns", 5, params.mNumColumns); + assertEquals("6 key fix 5 R0 rows", 2, params.mNumRows); + assertEquals("6 key fix 5 R0 left", 4, params.mLeftKeys); + assertEquals("6 key fix 5 R0 right", 1, params.mRightKeys); + assertEquals("6 key fix 5 R0 [1]", -4, params.getColumnPos(0)); + assertEquals("6 key fix 5 R0 [2]", -3, params.getColumnPos(1)); + assertEquals("6 key fix 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("6 key fix 5 R0 [4]", -1, params.getColumnPos(3)); + assertEquals("6 key fix 5 R0 <5>", 0, params.getColumnPos(4)); + assertEquals("6 key fix 5 R0 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key fix 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 5 R0 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [6] ___| + // [1] [2] [3] [4] <5> ___| + @Test + public void testLayout6KeyFix5R1() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R1); + assertEquals("6 key fix 5 R1 columns", 5, params.mNumColumns); + assertEquals("6 key fix 5 R1 rows", 2, params.mNumRows); + assertEquals("6 key fix 5 R1 left", 4, params.mLeftKeys); + assertEquals("6 key fix 5 R1 right", 1, params.mRightKeys); + assertEquals("6 key fix 5 R1 [1]", -4, params.getColumnPos(0)); + assertEquals("6 key fix 5 R1 [2]", -3, params.getColumnPos(1)); + assertEquals("6 key fix 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("6 key fix 5 R1 [4]", -1, params.getColumnPos(3)); + assertEquals("6 key fix 5 R1 <5>", 0, params.getColumnPos(4)); + assertEquals("6 key fix 5 R1 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key fix 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 5 R1 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [6] ___| + // [1] [2] [3] <4> [5] ___| + @Test + public void testLayout6KeyFix5R2() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R2); + assertEquals("6 key fix 5 R2 columns", 5, params.mNumColumns); + assertEquals("6 key fix 5 R2 rows", 2, params.mNumRows); + assertEquals("6 key fix 5 R2 left", 3, params.mLeftKeys); + assertEquals("6 key fix 5 R2 right", 2, params.mRightKeys); + assertEquals("6 key fix 5 R2 [1]", -3, params.getColumnPos(0)); + assertEquals("6 key fix 5 R2 [2]", -2, params.getColumnPos(1)); + assertEquals("6 key fix 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("6 key fix 5 R2 <4>", 0, params.getColumnPos(3)); + assertEquals("6 key fix 5 R2 [5]", 1, params.getColumnPos(4)); + assertEquals("6 key fix 5 R2 [6]", 0, params.getColumnPos(5)); + assertEquals("6 key fix 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key fix 5 R2 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [6] [7] + // [1] [2] <3> [4] [5] + @Test + public void testLayout7KeyFix5M0() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_M0); + assertEquals("7 key fix 5 columns", 5, params.mNumColumns); + assertEquals("7 key fix 5 rows", 2, params.mNumRows); + assertEquals("7 key fix 5 left", 2, params.mLeftKeys); + assertEquals("7 key fix 5 right", 3, params.mRightKeys); + assertEquals("7 key fix 5 [1]", -2, params.getColumnPos(0)); + assertEquals("7 key fix 5 [2]", -1, params.getColumnPos(1)); + assertEquals("7 key fix 5 <3>", 0, params.getColumnPos(2)); + assertEquals("7 key fix 5 [4]", 1, params.getColumnPos(3)); + assertEquals("7 key fix 5 [5]", 2, params.getColumnPos(4)); + assertEquals("7 key fix 5 [6]", 0, params.getColumnPos(5)); + assertEquals("7 key fix 5 [7]", 1, params.getColumnPos(6)); + assertEquals("7 key fix 5 adjust", -1, params.mTopRowAdjustment); + assertEquals("7 key fix 5 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |[6] [7] + // |<1> [2] [3] [4] [5] + @Test + public void testLayout7KeyFix5L0() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L0); + assertEquals("7 key fix 5 L0 columns", 5, params.mNumColumns); + assertEquals("7 key fix 5 L0 rows", 2, params.mNumRows); + assertEquals("7 key fix 5 L0 left", 0, params.mLeftKeys); + assertEquals("7 key fix 5 L0 right", 5, params.mRightKeys); + assertEquals("7 key fix 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key fix 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key fix 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key fix 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("7 key fix 5 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("7 key fix 5 L0 [6]", 0, params.getColumnPos(5)); + assertEquals("7 key fix 5 L0 [7]", 1, params.getColumnPos(6)); + assertEquals("7 key fix 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] + // |___ <1> [2] [3] [4] [5] + @Test + public void testLayout7KeyFix5L1() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L1); + assertEquals("7 key fix 5 L1 columns", 5, params.mNumColumns); + assertEquals("7 key fix 5 L1 rows", 2, params.mNumRows); + assertEquals("7 key fix 5 L1 left", 0, params.mLeftKeys); + assertEquals("7 key fix 5 L1 right", 5, params.mRightKeys); + assertEquals("7 key fix 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key fix 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key fix 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key fix 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("7 key fix 5 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("7 key fix 5 L1 [6]", 0, params.getColumnPos(5)); + assertEquals("7 key fix 5 L1 [7]", 1, params.getColumnPos(6)); + assertEquals("7 key fix 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] + // |___ [1] <2> [3] [4] [5] + @Test + public void testLayout7KeyFix5L2() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L2); + assertEquals("7 key fix 5 L2 columns", 5, params.mNumColumns); + assertEquals("7 key fix 5 L2 rows", 2, params.mNumRows); + assertEquals("7 key fix 5 L2 left", 1, params.mLeftKeys); + assertEquals("7 key fix 5 L2 right", 4, params.mRightKeys); + assertEquals("7 key fix 5 L2 [1]", -1, params.getColumnPos(0)); + assertEquals("7 key fix 5 L2 <2>", 0, params.getColumnPos(1)); + assertEquals("7 key fix 5 L2 [3]", 1, params.getColumnPos(2)); + assertEquals("7 key fix 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key fix 5 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("7 key fix 5 L2 [6]", 0, params.getColumnPos(5)); + assertEquals("7 key fix 5 L2 [7]", 1, params.getColumnPos(6)); + assertEquals("7 key fix 5 L2 adjust", -1, params.mTopRowAdjustment); + assertEquals("7 key fix 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [6] [7]| + // [1] [2] [3] [4] <5>| + @Test + public void testLayout7KeyFix5R0() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R0); + assertEquals("7 key fix 5 R0 columns", 5, params.mNumColumns); + assertEquals("7 key fix 5 R0 rows", 2, params.mNumRows); + assertEquals("7 key fix 5 R0 left", 4, params.mLeftKeys); + assertEquals("7 key fix 5 R0 right", 1, params.mRightKeys); + assertEquals("7 key fix 5 R0 [1]", -4, params.getColumnPos(0)); + assertEquals("7 key fix 5 R0 [2]", -3, params.getColumnPos(1)); + assertEquals("7 key fix 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("7 key fix 5 R0 [4]", -1, params.getColumnPos(3)); + assertEquals("7 key fix 5 R0 <5>", 0, params.getColumnPos(4)); + assertEquals("7 key fix 5 R0 [6]", -1, params.getColumnPos(5)); + assertEquals("7 key fix 5 R0 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key fix 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 5 R0 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [6] [7] ___| + // [1] [2] [3] [4] <5> ___| + @Test + public void testLayout7KeyFix5R1() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R1); + assertEquals("7 key fix 5 R1 columns", 5, params.mNumColumns); + assertEquals("7 key fix 5 R1 rows", 2, params.mNumRows); + assertEquals("7 key fix 5 R1 left", 4, params.mLeftKeys); + assertEquals("7 key fix 5 R1 right", 1, params.mRightKeys); + assertEquals("7 key fix 5 R1 [1]", -4, params.getColumnPos(0)); + assertEquals("7 key fix 5 R1 [2]", -3, params.getColumnPos(1)); + assertEquals("7 key fix 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("7 key fix 5 R1 [4]", -1, params.getColumnPos(3)); + assertEquals("7 key fix 5 R1 <5>", 0, params.getColumnPos(4)); + assertEquals("7 key fix 5 R1 [6]", -1, params.getColumnPos(5)); + assertEquals("7 key fix 5 R1 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key fix 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 5 R1 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [6] [7] ___| + // [1] [2] [3] <4> [5] ___| + @Test + public void testLayout7KeyFix5R2() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R2); + assertEquals("7 key fix 5 R2 columns",5, params.mNumColumns); + assertEquals("7 key fix 5 R2 rows", 2, params.mNumRows); + assertEquals("7 key fix 5 R2 left", 3, params.mLeftKeys); + assertEquals("7 key fix 5 R2 right", 2, params.mRightKeys); + assertEquals("7 key fix 5 R2 [1]", -3, params.getColumnPos(0)); + assertEquals("7 key fix 5 R2 [2]", -2, params.getColumnPos(1)); + assertEquals("7 key fix 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key fix 5 R2 <4>", 0, params.getColumnPos(3)); + assertEquals("7 key fix 5 R2 [5]", 1, params.getColumnPos(4)); + assertEquals("7 key fix 5 R2 [6]", 0, params.getColumnPos(5)); + assertEquals("7 key fix 5 R2 [7]", 1, params.getColumnPos(6)); + assertEquals("7 key fix 5 R2 adjust", -1, params.mTopRowAdjustment); + assertEquals("7 key fix 5 R2 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [6] [7] [8] + // [1] [2] <3> [4] [5] + @Test + public void testLayout8KeyFix5M0() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_M0); + assertEquals("8 key fix 5 M0 columns", 5, params.mNumColumns); + assertEquals("8 key fix 5 M0 rows", 2, params.mNumRows); + assertEquals("8 key fix 5 M0 left", 2, params.mLeftKeys); + assertEquals("8 key fix 5 M0 right", 3, params.mRightKeys); + assertEquals("8 key fix 5 M0 [1]", -2, params.getColumnPos(0)); + assertEquals("8 key fix 5 M0 [2]", -1, params.getColumnPos(1)); + assertEquals("8 key fix 5 M0 <3>", 0, params.getColumnPos(2)); + assertEquals("8 key fix 5 M0 [4]", 1, params.getColumnPos(3)); + assertEquals("8 key fix 5 M0 [5]", 2, params.getColumnPos(4)); + assertEquals("8 key fix 5 M0 [6]", -1, params.getColumnPos(5)); + assertEquals("8 key fix 5 M0 [7]", 0, params.getColumnPos(6)); + assertEquals("8 key fix 5 M0 [8]", 1, params.getColumnPos(7)); + assertEquals("8 key fix 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key fix 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |[6] [7] [8] + // |<1> [2] [3] [4] [5] + @Test + public void testLayout8KeyFix5L0() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L0); + assertEquals("8 key fix 5 L0 columns", 5, params.mNumColumns); + assertEquals("8 key fix 5 L0 rows", 2, params.mNumRows); + assertEquals("8 key fix 5 L0 left", 0, params.mLeftKeys); + assertEquals("8 key fix 5 L0 right", 5, params.mRightKeys); + assertEquals("8 key fix 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key fix 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("8 key fix 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("8 key fix 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("8 key fix 5 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("8 key fix 5 L0 [6]", 0, params.getColumnPos(5)); + assertEquals("8 key fix 5 L0 [7]", 1, params.getColumnPos(6)); + assertEquals("8 key fix 5 L0 [8]", 2, params.getColumnPos(7)); + assertEquals("8 key fix 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key fix 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] [8] + // |___ <1> [2] [3] [4] [5] + @Test + public void testLayout8KeyFix5L1() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L1); + assertEquals("8 key fix 5 L1 columns", 5, params.mNumColumns); + assertEquals("8 key fix 5 L1 rows", 2, params.mNumRows); + assertEquals("8 key fix 5 L1 left", 0, params.mLeftKeys); + assertEquals("8 key fix 5 L1 right", 5, params.mRightKeys); + assertEquals("8 key fix 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key fix 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("8 key fix 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("8 key fix 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("8 key fix 5 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("8 key fix 5 L1 [6]", 0, params.getColumnPos(5)); + assertEquals("8 key fix 5 L1 [7]", 1, params.getColumnPos(6)); + assertEquals("8 key fix 5 L1 [8]", 2, params.getColumnPos(7)); + assertEquals("8 key fix 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key fix 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] [8] + // |___ [1] <2> [3] [4] [5] + @Test + public void testLayout8KeyFix5L2() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L2); + assertEquals("8 key fix 5 L2 columns", 5, params.mNumColumns); + assertEquals("8 key fix 5 L2 rows", 2, params.mNumRows); + assertEquals("8 key fix 5 L2 left", 1, params.mLeftKeys); + assertEquals("8 key fix 5 L2 right", 4, params.mRightKeys); + assertEquals("8 key fix 5 L2 [1]", -1, params.getColumnPos(0)); + assertEquals("8 key fix 5 L2 <2>", 0, params.getColumnPos(1)); + assertEquals("8 key fix 5 L2 [3]", 1, params.getColumnPos(2)); + assertEquals("8 key fix 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("8 key fix 5 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("8 key fix 5 L2 [6]", -1, params.getColumnPos(5)); + assertEquals("8 key fix 5 L2 [7]", 0, params.getColumnPos(6)); + assertEquals("8 key fix 5 L2 [8]", 1, params.getColumnPos(7)); + assertEquals("8 key fix 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key fix 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [6] [7] [8]| + // [1] [2] [3] [4] <5>| + @Test + public void testLayout8KeyFix5R0() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R0); + assertEquals("8 key fix 5 R0 columns", 5, params.mNumColumns); + assertEquals("8 key fix 5 R0 rows", 2, params.mNumRows); + assertEquals("8 key fix 5 R0 left", 4, params.mLeftKeys); + assertEquals("8 key fix 5 R0 right", 1, params.mRightKeys); + assertEquals("8 key fix 5 R0 [1]", -4, params.getColumnPos(0)); + assertEquals("8 key fix 5 R0 [2]", -3, params.getColumnPos(1)); + assertEquals("8 key fix 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("8 key fix 5 R0 [4]", -1, params.getColumnPos(3)); + assertEquals("8 key fix 5 R0 <5>", 0, params.getColumnPos(4)); + assertEquals("8 key fix 5 R0 [6]", -2, params.getColumnPos(5)); + assertEquals("8 key fix 5 R0 [7]", -1, params.getColumnPos(6)); + assertEquals("8 key fix 5 R0 [8]", 0, params.getColumnPos(7)); + assertEquals("8 key fix 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key fix 5 R0 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [6] [7] [8] ___| + // [1] [2] [3] [4] <5> ___| + @Test + public void testLayout8KeyFix5R1() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R1); + assertEquals("8 key fix 5 R1 columns", 5, params.mNumColumns); + assertEquals("8 key fix 5 R1 rows", 2, params.mNumRows); + assertEquals("8 key fix 5 R1 left", 4, params.mLeftKeys); + assertEquals("8 key fix 5 R1 right", 1, params.mRightKeys); + assertEquals("8 key fix 5 R1 [1]", -4, params.getColumnPos(0)); + assertEquals("8 key fix 5 R1 [2]", -3, params.getColumnPos(1)); + assertEquals("8 key fix 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("8 key fix 5 R1 [4]", -1, params.getColumnPos(3)); + assertEquals("8 key fix 5 R1 <5>", 0, params.getColumnPos(4)); + assertEquals("8 key fix 5 R1 [6]", -2, params.getColumnPos(5)); + assertEquals("8 key fix 5 R1 [7]", -1, params.getColumnPos(6)); + assertEquals("8 key fix 5 R1 [8]", 0, params.getColumnPos(7)); + assertEquals("8 key fix 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key fix 5 R1 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [6] [7] [8] ___| + // [1] [2] [3] <4> [5] ___| + @Test + public void testLayout8KeyFix5R2() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R2); + assertEquals("8 key fix 5 R2 columns", 5, params.mNumColumns); + assertEquals("8 key fix 5 R2 rows", 2, params.mNumRows); + assertEquals("8 key fix 5 R2 left", 3, params.mLeftKeys); + assertEquals("8 key fix 5 R2 right", 2, params.mRightKeys); + assertEquals("8 key fix 5 R2 [1]", -3, params.getColumnPos(0)); + assertEquals("8 key fix 5 R2 [2]", -2, params.getColumnPos(1)); + assertEquals("8 key fix 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("8 key fix 5 R2 <4>", 0, params.getColumnPos(3)); + assertEquals("8 key fix 5 R2 [5]", 1, params.getColumnPos(4)); + assertEquals("8 key fix 5 R2 [6]", -1, params.getColumnPos(5)); + assertEquals("8 key fix 5 R2 [7]", 0, params.getColumnPos(6)); + assertEquals("8 key fix 5 R2 [8]", 1, params.getColumnPos(7)); + assertEquals("8 key fix 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key fix 5 R2 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [6] [7] [8] [9] + // [1] [2] <3> [4] [5] + @Test + public void testLayout9KeyFix5M0() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_M0); + assertEquals("9 key fix 5 M0 columns", 5, params.mNumColumns); + assertEquals("9 key fix 5 M0 rows", 2, params.mNumRows); + assertEquals("9 key fix 5 M0 left", 2, params.mLeftKeys); + assertEquals("9 key fix 5 M0 right", 3, params.mRightKeys); + assertEquals("9 key fix 5 M0 [1]", -2, params.getColumnPos(0)); + assertEquals("9 key fix 5 M0 [2]", -1, params.getColumnPos(1)); + assertEquals("9 key fix 5 M0 <3>", 0, params.getColumnPos(2)); + assertEquals("9 key fix 5 M0 [4]", 1, params.getColumnPos(3)); + assertEquals("9 key fix 5 M0 [5]", 2, params.getColumnPos(4)); + assertEquals("9 key fix 5 M0 [6]", -1, params.getColumnPos(5)); + assertEquals("9 key fix 5 M0 [7]", 0, params.getColumnPos(6)); + assertEquals("9 key fix 5 M0 [8]", 1, params.getColumnPos(7)); + assertEquals("9 key fix 5 M0 [9]", 2, params.getColumnPos(8)); + assertEquals("9 key fix 5 M0 adjust", -1, params.mTopRowAdjustment); + assertEquals("9 key fix 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |[6] [7] [8] [9] + // |<1> [2] [3] [4] [5] + @Test + public void testLayout9KeyFix5L0() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L0); + assertEquals("9 key fix 5 L0 columns", 5, params.mNumColumns); + assertEquals("9 key fix 5 L0 rows", 2, params.mNumRows); + assertEquals("9 key fix 5 L0 left", 0, params.mLeftKeys); + assertEquals("9 key fix 5 L0 right", 5, params.mRightKeys); + assertEquals("9 key fix 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("9 key fix 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("9 key fix 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("9 key fix 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("9 key fix 5 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("9 key fix 5 L0 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key fix 5 L0 [7]", 1, params.getColumnPos(6)); + assertEquals("9 key fix 5 L0 [8]", 2, params.getColumnPos(7)); + assertEquals("9 key fix 5 L0 [9]", 3, params.getColumnPos(8)); + assertEquals("9 key fix 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("9 key fix 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] [8] [9] + // |___ <1> [2] [3] [4] [5] + @Test + public void testLayout9KeyFix5L1() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L1); + assertEquals("9 key fix 5 L1 columns", 5, params.mNumColumns); + assertEquals("9 key fix 5 L1 rows", 2, params.mNumRows); + assertEquals("9 key fix 5 L1 left", 0, params.mLeftKeys); + assertEquals("9 key fix 5 L1 right", 5, params.mRightKeys); + assertEquals("9 key fix 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("9 key fix 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("9 key fix 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("9 key fix 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("9 key fix 5 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("9 key fix 5 L1 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key fix 5 L1 [7]", 1, params.getColumnPos(6)); + assertEquals("9 key fix 5 L1 [8]", 2, params.getColumnPos(7)); + assertEquals("9 key fix 5 L1 [9]", 3, params.getColumnPos(8)); + assertEquals("9 key fix 5 L1 adjust",0, params.mTopRowAdjustment); + assertEquals("9 key fix 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] [8] [9] + // |___ [1] <2> [3] [4] [5] + @Test + public void testLayout9KeyFix5L2() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L2); + assertEquals("9 key fix 5 L2 columns", 5, params.mNumColumns); + assertEquals("9 key fix 5 L2 rows", 2, params.mNumRows); + assertEquals("9 key fix 5 L2 left", 1, params.mLeftKeys); + assertEquals("9 key fix 5 L2 right", 4, params.mRightKeys); + assertEquals("9 key fix 5 L2 [1]", -1, params.getColumnPos(0)); + assertEquals("9 key fix 5 L2 <2>", 0, params.getColumnPos(1)); + assertEquals("9 key fix 5 L2 [3]", 1, params.getColumnPos(2)); + assertEquals("9 key fix 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("9 key fix 5 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("9 key fix 5 L2 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key fix 5 L2 [7]", 1, params.getColumnPos(6)); + assertEquals("9 key fix 5 L2 [8]", 2, params.getColumnPos(7)); + assertEquals("9 key fix 5 L2 [9]", 3, params.getColumnPos(8)); + assertEquals("9 key fix 5 L2 adjust", -1, params.mTopRowAdjustment); + assertEquals("9 key fix 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [6] [7] [8] [9]| + // [1] [2] [3] [4] <5>| + @Test + public void testLayout9KeyFix5R0() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R0); + assertEquals("9 key fix 5 R0 columns", 5, params.mNumColumns); + assertEquals("9 key fix 5 R0 rows", 2, params.mNumRows); + assertEquals("9 key fix 5 R0 left", 4, params.mLeftKeys); + assertEquals("9 key fix 5 R0 right", 1, params.mRightKeys); + assertEquals("9 key fix 5 R0 [1]", -4, params.getColumnPos(0)); + assertEquals("9 key fix 5 R0 [2]", -3, params.getColumnPos(1)); + assertEquals("9 key fix 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("9 key fix 5 R0 [4]", -1, params.getColumnPos(3)); + assertEquals("9 key fix 5 R0 <5>", 0, params.getColumnPos(4)); + assertEquals("9 key fix 5 R0 [6]", -3, params.getColumnPos(5)); + assertEquals("9 key fix 5 R0 [7]", -2, params.getColumnPos(6)); + assertEquals("9 key fix 5 R0 [8]", -1, params.getColumnPos(7)); + assertEquals("9 key fix 5 R0 [9]", 0, params.getColumnPos(8)); + assertEquals("9 key fix 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("9 key fix 5 R0 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [6] [7] [8] [9] ___| + // [1] [2] [3] [4] <5> ___| + @Test + public void testLayout9KeyFix5R1() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R1); + assertEquals("9 key fix 5 R1 columns", 5, params.mNumColumns); + assertEquals("9 key fix 5 R1 rows", 2, params.mNumRows); + assertEquals("9 key fix 5 R1 left", 4, params.mLeftKeys); + assertEquals("9 key fix 5 R1 right", 1, params.mRightKeys); + assertEquals("9 key fix 5 R1 [1]", -4, params.getColumnPos(0)); + assertEquals("9 key fix 5 R1 [2]", -3, params.getColumnPos(1)); + assertEquals("9 key fix 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("9 key fix 5 R1 [4]", -1, params.getColumnPos(3)); + assertEquals("9 key fix 5 R1 <5>", 0, params.getColumnPos(4)); + assertEquals("9 key fix 5 R1 [6]", -3, params.getColumnPos(5)); + assertEquals("9 key fix 5 R1 [7]", -2, params.getColumnPos(6)); + assertEquals("9 key fix 5 R1 [8]", -1, params.getColumnPos(7)); + assertEquals("9 key fix 5 R1 [9]", 0, params.getColumnPos(8)); + assertEquals("9 key fix 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("9 key fix 5 R1 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [6] [7] [8] [9] ___| + // [1] [2] [3] <4> [5] ___| + @Test + public void testLayout9KeyFix5R2() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R2); + assertEquals("9 key fix 5 R2 columns", 5, params.mNumColumns); + assertEquals("9 key fix 5 R2 rows", 2, params.mNumRows); + assertEquals("9 key fix 5 R2 left", 3, params.mLeftKeys); + assertEquals("9 key fix 5 R2 right", 2, params.mRightKeys); + assertEquals("9 key fix 5 R2 [1]", -3, params.getColumnPos(0)); + assertEquals("9 key fix 5 R2 [2]", -2, params.getColumnPos(1)); + assertEquals("9 key fix 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("9 key fix 5 R2 <4>", 0, params.getColumnPos(3)); + assertEquals("9 key fix 5 R2 [5]", 1, params.getColumnPos(4)); + assertEquals("9 key fix 5 R2 [6]", -2, params.getColumnPos(5)); + assertEquals("9 key fix 5 R2 [7]", -1, params.getColumnPos(6)); + assertEquals("9 key fix 5 R2 [8]", 0, params.getColumnPos(7)); + assertEquals("9 key fix 5 R2 [9]", 1, params.getColumnPos(8)); + assertEquals("9 key fix 5 R2 adjust", -1, params.mTopRowAdjustment); + assertEquals("9 key fix 5 R2 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [6] [7] [8] [9] [A] + // [1] [2] <3> [4] [5] + @Test + public void testLayout10KeyFix5M0() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_M0); + assertEquals("10 key fix 5 M0 columns", 5, params.mNumColumns); + assertEquals("10 key fix 5 M0 rows", 2, params.mNumRows); + assertEquals("10 key fix 5 M0 left", 2, params.mLeftKeys); + assertEquals("10 key fix 5 M0 right", 3, params.mRightKeys); + assertEquals("10 key fix 5 M0 [1]", -2, params.getColumnPos(0)); + assertEquals("10 key fix 5 M0 [2]", -1, params.getColumnPos(1)); + assertEquals("10 key fix 5 M0 <3>", 0, params.getColumnPos(2)); + assertEquals("10 key fix 5 M0 [4]", 1, params.getColumnPos(3)); + assertEquals("10 key fix 5 M0 [5]", 2, params.getColumnPos(4)); + assertEquals("10 key fix 5 M0 [6]", -2, params.getColumnPos(5)); + assertEquals("10 key fix 5 M0 [7]", -1, params.getColumnPos(6)); + assertEquals("10 key fix 5 M0 [8]", 0, params.getColumnPos(7)); + assertEquals("10 key fix 5 M0 [9]", 1, params.getColumnPos(8)); + assertEquals("10 key fix 5 M0 [A]", 2, params.getColumnPos(9)); + assertEquals("10 key fix 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key fix 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |[6] [7] [8] [9] [A] + // |<1> [2] [3] [4] [5] + @Test + public void testLayout10KeyFix5L0() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L0); + assertEquals("10 key fix 5 L0 columns", 5, params.mNumColumns); + assertEquals("10 key fix 5 L0 rows", 2, params.mNumRows); + assertEquals("10 key fix 5 L0 left", 0, params.mLeftKeys); + assertEquals("10 key fix 5 L0 right", 5, params.mRightKeys); + assertEquals("10 key fix 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("10 key fix 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("10 key fix 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("10 key fix 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("10 key fix 5 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("10 key fix 5 L0 [6]", 0, params.getColumnPos(5)); + assertEquals("10 key fix 5 L0 [7]", 1, params.getColumnPos(6)); + assertEquals("10 key fix 5 L0 [8]", 2, params.getColumnPos(7)); + assertEquals("10 key fix 5 L0 [9]", 3, params.getColumnPos(8)); + assertEquals("10 key fix 5 L0 [A]", 4, params.getColumnPos(9)); + assertEquals("10 key fix 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key fix 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] [8] [9] [A] + // |___ <1> [2] [3] [4] [5] + @Test + public void testLayout10KeyFix5L1() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L1); + assertEquals("10 key fix 5 L1 columns", 5, params.mNumColumns); + assertEquals("10 key fix 5 L1 rows", 2, params.mNumRows); + assertEquals("10 key fix 5 L1 left", 0, params.mLeftKeys); + assertEquals("10 key fix 5 L1 right", 5, params.mRightKeys); + assertEquals("10 key fix 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("10 key fix 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("10 key fix 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("10 key fix 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("10 key fix 5 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("10 key fix 5 L1 [6]", 0, params.getColumnPos(5)); + assertEquals("10 key fix 5 L1 [7]", 1, params.getColumnPos(6)); + assertEquals("10 key fix 5 L1 [8]", 2, params.getColumnPos(7)); + assertEquals("10 key fix 5 L1 [9]", 3, params.getColumnPos(8)); + assertEquals("10 key fix 5 L1 [A]", 4, params.getColumnPos(9)); + assertEquals("10 key fix 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key fix 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] [8] [9] [A] + // |___ [1] <2> [3] [4] [5] + @Test + public void testLayout10KeyFix5L2() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L2); + assertEquals("10 key fix 5 L2 columns", 5, params.mNumColumns); + assertEquals("10 key fix 5 L2 rows", 2, params.mNumRows); + assertEquals("10 key fix 5 L2 left", 1, params.mLeftKeys); + assertEquals("10 key fix 5 L2 right", 4, params.mRightKeys); + assertEquals("10 key fix 5 L2 [1]", -1, params.getColumnPos(0)); + assertEquals("10 key fix 5 L2 <2>", 0, params.getColumnPos(1)); + assertEquals("10 key fix 5 L2 [3]", 1, params.getColumnPos(2)); + assertEquals("10 key fix 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("10 key fix 5 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("10 key fix 5 L2 [6]", -1, params.getColumnPos(5)); + assertEquals("10 key fix 5 L2 [7]", 0, params.getColumnPos(6)); + assertEquals("10 key fix 5 L2 [8]", 1, params.getColumnPos(7)); + assertEquals("10 key fix 5 L2 [9]", 2, params.getColumnPos(8)); + assertEquals("10 key fix 5 L2 [A]", 3, params.getColumnPos(9)); + assertEquals("10 key fix 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key fix 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [6] [7] [8] [9] [A]| + // [1] [2] [3] [4] <5>| + @Test + public void testLayout10KeyFix5R0() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R0); + assertEquals("10 key fix 5 R0 columns", 5, params.mNumColumns); + assertEquals("10 key fix 5 R0 rows", 2, params.mNumRows); + assertEquals("10 key fix 5 R0 left", 4, params.mLeftKeys); + assertEquals("10 key fix 5 R0 right", 1, params.mRightKeys); + assertEquals("10 key fix 5 R0 [1]", -4, params.getColumnPos(0)); + assertEquals("10 key fix 5 R0 [2]", -3, params.getColumnPos(1)); + assertEquals("10 key fix 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("10 key fix 5 R0 [4]", -1, params.getColumnPos(3)); + assertEquals("10 key fix 5 R0 <5>", 0, params.getColumnPos(4)); + assertEquals("10 key fix 5 R0 [6]", -4, params.getColumnPos(5)); + assertEquals("10 key fix 5 R0 [7]", -3, params.getColumnPos(6)); + assertEquals("10 key fix 5 R0 [8]", -2, params.getColumnPos(7)); + assertEquals("10 key fix 5 R0 [9]", -1, params.getColumnPos(8)); + assertEquals("10 key fix 5 R0 [A]", 0, params.getColumnPos(9)); + assertEquals("10 key fix 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key fix 5 R0 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [6] [7] [8] [9] [A] ___| + // [1] [2] [3] [4] <5> ___| + @Test + public void testLayout10KeyFix5R1() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R1); + assertEquals("10 key fix 5 R1 columns", 5, params.mNumColumns); + assertEquals("10 key fix 5 R1 rows", 2, params.mNumRows); + assertEquals("10 key fix 5 R1 left", 4, params.mLeftKeys); + assertEquals("10 key fix 5 R1 right", 1, params.mRightKeys); + assertEquals("10 key fix 5 R1 [1]", -4, params.getColumnPos(0)); + assertEquals("10 key fix 5 R1 [2]", -3, params.getColumnPos(1)); + assertEquals("10 key fix 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("10 key fix 5 R1 [4]", -1, params.getColumnPos(3)); + assertEquals("10 key fix 5 R1 <5>", 0, params.getColumnPos(4)); + assertEquals("10 key fix 5 R1 [6]", -4, params.getColumnPos(5)); + assertEquals("10 key fix 5 R1 [7]", -3, params.getColumnPos(6)); + assertEquals("10 key fix 5 R1 [8]", -2, params.getColumnPos(7)); + assertEquals("10 key fix 5 R1 [9]", -1, params.getColumnPos(8)); + assertEquals("10 key fix 5 R1 [A]", 0, params.getColumnPos(9)); + assertEquals("10 key fix 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key fix 5 R1 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [6] [7] [8] [9] [A] ___| + // [1] [2] [3] <4> [5] ___| + @Test + public void testLayout10KeyFix5R2() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R2); + assertEquals("10 key fix 5 R2 columns", 5, params.mNumColumns); + assertEquals("10 key fix 5 R2 rows", 2, params.mNumRows); + assertEquals("10 key fix 5 R2 left", 3, params.mLeftKeys); + assertEquals("10 key fix 5 R2 right", 2, params.mRightKeys); + assertEquals("10 key fix 5 R2 [1]", -3, params.getColumnPos(0)); + assertEquals("10 key fix 5 R2 [2]", -2, params.getColumnPos(1)); + assertEquals("10 key fix 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("10 key fix 5 R2 <4>", 0, params.getColumnPos(3)); + assertEquals("10 key fix 5 R2 [5]", 1, params.getColumnPos(4)); + assertEquals("10 key fix 5 R2 [6]", -3, params.getColumnPos(5)); + assertEquals("10 key fix 5 R2 [7]", -2, params.getColumnPos(6)); + assertEquals("10 key fix 5 R2 [8]", -1, params.getColumnPos(7)); + assertEquals("10 key fix 5 R2 [9]", 0, params.getColumnPos(8)); + assertEquals("10 key fix 5 R2 [A]", 1, params.getColumnPos(9)); + assertEquals("10 key fix 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key fix 5 R2 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [B] + // [6] [7] [8] [9] [A] + // [1] [2] <3> [4] [5] + @Test + public void testLayout11KeyFix5M0() { + MoreKeysKeyboardParams params = createParams(11, 5, XPOS_M0); + assertEquals("11 key fix 5 M0 columns", 5, params.mNumColumns); + assertEquals("11 key fix 5 M0 rows", 3, params.mNumRows); + assertEquals("11 key fix 5 M0 left", 2, params.mLeftKeys); + assertEquals("11 key fix 5 M0 right", 3, params.mRightKeys); + assertEquals("11 key fix 5 M0 [1]", -2, params.getColumnPos(0)); + assertEquals("11 key fix 5 M0 [2]", -1, params.getColumnPos(1)); + assertEquals("11 key fix 5 M0 <3>", 0, params.getColumnPos(2)); + assertEquals("11 key fix 5 M0 [4]", 1, params.getColumnPos(3)); + assertEquals("11 key fix 5 M0 [5]", 2, params.getColumnPos(4)); + assertEquals("11 key fix 5 M0 [6]", -2, params.getColumnPos(5)); + assertEquals("11 key fix 5 M0 [7]", -1, params.getColumnPos(6)); + assertEquals("11 key fix 5 M0 [8]", 0, params.getColumnPos(7)); + assertEquals("11 key fix 5 M0 [9]", 1, params.getColumnPos(8)); + assertEquals("11 key fix 5 M0 [A]", 2, params.getColumnPos(9)); + assertEquals("11 key fix 5 M0 [B]", 0, params.getColumnPos(10)); + assertEquals("11 key fix 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("11 key fix 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [B] [C] + // [6] [7] [8] [9] [A] + // [1] [2] <3> [4] [5] + @Test + public void testLayout12KeyFix5M0() { + MoreKeysKeyboardParams params = createParams(12, 5, XPOS_M0); + assertEquals("12 key fix 5 M0 columns", 5, params.mNumColumns); + assertEquals("12 key fix 5 M0 rows", 3, params.mNumRows); + assertEquals("12 key fix 5 M0 left", 2, params.mLeftKeys); + assertEquals("12 key fix 5 M0 right", 3, params.mRightKeys); + assertEquals("12 key fix 5 M0 [1]", -2, params.getColumnPos(0)); + assertEquals("12 key fix 5 M0 [2]", -1, params.getColumnPos(1)); + assertEquals("12 key fix 5 M0 <3>", 0, params.getColumnPos(2)); + assertEquals("12 key fix 5 M0 [4]", 1, params.getColumnPos(3)); + assertEquals("12 key fix 5 M0 [5]", 2, params.getColumnPos(4)); + assertEquals("12 key fix 5 M0 [6]", -2, params.getColumnPos(5)); + assertEquals("12 key fix 5 M0 [7]", -1, params.getColumnPos(6)); + assertEquals("12 key fix 5 M0 [8]", 0, params.getColumnPos(7)); + assertEquals("12 key fix 5 M0 [9]", 1, params.getColumnPos(8)); + assertEquals("12 key fix 5 M0 [A]", 2, params.getColumnPos(9)); + assertEquals("12 key fix 5 M0 [B]", 0, params.getColumnPos(10)); + assertEquals("12 key fix 5 M0 [C]", 1, params.getColumnPos(11)); + assertEquals("12 key fix 5 M0 adjust", -1, params.mTopRowAdjustment); + assertEquals("12 key fix 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [B] [C] [D] + // [6] [7] [8] [9] [A] + // [1] [2] <3> [4] [5] + @Test + public void testLayout13KeyFix5M0() { + MoreKeysKeyboardParams params = createParams(13, 5, XPOS_M0); + assertEquals("13 key fix 5 M0 columns", 5, params.mNumColumns); + assertEquals("13 key fix 5 M0 rows", 3, params.mNumRows); + assertEquals("13 key fix 5 M0 left", 2, params.mLeftKeys); + assertEquals("13 key fix 5 M0 right", 3, params.mRightKeys); + assertEquals("13 key fix 5 M0 [1]", -2, params.getColumnPos(0)); + assertEquals("13 key fix 5 M0 [2]", -1, params.getColumnPos(1)); + assertEquals("13 key fix 5 M0 <3>", 0, params.getColumnPos(2)); + assertEquals("13 key fix 5 M0 [4]", 1, params.getColumnPos(3)); + assertEquals("13 key fix 5 M0 [5]", 2, params.getColumnPos(4)); + assertEquals("13 key fix 5 M0 [6]", -2, params.getColumnPos(5)); + assertEquals("13 key fix 5 M0 [7]", -1, params.getColumnPos(6)); + assertEquals("13 key fix 5 M0 [8]", 0, params.getColumnPos(7)); + assertEquals("13 key fix 5 M0 [9]", 1, params.getColumnPos(8)); + assertEquals("13 key fix 5 M0 [A]", 2, params.getColumnPos(9)); + assertEquals("13 key fix 5 M0 [B]", -1, params.getColumnPos(10)); + assertEquals("13 key fix 5 M0 [C]", 0, params.getColumnPos(11)); + assertEquals("13 key fix 5 M0 [D]", 1, params.getColumnPos(12)); + assertEquals("13 key fix 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("13 key fix 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [B] [C] [D] [E] + // [6] [7] [8] [9] [A] + // [1] [2] <3> [4] [5] + @Test + public void testLayout14KeyFix5M0() { + MoreKeysKeyboardParams params = createParams(14, 5, XPOS_M0); + assertEquals("14 key fix 5 M0 columns", 5, params.mNumColumns); + assertEquals("14 key fix 5 M0 rows", 3, params.mNumRows); + assertEquals("14 key fix 5 M0 left", 2, params.mLeftKeys); + assertEquals("14 key fix 5 M0 right", 3, params.mRightKeys); + assertEquals("14 key fix 5 M0 [1]", -2, params.getColumnPos(0)); + assertEquals("14 key fix 5 M0 [2]", -1, params.getColumnPos(1)); + assertEquals("14 key fix 5 M0 <3>", 0, params.getColumnPos(2)); + assertEquals("14 key fix 5 M0 [4]", 1, params.getColumnPos(3)); + assertEquals("14 key fix 5 M0 [5]", 2, params.getColumnPos(4)); + assertEquals("14 key fix 5 M0 [6]", -2, params.getColumnPos(5)); + assertEquals("14 key fix 5 M0 [7]", -1, params.getColumnPos(6)); + assertEquals("14 key fix 5 M0 [8]", 0, params.getColumnPos(7)); + assertEquals("14 key fix 5 M0 [9]", 1, params.getColumnPos(8)); + assertEquals("14 key fix 5 M0 [A]", 2, params.getColumnPos(9)); + assertEquals("14 key fix 5 M0 [B]", -1, params.getColumnPos(10)); + assertEquals("14 key fix 5 M0 [C]", 0, params.getColumnPos(11)); + assertEquals("14 key fix 5 M0 [D]", 1, params.getColumnPos(12)); + assertEquals("14 key fix 5 M0 [E]", 2, params.getColumnPos(13)); + assertEquals("14 key fix 5 M0 adjust", -1, params.mTopRowAdjustment); + assertEquals("14 key fix 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |<1> [2] [3] [4] [5] [6] [7] + @Test + public void testLayout7KeyFix7L0() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L0); + assertEquals("7 key fix 7 L0 columns", 7, params.mNumColumns); + assertEquals("7 key fix 7 L0 rows", 1, params.mNumRows); + assertEquals("7 key fix 7 L0 left", 0, params.mLeftKeys); + assertEquals("7 key fix 7 L0 right", 7, params.mRightKeys); + assertEquals("7 key fix 7 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key fix 7 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key fix 7 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key fix 7 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("7 key fix 7 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("7 key fix 7 L0 [6]", 5, params.getColumnPos(5)); + assertEquals("7 key fix 7 L0 [7]", 6, params.getColumnPos(6)); + assertEquals("7 key fix 7 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 7 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] [3] [4] [5] [6] [7] + @Test + public void testLayout7KeyFix7L1() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L1); + assertEquals("7 key fix 7 L1 columns", 7, params.mNumColumns); + assertEquals("7 key fix 7 L1 rows", 1, params.mNumRows); + assertEquals("7 key fix 7 L1 left", 0, params.mLeftKeys); + assertEquals("7 key fix 7 L1 right", 7, params.mRightKeys); + assertEquals("7 key fix 7 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key fix 7 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key fix 7 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key fix 7 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("7 key fix 7 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("7 key fix 7 L1 [6]", 5, params.getColumnPos(5)); + assertEquals("7 key fix 7 L1 [7]", 6, params.getColumnPos(6)); + assertEquals("7 key fix 7 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 7 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [1] <2> [3] [4] [5] [6] [7] + @Test + public void testLayout7KeyFix7L2() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L2); + assertEquals("7 key fix 7 L2 columns", 7, params.mNumColumns); + assertEquals("7 key fix 7 L2 rows", 1, params.mNumRows); + assertEquals("7 key fix 7 L2 left", 1, params.mLeftKeys); + assertEquals("7 key fix 7 L2 right", 6, params.mRightKeys); + assertEquals("7 key fix 7 L2 [1]", -1, params.getColumnPos(0)); + assertEquals("7 key fix 7 L2 <2>", 0, params.getColumnPos(1)); + assertEquals("7 key fix 7 L2 [3]", 1, params.getColumnPos(2)); + assertEquals("7 key fix 7 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key fix 7 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("7 key fix 7 L2 [6]", 4, params.getColumnPos(5)); + assertEquals("7 key fix 7 L2 [7]", 5, params.getColumnPos(6)); + assertEquals("7 key fix 7 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 7 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |___ [1] [2] <3> [4] [5] [6] [7] + @Test + public void testLayout7KeyFix7L3() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L3); + assertEquals("7 key fix 7 L3 columns", 7, params.mNumColumns); + assertEquals("7 key fix 7 L3 rows", 1, params.mNumRows); + assertEquals("7 key fix 7 L3 left", 2, params.mLeftKeys); + assertEquals("7 key fix 7 L3 right", 5, params.mRightKeys); + assertEquals("7 key fix 7 L3 [1]", -2, params.getColumnPos(0)); + assertEquals("7 key fix 7 L3 [2]", -1, params.getColumnPos(1)); + assertEquals("7 key fix 7 L3 <3>", 0, params.getColumnPos(2)); + assertEquals("7 key fix 7 L3 [4]", 1, params.getColumnPos(3)); + assertEquals("7 key fix 7 L3 [5]", 2, params.getColumnPos(4)); + assertEquals("7 key fix 7 L3 [6]", 3, params.getColumnPos(5)); + assertEquals("7 key fix 7 L3 [7]", 4, params.getColumnPos(6)); + assertEquals("7 key fix 7 L3 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 7 L3 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |___ [1] [2] [3] <4> [5] [6] [7] ___ ___| + @Test + public void testLayout7KeyFix7M0() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_M0); + assertEquals("7 key fix 7 M0 columns", 7, params.mNumColumns); + assertEquals("7 key fix 7 M0 rows", 1, params.mNumRows); + assertEquals("7 key fix 7 M0 left", 3, params.mLeftKeys); + assertEquals("7 key fix 7 M0 right", 4, params.mRightKeys); + assertEquals("7 key fix 7 M0 [1]", -3, params.getColumnPos(0)); + assertEquals("7 key fix 7 M0 [2]", -2, params.getColumnPos(1)); + assertEquals("7 key fix 7 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key fix 7 M0 <4>", 0, params.getColumnPos(3)); + assertEquals("7 key fix 7 M0 [5]", 1, params.getColumnPos(4)); + assertEquals("7 key fix 7 M0 [6]", 2, params.getColumnPos(5)); + assertEquals("7 key fix 7 M0 [7]", 3, params.getColumnPos(6)); + assertEquals("7 key fix 7 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 7 M0 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // |___ ___ [1] [2] [3] <4> [5] [6] [7] ___| + @Test + public void testLayout7KeyFix7M1() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_M1); + assertEquals("7 key fix 7 M1 columns", 7, params.mNumColumns); + assertEquals("7 key fix 7 M1 rows", 1, params.mNumRows); + assertEquals("7 key fix 7 M1 left", 3, params.mLeftKeys); + assertEquals("7 key fix 7 M1 right", 4, params.mRightKeys); + assertEquals("7 key fix 7 M1 [1]", -3, params.getColumnPos(0)); + assertEquals("7 key fix 7 M1 [2]", -2, params.getColumnPos(1)); + assertEquals("7 key fix 7 M1 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key fix 7 M1 <4>", 0, params.getColumnPos(3)); + assertEquals("7 key fix 7 M1 [5]", 1, params.getColumnPos(4)); + assertEquals("7 key fix 7 M1 [6]", 2, params.getColumnPos(5)); + assertEquals("7 key fix 7 M1 [7]", 3, params.getColumnPos(6)); + assertEquals("7 key fix 7 M1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 7 M1 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [1] [2] [3] [4] <5> [6] [7] ___| + @Test + public void testLayout7KeyFix7R3() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R3); + assertEquals("7 key fix 7 R3 columns", 7, params.mNumColumns); + assertEquals("7 key fix 7 R3 rows", 1, params.mNumRows); + assertEquals("7 key fix 7 R3 left", 4, params.mLeftKeys); + assertEquals("7 key fix 7 R3 right", 3, params.mRightKeys); + assertEquals("7 key fix 7 R3 [1]", -4, params.getColumnPos(0)); + assertEquals("7 key fix 7 R3 [2]", -3, params.getColumnPos(1)); + assertEquals("7 key fix 7 R3 [3]", -2, params.getColumnPos(2)); + assertEquals("7 key fix 7 R3 [4]", -1, params.getColumnPos(3)); + assertEquals("7 key fix 7 R3 <5>", 0, params.getColumnPos(4)); + assertEquals("7 key fix 7 R3 [6]", 1, params.getColumnPos(5)); + assertEquals("7 key fix 7 R3 [7]", 2, params.getColumnPos(6)); + assertEquals("7 key fix 7 R3 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 7 R3 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [1] [2] [3] [4] [5] <6> [7] ___| + @Test + public void testLayout7KeyFix7R2() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R2); + assertEquals("7 key fix 7 R2 columns", 7, params.mNumColumns); + assertEquals("7 key fix 7 R2 rows", 1, params.mNumRows); + assertEquals("7 key fix 7 R2 left", 5, params.mLeftKeys); + assertEquals("7 key fix 7 R2 right", 2, params.mRightKeys); + assertEquals("7 key fix 7 R2 [1]", -5, params.getColumnPos(0)); + assertEquals("7 key fix 7 R2 [2]", -4, params.getColumnPos(1)); + assertEquals("7 key fix 7 R2 [3]", -3, params.getColumnPos(2)); + assertEquals("7 key fix 7 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("7 key fix 7 R2 [5]", -1, params.getColumnPos(4)); + assertEquals("7 key fix 7 R2 <6>", 0, params.getColumnPos(5)); + assertEquals("7 key fix 7 R2 [7]", 1, params.getColumnPos(6)); + assertEquals("7 key fix 7 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 7 R2 default", WIDTH * 5, params.getDefaultKeyCoordX()); + } + + // [1] [2] [3] [4] [5] [6] <7> ___| + @Test + public void testLayout7KeyFix7R1() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R1); + assertEquals("7 key fix 7 R1 columns", 7, params.mNumColumns); + assertEquals("7 key fix 7 R1 rows", 1, params.mNumRows); + assertEquals("7 key fix 7 R1 left", 6, params.mLeftKeys); + assertEquals("7 key fix 7 R1 right", 1, params.mRightKeys); + assertEquals("7 key fix 7 R1 [1]", -6, params.getColumnPos(0)); + assertEquals("7 key fix 7 R1 [2]", -5, params.getColumnPos(1)); + assertEquals("7 key fix 7 R1 [3]", -4, params.getColumnPos(2)); + assertEquals("7 key fix 7 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("7 key fix 7 R1 [5]", -2, params.getColumnPos(4)); + assertEquals("7 key fix 7 R1 [6]", -1, params.getColumnPos(5)); + assertEquals("7 key fix 7 R1 <7>", 0, params.getColumnPos(6)); + assertEquals("7 key fix 7 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 7 R1 default", WIDTH * 6, params.getDefaultKeyCoordX()); + } + + // [1] [2] [3] [4] [5] [6] <7>| + @Test + public void testLayout7KeyFix7R0() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R0); + assertEquals("7 key fix 7 R0 columns", 7, params.mNumColumns); + assertEquals("7 key fix 7 R0 rows", 1, params.mNumRows); + assertEquals("7 key fix 7 R0 left", 6, params.mLeftKeys); + assertEquals("7 key fix 7 R0 right", 1, params.mRightKeys); + assertEquals("7 key fix 7 R0 [1]", -6, params.getColumnPos(0)); + assertEquals("7 key fix 7 R0 [2]", -5, params.getColumnPos(1)); + assertEquals("7 key fix 7 R0 [3]", -4, params.getColumnPos(2)); + assertEquals("7 key fix 7 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("7 key fix 7 R0 [5]", -2, params.getColumnPos(4)); + assertEquals("7 key fix 7 R0 [6]", -1, params.getColumnPos(5)); + assertEquals("7 key fix 7 R0 <7>", 0, params.getColumnPos(6)); + assertEquals("7 key fix 7 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key fix 7 R0 default", WIDTH * 6, params.getDefaultKeyCoordX()); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/MoreKeysKeyboardBuilderMaxOrderTests.java b/tests/src/org/kelar/inputmethod/keyboard/MoreKeysKeyboardBuilderMaxOrderTests.java new file mode 100644 index 000000000..85a49f80c --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/MoreKeysKeyboardBuilderMaxOrderTests.java @@ -0,0 +1,2505 @@ +/* + * Copyright (C) 2011 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 org.kelar.inputmethod.keyboard; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import androidx.test.filters.MediumTest; +import androidx.test.runner.AndroidJUnit4; + +import org.kelar.inputmethod.keyboard.MoreKeysKeyboard.MoreKeysKeyboardParams; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@MediumTest +@RunWith(AndroidJUnit4.class) +public class MoreKeysKeyboardBuilderMaxOrderTests { + private static final int WIDTH = 10; + private static final int HEIGHT = 10; + + private static final int KEYBOARD_WIDTH = WIDTH * 10; + private static final int XPOS_L0 = WIDTH * 0 + WIDTH / 2; + private static final int XPOS_L1 = WIDTH * 1 + WIDTH / 2; + private static final int XPOS_L2 = WIDTH * 2 + WIDTH / 2; + private static final int XPOS_L3 = WIDTH * 3 + WIDTH / 2; + private static final int XPOS_M0 = WIDTH * 4 + WIDTH / 2; + private static final int XPOS_M1 = WIDTH * 5 + WIDTH / 2; + private static final int XPOS_R3 = WIDTH * 6 + WIDTH / 2; + private static final int XPOS_R2 = WIDTH * 7 + WIDTH / 2; + private static final int XPOS_R1 = WIDTH * 8 + WIDTH / 2; + private static final int XPOS_R0 = WIDTH * 9 + WIDTH / 2; + + private static MoreKeysKeyboardParams createParams(final int numKeys, final int maxColumns, + final int coordXInParent) { + final MoreKeysKeyboardParams params = new MoreKeysKeyboardParams(); + params.setParameters(numKeys, maxColumns, WIDTH, HEIGHT, coordXInParent, KEYBOARD_WIDTH, + false /* isMoreKeysFixedColumn */, false /* isMoreKeysFixedOrder */, + 0 /* dividerWidth */); + return params; + } + + @Test + public void testLayoutError() { + MoreKeysKeyboardParams params = null; + try { + final int maxColumns = KEYBOARD_WIDTH / WIDTH; + params = createParams(maxColumns + 1, maxColumns + 1, HEIGHT); + fail("Should throw IllegalArgumentException"); + } catch (IllegalArgumentException e) { + // Too small keyboard to hold more keys keyboard. + } + assertNull("Too small keyboard to hold more keys keyboard", params); + } + + // More keys keyboard layout test. + // "[n]" represents n-th key position in more keys keyboard. + // "<1>" is the default key. + + // <1> + @Test + public void testLayout1KeyMax5M0() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_M0); + assertEquals("1 key max 5 M0 columns", 1, params.mNumColumns); + assertEquals("1 key max 5 M0 rows", 1, params.mNumRows); + assertEquals("1 key max 5 M0 left", 0, params.mLeftKeys); + assertEquals("1 key max 5 M0 right", 1, params.mRightKeys); + assertEquals("1 key max 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key max 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key max 5 M0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |<1> + @Test + public void testLayout1KeyMax5L0() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L0); + assertEquals("1 key max 5 L0 columns", 1, params.mNumColumns); + assertEquals("1 key max 5 L0 rows", 1, params.mNumRows); + assertEquals("1 key max 5 L0 left", 0, params.mLeftKeys); + assertEquals("1 key max 5 L0 right", 1, params.mRightKeys); + assertEquals("1 key max 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key max 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key max 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> + @Test + public void testLayout1KeyMax5L1() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L1); + assertEquals("1 key max 5 L1 columns", 1, params.mNumColumns); + assertEquals("1 key max 5 L1 rows", 1, params.mNumRows); + assertEquals("1 key max 5 L1 left", 0, params.mLeftKeys); + assertEquals("1 key max 5 L1 right", 1, params.mRightKeys); + assertEquals("1 key max 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key max 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key max 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ ___ <1> + @Test + public void testLayout1KeyMax5L2() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_L2); + assertEquals("1 key max 5 L2 columns", 1, params.mNumColumns); + assertEquals("1 key max 5 L2 rows", 1, params.mNumRows); + assertEquals("1 key max 5 L2 left", 0, params.mLeftKeys); + assertEquals("1 key max 5 L2 right", 1, params.mRightKeys); + assertEquals("1 key max 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key max 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key max 5 L2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // <1>| + @Test + public void testLayout1KeyMax5R0() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R0); + assertEquals("1 key max 5 R0 columns", 1, params.mNumColumns); + assertEquals("1 key max 5 R0 rows", 1, params.mNumRows); + assertEquals("1 key max 5 R0 left", 0, params.mLeftKeys); + assertEquals("1 key max 5 R0 right", 1, params.mRightKeys); + assertEquals("1 key max 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key max 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key max 5 R0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // <1> ___| + @Test + public void testLayout1KeyMax5R1() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R1); + assertEquals("1 key max 5 R1 columns", 1, params.mNumColumns); + assertEquals("1 key max 5 R1 rows", 1, params.mNumRows); + assertEquals("1 key max 5 R1 left", 0, params.mLeftKeys); + assertEquals("1 key max 5 R1 right", 1, params.mRightKeys); + assertEquals("1 key max 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key max 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key max 5 R1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // <1> ___ ___| + @Test + public void testLayout1KeyMax5R2() { + MoreKeysKeyboardParams params = createParams(1, 5, XPOS_R2); + assertEquals("1 key max 5 R2 columns", 1, params.mNumColumns); + assertEquals("1 key max 5 R2 rows", 1, params.mNumRows); + assertEquals("1 key max 5 R2 left", 0, params.mLeftKeys); + assertEquals("1 key max 5 R2 right", 1, params.mRightKeys); + assertEquals("1 key max 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("1 key max 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("1 key max 5 R2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // <1> [2] + @Test + public void testLayout2KeyMax5M0() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_M0); + assertEquals("2 key max 5 M0 columns", 2, params.mNumColumns); + assertEquals("2 key max 5 M0 rows", 1, params.mNumRows); + assertEquals("2 key max 5 M0 left", 0, params.mLeftKeys); + assertEquals("2 key max 5 M0 right", 2, params.mRightKeys); + assertEquals("2 key max 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key max 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("2 key max 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key max 5 M0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |<1> [2] + @Test + public void testLayout2KeyMax5L0() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L0); + assertEquals("2 key max 5 L0 columns", 2, params.mNumColumns); + assertEquals("2 key max 5 L0 rows", 1, params.mNumRows); + assertEquals("2 key max 5 L0 left", 0, params.mLeftKeys); + assertEquals("2 key max 5 L0 right", 2, params.mRightKeys); + assertEquals("2 key max 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key max 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("2 key max 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key max 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] + @Test + public void testLayout2KeyMax5L1() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L1); + assertEquals("2 key max 5 L1 columns", 2, params.mNumColumns); + assertEquals("2 key max 5 L1 rows", 1, params.mNumRows); + assertEquals("2 key max 5 L1 left", 0, params.mLeftKeys); + assertEquals("2 key max 5 L1 right", 2, params.mRightKeys); + assertEquals("2 key max 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key max 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("2 key max 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key max 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ ___ <1> [2] + @Test + public void testLayout2KeyMax5L2() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_L2); + assertEquals("2 key max 5 L2 columns", 2, params.mNumColumns); + assertEquals("2 key max 5 L2 rows", 1, params.mNumRows); + assertEquals("2 key max 5 L2 left", 0, params.mLeftKeys); + assertEquals("2 key max 5 L2 right", 2, params.mRightKeys); + assertEquals("2 key max 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key max 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("2 key max 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key max 5 L2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // [2] <1>| + @Test + public void testLayout2KeyMax5R0() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R0); + assertEquals("2 key max 5 R0 columns", 2, params.mNumColumns); + assertEquals("2 key max 5 R0 rows", 1, params.mNumRows); + assertEquals("2 key max 5 R0 left", 1, params.mLeftKeys); + assertEquals("2 key max 5 R0 right", 1, params.mRightKeys); + assertEquals("2 key max 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key max 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("2 key max 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key max 5 R0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [2] <1> ___| + @Test + public void testLayout2KeyMax5R1() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R1); + assertEquals("2 key max 5 R1 columns", 2, params.mNumColumns); + assertEquals("2 key max 5 R1 rows", 1, params.mNumRows); + assertEquals("2 key max 5 R1 left", 1, params.mLeftKeys); + assertEquals("2 key max 5 R1 right", 1, params.mRightKeys); + assertEquals("2 key max 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key max 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("2 key max 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key max 5 R1 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // <1> [2] ___| + @Test + public void testLayout2KeyMax5R2() { + MoreKeysKeyboardParams params = createParams(2, 5, XPOS_R2); + assertEquals("2 key max 5 R2 columns", 2, params.mNumColumns); + assertEquals("2 key max 5 R2 rows", 1, params.mNumRows); + assertEquals("2 key max 5 R2 left", 0, params.mLeftKeys); + assertEquals("2 key max 5 R2 right", 2, params.mRightKeys); + assertEquals("2 key max 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("2 key max 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("2 key max 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("2 key max 5 R2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // [3] <1> [2] + @Test + public void testLayout3KeyMax5M0() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_M0); + assertEquals("3 key max 5 M0 columns", 3, params.mNumColumns); + assertEquals("3 key max 5 M0 rows", 1, params.mNumRows); + assertEquals("3 key max 5 M0 left", 1, params.mLeftKeys); + assertEquals("3 key max 5 M0 right", 2, params.mRightKeys); + assertEquals("3 key max 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key max 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key max 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("3 key max 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key max 5 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |<1> [2] [3] + @Test + public void testLayout3KeyMax5L0() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L0); + assertEquals("3 key max 5 L0 columns", 3, params.mNumColumns); + assertEquals("3 key max 5 L0 rows", 1, params.mNumRows); + assertEquals("3 key max 5 L0 left", 0, params.mLeftKeys); + assertEquals("3 key max 5 L0 right", 3, params.mRightKeys); + assertEquals("3 key max 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key max 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key max 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("3 key max 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key max 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] [3] + @Test + public void testLayout3KeyMax5L1() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L1); + assertEquals("3 key max 5 L1 columns", 3, params.mNumColumns); + assertEquals("3 key max 5 L1 rows", 1, params.mNumRows); + assertEquals("3 key max 5 L1 left", 0, params.mLeftKeys); + assertEquals("3 key max 5 L1 right", 3, params.mRightKeys); + assertEquals("3 key max 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key max 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key max 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("3 key max 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key max 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [3] <1> [2] + @Test + public void testLayout3KeyMax5L2() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_L2); + assertEquals("3 key max 5 L2 columns", 3, params.mNumColumns); + assertEquals("3 key max 5 L2 rows", 1, params.mNumRows); + assertEquals("3 key max 5 L2 left", 1, params.mLeftKeys); + assertEquals("3 key max 5 L2 right", 2, params.mRightKeys); + assertEquals("3 key max 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key max 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key max 5 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("3 key max 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key max 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [3] [2] <1>| + @Test + public void testLayout3KeyMax5R0() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R0); + assertEquals("3 key max 5 R0 columns", 3, params.mNumColumns); + assertEquals("3 key max 5 R0 rows", 1, params.mNumRows); + assertEquals("3 key max 5 R0 left", 2, params.mLeftKeys); + assertEquals("3 key max 5 R0 right", 1, params.mRightKeys); + assertEquals("3 key max 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key max 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("3 key max 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("3 key max 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key max 5 R0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [3] [2] <1> ___| + @Test + public void testLayout3KeyMax5R1() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R1); + assertEquals("3 key max 5 R1 columns", 3, params.mNumColumns); + assertEquals("3 key max 5 R1 rows", 1, params.mNumRows); + assertEquals("3 key max 5 R1 left", 2, params.mLeftKeys); + assertEquals("3 key max 5 R1 right", 1, params.mRightKeys); + assertEquals("3 key max 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key max 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("3 key max 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("3 key max 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key max 5 R1 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [3] <1> [2] ___| + @Test + public void testLayout3KeyMax5R2() { + MoreKeysKeyboardParams params = createParams(3, 5, XPOS_R2); + assertEquals("3 key max 5 R2 columns", 3, params.mNumColumns); + assertEquals("3 key max 5 R2 rows", 1, params.mNumRows); + assertEquals("3 key max 5 R2 left", 1, params.mLeftKeys); + assertEquals("3 key max 5 R2 right", 2, params.mRightKeys); + assertEquals("3 key max 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key max 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key max 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("3 key max 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key max 5 R2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [3] + // <1> [2] + @Test + public void testLayout3KeyMax2M0() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_M0); + assertEquals("3 key max 2 M0 columns", 2, params.mNumColumns); + assertEquals("3 key max 2 M0 rows", 2, params.mNumRows); + assertEquals("3 key max 2 M0 left", 0, params.mLeftKeys); + assertEquals("3 key max 2 M0 right", 2, params.mRightKeys); + assertEquals("3 key max 2 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key max 2 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key max 2 M0 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key max 2 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key max 2 M0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |[3] + // |<1> [2] + @Test + public void testLayout3KeyMax2L0() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L0); + assertEquals("3 key max 2 L0 columns", 2, params.mNumColumns); + assertEquals("3 key max 2 L0 rows", 2, params.mNumRows); + assertEquals("3 key max 2 L0 left", 0, params.mLeftKeys); + assertEquals("3 key max 2 L0 right", 2, params.mRightKeys); + assertEquals("3 key max 2 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key max 2 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key max 2 L0 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key max 2 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key max 2 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [3] + // |___ <1> [2] + @Test + public void testLayout3KeyMax2L1() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L1); + assertEquals("3 key max 2 L1 columns", 2, params.mNumColumns); + assertEquals("3 key max 2 L1 rows", 2, params.mNumRows); + assertEquals("3 key max 2 L1 left", 0, params.mLeftKeys); + assertEquals("3 key max 2 L1 right", 2, params.mRightKeys); + assertEquals("3 key max 2 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key max 2 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key max 2 L1 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key max 2 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key max 2 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // | [3] + // |___ ___ <1> [2] + @Test + public void testLayout3KeyMax2L2() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_L2); + assertEquals("3 key max 2 L2 columns", 2, params.mNumColumns); + assertEquals("3 key max 2 L2 rows", 2, params.mNumRows); + assertEquals("3 key max 2 L2 left", 0, params.mLeftKeys); + assertEquals("3 key max 2 L2 right", 2, params.mRightKeys); + assertEquals("3 key max 2 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key max 2 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key max 2 L2 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key max 2 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key max 2 L2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // [3]| + // [2] <1>| + @Test + public void testLayout3KeyMax2R0() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R0); + assertEquals("3 key max 2 R0 columns", 2, params.mNumColumns); + assertEquals("3 key max 2 R0 rows", 2, params.mNumRows); + assertEquals("3 key max 2 R0 left", 1, params.mLeftKeys); + assertEquals("3 key max 2 R0 right", 1, params.mRightKeys); + assertEquals("3 key max 2 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key max 2 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("3 key max 2 R0 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key max 2 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key max 2 R0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [3] | + // [2] <1> ___| + @Test + public void testLayout3KeyMax2R1() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R1); + assertEquals("3 key max 2 R1 columns", 2, params.mNumColumns); + assertEquals("3 key max 2 R1 rows", 2, params.mNumRows); + assertEquals("3 key max 2 R1 left", 1, params.mLeftKeys); + assertEquals("3 key max 2 R1 right", 1, params.mRightKeys); + assertEquals("3 key max 2 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key max 2 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("3 key max 2 R1 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key max 2 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key max 2 R1 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [3] | + // <1> [2] ___| + @Test + public void testLayout3KeyMax2R2() { + MoreKeysKeyboardParams params = createParams(3, 2, XPOS_R2); + assertEquals("3 key max 2 R2 columns", 2, params.mNumColumns); + assertEquals("3 key max 2 R2 rows", 2, params.mNumRows); + assertEquals("3 key max 2 R2 left", 0, params.mLeftKeys); + assertEquals("3 key max 2 R2 right", 2, params.mRightKeys); + assertEquals("3 key max 2 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("3 key max 2 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("3 key max 2 R2 [3]", 0, params.getColumnPos(2)); + assertEquals("3 key max 2 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("3 key max 2 R2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // [3] [4] + // <1> [2] + @Test + public void testLayout4KeyMax3M0() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_M0); + assertEquals("4 key max 3 M0 columns", 2, params.mNumColumns); + assertEquals("4 key max 3 M0 rows", 2, params.mNumRows); + assertEquals("4 key max 3 M0 left", 0, params.mLeftKeys); + assertEquals("4 key max 3 M0 right", 2, params.mRightKeys); + assertEquals("4 key max 3 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 3 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key max 3 M0 [3]", 0, params.getColumnPos(2)); + assertEquals("4 key max 3 M0 [4]", 1, params.getColumnPos(3)); + assertEquals("4 key max 3 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 3 M0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |[3] [4] + // |<1> [2] + @Test + public void testLayout4KeyMax3L0() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L0); + assertEquals("4 key max 3 L0 columns", 2, params.mNumColumns); + assertEquals("4 key max 3 L0 rows", 2, params.mNumRows); + assertEquals("4 key max 3 L0 left", 0, params.mLeftKeys); + assertEquals("4 key max 3 L0 right", 2, params.mRightKeys); + assertEquals("4 key max 3 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 3 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key max 3 L0 [3]", 0, params.getColumnPos(2)); + assertEquals("4 key max 3 L0 [4]", 1, params.getColumnPos(3)); + assertEquals("4 key max 3 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 3 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [3] [4] + // |___ <1> [2] + @Test + public void testLayout4KeyMax3L1() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L1); + assertEquals("4 key max 3 L1 columns", 2, params.mNumColumns); + assertEquals("4 key max 3 L1 rows", 2, params.mNumRows); + assertEquals("4 key max 3 L1 left", 0, params.mLeftKeys); + assertEquals("4 key max 3 L1 right", 2, params.mRightKeys); + assertEquals("4 key max 3 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 3 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key max 3 L1 [3]", 0, params.getColumnPos(2)); + assertEquals("4 key max 3 L1 [4]", 1, params.getColumnPos(3)); + assertEquals("4 key max 3 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 3 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ ___ [3] [4] + // |___ ___ <1> [2] + @Test + public void testLayout4KeyMax3L2() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_L2); + assertEquals("4 key max 3 L2 columns", 2, params.mNumColumns); + assertEquals("4 key max 3 L2 rows", 2, params.mNumRows); + assertEquals("4 key max 3 L2 left", 0, params.mLeftKeys); + assertEquals("4 key max 3 L2 right", 2, params.mRightKeys); + assertEquals("4 key max 3 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 3 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key max 3 L2 [3]", 0, params.getColumnPos(2)); + assertEquals("4 key max 3 L2 [4]", 1, params.getColumnPos(3)); + assertEquals("4 key max 3 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 3 L2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // [4] [3]| + // [2] <1>| + @Test + public void testLayout4KeyMax3R0() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R0); + assertEquals("4 key max 3 R0 columns", 2, params.mNumColumns); + assertEquals("4 key max 3 R0 rows", 2, params.mNumRows); + assertEquals("4 key max 3 R0 left", 1, params.mLeftKeys); + assertEquals("4 key max 3 R0 right", 1, params.mRightKeys); + assertEquals("4 key max 3 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 3 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("4 key max 3 R0 [3]", 0, params.getColumnPos(2)); + assertEquals("4 key max 3 R0 [4]", -1, params.getColumnPos(3)); + assertEquals("4 key max 3 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 3 R0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [4] [3] ___| + // [2] <1> ___| + @Test + public void testLayout4KeyMax3R1() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R1); + assertEquals("4 key max 3 R1 columns", 2, params.mNumColumns); + assertEquals("4 key max 3 R1 rows", 2, params.mNumRows); + assertEquals("4 key max 3 R1 left", 1, params.mLeftKeys); + assertEquals("4 key max 3 R1 right", 1, params.mRightKeys); + assertEquals("4 key max 3 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 3 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("4 key max 3 R1 [3]", 0, params.getColumnPos(2)); + assertEquals("4 key max 3 R1 [4]", -1, params.getColumnPos(3)); + assertEquals("4 key max 3 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 3 R1 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [3] [4] ___| + // <1> [2] ___| + @Test + public void testLayout4KeyMax3R2() { + MoreKeysKeyboardParams params = createParams(4, 3, XPOS_R2); + assertEquals("4 key max 3 R2 columns", 2, params.mNumColumns); + assertEquals("4 key max 3 R2 rows", 2, params.mNumRows); + assertEquals("4 key max 3 R2 left", 0, params.mLeftKeys); + assertEquals("4 key max 3 R2 right", 2, params.mRightKeys); + assertEquals("4 key max 3 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 3 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key max 3 R2 [3]", 0, params.getColumnPos(2)); + assertEquals("4 key max 3 R2 [4]", 1, params.getColumnPos(3)); + assertEquals("4 key max 3 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 3 R2 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // [3] <1> [2] [4] + @Test + public void testLayout4KeyMax4M0() { + MoreKeysKeyboardParams params = createParams(4, 4, XPOS_M0); + assertEquals("4 key max 4 M0 columns", 4, params.mNumColumns); + assertEquals("4 key max 4 M0 rows", 1, params.mNumRows); + assertEquals("4 key max 4 M0 left", 1, params.mLeftKeys); + assertEquals("4 key max 4 M0 right", 3, params.mRightKeys); + assertEquals("4 key max 4 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 4 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key max 4 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key max 4 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("4 key max 4 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 4 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |<1> [2] [3] [4] + @Test + public void testLayout4KeyMax4L0() { + MoreKeysKeyboardParams params = createParams(4, 4, XPOS_L0); + assertEquals("4 key max 4 L0 columns", 4, params.mNumColumns); + assertEquals("4 key max 4 L0 rows", 1, params.mNumRows); + assertEquals("4 key max 4 L0 left", 0, params.mLeftKeys); + assertEquals("4 key max 4 L0 right", 4, params.mRightKeys); + assertEquals("4 key max 4 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 4 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key max 4 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("4 key max 4 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("4 key max 4 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 4 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] [3] [4] + @Test + public void testLayout4KeyMax4L1() { + MoreKeysKeyboardParams params = createParams(4, 4, XPOS_L1); + assertEquals("4 key max 4 L1 columns", 4, params.mNumColumns); + assertEquals("4 key max 4 L1 rows", 1, params.mNumRows); + assertEquals("4 key max 4 L1 left", 0, params.mLeftKeys); + assertEquals("4 key max 4 L1 right", 4, params.mRightKeys); + assertEquals("4 key max 4 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 4 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key max 4 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("4 key max 4 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("4 key max 4 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 4 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [3] <1> [2] [4] + @Test + public void testLayout4KeyMax4L2() { + MoreKeysKeyboardParams params = createParams(4, 4, XPOS_L2); + assertEquals("4 key max 4 L2 columns", 4, params.mNumColumns); + assertEquals("4 key max 4 L2 rows", 1, params.mNumRows); + assertEquals("4 key max 4 L2 left", 1, params.mLeftKeys); + assertEquals("4 key max 4 L2 right", 3, params.mRightKeys); + assertEquals("4 key max 4 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 4 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key max 4 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key max 4 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("4 key max 4 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 4 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [4] [3] [2] <1>| + @Test + public void testLayout4KeyMax4R0() { + MoreKeysKeyboardParams params = createParams(4, 4, XPOS_R0); + assertEquals("4 key max 4 R0 columns", 4, params.mNumColumns); + assertEquals("4 key max 4 R0 rows", 1, params.mNumRows); + assertEquals("4 key max 4 R0 left", 3, params.mLeftKeys); + assertEquals("4 key max 4 R0 right", 1, params.mRightKeys); + assertEquals("4 key max 4 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 4 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("4 key max 4 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("4 key max 4 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("4 key max 4 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 4 R0 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [4] [3] [2] <1> ___| + @Test + public void testLayout4KeyMax4R1() { + MoreKeysKeyboardParams params = createParams(4, 4, XPOS_R1); + assertEquals("4 key max 4 R1 columns", 4, params.mNumColumns); + assertEquals("4 key max 4 R1 rows", 1, params.mNumRows); + assertEquals("4 key max 4 R1 left", 3, params.mLeftKeys); + assertEquals("4 key max 4 R1 right", 1, params.mRightKeys); + assertEquals("4 key max 4 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 4 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("4 key max 4 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("4 key max 4 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("4 key max 4 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 4 R1 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [4] [3] <1> [2] ___| + @Test + public void testLayout4KeyMax4R2() { + MoreKeysKeyboardParams params = createParams(4, 4, XPOS_R2); + assertEquals("4 key max 4 R2 columns", 4, params.mNumColumns); + assertEquals("4 key max 4 R2 rows", 1, params.mNumRows); + assertEquals("4 key max 4 R2 left", 2, params.mLeftKeys); + assertEquals("4 key max 4 R2 right", 2, params.mRightKeys); + assertEquals("4 key max 4 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 4 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key max 4 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key max 4 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("4 key max 4 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 4 R2 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [3] <1> [2] [4] + @Test + public void testLayout4KeyMax5M0() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_M0); + assertEquals("4 key max 5 M0 columns", 4, params.mNumColumns); + assertEquals("4 key max 5 M0 rows", 1, params.mNumRows); + assertEquals("4 key max 5 M0 left", 1, params.mLeftKeys); + assertEquals("4 key max 5 M0 right", 3, params.mRightKeys); + assertEquals("4 key max 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key max 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key max 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("4 key max 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 5 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |<1> [2] [3] [4] + @Test + public void testLayout4KeyMax5L0() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L0); + assertEquals("4 key max 5 L0 columns", 4, params.mNumColumns); + assertEquals("4 key max 5 L0 rows", 1, params.mNumRows); + assertEquals("4 key max 5 L0 left", 0, params.mLeftKeys); + assertEquals("4 key max 5 L0 right", 4, params.mRightKeys); + assertEquals("4 key max 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key max 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("4 key max 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("4 key max 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] [3] [4] + @Test + public void testLayout4KeyMax5L1() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L1); + assertEquals("4 key max 5 L1 columns", 4, params.mNumColumns); + assertEquals("4 key max 5 L1 rows", 1, params.mNumRows); + assertEquals("4 key max 5 L1 left", 0, params.mLeftKeys); + assertEquals("4 key max 5 L1 right", 4, params.mRightKeys); + assertEquals("4 key max 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key max 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("4 key max 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("4 key max 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [3] <1> [2] [4] + @Test + public void testLayout4KeyMax5L2() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_L2); + assertEquals("4 key max 5 L2 columns", 4, params.mNumColumns); + assertEquals("4 key max 5 L2 rows", 1, params.mNumRows); + assertEquals("4 key max 5 L2 left", 1, params.mLeftKeys); + assertEquals("4 key max 5 L2 right", 3, params.mRightKeys); + assertEquals("4 key max 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key max 5 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key max 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("4 key max 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [4] [3] [2] <1>| + @Test + public void testLayout4KeyMax5R0() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R0); + assertEquals("4 key max 5 R0 columns", 4, params.mNumColumns); + assertEquals("4 key max 5 R0 rows", 1, params.mNumRows); + assertEquals("4 key max 5 R0 left", 3, params.mLeftKeys); + assertEquals("4 key max 5 R0 right", 1, params.mRightKeys); + assertEquals("4 key max 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("4 key max 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("4 key max 5 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("4 key max 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 5 R0 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [4] [3] [2] <1> ___| + @Test + public void testLayout4KeyMax5R1() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R1); + assertEquals("4 key max 5 R1 columns", 4, params.mNumColumns); + assertEquals("4 key max 5 R1 rows", 1, params.mNumRows); + assertEquals("4 key max 5 R1 left", 3, params.mLeftKeys); + assertEquals("4 key max 5 R1 right", 1, params.mRightKeys); + assertEquals("4 key max 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("4 key max 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("4 key max 5 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("4 key max 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 5 R1 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [4] [3] <1> [2] ___| + @Test + public void testLayout4KeyMax5R2() { + MoreKeysKeyboardParams params = createParams(4, 5, XPOS_R2); + assertEquals("4 key max 5 R2 columns", 4, params.mNumColumns); + assertEquals("4 key max 5 R2 rows", 1, params.mNumRows); + assertEquals("4 key max 5 R2 left", 2, params.mLeftKeys); + assertEquals("4 key max 5 R2 right", 2, params.mRightKeys); + assertEquals("4 key max 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("4 key max 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("4 key max 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("4 key max 5 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("4 key max 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("4 key max 5 R2 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [4] [5] + // [3] <1> [2] + @Test + public void testLayout5KeyMax3M0() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_M0); + assertEquals("5 key max 3 M0 columns", 3, params.mNumColumns); + assertEquals("5 key max 3 M0 rows", 2, params.mNumRows); + assertEquals("5 key max 3 M0 left", 1, params.mLeftKeys); + assertEquals("5 key max 3 M0 right", 2, params.mRightKeys); + assertEquals("5 key max 3 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 3 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key max 3 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key max 3 M0 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key max 3 M0 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key max 3 M0 adjust", -1, params.mTopRowAdjustment); + assertEquals("5 key max 3 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[4] [5] + // |<1> [2] [3] + @Test + public void testLayout5KeyMax3L0() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L0); + assertEquals("5 key max 3 L0 columns", 3, params.mNumColumns); + assertEquals("5 key max 3 L0 rows", 2, params.mNumRows); + assertEquals("5 key max 3 L0 left", 0, params.mLeftKeys); + assertEquals("5 key max 3 L0 right", 3, params.mRightKeys); + assertEquals("5 key max 3 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 3 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key max 3 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key max 3 L0 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key max 3 L0 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key max 3 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key max 3 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [4] [5] + // |___ <1> [2] [3] + @Test + public void testLayout5KeyMax3L1() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L1); + assertEquals("5 key max 3 L1 columns", 3, params.mNumColumns); + assertEquals("5 key max 3 L1 rows", 2, params.mNumRows); + assertEquals("5 key max 3 L1 left", 0, params.mLeftKeys); + assertEquals("5 key max 3 L1 right", 3, params.mRightKeys); + assertEquals("5 key max 3 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 3 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key max 3 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key max 3 L1 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key max 3 L1 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key max 3 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key max 3 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [4] [5] + // |___ [3] <1> [2] + @Test + public void testLayout5KeyMax3L2() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_L2); + assertEquals("5 key max 3 L2 columns", 3, params.mNumColumns); + assertEquals("5 key max 3 L2 rows", 2, params.mNumRows); + assertEquals("5 key max 3 L2 left", 1, params.mLeftKeys); + assertEquals("5 key max 3 L2 right", 2, params.mRightKeys); + assertEquals("5 key max 3 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 3 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key max 3 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key max 3 L2 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key max 3 L2 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key max 3 L2 adjust", -1, params.mTopRowAdjustment); + assertEquals("5 key max 3 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [5] [4]| + // [3] [2] <1>| + @Test + public void testLayout5KeyMax3R0() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R0); + assertEquals("5 key max 3 R0 columns", 3, params.mNumColumns); + assertEquals("5 key max 3 R0 rows", 2, params.mNumRows); + assertEquals("5 key max 3 R0 left", 2, params.mLeftKeys); + assertEquals("5 key max 3 R0 right", 1, params.mRightKeys); + assertEquals("5 key max 3 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 3 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("5 key max 3 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("5 key max 3 R0 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key max 3 R0 [5]", -1, params.getColumnPos(4)); + assertEquals("5 key max 3 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key max 3 R0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [5] [4] ___| + // [3] [2] <1> ___| + @Test + public void testLayout5KeyMax3R1() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R1); + assertEquals("5 key max 3 R1 columns", 3, params.mNumColumns); + assertEquals("5 key max 3 R1 rows", 2, params.mNumRows); + assertEquals("5 key max 3 R1 left", 2, params.mLeftKeys); + assertEquals("5 key max 3 R1 right", 1, params.mRightKeys); + assertEquals("5 key max 3 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 3 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("5 key max 3 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("5 key max 3 R1 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key max 3 R1 [5]", -1, params.getColumnPos(4)); + assertEquals("5 key max 3 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key max 3 R1 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [4] [5] ___| + // [3] <1> [2] ___| + @Test + public void testLayout5KeyMax3R2() { + MoreKeysKeyboardParams params = createParams(5, 3, XPOS_R2); + assertEquals("5 key max 3 R2 columns", 3, params.mNumColumns); + assertEquals("5 key max 3 R2 rows", 2, params.mNumRows); + assertEquals("5 key max 3 R2 left", 1, params.mLeftKeys); + assertEquals("5 key max 3 R2 right", 2, params.mRightKeys); + assertEquals("5 key max 3 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 3 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key max 3 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key max 3 R2 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key max 3 R2 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key max 3 R2 adjust", -1, params.mTopRowAdjustment); + assertEquals("5 key max 3 R2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [4] [5] + // [3] <1> [2] + @Test + public void testLayout5KeyMax4M0() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_M0); + assertEquals("5 key max 4 M0 columns", 3, params.mNumColumns); + assertEquals("5 key max 4 M0 rows", 2, params.mNumRows); + assertEquals("5 key max 4 M0 left", 1, params.mLeftKeys); + assertEquals("5 key max 4 M0 right", 2, params.mRightKeys); + assertEquals("5 key max 4 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 4 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key max 4 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key max 4 M0 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key max 4 M0 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key max 4 M0 adjust", -1, params.mTopRowAdjustment); + assertEquals("5 key max 4 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[4] [5] + // |<1> [2] [3] + @Test + public void testLayout5KeyMax4L0() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L0); + assertEquals("5 key max 4 L0 columns", 3, params.mNumColumns); + assertEquals("5 key max 4 L0 rows", 2, params.mNumRows); + assertEquals("5 key max 4 L0 left", 0, params.mLeftKeys); + assertEquals("5 key max 4 L0 right", 3, params.mRightKeys); + assertEquals("5 key max 4 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 4 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key max 4 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key max 4 L0 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key max 4 L0 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key max 4 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key max 4 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [4] [5] + // |___ <1> [2] [3] + @Test + public void testLayout5KeyMax4L1() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L1); + assertEquals("5 key max 4 L1 columns", 3, params.mNumColumns); + assertEquals("5 key max 4 L1 rows", 2, params.mNumRows); + assertEquals("5 key max 4 L1 left", 0, params.mLeftKeys); + assertEquals("5 key max 4 L1 right", 3, params.mRightKeys); + assertEquals("5 key max 4 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 4 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key max 4 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key max 4 L1 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key max 4 L1 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key max 4 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key max 4 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [4] [5] + // |___ [3] <1> [2] + @Test + public void testLayout5KeyMax4L2() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_L2); + assertEquals("5 key max 4 L2 columns", 3, params.mNumColumns); + assertEquals("5 key max 4 L2 rows", 2, params.mNumRows); + assertEquals("5 key max 4 L2 left", 1, params.mLeftKeys); + assertEquals("5 key max 4 L2 right", 2, params.mRightKeys); + assertEquals("5 key max 4 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 4 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key max 4 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key max 4 L2 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key max 4 L2 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key max 4 L2 adjust", -1, params.mTopRowAdjustment); + assertEquals("5 key max 4 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [5] [4]| + // [3] [2] <1>| + @Test + public void testLayout5KeyMax4R0() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R0); + assertEquals("5 key max 4 R0 columns", 3, params.mNumColumns); + assertEquals("5 key max 4 R0 rows", 2, params.mNumRows); + assertEquals("5 key max 4 R0 left", 2, params.mLeftKeys); + assertEquals("5 key max 4 R0 right", 1, params.mRightKeys); + assertEquals("5 key max 4 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 4 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("5 key max 4 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("5 key max 4 R0 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key max 4 R0 [5]", -1, params.getColumnPos(4)); + assertEquals("5 key max 4 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key max 4 R0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [5] [4] ___| + // [3] [2] <1> ___| + @Test + public void testLayout5KeyMax4R1() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R1); + assertEquals("5 key max 4 R1 columns", 3, params.mNumColumns); + assertEquals("5 key max 4 R1 rows", 2, params.mNumRows); + assertEquals("5 key max 4 R1 left", 2, params.mLeftKeys); + assertEquals("5 key max 4 R1 right", 1, params.mRightKeys); + assertEquals("5 key max 4 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 4 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("5 key max 4 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("5 key max 4 R1 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key max 4 R1 [5]", -1, params.getColumnPos(4)); + assertEquals("5 key max 4 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key max 4 R1 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [4] [5] ___| + // [3] <1> [2] ___| + @Test + public void testLayout5KeyMax4R2() { + MoreKeysKeyboardParams params = createParams(5, 4, XPOS_R2); + assertEquals("5 key max 4 R2 columns", 3, params.mNumColumns); + assertEquals("5 key max 4 R2 rows", 2, params.mNumRows); + assertEquals("5 key max 4 R2 left", 1, params.mLeftKeys); + assertEquals("5 key max 4 R2 right", 2, params.mRightKeys); + assertEquals("5 key max 4 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 4 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key max 4 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key max 4 R2 [4]", 0, params.getColumnPos(3)); + assertEquals("5 key max 4 R2 [5]", 1, params.getColumnPos(4)); + assertEquals("5 key max 4 R2 adjust", -1, params.mTopRowAdjustment); + assertEquals("5 key max 4 R2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [5] [3] <1> [2] [4] + @Test + public void testLayout5KeyMax5M0() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_M0); + assertEquals("5 key max 5 M0 columns", 5, params.mNumColumns); + assertEquals("5 key max 5 M0 rows", 1, params.mNumRows); + assertEquals("5 key max 5 M0 left", 2, params.mLeftKeys); + assertEquals("5 key max 5 M0 right", 3, params.mRightKeys); + assertEquals("5 key max 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key max 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key max 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("5 key max 5 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("5 key max 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key max 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |<1> [2] [3] [4] [5] + @Test + public void testLayout5KeyMax5L0() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L0); + assertEquals("5 key max 5 L0 columns", 5, params.mNumColumns); + assertEquals("5 key max 5 L0 rows", 1, params.mNumRows); + assertEquals("5 key max 5 L0 left", 0, params.mLeftKeys); + assertEquals("5 key max 5 L0 right", 5, params.mRightKeys); + assertEquals("5 key max 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key max 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key max 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("5 key max 5 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("5 key max 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key max 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] [3] [4] [5] + @Test + public void testLayout5KeyMax5L1() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L1); + assertEquals("5 key max 5 L1 columns", 5, params.mNumColumns); + assertEquals("5 key max 5 L1 rows", 1, params.mNumRows); + assertEquals("5 key max 5 L1 left", 0, params.mLeftKeys); + assertEquals("5 key max 5 L1 right", 5, params.mRightKeys); + assertEquals("5 key max 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key max 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("5 key max 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("5 key max 5 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("5 key max 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key max 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [3] <1> [2] [4] [5] + @Test + public void testLayout5KeyMax5L2() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_L2); + assertEquals("5 key max 5 L2 columns", 5, params.mNumColumns); + assertEquals("5 key max 5 L2 rows", 1, params.mNumRows); + assertEquals("5 key max 5 L2 left", 1, params.mLeftKeys); + assertEquals("5 key max 5 L2 right", 4, params.mRightKeys); + assertEquals("5 key max 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key max 5 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key max 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("5 key max 5 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("5 key max 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key max 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [5] [4] [3] [2] <1>| + @Test + public void testLayout5KeyMax5R0() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R0); + assertEquals("5 key max 5 R0 columns", 5, params.mNumColumns); + assertEquals("5 key max 5 R0 rows", 1, params.mNumRows); + assertEquals("5 key max 5 R0 left", 4, params.mLeftKeys); + assertEquals("5 key max 5 R0 right", 1, params.mRightKeys); + assertEquals("5 key max 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("5 key max 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("5 key max 5 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("5 key max 5 R0 [5]", -4, params.getColumnPos(4)); + assertEquals("5 key max 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key max 5 R0 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [5] [4] [3] [2] <1> ___| + @Test + public void testLayout5KeyMax5R1() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R1); + assertEquals("5 key max 5 R1 columns", 5, params.mNumColumns); + assertEquals("5 key max 5 R1 rows", 1, params.mNumRows); + assertEquals("5 key max 5 R1 left", 4, params.mLeftKeys); + assertEquals("5 key max 5 R1 right", 1, params.mRightKeys); + assertEquals("5 key max 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("5 key max 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("5 key max 5 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("5 key max 5 R1 [5]", -4, params.getColumnPos(4)); + assertEquals("5 key max 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key max 5 R1 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [5] [4] [3] <1> [2] ___| + @Test + public void testLayout5KeyMax5R2() { + MoreKeysKeyboardParams params = createParams(5, 5, XPOS_R2); + assertEquals("5 key max 5 R2 columns", 5, params.mNumColumns); + assertEquals("5 key max 5 R2 rows", 1, params.mNumRows); + assertEquals("5 key max 5 R2 left", 3, params.mLeftKeys); + assertEquals("5 key max 5 R2 right", 2, params.mRightKeys); + assertEquals("5 key max 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("5 key max 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("5 key max 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("5 key max 5 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("5 key max 5 R2 [5]", -3, params.getColumnPos(4)); + assertEquals("5 key max 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("5 key max 5 R2 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [6] [4] [5] + // [3] <1> [2] + @Test + public void testLayout6KeyMax4M0() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_M0); + assertEquals("6 key max 4 M0 columns", 3, params.mNumColumns); + assertEquals("6 key max 4 M0 rows", 2, params.mNumRows); + assertEquals("6 key max 4 M0 left", 1, params.mLeftKeys); + assertEquals("6 key max 4 M0 right", 2, params.mRightKeys); + assertEquals("6 key max 4 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key max 4 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key max 4 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("6 key max 4 M0 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key max 4 M0 [5]", 1, params.getColumnPos(4)); + assertEquals("6 key max 4 M0 [6]", -1, params.getColumnPos(5)); + assertEquals("6 key max 4 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key max 4 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[4] [5] [6] + // |<1> [2] [3] + @Test + public void testLayout6KeyMax4L0() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L0); + assertEquals("6 key max 4 L0 columns", 3, params.mNumColumns); + assertEquals("6 key max 4 L0 rows", 2, params.mNumRows); + assertEquals("6 key max 4 L0 left", 0, params.mLeftKeys); + assertEquals("6 key max 4 L0 right", 3, params.mRightKeys); + assertEquals("6 key max 4 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key max 4 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key max 4 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("6 key max 4 L0 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key max 4 L0 [5]", 1, params.getColumnPos(4)); + assertEquals("6 key max 4 L0 [6]", 2, params.getColumnPos(5)); + assertEquals("6 key max 4 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key max 4 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [4] [5] [6] + // |___ <1> [2] [3] + @Test + public void testLayout6KeyMax4L1() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L1); + assertEquals("6 key max 4 L1 columns", 3, params.mNumColumns); + assertEquals("6 key max 4 L1 rows", 2, params.mNumRows); + assertEquals("6 key max 4 L1 left", 0, params.mLeftKeys); + assertEquals("6 key max 4 L1 right", 3, params.mRightKeys); + assertEquals("6 key max 4 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key max 4 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key max 4 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("6 key max 4 L1 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key max 4 L1 [5]", 1, params.getColumnPos(4)); + assertEquals("6 key max 4 L1 [6]", 2, params.getColumnPos(5)); + assertEquals("6 key max 4 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key max 4 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [4] [5] + // |___ [3] <1> [2] + @Test + public void testLayout6KeyMax4L2() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_L2); + assertEquals("6 key max 4 L2 columns", 3, params.mNumColumns); + assertEquals("6 key max 4 L2 rows", 2, params.mNumRows); + assertEquals("6 key max 4 L2 left", 1, params.mLeftKeys); + assertEquals("6 key max 4 L2 right", 2, params.mRightKeys); + assertEquals("6 key max 4 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key max 4 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key max 4 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("6 key max 4 L2 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key max 4 L2 [5]", 1, params.getColumnPos(4)); + assertEquals("6 key max 4 L2 [6]", -1, params.getColumnPos(5)); + assertEquals("6 key max 4 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key max 4 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [6] [5] [4]| + // [3] [2] <1>| + @Test + public void testLayout6KeyMax4R0() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R0); + assertEquals("6 key max 4 R0 columns", 3, params.mNumColumns); + assertEquals("6 key max 4 R0 rows", 2, params.mNumRows); + assertEquals("6 key max 4 R0 left", 2, params.mLeftKeys); + assertEquals("6 key max 4 R0 right", 1, params.mRightKeys); + assertEquals("6 key max 4 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key max 4 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("6 key max 4 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("6 key max 4 R0 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key max 4 R0 [5]", -1, params.getColumnPos(4)); + assertEquals("6 key max 4 R0 [6]", -2, params.getColumnPos(5)); + assertEquals("6 key max 4 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key max 4 R0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [6] [5] [4] ___| + // [3] [2] <1> ___| + @Test + public void testLayout6KeyMax4R1() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R1); + assertEquals("6 key max 4 R1 columns", 3, params.mNumColumns); + assertEquals("6 key max 4 R1 rows", 2, params.mNumRows); + assertEquals("6 key max 4 R1 left", 2, params.mLeftKeys); + assertEquals("6 key max 4 R1 right", 1, params.mRightKeys); + assertEquals("6 key max 4 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key max 4 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("6 key max 4 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("6 key max 4 R1 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key max 4 R1 [5]", -1, params.getColumnPos(4)); + assertEquals("6 key max 4 R1 [6]", -2, params.getColumnPos(5)); + assertEquals("6 key max 4 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key max 4 R1 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [6] [4] [5] ___| + // [3] <1> [2] ___| + @Test + public void testLayout6KeyMax4R2() { + MoreKeysKeyboardParams params = createParams(6, 4, XPOS_R2); + assertEquals("6 key max 4 R2 columns", 3, params.mNumColumns); + assertEquals("6 key max 4 R2 rows", 2, params.mNumRows); + assertEquals("6 key max 4 R2 left", 1, params.mLeftKeys); + assertEquals("6 key max 4 R2 right", 2, params.mRightKeys); + assertEquals("6 key max 4 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key max 4 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key max 4 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("6 key max 4 R2 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key max 4 R2 [5]", 1, params.getColumnPos(4)); + assertEquals("6 key max 4 R2 [6]", -1, params.getColumnPos(5)); + assertEquals("6 key max 4 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key max 4 R2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [6] [4] [5] + // [3] <1> [2] + @Test + public void testLayout6KeyMax5M0() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_M0); + assertEquals("6 key max 5 M0 columns", 3, params.mNumColumns); + assertEquals("6 key max 5 M0 rows", 2, params.mNumRows); + assertEquals("6 key max 5 M0 left", 1, params.mLeftKeys); + assertEquals("6 key max 5 M0 right", 2, params.mRightKeys); + assertEquals("6 key max 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key max 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key max 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("6 key max 5 M0 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key max 5 M0 [5]", 1, params.getColumnPos(4)); + assertEquals("6 key max 5 M0 [6]", -1, params.getColumnPos(5)); + assertEquals("6 key max 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key max 5 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[4] [5] [6] + // |<1> [2] [3] + @Test + public void testLayout6KeyMax5L0() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L0); + assertEquals("6 key max 5 L0 columns", 3, params.mNumColumns); + assertEquals("6 key max 5 L0 rows", 2, params.mNumRows); + assertEquals("6 key max 5 L0 left", 0, params.mLeftKeys); + assertEquals("6 key max 5 L0 right", 3, params.mRightKeys); + assertEquals("6 key max 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key max 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key max 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("6 key max 5 L0 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key max 5 L0 [5]", 1, params.getColumnPos(4)); + assertEquals("6 key max 5 L0 [6]", 2, params.getColumnPos(5)); + assertEquals("6 key max 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key max 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [4] [5] [6] + // |___ <1> [2] [3] + @Test + public void testLayout6KeyMax5L1() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L1); + assertEquals("6 key max 5 L1 columns", 3, params.mNumColumns); + assertEquals("6 key max 5 L1 rows", 2, params.mNumRows); + assertEquals("6 key max 5 L1 left", 0, params.mLeftKeys); + assertEquals("6 key max 5 L1 right", 3, params.mRightKeys); + assertEquals("6 key max 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key max 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key max 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("6 key max 5 L1 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key max 5 L1 [5]", 1, params.getColumnPos(4)); + assertEquals("6 key max 5 L1 [6]", 2, params.getColumnPos(5)); + assertEquals("6 key max 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key max 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [4] [5] + // |___ [3] <1> [2] + @Test + public void testLayout6KeyMax5L2() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_L2); + assertEquals("6 key max 5 L2 columns", 3, params.mNumColumns); + assertEquals("6 key max 5 L2 rows", 2, params.mNumRows); + assertEquals("6 key max 5 L2 left", 1, params.mLeftKeys); + assertEquals("6 key max 5 L2 right", 2, params.mRightKeys); + assertEquals("6 key max 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key max 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key max 5 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("6 key max 5 L2 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key max 5 L2 [5]", 1, params.getColumnPos(4)); + assertEquals("6 key max 5 L2 [6]", -1, params.getColumnPos(5)); + assertEquals("6 key max 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key max 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [6] [5] [4]| + // [3] [2] <1>| + @Test + public void testLayout6KeyMax5R0() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R0); + assertEquals("6 key max 5 R0 columns", 3, params.mNumColumns); + assertEquals("6 key max 5 R0 rows", 2, params.mNumRows); + assertEquals("6 key max 5 R0 left", 2, params.mLeftKeys); + assertEquals("6 key max 5 R0 right", 1, params.mRightKeys); + assertEquals("6 key max 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key max 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("6 key max 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("6 key max 5 R0 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key max 5 R0 [5]", -1, params.getColumnPos(4)); + assertEquals("6 key max 5 R0 [6]", -2, params.getColumnPos(5)); + assertEquals("6 key max 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key max 5 R0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [6] [5] [4] ___| + // [3] [2] <1> ___| + @Test + public void testLayout6KeyMax5R1() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R1); + assertEquals("6 key max 5 R1 columns", 3, params.mNumColumns); + assertEquals("6 key max 5 R1 rows", 2, params.mNumRows); + assertEquals("6 key max 5 R1 left", 2, params.mLeftKeys); + assertEquals("6 key max 5 R1 right", 1, params.mRightKeys); + assertEquals("6 key max 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key max 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("6 key max 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("6 key max 5 R1 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key max 5 R1 [5]", -1, params.getColumnPos(4)); + assertEquals("6 key max 5 R1 [6]", -2, params.getColumnPos(5)); + assertEquals("6 key max 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key max 5 R1 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [6] [4] [5] ___| + // [3] <1> [2] ___| + @Test + public void testLayout6KeyMax5R2() { + MoreKeysKeyboardParams params = createParams(6, 5, XPOS_R2); + assertEquals("6 key max 5 R2 columns", 3, params.mNumColumns); + assertEquals("6 key max 5 R2 rows", 2, params.mNumRows); + assertEquals("6 key max 5 R2 left", 1, params.mLeftKeys); + assertEquals("6 key max 5 R2 right", 2, params.mRightKeys); + assertEquals("6 key max 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("6 key max 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("6 key max 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("6 key max 5 R2 [4]", 0, params.getColumnPos(3)); + assertEquals("6 key max 5 R2 [5]", 1, params.getColumnPos(4)); + assertEquals("6 key max 5 R2 [6]", -1, params.getColumnPos(5)); + assertEquals("6 key max 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("6 key max 5 R2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |<1> [2] [3] [4] [5] [6] [7] ___ ___ ___| + @Test + public void testLayout7KeyMax7L0() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L0); + assertEquals("7 key max 7 L0 columns", 7, params.mNumColumns); + assertEquals("7 key max 7 L0 rows", 1, params.mNumRows); + assertEquals("7 key max 7 L0 left", 0, params.mLeftKeys); + assertEquals("7 key max 7 L0 right", 7, params.mRightKeys); + assertEquals("7 key max 7 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 7 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 7 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key max 7 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("7 key max 7 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("7 key max 7 L0 [6]", 5, params.getColumnPos(5)); + assertEquals("7 key max 7 L0 [7]", 6, params.getColumnPos(6)); + assertEquals("7 key max 7 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 7 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ <1> [2] [3] [4] [5] [6] [7] ___ ___| + @Test + public void testLayout7KeyMax7L1() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L1); + assertEquals("7 key max 7 L1 columns", 7, params.mNumColumns); + assertEquals("7 key max 7 L1 rows", 1, params.mNumRows); + assertEquals("7 key max 7 L1 left", 0, params.mLeftKeys); + assertEquals("7 key max 7 L1 right", 7, params.mRightKeys); + assertEquals("7 key max 7 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 7 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 7 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key max 7 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("7 key max 7 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("7 key max 7 L1 [6]", 5, params.getColumnPos(5)); + assertEquals("7 key max 7 L1 [7]", 6, params.getColumnPos(6)); + assertEquals("7 key max 7 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 7 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [3] <1> [2] [4] [5] [6] [7] ___ ___| + @Test + public void testLayout7KeyMax7L2() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L2); + assertEquals("7 key max 7 L2 columns", 7, params.mNumColumns); + assertEquals("7 key max 7 L2 rows", 1, params.mNumRows); + assertEquals("7 key max 7 L2 left", 1, params.mLeftKeys); + assertEquals("7 key max 7 L2 right", 6, params.mRightKeys); + assertEquals("7 key max 7 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 7 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 7 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key max 7 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key max 7 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("7 key max 7 L2 [6]", 4, params.getColumnPos(5)); + assertEquals("7 key max 7 L2 [7]", 5, params.getColumnPos(6)); + assertEquals("7 key max 7 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 7 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |___ [5] [3] <1> [2] [4] [6] [7] ___ ___| + @Test + public void testLayout7KeyMax7L3() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_L3); + assertEquals("7 key max 7 L3 columns", 7, params.mNumColumns); + assertEquals("7 key max 7 L3 rows", 1, params.mNumRows); + assertEquals("7 key max 7 L3 left", 2, params.mLeftKeys); + assertEquals("7 key max 7 L3 right", 5, params.mRightKeys); + assertEquals("7 key max 7 L3 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 7 L3 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 7 L3 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key max 7 L3 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key max 7 L3 [5]", -2, params.getColumnPos(4)); + assertEquals("7 key max 7 L3 [6]", 3, params.getColumnPos(5)); + assertEquals("7 key max 7 L3 [7]", 4, params.getColumnPos(6)); + assertEquals("7 key max 7 L3 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 7 L3 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |___ [7] [5] [3] <1> [2] [4] [6] ___ ___| + @Test + public void testLayout7KeyMax7M0() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_M0); + assertEquals("7 key max 7 M0 columns", 7, params.mNumColumns); + assertEquals("7 key max 7 M0 rows", 1, params.mNumRows); + assertEquals("7 key max 7 M0 left", 3, params.mLeftKeys); + assertEquals("7 key max 7 M0 right", 4, params.mRightKeys); + assertEquals("7 key max 7 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 7 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 7 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key max 7 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key max 7 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("7 key max 7 M0 [6]", 3, params.getColumnPos(5)); + assertEquals("7 key max 7 M0 [7]", -3, params.getColumnPos(6)); + assertEquals("7 key max 7 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 7 M0 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // |___ ___ [7] [5] [3] <1> [2] [4] [6] ___| + @Test + public void testLayout7KeyMax7M1() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_M1); + assertEquals("7 key max 7 M1 columns", 7, params.mNumColumns); + assertEquals("7 key max 7 M1 rows", 1, params.mNumRows); + assertEquals("7 key max 7 M1 left", 3, params.mLeftKeys); + assertEquals("7 key max 7 M1 right", 4, params.mRightKeys); + assertEquals("7 key max 7 M1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 7 M1 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 7 M1 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key max 7 M1 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key max 7 M1 [5]", -2, params.getColumnPos(4)); + assertEquals("7 key max 7 M1 [6]", 3, params.getColumnPos(5)); + assertEquals("7 key max 7 M1 [7]", -3, params.getColumnPos(6)); + assertEquals("7 key max 7 M1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 7 M1 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // |___ ___ [7] [6] [5] [3] <1> [2] [4] ___| + @Test + public void testLayout7KeyMax7R3() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R3); + assertEquals("7 key max 7 R3 columns", 7, params.mNumColumns); + assertEquals("7 key max 7 R3 rows", 1, params.mNumRows); + assertEquals("7 key max 7 R3 left", 4, params.mLeftKeys); + assertEquals("7 key max 7 R3 right", 3, params.mRightKeys); + assertEquals("7 key max 7 R3 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 7 R3 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 7 R3 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key max 7 R3 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key max 7 R3 [5]", -2, params.getColumnPos(4)); + assertEquals("7 key max 7 R3 [6]", -3, params.getColumnPos(5)); + assertEquals("7 key max 7 R3 [7]", -4, params.getColumnPos(6)); + assertEquals("7 key max 7 R3 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 7 R3 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // |___ ___ [7] [6] [5] [4] [3] <1> [2] ___| + @Test + public void testLayout7KeyMax7R2() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R2); + assertEquals("7 key max 7 R2 columns", 7, params.mNumColumns); + assertEquals("7 key max 7 R2 rows", 1, params.mNumRows); + assertEquals("7 key max 7 R2 left", 5, params.mLeftKeys); + assertEquals("7 key max 7 R2 right", 2, params.mRightKeys); + assertEquals("7 key max 7 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 7 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 7 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key max 7 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("7 key max 7 R2 [5]", -3, params.getColumnPos(4)); + assertEquals("7 key max 7 R2 [6]", -4, params.getColumnPos(5)); + assertEquals("7 key max 7 R2 [7]", -5, params.getColumnPos(6)); + assertEquals("7 key max 7 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 7 R2 default", WIDTH * 5, params.getDefaultKeyCoordX()); + } + + // |___ ___ [7] [6] [5] [4] [3] [2] <1> ___| + @Test + public void testLayout7KeyMax7R1() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R1); + assertEquals("7 key max 7 R1 columns", 7, params.mNumColumns); + assertEquals("7 key max 7 R1 rows", 1, params.mNumRows); + assertEquals("7 key max 7 R1 left", 6, params.mLeftKeys); + assertEquals("7 key max 7 R1 right", 1, params.mRightKeys); + assertEquals("7 key max 7 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 7 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("7 key max 7 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("7 key max 7 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("7 key max 7 R1 [5]", -4, params.getColumnPos(4)); + assertEquals("7 key max 7 R1 [6]", -5, params.getColumnPos(5)); + assertEquals("7 key max 7 R1 [7]", -6, params.getColumnPos(6)); + assertEquals("7 key max 7 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 7 R1 default", WIDTH * 6, params.getDefaultKeyCoordX()); + } + + // |___ ___ [7] [6] [5] [4] [3] [2] <1>| + @Test + public void testLayout7KeyMax7R0() { + MoreKeysKeyboardParams params = createParams(7, 7, XPOS_R0); + assertEquals("7 key max 7 R0 columns", 7, params.mNumColumns); + assertEquals("7 key max 7 R0 rows", 1, params.mNumRows); + assertEquals("7 key max 7 R0 left", 6, params.mLeftKeys); + assertEquals("7 key max 7 R0 right", 1, params.mRightKeys); + assertEquals("7 key max 7 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 7 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("7 key max 7 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("7 key max 7 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("7 key max 7 R0 [5]", -4, params.getColumnPos(4)); + assertEquals("7 key max 7 R0 [6]", -5, params.getColumnPos(5)); + assertEquals("7 key max 7 R0 [7]", -6, params.getColumnPos(6)); + assertEquals("7 key max 7 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 7 R0 default", WIDTH * 6, params.getDefaultKeyCoordX()); + } + + // [5] [6] [7] + // [3] <1> [2] [4] + @Test + public void testLayout7KeyMax5M0() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_M0); + assertEquals("7 key max 5 M0 columns", 4, params.mNumColumns); + assertEquals("7 key max 5 M0 rows", 2, params.mNumRows); + assertEquals("7 key max 5 M0 left", 1, params.mLeftKeys); + assertEquals("7 key max 5 M0 right", 3, params.mRightKeys); + assertEquals("7 key max 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key max 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key max 5 M0 [5]", 0, params.getColumnPos(4)); + assertEquals("7 key max 5 M0 [6]", 1, params.getColumnPos(5)); + assertEquals("7 key max 5 M0 [7]", 2, params.getColumnPos(6)); + assertEquals("7 key max 5 M0 adjust", -1, params.mTopRowAdjustment); + assertEquals("7 key max 5 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[5] [6] [7] + // |<1> [2] [3] [4] + @Test + public void testLayout7KeyMax5L0() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L0); + assertEquals("7 key max 5 L0 columns", 4, params.mNumColumns); + assertEquals("7 key max 5 L0 rows", 2, params.mNumRows); + assertEquals("7 key max 5 L0 left", 0, params.mLeftKeys); + assertEquals("7 key max 5 L0 right", 4, params.mRightKeys); + assertEquals("7 key max 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key max 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("7 key max 5 L0 [5]", 0, params.getColumnPos(4)); + assertEquals("7 key max 5 L0 [6]", 1, params.getColumnPos(5)); + assertEquals("7 key max 5 L0 [7]", 2, params.getColumnPos(6)); + assertEquals("7 key max 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [5] [6] [7] + // |___ <1> [2] [3] [4] + @Test + public void testLayout7KeyMax5L1() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L1); + assertEquals("7 key max 5 L1 columns", 4, params.mNumColumns); + assertEquals("7 key max 5 L1 rows", 2, params.mNumRows); + assertEquals("7 key max 5 L1 left", 0, params.mLeftKeys); + assertEquals("7 key max 5 L1 right", 4, params.mRightKeys); + assertEquals("7 key max 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key max 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("7 key max 5 L1 [5]", 0, params.getColumnPos(4)); + assertEquals("7 key max 5 L1 [6]", 1, params.getColumnPos(5)); + assertEquals("7 key max 5 L1 [7]", 2, params.getColumnPos(6)); + assertEquals("7 key max 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [5] [6] [7] + // |___ [3] <1> [2] [4] + @Test + public void testLayout7KeyMax5L2() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_L2); + assertEquals("7 key max 5 L2 columns", 4, params.mNumColumns); + assertEquals("7 key max 5 L2 rows", 2, params.mNumRows); + assertEquals("7 key max 5 L2 left", 1, params.mLeftKeys); + assertEquals("7 key max 5 L2 right", 3, params.mRightKeys); + assertEquals("7 key max 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 5 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key max 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("7 key max 5 L2 [5]", 0, params.getColumnPos(4)); + assertEquals("7 key max 5 L2 [6]", 1, params.getColumnPos(5)); + assertEquals("7 key max 5 L2 [7]", 2, params.getColumnPos(6)); + assertEquals("7 key max 5 L2 adjust", -1, params.mTopRowAdjustment); + assertEquals("7 key max 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [7] [6] [5]| + // [4] [3] [2] <1>| + @Test + public void testLayout7KeyMax5R0() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R0); + assertEquals("7 key max 5 R0 columns", 4, params.mNumColumns); + assertEquals("7 key max 5 R0 rows", 2, params.mNumRows); + assertEquals("7 key max 5 R0 left", 3, params.mLeftKeys); + assertEquals("7 key max 5 R0 right", 1, params.mRightKeys); + assertEquals("7 key max 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("7 key max 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("7 key max 5 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("7 key max 5 R0 [5]", 0, params.getColumnPos(4)); + assertEquals("7 key max 5 R0 [6]", -1, params.getColumnPos(5)); + assertEquals("7 key max 5 R0 [7]", -2, params.getColumnPos(6)); + assertEquals("7 key max 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 5 R0 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [7] [6] [5] ___| + // [4] [3] [2] <1> ___| + @Test + public void testLayout7KeyMax5R1() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R1); + assertEquals("7 key max 5 R1 columns", 4, params.mNumColumns); + assertEquals("7 key max 5 R1 rows", 2, params.mNumRows); + assertEquals("7 key max 5 R1 left", 3, params.mLeftKeys); + assertEquals("7 key max 5 R1 right", 1, params.mRightKeys); + assertEquals("7 key max 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("7 key max 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("7 key max 5 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("7 key max 5 R1 [5]", 0, params.getColumnPos(4)); + assertEquals("7 key max 5 R1 [6]", -1, params.getColumnPos(5)); + assertEquals("7 key max 5 R1 [7]", -2, params.getColumnPos(6)); + assertEquals("7 key max 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 5 R1 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [7] [5] [6] ___| + // [4] [3] <1> [2] ___| + @Test + public void testLayout7KeyMax5R2() { + MoreKeysKeyboardParams params = createParams(7, 5, XPOS_R2); + assertEquals("7 key max 5 R2 columns", 4, params.mNumColumns); + assertEquals("7 key max 5 R2 rows", 2, params.mNumRows); + assertEquals("7 key max 5 R2 left", 2, params.mLeftKeys); + assertEquals("7 key max 5 R2 right", 2, params.mRightKeys); + assertEquals("7 key max 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key max 5 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("7 key max 5 R2 [5]", 0, params.getColumnPos(4)); + assertEquals("7 key max 5 R2 [6]", 1, params.getColumnPos(5)); + assertEquals("7 key max 5 R2 [7]", -1, params.getColumnPos(6)); + assertEquals("7 key max 5 R2 adjust", -1, params.mTopRowAdjustment); + assertEquals("7 key max 5 R2 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [7] + // [6] [4] [5] + // [3] <1> [2] + @Test + public void testLayout7KeyMax3M0() { + MoreKeysKeyboardParams params = createParams(7, 3, XPOS_M0); + assertEquals("7 key max 3 M0 columns", 3, params.mNumColumns); + assertEquals("7 key max 3 M0 rows", 3, params.mNumRows); + assertEquals("7 key max 3 M0 left", 1, params.mLeftKeys); + assertEquals("7 key max 3 M0 right", 2, params.mRightKeys); + assertEquals("7 key max 3 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 3 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 3 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key max 3 M0 [4]", 0, params.getColumnPos(3)); + assertEquals("7 key max 3 M0 [5]", 1, params.getColumnPos(4)); + assertEquals("7 key max 3 M0 [6]", -1, params.getColumnPos(5)); + assertEquals("7 key max 3 M0 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key max 3 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 3 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[7] + // |[4] [5] [6] + // |<1> [2] [3] + @Test + public void testLayout7KeyMax3L0() { + MoreKeysKeyboardParams params = createParams(7, 3, XPOS_L0); + assertEquals("7 key max 3 L0 columns", 3, params.mNumColumns); + assertEquals("7 key max 3 L0 rows", 3, params.mNumRows); + assertEquals("7 key max 3 L0 left", 0, params.mLeftKeys); + assertEquals("7 key max 3 L0 right", 3, params.mRightKeys); + assertEquals("7 key max 3 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 3 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 3 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key max 3 L0 [4]", 0, params.getColumnPos(3)); + assertEquals("7 key max 3 L0 [5]", 1, params.getColumnPos(4)); + assertEquals("7 key max 3 L0 [6]", 2, params.getColumnPos(5)); + assertEquals("7 key max 3 L0 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key max 3 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 3 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [7] + // |___ [4] [5] [6] + // |___ <1> [2] [3] + @Test + public void testLayout7KeyMax3L1() { + MoreKeysKeyboardParams params = createParams(7, 3, XPOS_L1); + assertEquals("7 key max 3 L1 columns", 3, params.mNumColumns); + assertEquals("7 key max 3 L1 rows", 3, params.mNumRows); + assertEquals("7 key max 3 L1 left", 0, params.mLeftKeys); + assertEquals("7 key max 3 L1 right", 3, params.mRightKeys); + assertEquals("7 key max 3 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 3 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 3 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("7 key max 3 L1 [4]", 0, params.getColumnPos(3)); + assertEquals("7 key max 3 L1 [5]", 1, params.getColumnPos(4)); + assertEquals("7 key max 3 L1 [6]", 2, params.getColumnPos(5)); + assertEquals("7 key max 3 L1 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key max 3 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 3 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [7] + // |___ [6] [4] [5] + // |___ [3] <1> [2] + @Test + public void testLayout7KeyMax3L2() { + MoreKeysKeyboardParams params = createParams(7, 3, XPOS_L2); + assertEquals("7 key max 3 L2 columns", 3, params.mNumColumns); + assertEquals("7 key max 3 L2 rows", 3, params.mNumRows); + assertEquals("7 key max 3 L2 left", 1, params.mLeftKeys); + assertEquals("7 key max 3 L2 right", 2, params.mRightKeys); + assertEquals("7 key max 3 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 3 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 3 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key max 3 L2 [4]", 0, params.getColumnPos(3)); + assertEquals("7 key max 3 L2 [5]", 1, params.getColumnPos(4)); + assertEquals("7 key max 3 L2 [6]", -1, params.getColumnPos(5)); + assertEquals("7 key max 3 L2 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key max 3 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 3 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [7]| + // [6] [5] [4]| + // [3] [2] <1>| + @Test + public void testLayout7KeyMax3R0() { + MoreKeysKeyboardParams params = createParams(7, 3, XPOS_R0); + assertEquals("7 key max 3 R0 columns", 3, params.mNumColumns); + assertEquals("7 key max 3 R0 rows", 3, params.mNumRows); + assertEquals("7 key max 3 R0 left", 2, params.mLeftKeys); + assertEquals("7 key max 3 R0 right", 1, params.mRightKeys); + assertEquals("7 key max 3 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 3 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("7 key max 3 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("7 key max 3 R0 [4]", 0, params.getColumnPos(3)); + assertEquals("7 key max 3 R0 [5]", -1, params.getColumnPos(4)); + assertEquals("7 key max 3 R0 [6]", -2, params.getColumnPos(5)); + assertEquals("7 key max 3 R0 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key max 3 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 3 R0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [7] ___| + // [6] [5] [4] ___| + // [3] [2] <1> ___| + @Test + public void testLayout7KeyMax3R1() { + MoreKeysKeyboardParams params = createParams(7, 3, XPOS_R1); + assertEquals("7 key max 3 R1 columns", 3, params.mNumColumns); + assertEquals("7 key max 3 R1 rows", 3, params.mNumRows); + assertEquals("7 key max 3 R1 left", 2, params.mLeftKeys); + assertEquals("7 key max 3 R1 right", 1, params.mRightKeys); + assertEquals("7 key max 3 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 3 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("7 key max 3 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("7 key max 3 R1 [4]", 0, params.getColumnPos(3)); + assertEquals("7 key max 3 R1 [5]", -1, params.getColumnPos(4)); + assertEquals("7 key max 3 R1 [6]", -2, params.getColumnPos(5)); + assertEquals("7 key max 3 R1 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key max 3 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 3 R1 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [7] ___| + // [6] [4] [5] ___| + // [3] <1> [2] ___| + @Test + public void testLayout7KeyMax3R2() { + MoreKeysKeyboardParams params = createParams(7, 3, XPOS_R2); + assertEquals("7 key max 3 R2 columns", 3, params.mNumColumns); + assertEquals("7 key max 3 R2 rows", 3, params.mNumRows); + assertEquals("7 key max 3 R2 left", 1, params.mLeftKeys); + assertEquals("7 key max 3 R2 right", 2, params.mRightKeys); + assertEquals("7 key max 3 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("7 key max 3 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("7 key max 3 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("7 key max 3 R2 [4]", 0, params.getColumnPos(3)); + assertEquals("7 key max 3 R2 [5]", 1, params.getColumnPos(4)); + assertEquals("7 key max 3 R2 [6]", -1, params.getColumnPos(5)); + assertEquals("7 key max 3 R2 [7]", 0, params.getColumnPos(6)); + assertEquals("7 key max 3 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("7 key max 3 R2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [7] [5] [6] [8] + // [3] <1> [2] [4] + @Test + public void testLayout8KeyMax5M0() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_M0); + assertEquals("8 key max 5 M0 columns", 4, params.mNumColumns); + assertEquals("8 key max 5 M0 rows", 2, params.mNumRows); + assertEquals("8 key max 5 M0 left", 1, params.mLeftKeys); + assertEquals("8 key max 5 M0 right", 3, params.mRightKeys); + assertEquals("8 key max 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key max 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("8 key max 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("8 key max 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("8 key max 5 M0 [5]", 0, params.getColumnPos(4)); + assertEquals("8 key max 5 M0 [6]", 1, params.getColumnPos(5)); + assertEquals("8 key max 5 M0 [7]", -1, params.getColumnPos(6)); + assertEquals("8 key max 5 M0 [8]", 2, params.getColumnPos(7)); + assertEquals("8 key max 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key max 5 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // |[5] [6] [7] [8] + // |<1> [2] [3] [4] + @Test + public void testLayout8KeyMax5L0() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L0); + assertEquals("8 key max 5 L0 columns", 4, params.mNumColumns); + assertEquals("8 key max 5 L0 rows", 2, params.mNumRows); + assertEquals("8 key max 5 L0 left", 0, params.mLeftKeys); + assertEquals("8 key max 5 L0 right", 4, params.mRightKeys); + assertEquals("8 key max 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key max 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("8 key max 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("8 key max 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("8 key max 5 L0 [5]", 0, params.getColumnPos(4)); + assertEquals("8 key max 5 L0 [6]", 1, params.getColumnPos(5)); + assertEquals("8 key max 5 L0 [7]", 2, params.getColumnPos(6)); + assertEquals("8 key max 5 L0 [8]", 3, params.getColumnPos(7)); + assertEquals("8 key max 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key max 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [5] [6] [7] [8] + // |___ <1> [2] [3] [4] + @Test + public void testLayout8KeyMax5L1() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L1); + assertEquals("8 key max 5 L1 columns", 4, params.mNumColumns); + assertEquals("8 key max 5 L1 rows", 2, params.mNumRows); + assertEquals("8 key max 5 L1 left", 0, params.mLeftKeys); + assertEquals("8 key max 5 L1 right", 4, params.mRightKeys); + assertEquals("8 key max 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key max 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("8 key max 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("8 key max 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("8 key max 5 L1 [5]", 0, params.getColumnPos(4)); + assertEquals("8 key max 5 L1 [6]", 1, params.getColumnPos(5)); + assertEquals("8 key max 5 L1 [7]", 2, params.getColumnPos(6)); + assertEquals("8 key max 5 L1 [8]", 3, params.getColumnPos(7)); + assertEquals("8 key max 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key max 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [7] [5] [6] [8] + // |___ [3] <1> [2] [4] + @Test + public void testLayout8KeyMax5L2() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_L2); + assertEquals("8 key max 5 L2 columns", 4, params.mNumColumns); + assertEquals("8 key max 5 L2 rows", 2, params.mNumRows); + assertEquals("8 key max 5 L2 left", 1, params.mLeftKeys); + assertEquals("8 key max 5 L2 right", 3, params.mRightKeys); + assertEquals("8 key max 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key max 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("8 key max 5 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("8 key max 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("8 key max 5 L2 [5]", 0, params.getColumnPos(4)); + assertEquals("8 key max 5 L2 [6]", 1, params.getColumnPos(5)); + assertEquals("8 key max 5 L2 [7]", -1, params.getColumnPos(6)); + assertEquals("8 key max 5 L2 [8]", 2, params.getColumnPos(7)); + assertEquals("8 key max 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key max 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [8] [7] [6] [5]| + // [4] [3] [2] <1>| + @Test + public void testLayout8KeyMax5R0() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R0); + assertEquals("8 key max 5 R0 columns", 4, params.mNumColumns); + assertEquals("8 key max 5 R0 rows", 2, params.mNumRows); + assertEquals("8 key max 5 R0 left", 3, params.mLeftKeys); + assertEquals("8 key max 5 R0 right", 1, params.mRightKeys); + assertEquals("8 key max 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key max 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("8 key max 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("8 key max 5 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("8 key max 5 R0 [5]", 0, params.getColumnPos(4)); + assertEquals("8 key max 5 R0 [6]", -1, params.getColumnPos(5)); + assertEquals("8 key max 5 R0 [7]", -2, params.getColumnPos(6)); + assertEquals("8 key max 5 R0 [8]", -3, params.getColumnPos(7)); + assertEquals("8 key max 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key max 5 R0 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [8] [7] [6] [5] ___| + // [4] [3] [2] <1> ___| + @Test + public void testLayout8KeyMax5R1() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R1); + assertEquals("8 key max 5 R1 columns", 4, params.mNumColumns); + assertEquals("8 key max 5 R1 rows", 2, params.mNumRows); + assertEquals("8 key max 5 R1 left", 3, params.mLeftKeys); + assertEquals("8 key max 5 R1 right", 1, params.mRightKeys); + assertEquals("8 key max 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key max 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("8 key max 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("8 key max 5 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("8 key max 5 R1 [5]", 0, params.getColumnPos(4)); + assertEquals("8 key max 5 R1 [6]", -1, params.getColumnPos(5)); + assertEquals("8 key max 5 R1 [7]", -2, params.getColumnPos(6)); + assertEquals("8 key max 5 R1 [8]", -3, params.getColumnPos(7)); + assertEquals("8 key max 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key max 5 R1 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [8] [7] [5] [6] ___| + // [4] [3] <1> [2] ___| + @Test + public void testLayout8KeyMax5R2() { + MoreKeysKeyboardParams params = createParams(8, 5, XPOS_R2); + assertEquals("8 key max 5 R2 columns", 4, params.mNumColumns); + assertEquals("8 key max 5 R2 rows", 2, params.mNumRows); + assertEquals("8 key max 5 R2 left", 2, params.mLeftKeys); + assertEquals("8 key max 5 R2 right", 2, params.mRightKeys); + assertEquals("8 key max 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("8 key max 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("8 key max 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("8 key max 5 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("8 key max 5 R2 [5]", 0, params.getColumnPos(4)); + assertEquals("8 key max 5 R2 [6]", 1, params.getColumnPos(5)); + assertEquals("8 key max 5 R2 [7]", -1, params.getColumnPos(6)); + assertEquals("8 key max 5 R2 [8]", -2, params.getColumnPos(7)); + assertEquals("8 key max 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("8 key max 5 R2 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [8] [6] [7] [9] + // [5] [3] <1> [2] [4] + @Test + public void testLayout9KeyMax5M0() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_M0); + assertEquals("9 key max 5 M0 columns", 5, params.mNumColumns); + assertEquals("9 key max 5 M0 rows", 2, params.mNumRows); + assertEquals("9 key max 5 M0 left", 2, params.mLeftKeys); + assertEquals("9 key max 5 M0 right", 3, params.mRightKeys); + assertEquals("9 key max 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("9 key max 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("9 key max 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("9 key max 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("9 key max 5 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("9 key max 5 M0 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key max 5 M0 [7]", 1, params.getColumnPos(6)); + assertEquals("9 key max 5 M0 [8]", -1, params.getColumnPos(7)); + assertEquals("9 key max 5 M0 [9]", 2, params.getColumnPos(8)); + assertEquals("9 key max 5 M0 adjust", -1, params.mTopRowAdjustment); + assertEquals("9 key max 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |[6] [7] [8] [9] + // |<1> [2] [3] [4] [5] + @Test + public void testLayout9KeyMax5L0() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L0); + assertEquals("9 key max 5 L0 columns", 5, params.mNumColumns); + assertEquals("9 key max 5 L0 rows", 2, params.mNumRows); + assertEquals("9 key max 5 L0 left", 0, params.mLeftKeys); + assertEquals("9 key max 5 L0 right", 5, params.mRightKeys); + assertEquals("9 key max 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("9 key max 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("9 key max 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("9 key max 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("9 key max 5 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("9 key max 5 L0 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key max 5 L0 [7]", 1, params.getColumnPos(6)); + assertEquals("9 key max 5 L0 [8]", 2, params.getColumnPos(7)); + assertEquals("9 key max 5 L0 [9]", 3, params.getColumnPos(8)); + assertEquals("9 key max 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("9 key max 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] [8] [9] + // |___ <1> [2] [3] [4] [5] + @Test + public void testLayout9KeyMax5L1() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L1); + assertEquals("9 key max 5 L1 columns", 5, params.mNumColumns); + assertEquals("9 key max 5 L1 rows", 2, params.mNumRows); + assertEquals("9 key max 5 L1 left", 0, params.mLeftKeys); + assertEquals("9 key max 5 L1 right", 5, params.mRightKeys); + assertEquals("9 key max 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("9 key max 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("9 key max 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("9 key max 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("9 key max 5 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("9 key max 5 L1 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key max 5 L1 [7]", 1, params.getColumnPos(6)); + assertEquals("9 key max 5 L1 [8]", 2, params.getColumnPos(7)); + assertEquals("9 key max 5 L1 [9]", 3, params.getColumnPos(8)); + assertEquals("9 key max 5 L1 adjust",0, params.mTopRowAdjustment); + assertEquals("9 key max 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] [8] [9] + // |___ [3] <1> [2] [4] [5] + @Test + public void testLayout9KeyMax5L2() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_L2); + assertEquals("9 key max 5 L2 columns", 5, params.mNumColumns); + assertEquals("9 key max 5 L2 rows", 2, params.mNumRows); + assertEquals("9 key max 5 L2 left", 1, params.mLeftKeys); + assertEquals("9 key max 5 L2 right", 4, params.mRightKeys); + assertEquals("9 key max 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("9 key max 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("9 key max 5 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("9 key max 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("9 key max 5 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("9 key max 5 L2 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key max 5 L2 [7]", 1, params.getColumnPos(6)); + assertEquals("9 key max 5 L2 [8]", 2, params.getColumnPos(7)); + assertEquals("9 key max 5 L2 [9]", 3, params.getColumnPos(8)); + assertEquals("9 key max 5 L2 adjust", -1, params.mTopRowAdjustment); + assertEquals("9 key max 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [9] [8] [7] [6]| + // [5] [4] [3] [2] <1>| + @Test + public void testLayout9KeyMax5R0() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R0); + assertEquals("9 key max 5 R0 columns", 5, params.mNumColumns); + assertEquals("9 key max 5 R0 rows", 2, params.mNumRows); + assertEquals("9 key max 5 R0 left", 4, params.mLeftKeys); + assertEquals("9 key max 5 R0 right", 1, params.mRightKeys); + assertEquals("9 key max 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("9 key max 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("9 key max 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("9 key max 5 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("9 key max 5 R0 [5]", -4, params.getColumnPos(4)); + assertEquals("9 key max 5 R0 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key max 5 R0 [7]", -1, params.getColumnPos(6)); + assertEquals("9 key max 5 R0 [8]", -2, params.getColumnPos(7)); + assertEquals("9 key max 5 R0 [9]", -3, params.getColumnPos(8)); + assertEquals("9 key max 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("9 key max 5 R0 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [9] [8] [7] [6] ___| + // [5] [4] [3] [2] <1> ___| + @Test + public void testLayout9KeyMax5R1() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R1); + assertEquals("9 key max 5 R1 columns", 5, params.mNumColumns); + assertEquals("9 key max 5 R1 rows", 2, params.mNumRows); + assertEquals("9 key max 5 R1 left", 4, params.mLeftKeys); + assertEquals("9 key max 5 R1 right", 1, params.mRightKeys); + assertEquals("9 key max 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("9 key max 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("9 key max 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("9 key max 5 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("9 key max 5 R1 [5]", -4, params.getColumnPos(4)); + assertEquals("9 key max 5 R1 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key max 5 R1 [7]", -1, params.getColumnPos(6)); + assertEquals("9 key max 5 R1 [8]", -2, params.getColumnPos(7)); + assertEquals("9 key max 5 R1 [9]", -3, params.getColumnPos(8)); + assertEquals("9 key max 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("9 key max 5 R1 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [9] [8] [6] [7] ___| + // [5] [4] [3] <1> [2] ___| + @Test + public void testLayout9KeyMax5R2() { + MoreKeysKeyboardParams params = createParams(9, 5, XPOS_R2); + assertEquals("9 key max 5 R2 columns", 5, params.mNumColumns); + assertEquals("9 key max 5 R2 rows", 2, params.mNumRows); + assertEquals("9 key max 5 R2 left", 3, params.mLeftKeys); + assertEquals("9 key max 5 R2 right", 2, params.mRightKeys); + assertEquals("9 key max 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("9 key max 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("9 key max 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("9 key max 5 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("9 key max 5 R2 [5]", -3, params.getColumnPos(4)); + assertEquals("9 key max 5 R2 [6]", 0, params.getColumnPos(5)); + assertEquals("9 key max 5 R2 [7]", 1, params.getColumnPos(6)); + assertEquals("9 key max 5 R2 [8]", -1, params.getColumnPos(7)); + assertEquals("9 key max 5 R2 [9]", -2, params.getColumnPos(8)); + assertEquals("9 key max 5 R2 adjust", -1, params.mTopRowAdjustment); + assertEquals("9 key max 5 R2 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [A] [8] [6] [7] [9] + // [5] [3] <1> [2] [4] + @Test + public void testLayout10KeyMax5M0() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_M0); + assertEquals("10 key max 5 M0 columns", 5, params.mNumColumns); + assertEquals("10 key max 5 M0 rows", 2, params.mNumRows); + assertEquals("10 key max 5 M0 left", 2, params.mLeftKeys); + assertEquals("10 key max 5 M0 right", 3, params.mRightKeys); + assertEquals("10 key max 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("10 key max 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("10 key max 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("10 key max 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("10 key max 5 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("10 key max 5 M0 [6]", 0, params.getColumnPos(5)); + assertEquals("10 key max 5 M0 [7]", 1, params.getColumnPos(6)); + assertEquals("10 key max 5 M0 [8]", -1, params.getColumnPos(7)); + assertEquals("10 key max 5 M0 [9]", 2, params.getColumnPos(8)); + assertEquals("10 key max 5 M0 [A]", -2, params.getColumnPos(9)); + assertEquals("10 key max 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key max 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // |[6] [7] [8] [9] [A] + // |<1> [2] [3] [4] [5] + @Test + public void testLayout10KeyMax5L0() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L0); + assertEquals("10 key max 5 L0 columns", 5, params.mNumColumns); + assertEquals("10 key max 5 L0 rows", 2, params.mNumRows); + assertEquals("10 key max 5 L0 left", 0, params.mLeftKeys); + assertEquals("10 key max 5 L0 right", 5, params.mRightKeys); + assertEquals("10 key max 5 L0 <1>", 0, params.getColumnPos(0)); + assertEquals("10 key max 5 L0 [2]", 1, params.getColumnPos(1)); + assertEquals("10 key max 5 L0 [3]", 2, params.getColumnPos(2)); + assertEquals("10 key max 5 L0 [4]", 3, params.getColumnPos(3)); + assertEquals("10 key max 5 L0 [5]", 4, params.getColumnPos(4)); + assertEquals("10 key max 5 L0 [6]", 0, params.getColumnPos(5)); + assertEquals("10 key max 5 L0 [7]", 1, params.getColumnPos(6)); + assertEquals("10 key max 5 L0 [8]", 2, params.getColumnPos(7)); + assertEquals("10 key max 5 L0 [9]", 3, params.getColumnPos(8)); + assertEquals("10 key max 5 L0 [A]", 4, params.getColumnPos(9)); + assertEquals("10 key max 5 L0 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key max 5 L0 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [6] [7] [8] [9] [A] + // |___ <1> [2] [3] [4] [5] + @Test + public void testLayout10KeyMax5L1() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L1); + assertEquals("10 key max 5 L1 columns", 5, params.mNumColumns); + assertEquals("10 key max 5 L1 rows", 2, params.mNumRows); + assertEquals("10 key max 5 L1 left", 0, params.mLeftKeys); + assertEquals("10 key max 5 L1 right", 5, params.mRightKeys); + assertEquals("10 key max 5 L1 <1>", 0, params.getColumnPos(0)); + assertEquals("10 key max 5 L1 [2]", 1, params.getColumnPos(1)); + assertEquals("10 key max 5 L1 [3]", 2, params.getColumnPos(2)); + assertEquals("10 key max 5 L1 [4]", 3, params.getColumnPos(3)); + assertEquals("10 key max 5 L1 [5]", 4, params.getColumnPos(4)); + assertEquals("10 key max 5 L1 [6]", 0, params.getColumnPos(5)); + assertEquals("10 key max 5 L1 [7]", 1, params.getColumnPos(6)); + assertEquals("10 key max 5 L1 [8]", 2, params.getColumnPos(7)); + assertEquals("10 key max 5 L1 [9]", 3, params.getColumnPos(8)); + assertEquals("10 key max 5 L1 [A]", 4, params.getColumnPos(9)); + assertEquals("10 key max 5 L1 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key max 5 L1 default", WIDTH * 0, params.getDefaultKeyCoordX()); + } + + // |___ [8] [6] [7] [9] [A] + // |___ [3] <1> [2] [4] [5] + @Test + public void testLayout10KeyMax5L2() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_L2); + assertEquals("10 key max 5 L2 columns", 5, params.mNumColumns); + assertEquals("10 key max 5 L2 rows", 2, params.mNumRows); + assertEquals("10 key max 5 L2 left", 1, params.mLeftKeys); + assertEquals("10 key max 5 L2 right", 4, params.mRightKeys); + assertEquals("10 key max 5 L2 <1>", 0, params.getColumnPos(0)); + assertEquals("10 key max 5 L2 [2]", 1, params.getColumnPos(1)); + assertEquals("10 key max 5 L2 [3]", -1, params.getColumnPos(2)); + assertEquals("10 key max 5 L2 [4]", 2, params.getColumnPos(3)); + assertEquals("10 key max 5 L2 [5]", 3, params.getColumnPos(4)); + assertEquals("10 key max 5 L2 [6]", 0, params.getColumnPos(5)); + assertEquals("10 key max 5 L2 [7]", 1, params.getColumnPos(6)); + assertEquals("10 key max 5 L2 [8]", -1, params.getColumnPos(7)); + assertEquals("10 key max 5 L2 [9]", 2, params.getColumnPos(8)); + assertEquals("10 key max 5 L2 [A]", 3, params.getColumnPos(9)); + assertEquals("10 key max 5 L2 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key max 5 L2 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [A] [9] [8] [7] [6]| + // [5] [4] [3] [2] <1>| + @Test + public void testLayout10KeyMax5R0() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R0); + assertEquals("10 key max 5 R0 columns", 5, params.mNumColumns); + assertEquals("10 key max 5 R0 rows", 2, params.mNumRows); + assertEquals("10 key max 5 R0 left", 4, params.mLeftKeys); + assertEquals("10 key max 5 R0 right", 1, params.mRightKeys); + assertEquals("10 key max 5 R0 <1>", 0, params.getColumnPos(0)); + assertEquals("10 key max 5 R0 [2]", -1, params.getColumnPos(1)); + assertEquals("10 key max 5 R0 [3]", -2, params.getColumnPos(2)); + assertEquals("10 key max 5 R0 [4]", -3, params.getColumnPos(3)); + assertEquals("10 key max 5 R0 [5]", -4, params.getColumnPos(4)); + assertEquals("10 key max 5 R0 [6]", 0, params.getColumnPos(5)); + assertEquals("10 key max 5 R0 [7]", -1, params.getColumnPos(6)); + assertEquals("10 key max 5 R0 [8]", -2, params.getColumnPos(7)); + assertEquals("10 key max 5 R0 [9]", -3, params.getColumnPos(8)); + assertEquals("10 key max 5 R0 [A]", -4, params.getColumnPos(9)); + assertEquals("10 key max 5 R0 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key max 5 R0 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [A] [9] [8] [7] [6] ___| + // [5] [4] [3] [2] <1> ___| + @Test + public void testLayout10KeyMax5R1() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R1); + assertEquals("10 key max 5 R1 columns", 5, params.mNumColumns); + assertEquals("10 key max 5 R1 rows", 2, params.mNumRows); + assertEquals("10 key max 5 R1 left", 4, params.mLeftKeys); + assertEquals("10 key max 5 R1 right", 1, params.mRightKeys); + assertEquals("10 key max 5 R1 <1>", 0, params.getColumnPos(0)); + assertEquals("10 key max 5 R1 [2]", -1, params.getColumnPos(1)); + assertEquals("10 key max 5 R1 [3]", -2, params.getColumnPos(2)); + assertEquals("10 key max 5 R1 [4]", -3, params.getColumnPos(3)); + assertEquals("10 key max 5 R1 [5]", -4, params.getColumnPos(4)); + assertEquals("10 key max 5 R1 [6]", 0, params.getColumnPos(5)); + assertEquals("10 key max 5 R1 [7]", -1, params.getColumnPos(6)); + assertEquals("10 key max 5 R1 [8]", -2, params.getColumnPos(7)); + assertEquals("10 key max 5 R1 [9]", -3, params.getColumnPos(8)); + assertEquals("10 key max 5 R1 [A]", -4, params.getColumnPos(9)); + assertEquals("10 key max 5 R1 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key max 5 R1 default", WIDTH * 4, params.getDefaultKeyCoordX()); + } + + // [A] [9] [8] [6] [7] ___| + // [5] [4] [3] <1> [2] ___| + @Test + public void testLayout10KeyMax5R2() { + MoreKeysKeyboardParams params = createParams(10, 5, XPOS_R2); + assertEquals("10 key max 5 R2 columns", 5, params.mNumColumns); + assertEquals("10 key max 5 R2 rows", 2, params.mNumRows); + assertEquals("10 key max 5 R2 left", 3, params.mLeftKeys); + assertEquals("10 key max 5 R2 right", 2, params.mRightKeys); + assertEquals("10 key max 5 R2 <1>", 0, params.getColumnPos(0)); + assertEquals("10 key max 5 R2 [2]", 1, params.getColumnPos(1)); + assertEquals("10 key max 5 R2 [3]", -1, params.getColumnPos(2)); + assertEquals("10 key max 5 R2 [4]", -2, params.getColumnPos(3)); + assertEquals("10 key max 5 R2 [5]", -3, params.getColumnPos(4)); + assertEquals("10 key max 5 R2 [6]", 0, params.getColumnPos(5)); + assertEquals("10 key max 5 R2 [7]", 1, params.getColumnPos(6)); + assertEquals("10 key max 5 R2 [8]", -1, params.getColumnPos(7)); + assertEquals("10 key max 5 R2 [9]", -2, params.getColumnPos(8)); + assertEquals("10 key max 5 R2 [A]", -3, params.getColumnPos(9)); + assertEquals("10 key max 5 R2 adjust", 0, params.mTopRowAdjustment); + assertEquals("10 key max 5 R2 default", WIDTH * 3, params.getDefaultKeyCoordX()); + } + + // [9] [A] [B] + // [7] [5] [6] [8] + // [3] <1> [2] [4] + @Test + public void testLayout11KeyMax5M0() { + MoreKeysKeyboardParams params = createParams(11, 5, XPOS_M0); + assertEquals("11 key max 5 M0 columns", 4, params.mNumColumns); + assertEquals("11 key max 5 M0 rows", 3, params.mNumRows); + assertEquals("11 key max 5 M0 left", 1, params.mLeftKeys); + assertEquals("11 key max 5 M0 right", 3, params.mRightKeys); + assertEquals("11 key max 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("11 key max 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("11 key max 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("11 key max 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("11 key max 5 M0 [5]", 0, params.getColumnPos(4)); + assertEquals("11 key max 5 M0 [6]", 1, params.getColumnPos(5)); + assertEquals("11 key max 5 M0 [7]", -1, params.getColumnPos(6)); + assertEquals("11 key max 5 M0 [8]", 2, params.getColumnPos(7)); + assertEquals("11 key max 5 M0 [9]", 0, params.getColumnPos(8)); + assertEquals("11 key max 5 M0 [A]", 1, params.getColumnPos(9)); + assertEquals("11 key max 5 M0 [B]", 2, params.getColumnPos(10)); + assertEquals("11 key max 5 M0 adjust", -1, params.mTopRowAdjustment); + assertEquals("11 key max 5 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [B] [9] [A] [C] + // [7] [5] [6] [8] + // [3] <1> [2] [4] + @Test + public void testLayout12KeyMax5M0() { + MoreKeysKeyboardParams params = createParams(12, 5, XPOS_M0); + assertEquals("12 key max 5 M0 columns", 4, params.mNumColumns); + assertEquals("12 key max 5 M0 rows", 3, params.mNumRows); + assertEquals("12 key max 5 M0 left", 1, params.mLeftKeys); + assertEquals("12 key max 5 M0 right", 3, params.mRightKeys); + assertEquals("12 key max 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("12 key max 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("12 key max 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("12 key max 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("12 key max 5 M0 [5]", 0, params.getColumnPos(4)); + assertEquals("12 key max 5 M0 [6]", 1, params.getColumnPos(5)); + assertEquals("12 key max 5 M0 [7]", -1, params.getColumnPos(6)); + assertEquals("12 key max 5 M0 [8]", 2, params.getColumnPos(7)); + assertEquals("12 key max 5 M0 [9]", 0, params.getColumnPos(8)); + assertEquals("12 key max 5 M0 [A]", 1, params.getColumnPos(9)); + assertEquals("12 key max 5 M0 [B]", -1, params.getColumnPos(10)); + assertEquals("12 key max 5 M0 [C]", 2, params.getColumnPos(11)); + assertEquals("12 key max 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("12 key max 5 M0 default", WIDTH * 1, params.getDefaultKeyCoordX()); + } + + // [D] [B] [C] + // [A] [8] [6] [7] [9] + // [5] [3] <1> [2] [4] + @Test + public void testLayout13KeyMax5M0() { + MoreKeysKeyboardParams params = createParams(13, 5, XPOS_M0); + assertEquals("13 key max 5 M0 columns", 5, params.mNumColumns); + assertEquals("13 key max 5 M0 rows", 3, params.mNumRows); + assertEquals("13 key max 5 M0 left", 2, params.mLeftKeys); + assertEquals("13 key max 5 M0 right", 3, params.mRightKeys); + assertEquals("13 key max 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("13 key max 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("13 key max 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("13 key max 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("13 key max 5 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("13 key max 5 M0 [6]", 0, params.getColumnPos(5)); + assertEquals("13 key max 5 M0 [7]", 1, params.getColumnPos(6)); + assertEquals("13 key max 5 M0 [8]", -1, params.getColumnPos(7)); + assertEquals("13 key max 5 M0 [9]", 2, params.getColumnPos(8)); + assertEquals("13 key max 5 M0 [A]", -2, params.getColumnPos(9)); + assertEquals("13 key max 5 M0 [B]", 0, params.getColumnPos(10)); + assertEquals("13 key max 5 M0 [C]", 1, params.getColumnPos(11)); + assertEquals("13 key max 5 M0 [D]", -1, params.getColumnPos(12)); + assertEquals("13 key max 5 M0 adjust", 0, params.mTopRowAdjustment); + assertEquals("13 key max 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } + + // [D] [B] [C] [E] + // [A] [8] [6] [7] [9] + // [5] [3] <1> [2] [4] + @Test + public void testLayout14KeyMax5M0() { + MoreKeysKeyboardParams params = createParams(14, 5, XPOS_M0); + assertEquals("13 key max 5 M0 columns", 5, params.mNumColumns); + assertEquals("13 key max 5 M0 rows", 3, params.mNumRows); + assertEquals("13 key max 5 M0 left", 2, params.mLeftKeys); + assertEquals("13 key max 5 M0 right", 3, params.mRightKeys); + assertEquals("13 key max 5 M0 <1>", 0, params.getColumnPos(0)); + assertEquals("13 key max 5 M0 [2]", 1, params.getColumnPos(1)); + assertEquals("13 key max 5 M0 [3]", -1, params.getColumnPos(2)); + assertEquals("13 key max 5 M0 [4]", 2, params.getColumnPos(3)); + assertEquals("13 key max 5 M0 [5]", -2, params.getColumnPos(4)); + assertEquals("13 key max 5 M0 [6]", 0, params.getColumnPos(5)); + assertEquals("13 key max 5 M0 [7]", 1, params.getColumnPos(6)); + assertEquals("13 key max 5 M0 [8]", -1, params.getColumnPos(7)); + assertEquals("13 key max 5 M0 [9]", 2, params.getColumnPos(8)); + assertEquals("13 key max 5 M0 [A]", -2, params.getColumnPos(9)); + assertEquals("13 key max 5 M0 [B]", 0, params.getColumnPos(10)); + assertEquals("13 key max 5 M0 [C]", 1, params.getColumnPos(11)); + assertEquals("13 key max 5 M0 [D]", -1, params.getColumnPos(12)); + assertEquals("13 key max 5 M0 [E]", 2, params.getColumnPos(13)); + assertEquals("13 key max 5 M0 adjust", -1, params.mTopRowAdjustment); + assertEquals("13 key max 5 M0 default", WIDTH * 2, params.getDefaultKeyCoordX()); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/ActionTestsBase.java b/tests/src/org/kelar/inputmethod/keyboard/action/ActionTestsBase.java new file mode 100644 index 000000000..77ec4cee3 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/ActionTestsBase.java @@ -0,0 +1,115 @@ +/* + * 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 org.kelar.inputmethod.keyboard.action; + +import android.content.Context; +import android.content.res.Resources; +import android.text.InputType; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import org.kelar.inputmethod.keyboard.Key; +import org.kelar.inputmethod.keyboard.Keyboard; +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.KeyboardLayoutSet; +import org.kelar.inputmethod.keyboard.KeyboardLayoutSetTestsBase; +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyVisual; +import org.kelar.inputmethod.latin.common.Constants; +import org.kelar.inputmethod.latin.common.LocaleUtils; +import org.kelar.inputmethod.latin.utils.RunInLocale; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +import java.util.Locale; + +abstract class ActionTestsBase extends KeyboardLayoutSetTestsBase { + static class ExpectedActionKey { + static ExpectedActionKey newIconKey(final String iconName) { + final int iconId = KeyboardIconsSet.getIconId(iconName); + return new ExpectedActionKey(ExpectedKeyVisual.newInstance(iconId)); + } + + static ExpectedActionKey newLabelKey(final String label) { + return new ExpectedActionKey(ExpectedKeyVisual.newInstance(label)); + } + + static ExpectedActionKey newLabelKey(final int labelResId, + final Locale labelLocale, final Context context) { + final RunInLocale<String> getString = new RunInLocale<String>() { + @Override + protected String job(final Resources res) { + return res.getString(labelResId); + } + }; + return newLabelKey(getString.runInLocale(context.getResources(), labelLocale)); + } + + private final ExpectedKeyVisual mVisual; + + private ExpectedActionKey(final ExpectedKeyVisual visual) { + mVisual = visual; + } + + public int getIconId() { return mVisual.getIconId(); } + + public String getLabel() { return mVisual.getLabel(); } + } + + protected static Locale getLabelLocale(final InputMethodSubtype subtype) { + final String localeString = subtype.getLocale(); + if (localeString.equals(SubtypeLocaleUtils.NO_LANGUAGE)) { + return null; + } + return LocaleUtils.constructLocaleFromString(localeString); + } + + private static void assertActionKey(final String tag, final KeyboardLayoutSet layoutSet, + final int elementId, final ExpectedActionKey expectedKey) { + final Keyboard keyboard = layoutSet.getKeyboard(elementId); + final Key actualKey = keyboard.getKey(Constants.CODE_ENTER); + assertNotNull(tag + " enter key on " + keyboard.mId, actualKey); + assertEquals(tag + " label " + expectedKey, expectedKey.getLabel(), actualKey.getLabel()); + assertEquals(tag + " icon " + expectedKey, expectedKey.getIconId(), actualKey.getIconId()); + } + + protected void doTestActionKey(final String tag, final InputMethodSubtype subtype, + final int actionId, final ExpectedActionKey expectedKey) { + final EditorInfo editorInfo = new EditorInfo(); + editorInfo.imeOptions = actionId; + doTestActionKey(tag, subtype, editorInfo, expectedKey); + } + + protected void doTestActionKey(final String tag, final InputMethodSubtype subtype, + final EditorInfo editorInfo, final ExpectedActionKey expectedKey) { + // Test text layouts. + editorInfo.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_NORMAL; + final KeyboardLayoutSet layoutSet = createKeyboardLayoutSet(subtype, editorInfo); + assertActionKey(tag, layoutSet, KeyboardId.ELEMENT_ALPHABET, expectedKey); + assertActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS, expectedKey); + assertActionKey(tag, layoutSet, KeyboardId.ELEMENT_SYMBOLS_SHIFTED, expectedKey); + // Test phone number layouts. + assertActionKey(tag, layoutSet, KeyboardId.ELEMENT_PHONE, expectedKey); + assertActionKey(tag, layoutSet, KeyboardId.ELEMENT_PHONE_SYMBOLS, expectedKey); + // Test normal number layout. + assertActionKey(tag, layoutSet, KeyboardId.ELEMENT_NUMBER, expectedKey); + // Test number password layout. + editorInfo.inputType = + InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD; + final KeyboardLayoutSet passwordSet = createKeyboardLayoutSet(subtype, editorInfo); + assertActionKey(tag, passwordSet, KeyboardId.ELEMENT_NUMBER, expectedKey); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionCustomTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionCustomTests.java new file mode 100644 index 000000000..e8257cc9f --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionCustomTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class KlpActionCustomTests extends KlpActionTestsBase { + public void testActionCustom() { + for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { + final String tag = "custom " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + final EditorInfo editorInfo = new EditorInfo(); + editorInfo.imeOptions = EditorInfo.IME_ACTION_UNSPECIFIED; + editorInfo.actionLabel = "customLabel"; + final ExpectedActionKey expectedKey = ExpectedActionKey.newLabelKey("customLabel"); + doTestActionKey(tag, subtype, editorInfo, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionDoneTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionDoneTests.java new file mode 100644 index 000000000..557590041 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionDoneTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.latin.R; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class KlpActionDoneTests extends KlpActionTestsBase { + public void testActionDone() { + for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { + final String tag = "done " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + final ExpectedActionKey expectedKey = ExpectedActionKey.newLabelKey( + R.string.label_done_key, getLabelLocale(subtype), getContext()); + doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_DONE, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionGoTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionGoTests.java new file mode 100644 index 000000000..f77a4d38f --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionGoTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.latin.R; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class KlpActionGoTests extends KlpActionTestsBase { + public void testActionGo() { + for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { + final String tag = "go " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + final ExpectedActionKey expectedKey = ExpectedActionKey.newLabelKey( + R.string.label_go_key, getLabelLocale(subtype), getContext()); + doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_GO, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionLabelTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionLabelTests.java new file mode 100644 index 000000000..8297764c2 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionLabelTests.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 org.kelar.inputmethod.keyboard.action; + +import android.content.res.Resources; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.MediumTest; + +import org.kelar.inputmethod.keyboard.KeyboardLayoutSet; +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.keyboard.internal.KeyboardTextsSet; +import org.kelar.inputmethod.latin.R; +import org.kelar.inputmethod.latin.RichInputMethodManager; +import org.kelar.inputmethod.latin.utils.RunInLocale; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +import java.util.Locale; + +@MediumTest +public class KlpActionLabelTests extends KlpActionTestsBase { + void doTestActionKeys(final InputMethodSubtype subtype, final String tag, + final ExpectedActionKey unspecifiedKey, final ExpectedActionKey noneKey, + final ExpectedActionKey goKey, final ExpectedActionKey searchKey, + final ExpectedActionKey sendKey, final ExpectedActionKey nextKey, + final ExpectedActionKey doneKey, final ExpectedActionKey previousKey) { + doTestActionKey( + tag + " unspecified", subtype, EditorInfo.IME_ACTION_UNSPECIFIED, unspecifiedKey); + doTestActionKey(tag + " none", subtype, EditorInfo.IME_ACTION_NONE, noneKey); + doTestActionKey(tag + " go", subtype, EditorInfo.IME_ACTION_GO, goKey); + doTestActionKey(tag + " search", subtype, EditorInfo.IME_ACTION_SEARCH, searchKey); + doTestActionKey(tag + " send", subtype, EditorInfo.IME_ACTION_SEND, sendKey); + doTestActionKey(tag + " next", subtype, EditorInfo.IME_ACTION_NEXT, nextKey); + doTestActionKey(tag + " done", subtype, EditorInfo.IME_ACTION_DONE, doneKey); + doTestActionKey(tag + " previous", subtype, EditorInfo.IME_ACTION_PREVIOUS, previousKey); + } + + // Working variable to simulate system locale changing. + private Locale mSystemLocale = Locale.getDefault(); + + private void doTestActionKeysInLocaleWithStringResources(final InputMethodSubtype subtype, + final Locale labelLocale, final Locale systemLocale) { + // Simulate system locale changing, see {@link SystemBroadcastReceiver}. + if (!systemLocale.equals(mSystemLocale)) { + KeyboardLayoutSet.onSystemLocaleChanged(); + mSystemLocale = systemLocale; + } + final ExpectedActionKey enterKey = ExpectedActionKey.newIconKey( + KeyboardIconsSet.NAME_ENTER_KEY); + final ExpectedActionKey goKey = ExpectedActionKey.newLabelKey( + R.string.label_go_key, labelLocale, getContext()); + final ExpectedActionKey searchKey = ExpectedActionKey.newIconKey( + KeyboardIconsSet.NAME_SEARCH_KEY); + final ExpectedActionKey sendKey = ExpectedActionKey.newLabelKey( + R.string.label_send_key, labelLocale, getContext()); + final ExpectedActionKey nextKey = ExpectedActionKey.newLabelKey( + R.string.label_next_key, labelLocale, getContext()); + final ExpectedActionKey doneKey = ExpectedActionKey.newLabelKey( + R.string.label_done_key, labelLocale, getContext()); + final ExpectedActionKey previousKey = ExpectedActionKey.newLabelKey( + R.string.label_previous_key, labelLocale, getContext()); + final String tag = "label=" + labelLocale + " system=" + systemLocale + + " " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + final RunInLocale<Void> job = new RunInLocale<Void>() { + @Override + public Void job(final Resources res) { + doTestActionKeys(subtype, tag, enterKey, enterKey, goKey, searchKey, sendKey, + nextKey, doneKey, previousKey); + return null; + } + }; + job.runInLocale(getContext().getResources(), systemLocale); + } + + public void testActionLabelInOtherLocale() { + final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); + final InputMethodSubtype italian = richImm.findSubtypeByLocaleAndKeyboardLayoutSet( + Locale.ITALIAN.toString(), SubtypeLocaleUtils.QWERTY); + // An action label should be displayed in subtype's locale regardless of the system locale. + doTestActionKeysInLocaleWithStringResources(italian, Locale.ITALIAN, Locale.US); + doTestActionKeysInLocaleWithStringResources(italian, Locale.ITALIAN, Locale.FRENCH); + doTestActionKeysInLocaleWithStringResources(italian, Locale.ITALIAN, Locale.ITALIAN); + doTestActionKeysInLocaleWithStringResources(italian, Locale.ITALIAN, Locale.JAPANESE); + } + + public void testNoLanguageSubtypeActionLabel() { + final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); + final InputMethodSubtype noLanguage = richImm.findSubtypeByLocaleAndKeyboardLayoutSet( + SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.QWERTY); + // An action label of no language keyboard should be displayed in the system locale. + doTestActionKeysInLocaleWithStringResources(noLanguage, Locale.US, Locale.US); + doTestActionKeysInLocaleWithStringResources(noLanguage, Locale.FRENCH, Locale.FRENCH); + doTestActionKeysInLocaleWithStringResources(noLanguage, Locale.ITALIAN, Locale.ITALIAN); + doTestActionKeysInLocaleWithStringResources(noLanguage, Locale.JAPANESE, Locale.JAPANESE); + } + + private void doTestActionKeysInLocaleWithKeyboardTextsSet(final InputMethodSubtype subtype, + final Locale labelLocale, final Locale systemLocale) { + // Simulate system locale changing, see {@link SystemBroadcastReceiver}. + if (!systemLocale.equals(mSystemLocale)) { + KeyboardLayoutSet.onSystemLocaleChanged(); + mSystemLocale = systemLocale; + } + final KeyboardTextsSet textsSet = new KeyboardTextsSet(); + textsSet.setLocale(labelLocale, getContext()); + final ExpectedActionKey enterKey = ExpectedActionKey.newIconKey( + KeyboardIconsSet.NAME_ENTER_KEY); + final ExpectedActionKey goKey = ExpectedActionKey.newLabelKey( + textsSet.getText("label_go_key")); + final ExpectedActionKey searchKey = ExpectedActionKey.newIconKey( + KeyboardIconsSet.NAME_SEARCH_KEY); + final ExpectedActionKey sendKey = ExpectedActionKey.newLabelKey( + textsSet.getText("label_send_key")); + final ExpectedActionKey nextKey = ExpectedActionKey.newLabelKey( + textsSet.getText("label_next_key")); + final ExpectedActionKey doneKey = ExpectedActionKey.newLabelKey( + textsSet.getText("label_done_key")); + final ExpectedActionKey previousKey = ExpectedActionKey.newLabelKey( + textsSet.getText("label_previous_key")); + final String tag = "label=" + subtype.getLocale() + " system=" + systemLocale + + " " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + final RunInLocale<Void> job = new RunInLocale<Void>() { + @Override + public Void job(final Resources res) { + doTestActionKeys(subtype, tag, enterKey, enterKey, goKey, searchKey, sendKey, + nextKey, doneKey, previousKey); + return null; + } + }; + job.runInLocale(getContext().getResources(), systemLocale); + } + + public void testHinglishActionLabel() { + final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); + final Locale hi_ZZ = new Locale("hi", "ZZ"); + final InputMethodSubtype hiLatn = richImm.findSubtypeByLocaleAndKeyboardLayoutSet( + hi_ZZ.toString(), SubtypeLocaleUtils.QWERTY); + // This is a preliminary subtype and may not exist. + if (hiLatn == null) { + return; + } + // An action label should be displayed in subtype's locale regardless of the system locale. + doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, new Locale("hi")); + doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, Locale.US); + doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, Locale.FRENCH); + doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, Locale.ITALIAN); + doTestActionKeysInLocaleWithKeyboardTextsSet(hiLatn, hi_ZZ, Locale.JAPANESE); + } + + public void testSerbianLatinActionLabel() { + final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); + final Locale sr_ZZ = new Locale("sr", "ZZ"); + final InputMethodSubtype srLatn = richImm.findSubtypeByLocaleAndKeyboardLayoutSet( + sr_ZZ.toString(), "serbian_qwertz"); + // This is a preliminary subtype and may not exist. + if (srLatn == null) { + return; + } + // An action label should be displayed in subtype's locale regardless of the system locale. + doTestActionKeysInLocaleWithKeyboardTextsSet(srLatn, sr_ZZ, new Locale("sr")); + doTestActionKeysInLocaleWithKeyboardTextsSet(srLatn, sr_ZZ, Locale.US); + doTestActionKeysInLocaleWithKeyboardTextsSet(srLatn, sr_ZZ, Locale.FRENCH); + doTestActionKeysInLocaleWithKeyboardTextsSet(srLatn, sr_ZZ, Locale.ITALIAN); + doTestActionKeysInLocaleWithKeyboardTextsSet(srLatn, sr_ZZ, Locale.JAPANESE); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionNextTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionNextTests.java new file mode 100644 index 000000000..47170f062 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionNextTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.latin.R; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class KlpActionNextTests extends KlpActionTestsBase { + public void testActionNext() { + for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { + final String tag = "next " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + final ExpectedActionKey expectedKey = ExpectedActionKey.newLabelKey( + R.string.label_next_key, getLabelLocale(subtype), getContext()); + doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_NEXT, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionNoneTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionNoneTests.java new file mode 100644 index 000000000..09178bea9 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionNoneTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class KlpActionNoneTests extends KlpActionTestsBase { + public void testActionNone() { + final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey( + KeyboardIconsSet.NAME_ENTER_KEY); + for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { + final String tag = "none " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_NONE, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionPreviousTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionPreviousTests.java new file mode 100644 index 000000000..d779b2838 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionPreviousTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.latin.R; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class KlpActionPreviousTests extends KlpActionTestsBase { + public void testActionPrevious() { + for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { + final String tag = "previous " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + final ExpectedActionKey expectedKey = ExpectedActionKey.newLabelKey( + R.string.label_previous_key, getLabelLocale(subtype), getContext()); + doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_PREVIOUS, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionSearchTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionSearchTests.java new file mode 100644 index 000000000..2a2b6ab44 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionSearchTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class KlpActionSearchTests extends KlpActionTestsBase { + public void testActionSearch() { + final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey( + KeyboardIconsSet.NAME_SEARCH_KEY); + for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { + final String tag = "search " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_SEARCH, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionSendTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionSendTests.java new file mode 100644 index 000000000..5a0c7de48 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionSendTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.latin.R; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class KlpActionSendTests extends KlpActionTestsBase { + public void testActionSend() { + for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { + final String tag = "send " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + final ExpectedActionKey expectedKey = ExpectedActionKey.newLabelKey( + R.string.label_send_key, getLabelLocale(subtype), getContext()); + doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_SEND, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionTestsBase.java b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionTestsBase.java new file mode 100644 index 000000000..61156ebce --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionTestsBase.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.InputMethodSubtype; + +import org.kelar.inputmethod.keyboard.KeyboardTheme; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +import java.util.ArrayList; +import java.util.Locale; + +abstract class KlpActionTestsBase extends ActionTestsBase { + // Filter a subtype whose name should be displayed using {@link Locale#ROOT}, such like + // Hinglish (hi_ZZ) and Serbian-Latn (sr_ZZ). + static final SubtypeFilter SUBTYPE_FILTER_NAME_IN_BASE_LOCALE = new SubtypeFilter() { + @Override + public boolean accept(final InputMethodSubtype subtype) { + return Locale.ROOT.equals( + SubtypeLocaleUtils.getDisplayLocaleOfSubtypeLocale(subtype.getLocale())); + } + }; + + protected ArrayList<InputMethodSubtype> mSubtypesWhoseNameIsDisplayedInItsLocale; + + @Override + protected void setUp() throws Exception { + super.setUp(); + mSubtypesWhoseNameIsDisplayedInItsLocale = getSubtypesFilteredBy(new SubtypeFilter() { + @Override + public boolean accept(final InputMethodSubtype subtype) { + return !SUBTYPE_FILTER_NAME_IN_BASE_LOCALE.accept(subtype); + } + }); + } + + @Override + protected int getKeyboardThemeForTests() { + return KeyboardTheme.THEME_ID_KLP; + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionUnspecifiedTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionUnspecifiedTests.java new file mode 100644 index 000000000..11039bb29 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/KlpActionUnspecifiedTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class KlpActionUnspecifiedTests extends KlpActionTestsBase { + public void testActionUnspecified() { + final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey( + KeyboardIconsSet.NAME_ENTER_KEY); + for (final InputMethodSubtype subtype : mSubtypesWhoseNameIsDisplayedInItsLocale) { + final String tag = "unspecifiled " + + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_UNSPECIFIED, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionCustomTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionCustomTests.java new file mode 100644 index 000000000..fd958b2c0 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionCustomTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class LxxActionCustomTests extends LxxActionTestsBase { + public void testActionCustom() { + for (final InputMethodSubtype subtype : getAllSubtypesList()) { + final String tag = "custom " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + final EditorInfo editorInfo = new EditorInfo(); + editorInfo.imeOptions = EditorInfo.IME_ACTION_UNSPECIFIED; + editorInfo.actionLabel = "customLabel"; + final ExpectedActionKey expectedKey = ExpectedActionKey.newLabelKey("customLabel"); + doTestActionKey(tag, subtype, editorInfo, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionDoneTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionDoneTests.java new file mode 100644 index 000000000..d09a514a4 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionDoneTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class LxxActionDoneTests extends LxxActionTestsBase { + public void testActionDone() { + final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey( + KeyboardIconsSet.NAME_DONE_KEY); + for (final InputMethodSubtype subtype : getAllSubtypesList()) { + final String tag = "done " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_DONE, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionGoTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionGoTests.java new file mode 100644 index 000000000..c000f2154 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionGoTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class LxxActionGoTests extends LxxActionTestsBase { + public void testActionGo() { + final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey( + KeyboardIconsSet.NAME_GO_KEY); + for (final InputMethodSubtype subtype : getAllSubtypesList()) { + final String tag = "go " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_GO, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionNextTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionNextTests.java new file mode 100644 index 000000000..576fcde84 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionNextTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class LxxActionNextTests extends LxxActionTestsBase { + public void testActionNext() { + final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey( + KeyboardIconsSet.NAME_NEXT_KEY); + for (final InputMethodSubtype subtype : getAllSubtypesList()) { + final String tag = "next " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_NEXT, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionNoneTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionNoneTests.java new file mode 100644 index 000000000..07b7d01e3 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionNoneTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class LxxActionNoneTests extends LxxActionTestsBase { + public void testActionNone() { + final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey( + KeyboardIconsSet.NAME_ENTER_KEY); + for (final InputMethodSubtype subtype : getAllSubtypesList()) { + final String tag = "none " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_NONE, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionPreviousTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionPreviousTests.java new file mode 100644 index 000000000..eb9ecd10a --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionPreviousTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class LxxActionPreviousTests extends LxxActionTestsBase { + public void testActionPrevious() { + final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey( + KeyboardIconsSet.NAME_PREVIOUS_KEY); + for (final InputMethodSubtype subtype : getAllSubtypesList()) { + final String tag = "previous " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_PREVIOUS, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionSearchTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionSearchTests.java new file mode 100644 index 000000000..86b915ff8 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionSearchTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class LxxActionSearchTests extends LxxActionTestsBase { + public void testActionSearch() { + final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey( + KeyboardIconsSet.NAME_SEARCH_KEY); + for (final InputMethodSubtype subtype : getAllSubtypesList()) { + final String tag = "search " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_SEARCH, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionSendTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionSendTests.java new file mode 100644 index 000000000..8c57243ea --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionSendTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class LxxActionSendTests extends LxxActionTestsBase { + public void testActionSend() { + final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey( + KeyboardIconsSet.NAME_SEND_KEY); + for (final InputMethodSubtype subtype : getAllSubtypesList()) { + final String tag = "send " + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_SEND, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionTestsBase.java b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionTestsBase.java new file mode 100644 index 000000000..4e9fbcb4a --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionTestsBase.java @@ -0,0 +1,26 @@ +/* + * 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 org.kelar.inputmethod.keyboard.action; + +import org.kelar.inputmethod.keyboard.KeyboardTheme; + +abstract class LxxActionTestsBase extends ActionTestsBase { + @Override + protected int getKeyboardThemeForTests() { + return KeyboardTheme.THEME_ID_LXX_LIGHT; + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionUnspecifiedTests.java b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionUnspecifiedTests.java new file mode 100644 index 000000000..264e8951d --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/action/LxxActionUnspecifiedTests.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 org.kelar.inputmethod.keyboard.action; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.LargeTest; + +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +@LargeTest +public class LxxActionUnspecifiedTests extends LxxActionTestsBase { + public void testActionUnspecified() { + final ExpectedActionKey expectedKey = ExpectedActionKey.newIconKey( + KeyboardIconsSet.NAME_ENTER_KEY); + for (final InputMethodSubtype subtype : getAllSubtypesList()) { + final String tag = "unspecifiled " + + SubtypeLocaleUtils.getSubtypeNameForLogging(subtype); + doTestActionKey(tag, subtype, EditorInfo.IME_ACTION_UNSPECIFIED, expectedKey); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/internal/HermiteInterpolatorTests.java b/tests/src/org/kelar/inputmethod/keyboard/internal/HermiteInterpolatorTests.java new file mode 100644 index 000000000..f23fb8d3f --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/internal/HermiteInterpolatorTests.java @@ -0,0 +1,202 @@ +/* + * Copyright (C) 2013 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 org.kelar.inputmethod.keyboard.internal; + +import static org.junit.Assert.assertEquals; + +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@SmallTest +@RunWith(AndroidJUnit4.class) +public class HermiteInterpolatorTests { + private final HermiteInterpolator mInterpolator = new HermiteInterpolator(); + + private static final float EPSILON = 0.0000005f; + + // t=0 p0=(0,1) + // t=1 p1=(1,0) + // t=2 p2=(3,2) + // t=3 p3=(2,3) + // y + // | + // 3 + o p3 + // | + // 2 + o p2 + // | + // 1 o p0 + // | p1 + // 0 +---o---+---+-- x + // 0 1 2 3 + private final int[] mXCoords = { 0, 1, 3, 2 }; + private final int[] mYCoords = { 1, 0, 2, 3 }; + private static final int p0 = 0; + private static final int p1 = 1; + private static final int p2 = 2; + private static final int p3 = 3; + + @Test + public void testP0P1() { + // [(p0 p1) p2 p3] + mInterpolator.reset(mXCoords, mYCoords, p0, p3 + 1); + mInterpolator.setInterval(p0 - 1, p0, p1, p1 + 1); + assertEquals("p0x", mXCoords[p0], mInterpolator.mP1X); + assertEquals("p0y", mYCoords[p0], mInterpolator.mP1Y); + assertEquals("p1x", mXCoords[p1], mInterpolator.mP2X); + assertEquals("p1y", mYCoords[p1], mInterpolator.mP2Y); + // XY-slope at p0=3.0 (-0.75/-0.25) + assertEquals("slope x p0", -0.25f, mInterpolator.mSlope1X, EPSILON); + assertEquals("slope y p0", -0.75f, mInterpolator.mSlope1Y, EPSILON); + // XY-slope at p1=1/3.0 (0.50/1.50) + assertEquals("slope x p1", 1.50f, mInterpolator.mSlope2X, EPSILON); + assertEquals("slope y p1", 0.50f, mInterpolator.mSlope2Y, EPSILON); + // t=0.0 (p0) + mInterpolator.interpolate(0.0f); + assertEquals("t=0.0 x", 0.0f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=0.0 y", 1.0f, mInterpolator.mInterpolatedY, EPSILON); + // t=0.2 + mInterpolator.interpolate(0.2f); + assertEquals("t=0.2 x", 0.02400f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=0.2 y", 0.78400f, mInterpolator.mInterpolatedY, EPSILON); + // t=0.5 + mInterpolator.interpolate(0.5f); + assertEquals("t=0.5 x", 0.28125f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=0.5 y", 0.34375f, mInterpolator.mInterpolatedY, EPSILON); + // t=0.8 + mInterpolator.interpolate(0.8f); + assertEquals("t=0.8 x", 0.69600f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=0.8 y", 0.01600f, mInterpolator.mInterpolatedY, EPSILON); + // t=1.0 (p1) + mInterpolator.interpolate(1.0f); + assertEquals("t=1.0 x", 1.0f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=1.0 y", 0.0f, mInterpolator.mInterpolatedY, EPSILON); + } + + @Test + public void testP1P2() { + // [p0 (p1 p2) p3] + mInterpolator.reset(mXCoords, mYCoords, p0, p3 + 1); + mInterpolator.setInterval(p1 - 1, p1, p2, p2 + 1); + assertEquals("p1x", mXCoords[p1], mInterpolator.mP1X); + assertEquals("p1y", mYCoords[p1], mInterpolator.mP1Y); + assertEquals("p2x", mXCoords[p2], mInterpolator.mP2X); + assertEquals("p2y", mYCoords[p2], mInterpolator.mP2Y); + // XY-slope at p1=1/3.0 (0.50/1.50) + assertEquals("slope x p1", 1.50f, mInterpolator.mSlope1X, EPSILON); + assertEquals("slope y p1", 0.50f, mInterpolator.mSlope1Y, EPSILON); + // XY-slope at p2=3.0 (1.50/0.50) + assertEquals("slope x p2", 0.50f, mInterpolator.mSlope2X, EPSILON); + assertEquals("slope y p2", 1.50f, mInterpolator.mSlope2Y, EPSILON); + // t=0.0 (p1) + mInterpolator.interpolate(0.0f); + assertEquals("t=0.0 x", 1.0f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=0.0 y", 0.0f, mInterpolator.mInterpolatedY, EPSILON); + // t=0.2 + mInterpolator.interpolate(0.2f); + assertEquals("t=0.2 x", 1.384f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=0.2 y", 0.224f, mInterpolator.mInterpolatedY, EPSILON); + // t=0.5 + mInterpolator.interpolate(0.5f); + assertEquals("t=0.5 x", 2.125f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=0.5 y", 0.875f, mInterpolator.mInterpolatedY, EPSILON); + // t=0.8 + mInterpolator.interpolate(0.8f); + assertEquals("t=0.8 x", 2.776f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=0.8 y", 1.616f, mInterpolator.mInterpolatedY, EPSILON); + // t=1.0 (p2) + mInterpolator.interpolate(1.0f); + assertEquals("t=1.0 x", 3.0f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=1.0 y", 2.0f, mInterpolator.mInterpolatedY, EPSILON); + } + + @Test + public void testP2P3() { + // [p0 p1 (p2 p3)] + mInterpolator.reset(mXCoords, mYCoords, p0, p3 + 1); + mInterpolator.setInterval(p2 - 1, p2, p3, p3 + 1); + assertEquals("p2x", mXCoords[p2], mInterpolator.mP1X); + assertEquals("p2y", mYCoords[p2], mInterpolator.mP1Y); + assertEquals("p3x", mXCoords[p3], mInterpolator.mP2X); + assertEquals("p3y", mYCoords[p3], mInterpolator.mP2Y); + // XY-slope at p2=3.0 (1.50/0.50) + assertEquals("slope x p2", 0.50f, mInterpolator.mSlope1X, EPSILON); + assertEquals("slope y p2", 1.50f, mInterpolator.mSlope1Y, EPSILON); + // XY-slope at p3=1/3.0 (-0.25/-0.75) + assertEquals("slope x p3", -0.75f, mInterpolator.mSlope2X, EPSILON); + assertEquals("slope y p3", -0.25f, mInterpolator.mSlope2Y, EPSILON); + // t=0.0 (p2) + mInterpolator.interpolate(0.0f); + assertEquals("t=0.0 x", 3.0f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=0.0 y", 2.0f, mInterpolator.mInterpolatedY, EPSILON); + // t=0.2 + mInterpolator.interpolate(0.2f); + assertEquals("t=0.2 x", 2.98400f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=0.2 y", 2.30400f, mInterpolator.mInterpolatedY, EPSILON); + // t=0.5 + mInterpolator.interpolate(0.5f); + assertEquals("t=0.5 x", 2.65625f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=0.5 y", 2.71875f, mInterpolator.mInterpolatedY, EPSILON); + // t=0.8 + mInterpolator.interpolate(0.8f); + assertEquals("t=0.8 x", 2.21600f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=0.8 y", 2.97600f, mInterpolator.mInterpolatedY, EPSILON); + // t=1.0 (p3) + mInterpolator.interpolate(1.0f); + assertEquals("t=1.0 x", 2.0f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=1.0 y", 3.0f, mInterpolator.mInterpolatedY, EPSILON); + } + + @Test + public void testJustP1P2() { + // [(p1 p2)] + mInterpolator.reset(mXCoords, mYCoords, p1, p2 + 1); + mInterpolator.setInterval(p1 - 1, p1, p2, p2 + 1); + assertEquals("p1x", mXCoords[p1], mInterpolator.mP1X); + assertEquals("p1y", mYCoords[p1], mInterpolator.mP1Y); + assertEquals("p2x", mXCoords[p2], mInterpolator.mP2X); + assertEquals("p2y", mYCoords[p2], mInterpolator.mP2Y); + // XY-slope at p1=1.0 (2.0/2.0) + assertEquals("slope x p1", 2.00f, mInterpolator.mSlope1X, EPSILON); + assertEquals("slope y p1", 2.00f, mInterpolator.mSlope1Y, EPSILON); + // XY-slope at p2=1.0 (2.0/2.0) + assertEquals("slope x p2", 2.00f, mInterpolator.mSlope2X, EPSILON); + assertEquals("slope y p2", 2.00f, mInterpolator.mSlope2Y, EPSILON); + // t=0.0 (p1) + mInterpolator.interpolate(0.0f); + assertEquals("t=0.0 x", 1.0f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=0.0 y", 0.0f, mInterpolator.mInterpolatedY, EPSILON); + // t=0.2 + mInterpolator.interpolate(0.2f); + assertEquals("t=0.2 x", 1.4f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=0.2 y", 0.4f, mInterpolator.mInterpolatedY, EPSILON); + // t=0.5 + mInterpolator.interpolate(0.5f); + assertEquals("t=0.5 x", 2.0f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=0.5 y", 1.0f, mInterpolator.mInterpolatedY, EPSILON); + // t=0.8 + mInterpolator.interpolate(0.8f); + assertEquals("t=0.8 x", 2.6f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=0.8 y", 1.6f, mInterpolator.mInterpolatedY, EPSILON); + // t=1.0 (p2) + mInterpolator.interpolate(1.0f); + assertEquals("t=1.0 x", 3.0f, mInterpolator.mInterpolatedX, EPSILON); + assertEquals("t=1.0 y", 2.0f, mInterpolator.mInterpolatedY, EPSILON); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/internal/KeySpecParserTests.java b/tests/src/org/kelar/inputmethod/keyboard/internal/KeySpecParserTests.java new file mode 100644 index 000000000..1d3ceaf63 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/internal/KeySpecParserTests.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 org.kelar.inputmethod.keyboard.internal; + +import static org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet.ICON_UNDEFINED; +import static org.kelar.inputmethod.latin.common.Constants.CODE_UNSPECIFIED; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.latin.common.Constants; + +@SmallTest +public final class KeySpecParserTests extends KeySpecParserTestsBase { + @Override + protected void assertParser(final String message, final String keySpec, + final String expectedLabel, final String expectedOutputText, final int expectedIcon, + final int expectedCode) { + final String keySpecResolved = mTextsSet.resolveTextReference(keySpec); + final String actualLabel = KeySpecParser.getLabel(keySpecResolved); + final String actualOutputText = KeySpecParser.getOutputText(keySpecResolved); + final int actualIcon = KeySpecParser.getIconId(keySpecResolved); + final int actualCode = KeySpecParser.getCode(keySpecResolved); + assertEquals(message + " [label]", expectedLabel, actualLabel); + assertEquals(message + " [ouptputText]", expectedOutputText, actualOutputText); + assertEquals(message + " [icon]", + KeyboardIconsSet.getIconName(expectedIcon), + KeyboardIconsSet.getIconName(actualIcon)); + assertEquals(message + " [code]", + Constants.printableCode(expectedCode), + Constants.printableCode(actualCode)); + } + + // TODO: Remove this method. + // These should throw {@link KeySpecParserError} when Key.keyLabel attribute become mandatory. + public void testEmptySpec() { + assertParser("Null spec", null, + null, null, ICON_UNDEFINED, CODE_UNSPECIFIED); + assertParser("Empty spec", "", + null, null, ICON_UNDEFINED, CODE_UNSPECIFIED); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/internal/KeySpecParserTestsBase.java b/tests/src/org/kelar/inputmethod/keyboard/internal/KeySpecParserTestsBase.java new file mode 100644 index 000000000..8bf344c92 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/internal/KeySpecParserTestsBase.java @@ -0,0 +1,340 @@ +/* + * 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 org.kelar.inputmethod.keyboard.internal; + +import static org.kelar.inputmethod.keyboard.internal.KeyboardCodesSet.PREFIX_CODE; +import static org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet.ICON_UNDEFINED; +import static org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet.PREFIX_ICON; +import static org.kelar.inputmethod.latin.common.Constants.CODE_OUTPUT_TEXT; +import static org.kelar.inputmethod.latin.common.Constants.CODE_UNSPECIFIED; + +import android.test.AndroidTestCase; + +import java.util.Locale; + +abstract class KeySpecParserTestsBase extends AndroidTestCase { + private final static Locale TEST_LOCALE = Locale.ENGLISH; + protected final KeyboardTextsSet mTextsSet = new KeyboardTextsSet(); + + private static final String CODE_SETTINGS_NAME = "key_settings"; + private static final String CODE_SETTINGS = PREFIX_CODE + CODE_SETTINGS_NAME; + private static final String ICON_SETTINGS_NAME = "settings_key"; + private static final String ICON_SETTINGS = PREFIX_ICON + ICON_SETTINGS_NAME; + private static final String CODE_SETTINGS_UPPERCASE = CODE_SETTINGS.toUpperCase(Locale.ROOT); + private static final String ICON_SETTINGS_UPPERCASE = ICON_SETTINGS.toUpperCase(Locale.ROOT); + private static final String CODE_NON_EXISTING = PREFIX_CODE + "non_existing"; + private static final String ICON_NON_EXISTING = PREFIX_ICON + "non_existing"; + + private int mCodeSettings; + private int mCodeActionNext; + private int mSettingsIconId; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + mTextsSet.setLocale(TEST_LOCALE, getContext()); + mCodeSettings = KeyboardCodesSet.getCode(CODE_SETTINGS_NAME); + mCodeActionNext = KeyboardCodesSet.getCode("key_action_next"); + mSettingsIconId = KeyboardIconsSet.getIconId(ICON_SETTINGS_NAME); + } + + abstract protected void assertParser(final String message, final String keySpec, + final String expectedLabel, final String expectedOutputText, final int expectedIcon, + final int expectedCode); + + protected void assertParserError(final String message, final String keySpec, + final String expectedLabel, final String expectedOutputText, final int expectedIconId, + final int expectedCode) { + try { + assertParser(message, keySpec, expectedLabel, expectedOutputText, expectedIconId, + expectedCode); + fail(message); + } catch (Exception pcpe) { + // success. + } + } + + // \U001d11e: MUSICAL SYMBOL G CLEF + private static final String SURROGATE_PAIR1 = "\ud834\udd1e"; + private static final int SURROGATE_CODE1 = SURROGATE_PAIR1.codePointAt(0); + // \U001d122: MUSICAL SYMBOL F CLEF + private static final String SURROGATE_PAIR2 = "\ud834\udd22"; + private static final int SURROGATE_CODE2 = SURROGATE_PAIR2.codePointAt(0); + // \U002f8a6: CJK COMPATIBILITY IDEOGRAPH-2F8A6; variant character of \u6148. + private static final String SURROGATE_PAIR3 = "\ud87e\udca6"; + private static final String SURROGATE_PAIRS4 = SURROGATE_PAIR1 + SURROGATE_PAIR2; + private static final String SURROGATE_PAIRS5 = SURROGATE_PAIRS4 + SURROGATE_PAIR3; + + public void testSingleLetter() { + assertParser("Single letter", "a", + "a", null, ICON_UNDEFINED, 'a'); + assertParser("Single surrogate", SURROGATE_PAIR1, + SURROGATE_PAIR1, null, ICON_UNDEFINED, SURROGATE_CODE1); + assertParser("Sole vertical bar", "|", + "|", null, ICON_UNDEFINED, '|'); + assertParser("Single escaped vertical bar", "\\|", + "|", null, ICON_UNDEFINED, '|'); + assertParser("Single escaped escape", "\\\\", + "\\", null, ICON_UNDEFINED, '\\'); + assertParser("Single comma", ",", + ",", null, ICON_UNDEFINED, ','); + assertParser("Single escaped comma", "\\,", + ",", null, ICON_UNDEFINED, ','); + assertParser("Single escaped letter", "\\a", + "a", null, ICON_UNDEFINED, 'a'); + assertParser("Single escaped surrogate", "\\" + SURROGATE_PAIR2, + SURROGATE_PAIR2, null, ICON_UNDEFINED, SURROGATE_CODE2); + assertParser("Single bang", "!", + "!", null, ICON_UNDEFINED, '!'); + assertParser("Single escaped bang", "\\!", + "!", null, ICON_UNDEFINED, '!'); + assertParser("Single output text letter", "a|a", + "a", null, ICON_UNDEFINED, 'a'); + assertParser("Single surrogate pair outputText", "G Clef|" + SURROGATE_PAIR1, + "G Clef", null, ICON_UNDEFINED, SURROGATE_CODE1); + assertParser("Single letter with outputText", "a|abc", + "a", "abc", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Single letter with surrogate outputText", "a|" + SURROGATE_PAIRS4, + "a", SURROGATE_PAIRS4, ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Single surrogate with outputText", SURROGATE_PAIR3 + "|abc", + SURROGATE_PAIR3, "abc", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Single letter with escaped outputText", "a|a\\|c", + "a", "a|c", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Single letter with escaped surrogate outputText", + "a|" + SURROGATE_PAIR1 + "\\|" + SURROGATE_PAIR2, + "a", SURROGATE_PAIR1 + "|" + SURROGATE_PAIR2, ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Single letter with comma outputText", "a|a,b", + "a", "a,b", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Single letter with escaped comma outputText", "a|a\\,b", + "a", "a,b", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Single letter with outputText starts with bang", "a|!bc", + "a", "!bc", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Single letter with surrogate outputText starts with bang", + "a|!" + SURROGATE_PAIRS5, + "a", "!" + SURROGATE_PAIRS5, ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Single letter with outputText contains bang", "a|a!c", + "a", "a!c", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Single letter with escaped bang outputText", "a|\\!bc", + "a", "!bc", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Single escaped escape with single outputText", "\\\\|\\\\", + "\\", null, ICON_UNDEFINED, '\\'); + assertParser("Single escaped bar with single outputText", "\\||\\|", + "|", null, ICON_UNDEFINED, '|'); + assertParser("Single letter with code", "a|" + CODE_SETTINGS, + "a", null, ICON_UNDEFINED, mCodeSettings); + } + + public void testLabel() { + assertParser("Simple label", "abc", + "abc", "abc", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Simple surrogate label", SURROGATE_PAIRS4, + SURROGATE_PAIRS4, SURROGATE_PAIRS4, ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with escaped bar", "a\\|c", + "a|c", "a|c", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Surrogate label with escaped bar", SURROGATE_PAIR1 + "\\|" + SURROGATE_PAIR2, + SURROGATE_PAIR1 + "|" + SURROGATE_PAIR2, SURROGATE_PAIR1 + "|" + SURROGATE_PAIR2, + ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with escaped escape", "a\\\\c", + "a\\c", "a\\c", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with comma", "a,c", + "a,c", "a,c", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with escaped comma", "a\\,c", + "a,c", "a,c", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label starts with bang", "!bc", + "!bc", "!bc", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Surrogate label starts with bang", "!" + SURROGATE_PAIRS4, + "!" + SURROGATE_PAIRS4, "!" + SURROGATE_PAIRS4, ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label contains bang", "a!c", + "a!c", "a!c", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with escaped bang", "\\!bc", + "!bc", "!bc", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with escaped letter", "\\abc", + "abc", "abc", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with outputText", "abc|def", + "abc", "def", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with comma and outputText", "a,c|def", + "a,c", "def", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Escaped comma label with outputText", "a\\,c|def", + "a,c", "def", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Escaped label with outputText", "a\\|c|def", + "a|c", "def", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with escaped bar outputText", "abc|d\\|f", + "abc", "d|f", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Escaped escape label with outputText", "a\\\\|def", + "a\\", "def", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label starts with bang and outputText", "!bc|def", + "!bc", "def", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label contains bang label and outputText", "a!c|def", + "a!c", "def", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Escaped bang label with outputText", "\\!bc|def", + "!bc", "def", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with comma outputText", "abc|a,b", + "abc", "a,b", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with escaped comma outputText", "abc|a\\,b", + "abc", "a,b", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with outputText starts with bang", "abc|!bc", + "abc", "!bc", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with outputText contains bang", "abc|a!c", + "abc", "a!c", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with escaped bang outputText", "abc|\\!bc", + "abc", "!bc", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with escaped bar outputText", "abc|d\\|f", + "abc", "d|f", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Escaped bar label with escaped bar outputText", "a\\|c|d\\|f", + "a|c", "d|f", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with code", "abc|" + CODE_SETTINGS, + "abc", null, ICON_UNDEFINED, mCodeSettings); + assertParser("Escaped label with code", "a\\|c|" + CODE_SETTINGS, + "a|c", null, ICON_UNDEFINED, mCodeSettings); + } + + public void testCodes() { + assertParser("Hexadecimal code", "a|0x1000", + "a", null, ICON_UNDEFINED, 0x1000); + assertParserError("Illegal hexadecimal code", "a|0x100X", + "a", null, ICON_UNDEFINED, CODE_UNSPECIFIED); + assertParser("Escaped hexadecimal code 1", "a|\\0x1000", + "a", "0x1000", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Escaped hexadecimal code 2", "a|0\\x1000", + "a", "0x1000", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Escaped hexadecimal code 2", "a|0\\x1000", + "a", "0x1000", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParserError("Illegally escaped hexadecimal code", "a|0x1\\000", + "a", null, ICON_UNDEFINED, CODE_UNSPECIFIED); + // This is a workaround to have a key that has a supplementary code point. We can't put a + // string in resource as a XML entity of a supplementary code point or a surrogate pair. + // TODO: Should pass this test. +// assertParser("Hexadecimal supplementary code", String.format("a|0x%06x", SURROGATE_CODE2), +// SURROGATE_PAIR2, null, ICON_UNDEFINED, SURROGATE_CODE2); + assertParser("Zero is treated as output text", "a|0", + "a", null, ICON_UNDEFINED, '0'); + assertParser("Digit is treated as output text", "a|3", + "a", null, ICON_UNDEFINED, '3'); + assertParser("Decimal number is treated as an output text", "a|2014", + "a", "2014", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + } + + public void testIcons() { + assertParser("Icon with single letter", ICON_SETTINGS + "|a", + null, null, mSettingsIconId, 'a'); + assertParser("Icon with outputText", ICON_SETTINGS + "|abc", + null, "abc", mSettingsIconId, CODE_OUTPUT_TEXT); + assertParser("Icon with outputText starts with bang", ICON_SETTINGS + "|!bc", + null, "!bc", mSettingsIconId, CODE_OUTPUT_TEXT); + assertParser("Icon with outputText contains bang", ICON_SETTINGS + "|a!c", + null, "a!c", mSettingsIconId, CODE_OUTPUT_TEXT); + assertParser("Icon with escaped bang outputText", ICON_SETTINGS + "|\\!bc", + null, "!bc", mSettingsIconId, CODE_OUTPUT_TEXT); + assertParser("Label starts with bang and code", "!bc|" + CODE_SETTINGS, + "!bc", null, ICON_UNDEFINED, mCodeSettings); + assertParser("Label contains bang and code", "a!c|" + CODE_SETTINGS, + "a!c", null, ICON_UNDEFINED, mCodeSettings); + assertParser("Escaped bang label with code", "\\!bc|" + CODE_SETTINGS, + "!bc", null, ICON_UNDEFINED, mCodeSettings); + assertParser("Icon with code", ICON_SETTINGS + "|" + CODE_SETTINGS, + null, null, mSettingsIconId, mCodeSettings); + } + + public void testResourceReference() { + assertParser("Settings as more key", "!text/keyspec_settings", + null, null, mSettingsIconId, mCodeSettings); + + assertParser("Action next as more key", "!text/label_next_key|!code/key_action_next", + "Next", null, ICON_UNDEFINED, mCodeActionNext); + + assertParser("Popular domain", + "!text/keyspec_popular_domain|!text/keyspec_popular_domain ", + ".com", ".com ", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + } + + public void testFormatError() { + assertParserError("Empty label with outputText", "|a", + null, "a", ICON_UNDEFINED, CODE_UNSPECIFIED); + assertParserError("Empty label with code", "|" + CODE_SETTINGS, + null, null, ICON_UNDEFINED, mCodeSettings); + assertParserError("Empty outputText with label", "a|", + "a", null, ICON_UNDEFINED, CODE_UNSPECIFIED); + assertParserError("Empty outputText with icon", ICON_SETTINGS + "|", + null, null, mSettingsIconId, CODE_UNSPECIFIED); + assertParserError("Icon without code", ICON_SETTINGS, + null, null, mSettingsIconId, CODE_UNSPECIFIED); + assertParserError("Non existing icon", ICON_NON_EXISTING + "|abc", + null, "abc", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParserError("Non existing code", "abc|" + CODE_NON_EXISTING, + "abc", null, ICON_UNDEFINED, CODE_UNSPECIFIED); + assertParserError("Third bar at end", "a|b|", + "a", null, ICON_UNDEFINED, CODE_UNSPECIFIED); + assertParserError("Multiple bar", "a|b|c", + "a", null, ICON_UNDEFINED, CODE_UNSPECIFIED); + assertParserError("Multiple bar with label and code", "a|" + CODE_SETTINGS + "|c", + "a", null, ICON_UNDEFINED, mCodeSettings); + assertParserError("Multiple bar with icon and outputText", ICON_SETTINGS + "|b|c", + null, null, mSettingsIconId, CODE_UNSPECIFIED); + assertParserError("Multiple bar with icon and code", + ICON_SETTINGS + "|" + CODE_SETTINGS + "|c", + null, null, mSettingsIconId, mCodeSettings); + } + + public void testUselessUpperCaseSpecifier() { + assertParser("Single letter with CODE", "a|" + CODE_SETTINGS_UPPERCASE, + "a", "!CODE/KEY_SETTINGS", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label with CODE", "abc|" + CODE_SETTINGS_UPPERCASE, + "abc", "!CODE/KEY_SETTINGS", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Escaped label with CODE", "a\\|c|" + CODE_SETTINGS_UPPERCASE, + "a|c", "!CODE/KEY_SETTINGS", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("ICON with outputText", ICON_SETTINGS_UPPERCASE + "|abc", + "!ICON/SETTINGS_KEY", "abc", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("ICON with outputText starts with bang", ICON_SETTINGS_UPPERCASE + "|!bc", + "!ICON/SETTINGS_KEY", "!bc", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("ICON with outputText contains bang", ICON_SETTINGS_UPPERCASE + "|a!c", + "!ICON/SETTINGS_KEY", "a!c", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("ICON with escaped bang outputText", ICON_SETTINGS_UPPERCASE + "|\\!bc", + "!ICON/SETTINGS_KEY", "!bc", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label starts with bang and CODE", "!bc|" + CODE_SETTINGS_UPPERCASE, + "!bc", "!CODE/KEY_SETTINGS", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Label contains bang and CODE", "a!c|" + CODE_SETTINGS_UPPERCASE, + "a!c", "!CODE/KEY_SETTINGS", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("Escaped bang label with CODE", "\\!bc|" + CODE_SETTINGS_UPPERCASE, + "!bc", "!CODE/KEY_SETTINGS", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("ICON with CODE", ICON_SETTINGS_UPPERCASE + "|" + CODE_SETTINGS_UPPERCASE, + "!ICON/SETTINGS_KEY", "!CODE/KEY_SETTINGS", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParser("SETTINGS AS MORE KEY", "!TEXT/SETTINGS_AS_MORE_KEY", + "!TEXT/SETTINGS_AS_MORE_KEY", "!TEXT/SETTINGS_AS_MORE_KEY", ICON_UNDEFINED, + CODE_OUTPUT_TEXT); + assertParser("ACTION NEXT AS MORE KEY", "!TEXT/LABEL_NEXT_KEY|!CODE/KEY_ACTION_NEXT", + "!TEXT/LABEL_NEXT_KEY", "!CODE/KEY_ACTION_NEXT", ICON_UNDEFINED, + CODE_OUTPUT_TEXT); + assertParser("POPULAR DOMAIN", + "!TEXT/KEYLABEL_FOR_POPULAR_DOMAIN|!TEXT/KEYLABEL_FOR_POPULAR_DOMAIN ", + "!TEXT/KEYLABEL_FOR_POPULAR_DOMAIN", "!TEXT/KEYLABEL_FOR_POPULAR_DOMAIN ", + ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParserError("Empty label with CODE", "|" + CODE_SETTINGS_UPPERCASE, + null, null, ICON_UNDEFINED, mCodeSettings); + assertParserError("Empty outputText with ICON", ICON_SETTINGS_UPPERCASE + "|", + null, null, mSettingsIconId, CODE_UNSPECIFIED); + assertParser("ICON without code", ICON_SETTINGS_UPPERCASE, + "!ICON/SETTINGS_KEY", "!ICON/SETTINGS_KEY", ICON_UNDEFINED, CODE_OUTPUT_TEXT); + assertParserError("Multiple bar with label and CODE", "a|" + CODE_SETTINGS_UPPERCASE + "|c", + "a", null, ICON_UNDEFINED, mCodeSettings); + assertParserError("Multiple bar with ICON and outputText", ICON_SETTINGS_UPPERCASE + "|b|c", + null, null, mSettingsIconId, CODE_UNSPECIFIED); + assertParserError("Multiple bar with ICON and CODE", + ICON_SETTINGS_UPPERCASE + "|" + CODE_SETTINGS_UPPERCASE + "|c", + null, null, mSettingsIconId, mCodeSettings); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java b/tests/src/org/kelar/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java new file mode 100644 index 000000000..202718bbb --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/internal/KeyboardStateMultiTouchTests.java @@ -0,0 +1,476 @@ +/* + * Copyright (C) 2012 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 org.kelar.inputmethod.keyboard.internal; + +import androidx.test.filters.SmallTest; + +@SmallTest +public class KeyboardStateMultiTouchTests extends KeyboardStateTestsBase { + // Chording input in alphabet. + public void testChordingAlphabet() { + // Press shift key and hold, enter into choring shift state. + pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); + // Press/release letter key. + chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Release shift key, switch back to alphabet. + releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); + + // Press "?123" key and hold, enter into choring symbols state. + pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); + // Press/release symbol letter key. + chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Release "ABC" key, switch back to alphabet. + releaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); + } + + // Chording input in shifted. + public void testChordingShifted() { + // Press shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + + // Press shift key and hold, enter into choring shift state. + pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); + // Press/release letter key. + chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Release shift key, switch back to alphabet shifted. + releaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); + + // Press "?123" key and hold, enter into choring symbols state. + pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); + // Press/release symbol letter key. + chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Release "123?" key, switch back to alphabet unshifted. + releaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); + } + + // Chording input in shift locked. + public void testChordingShiftLocked() { + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + + // Press shift key and hold, enter into choring shift state. + pressKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED); + // Press/release letter key. + chordingPressAndReleaseKey('Z', ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED); + // Release shift key, switch back to alphabet shift locked. + releaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCKED); + + // Press "?123" key and hold, enter into choring symbols state. + pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); + // Press/release symbol letter key. + chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Release "123?" key, switch back to alphabet shift locked. + releaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED); + } + + // Chording input in symbols. + public void testChordingSymbols() { + // Press/release "?123" key, enter symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + + // Press "=\<" key and hold, enter into choring symbols shifted state. + pressKey(CODE_SHIFT, SYMBOLS_SHIFTED); + // Press/release symbol letter key. + chordingPressAndReleaseKey('1', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Release "=\<" key, switch back to symbols. + releaseKey(CODE_SHIFT, SYMBOLS_UNSHIFTED); + + // Press "ABC" key and hold, enter into choring alphabet state. + pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); + // Press/release letter key. + chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Release "ABC" key, switch back to symbols. + releaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); + + // Alphabet shifted -> symbols -> "ABC" key + letter -> symbols + // -> alphabet. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Press/release shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press "ABC" key, enter into chording alphabet state. + pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); + // Enter/release letter key. + chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Release "ABC" key, switch back to symbols. + releaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); + // Press/release "ABC" key, switch to alphabet (not alphabet shifted). + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + + // Alphabet shift locked -> symbols -> "ABC" key + letter -> symbols -> + // alphabet shift locked. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press "ABC" key, enter into chording alphabet shift locked. + pressKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED); + // Enter/release letter key. + chordingPressAndReleaseKey('A', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + // Release "ABC" key, switch back to symbols. + releaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); + // Press/release "ABC" key, switch to alphabet shift locked. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + + // Alphabet shift locked -> symbols -> "=\<" key + letter -> symbols -> + // alphabet shift locked. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press "=\<" key, enter into symbols shifted chording state. + pressKey(CODE_SHIFT, SYMBOLS_SHIFTED); + // Enter/release symbols shift letter key. + chordingPressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Release "=\<" key, switch back to symbols. + releaseKey(CODE_SHIFT, SYMBOLS_UNSHIFTED); + // Press/release "ABC" key, switch to alphabet shift locked. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + } + + // Chording input in symbol shifted. + public void testChordingSymbolsShifted() { + // Press/release "?123" key, enter symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + + // Press "?123" key and hold, enter into chording symbols state. + pressKey(CODE_SHIFT, SYMBOLS_UNSHIFTED); + // Press/release symbol letter key. + chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Release "=\<" key, switch back to symbols shifted state. + releaseKey(CODE_SHIFT, SYMBOLS_SHIFTED); + + // Press "ABC" key and hold, enter into choring alphabet state. + pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); + // Press/release letter key. + chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Release "ABC" key, switch back to symbols. + releaseKey(CODE_SYMBOL, SYMBOLS_SHIFTED); + + // Alphabet shifted -> symbols shifted -> "ABC" key + letter -> symbols shifted -> + // alphabet. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Press/release shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press "ABC" key, enter into chording alphabet state. + pressKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); + // Enter/release letter key. + chordingPressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Release "ABC" key, switch back to symbols shifted. + releaseKey(CODE_SYMBOL, SYMBOLS_SHIFTED); + // Press/release "ABC" key, switch to alphabet (not alphabet shifted). + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + + // Alphabet shift locked -> symbols shifted -> "ABC" key + letter -> symbols shifted + // -> alphabet shift locked. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press "ABC" key, enter into chording alphabet shift locked. + pressKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED); + // Enter/release letter key. + chordingPressAndReleaseKey('A', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + // Release "ABC" key, switch back to symbols shifted. + releaseKey(CODE_SYMBOL, SYMBOLS_SHIFTED); + // Press/release "ABC" key, switch to alphabet shift locked. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + + // Alphabet shift locked -> symbols shifted -> "=\<" key + letter -> symbols shifted + // -> alphabet shift locked. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press "=\<" key, enter into symbols chording state. + pressKey(CODE_SHIFT, SYMBOLS_UNSHIFTED); + // Enter/release symbols letter key. + chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Release "=\<" key, switch back to symbols shifted. + releaseKey(CODE_SHIFT, SYMBOLS_SHIFTED); + // Press/release "ABC" key, switch to alphabet shift locked. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + } + + // Chording input in automatic upper case. + public void testChordingAutomaticUpperCase() { + // Set capitalize the first character of all words mode. + setAutoCapsMode(CAP_MODE_WORDS); + + // Update shift state with auto caps enabled. + pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); + // Press shift key and hold, enter into chording shift state. + pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); + // Press/release letter key. + chordingPressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Release shift key, switch back to alphabet. + releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); + + // Update shift state with auto caps enabled. + pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); + // Press "123?" key and hold, enter into chording symbols state. + pressKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED); + // Press/release symbol letter key. + chordingPressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Release "123?" key, switch back to alphabet. + releaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED); + } + + // Chording letter key with shift key. + public void testChordingLetterAndShiftKey() { + // Press letter key and hold. + pressKey('z', ALPHABET_UNSHIFTED); + // Press shift key, {@link PointerTracker} will fire a phantom release letter key. + chordingReleaseKey('z', ALPHABET_UNSHIFTED); + chordingPressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); + // Press another letter key and hold. + chordingPressAndReleaseKey('J', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Release shift key + releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); + } + + // Multi touch input in manual shifted. + public void testMultiTouchManualShifted() { + // Press/release shift key, enter into alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + + // Press 'X' key and hold + pressKey('X', ALPHABET_MANUAL_SHIFTED); + // Press 'z' key and hold, switch back to alphabet unshifted. + chordingPressKey('z', ALPHABET_UNSHIFTED); + // Release 'X' key + releaseKey('X', ALPHABET_UNSHIFTED); + // Release 'z' key + releaseKey('z', ALPHABET_UNSHIFTED); + } + + // Multi touch input in automatic upper case. + public void testMultiTouchAutomaticUpperCase() { + // Set auto word caps mode on. + setAutoCapsMode(CAP_MODE_WORDS); + // Update shift state with auto caps enabled. + pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); + + // Press 'X' key and hold + pressKey('X', ALPHABET_AUTOMATIC_SHIFTED); + // Press 'z' key and hold, switch back to alphabet unshifted. + chordingPressKey('z', ALPHABET_UNSHIFTED); + // Release 'X' key + releaseKey('X', ALPHABET_UNSHIFTED); + // Release 'z' key + releaseKey('z', ALPHABET_UNSHIFTED); + } + + // Multi touch input in capitalize character mode. + public void testMultiTouchCapModeCharacter() { + // Set auto character caps mode on. + setAutoCapsMode(CAP_MODE_CHARACTERS); + // Update shift state with auto caps enabled. + pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); + + // Press 'X' key and hold + pressKey('X', ALPHABET_AUTOMATIC_SHIFTED); + // Press 'Z' key and hold, stay in automatic shifted mode. + chordingPressKey('Z', ALPHABET_AUTOMATIC_SHIFTED); + // Release 'X' key + releaseKey('X', ALPHABET_AUTOMATIC_SHIFTED); + // Release 'Z' key + releaseKey('Z', ALPHABET_AUTOMATIC_SHIFTED); + } + + // Multi touch shift chording input in manual shifted. + public void testMultiTouchShiftChordingManualShifted() { + // Press/release shift key, enter into alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + + // Press shift key and hold, stays in alphabet shifted. + pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); + // Press 'X' key and hold + chordingPressKey('X', ALPHABET_MANUAL_SHIFTED); + // Press 'Z' key and hold, stays in alphabet shifted. + chordingPressKey('Z', ALPHABET_MANUAL_SHIFTED); + // Release 'X' key + releaseKey('X', ALPHABET_MANUAL_SHIFTED); + // Release 'Z' key + releaseKey('Z', ALPHABET_MANUAL_SHIFTED); + // Release shift key, switch back to alphabet shifted. + releaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); + } + + // Multi touch shift chording input in automatic upper case. + public void testMultiTouchShiftChordingAutomaticUpperCase() { + // Set auto word caps mode on. + setAutoCapsMode(CAP_MODE_WORDS); + // Update shift state with auto caps enabled. + pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); + + // Press shift key and hold, switch to alphabet shifted. + pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); + // Press 'X' key and hold + chordingPressKey('X', ALPHABET_MANUAL_SHIFTED); + // Press 'Z' key and hold, stays in alphabet shifted. + chordingPressKey('Z', ALPHABET_MANUAL_SHIFTED); + // Release 'X' key + releaseKey('X', ALPHABET_MANUAL_SHIFTED); + // Release 'Z' key + releaseKey('Z', ALPHABET_MANUAL_SHIFTED); + // Release shift key, updated to alphabet unshifted. + releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); + + // Update shift state with auto caps enabled. + pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); + + // Press shift key and hold, switch to alphabet shifted. + pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); + // Press 'X' key and hold + chordingPressKey('X', ALPHABET_MANUAL_SHIFTED); + // Release 'X' key + releaseKey('X', ALPHABET_MANUAL_SHIFTED); + // Press key and hold, stays in alphabet shifted. + chordingPressKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_MANUAL_SHIFTED); + // Release 'Z' key + releaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_MANUAL_SHIFTED); + // Release shift key, updated to alphabet automatic shifted. + releaseKey(CODE_SHIFT, ALPHABET_AUTOMATIC_SHIFTED); + } + + // Multi touch shift chording input in capitalize character mode. + public void testMultiTouchShiftChordingCapModeCharacter() { + // Set auto character caps mode on. + setAutoCapsMode(CAP_MODE_CHARACTERS); + // Update shift state with auto caps enabled. + pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); + + // Press shift key and hold, switch to alphabet shifted. + pressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); + // Press 'X' key and hold + chordingPressKey('X', ALPHABET_MANUAL_SHIFTED); + // Press 'Z' key and hold, stay in automatic shifted mode. + chordingPressKey('Z', ALPHABET_MANUAL_SHIFTED); + // Release 'X' key + releaseKey('X', ALPHABET_MANUAL_SHIFTED); + // Release 'Z' key + releaseKey('Z', ALPHABET_MANUAL_SHIFTED); + // Release shift key, updated to alphabet automatic shifted. + releaseKey(CODE_SHIFT, ALPHABET_AUTOMATIC_SHIFTED); + } + + public void testLongPressShiftAndChording() { + // Long press shift key, enter maybe shift locked. + longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press/release letter key, remain in manual shifted. + chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Release shift key, back to alphabet (not shift locked). + releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); + + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Long press shift key, enter maybe alphabet. + longPressShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED); + // Press/release letter key, remain in manual shifted. + chordingPressAndReleaseKey('A', ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED); + // Release shift key, back to shift locked (not alphabet). + releaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCKED); + // Long press shift key, enter alphabet + longPressAndReleaseShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED, + ALPHABET_UNSHIFTED); + + // Press/release shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Long press shift key, enter maybe alphabet. + longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press/release letter key, remain in manual shifted. + chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Release shift key, back to alphabet shifted (not alphabet). + releaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); + + // Set capitalize the first character of all words mode. + setAutoCapsMode(CAP_MODE_WORDS); + // Load keyboard, should be in automatic shifted. + loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); + // Long press shift key, enter maybe shift locked. + longPressShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press/release letter key, remain in manual shifted. + chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Release shift key, back to alphabet (not shift locked). + releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); + } + + public void testDoubleTapShiftAndChording() { + // TODO: The following tests fail due to bug. Temporarily commented. +// // First shift key tap. +// pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); +// // Second shift key tap, maybe shift locked. +// secondPressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); +// // Press/release letter key, remain in manual shifted. +// chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); +// // Release shift key, back to alphabet shifted (not shift locked). +// releaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); +// +// // Long press shift key, enter alphabet shift locked. +// longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, +// ALPHABET_SHIFT_LOCKED); +// // First shift key tap. +// pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); +// // Second shift key tap, maybe shift unlocked. +// secondPressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); +// // Press/release letter key, remain in manual shifted. +// chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); +// // Release shift key, back to alphabet (not shift locked). +// releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); +// +// // Set capitalize the first character of all words mode. +// setAutoCapsMode(CAP_MODE_WORDS); +// // Load keyboard, should be in automatic shifted. +// loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); +// // First shift key tap. +// pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); +// // Second shift key tap, maybe shift locked. +// secondPressKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED); +// // Press/release letter key, remain in manual shifted. +// chordingPressAndReleaseKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); +// // Release shift key, back to alphabet (not shift locked). +// releaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java b/tests/src/org/kelar/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java new file mode 100644 index 000000000..f1621ebb0 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/internal/KeyboardStateSingleTouchTests.java @@ -0,0 +1,971 @@ +/* + * Copyright (C) 2012 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 org.kelar.inputmethod.keyboard.internal; + +import androidx.test.filters.SmallTest; + +@SmallTest +public class KeyboardStateSingleTouchTests extends KeyboardStateTestsBase { + // Shift key in alphabet. + public void testShiftAlphabet() { + // Press/release shift key, enter into alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + + // Press/release shift key, back to alphabet. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + + // Press/release shift key, enter into alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press/release letter key, switch back to alphabet. + pressAndReleaseKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + } + + // Shift key in symbols. + public void testShiftSymbols() { + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + + // Press/release "=\<" key, enter into symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + + // Press/release "?123" key, back to symbols. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + + // Press/release "=\<" key, enter into symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press/release symbol letter key, remain in symbols shifted. + pressAndReleaseKey('1', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + } + + // Switching between alphabet and symbols. + public void testAlphabetAndSymbols() { + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "ABC" key, back to alphabet. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + + // Press/release "=\<" key, enter into symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press/release "ABC" key, back to alphabet. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Press/release "?123" key, back to symbols (not symbols shifted). + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + } + + // Switching between alphabet shifted and symbols. + public void testAlphabetShiftedAndSymbols() { + // Press/release shift key, enter into alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "ABC" key, back to alphabet (not alphabet shifted). + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + + // Press/release shift key, enter into alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\< key, enter into symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press/release "ABC" key, back to alphabet (not alphabet shifted). + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + } + + // Switching between alphabet shift locked and symbols. + public void testAlphabetShiftLockedAndSymbols() { + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "ABC" key, back to alphabet shift locked. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + + // Press/release "=\<" key, enter into symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press/release "ABC" key, back to alphabet shift locked. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + // Press/release "?123" key, back to symbols (not symbols shifted). + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + } + + // Automatic switch back to alphabet by space key. + public void testSwitchBackBySpace() { + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Enter symbol letter. + pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Enter space, switch back to alphabet. + pressAndReleaseKey(CODE_SPACE, SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED); + + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter into symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Enter symbol shift letter. + pressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Enter space, switch back to alphabet. + pressAndReleaseKey(CODE_SPACE, SYMBOLS_SHIFTED, ALPHABET_UNSHIFTED); + // Press/release "?123" key, enter into symbols (not symbols shifted). + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + } + + // Automatic switch back to alphabet shift locked test by space key. + public void testSwitchBackBySpaceShiftLocked() { + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Enter symbol letter. + pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Enter space, switch back to alphabet shift locked. + pressAndReleaseKey(CODE_SPACE, SYMBOLS_UNSHIFTED, ALPHABET_SHIFT_LOCKED); + + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter into symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Enter symbol shift letter. + pressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Enter space, switch back to alphabet shift locked. + pressAndReleaseKey(CODE_SPACE, SYMBOLS_SHIFTED, ALPHABET_SHIFT_LOCKED); + } + + // Automatic upper case test + public void testAutomaticUpperCase() { + // Set capitalize the first character of all words mode. + setAutoCapsMode(CAP_MODE_WORDS); + // Load keyboard, should be in automatic shifted. + loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); + + // Press/release letter key, switch to alphabet. + pressAndReleaseKey('A', ALPHABET_AUTOMATIC_SHIFTED, ALPHABET_UNSHIFTED); + // Press/release auto caps trigger letter, should be in automatic shifted. + pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); + + // Press/release shift key, back to alphabet. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + // Press/release letter key, remain in alphabet. + pressAndReleaseKey('a', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Press/release auto caps trigger letter, should be in automatic shifted. + pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); + + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release symbol letter key, remain in symbols. + pressAndReleaseKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release space, switch back to automatic shifted. + pressAndReleaseKey(CODE_SPACE, SYMBOLS_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); + + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter into symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press/release symbol shift letter key, remain in symbols shifted. + pressAndReleaseKey('~', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press/release space, switch back to automatic shifted. + pressAndReleaseKey(CODE_SPACE, SYMBOLS_SHIFTED, ALPHABET_AUTOMATIC_SHIFTED); + } + + // Long press shift key. + public void testLongPressShift() { + // Set auto caps mode off. + setAutoCapsMode(CAP_MODE_OFF); + // Load keyboard, should be in alphabet. + loadKeyboard(ALPHABET_UNSHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release shift key, back to alphabet. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); + + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release letter key, remain in shift locked. + pressAndReleaseKey('A', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + // Press/release word separator, remain in shift locked. + pressAndReleaseKey(CODE_SPACE, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + // Press/release shift key, back to alphabet. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); + + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Long press shift key, back to alphabet. + longPressAndReleaseShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED, + ALPHABET_UNSHIFTED); + + // Press/release shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release shift key, back to alphabet. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); + + // Set capitalize the first character of all words mode. + setAutoCapsMode(CAP_MODE_WORDS); + // Load keyboard, should be in automatic shifted. + loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release shift key, back to alphabet. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); + } + + // Double tap shift key. + public void testDoubleTapShift() { + // First shift key tap. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Second shift key tap. + secondPressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + + // First shift key tap. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); + // Second shift key tap. + secondPressAndReleaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + + // Press/release shift key, enter alphabet manual shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + + // First shift key tap. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + // Second shift key tap. + secondPressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + + // First shift key tap. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); + // Second shift key tap. + secondPressAndReleaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + + // Set capitalize the first character of all words mode. + setAutoCapsMode(CAP_MODE_WORDS); + // Load keyboard, should be in automatic shifted. + loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); + + // First shift key tap. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + // Second shift key tap. + secondPressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + + // First shift key tap. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); + // Second shift key tap. + secondPressAndReleaseKey(CODE_SHIFT, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + } + + // Update shift state. + public void testUpdateShiftState() { + // Set auto caps mode off. + setAutoCapsMode(CAP_MODE_OFF); + // Load keyboard, should be in alphabet. + loadKeyboard(ALPHABET_UNSHIFTED); + // Update shift state, remained in alphabet. + updateShiftState(ALPHABET_UNSHIFTED); + + // Press/release shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Update shift state, back to alphabet. + updateShiftState(ALPHABET_UNSHIFTED); + + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Update shift state, remained in alphabet shift locked. + updateShiftState(ALPHABET_SHIFT_LOCKED); + // Long press shift key, back to alphabet. + longPressAndReleaseShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED, + ALPHABET_UNSHIFTED); + + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Update shift state, remained in symbols. + updateShiftState(SYMBOLS_UNSHIFTED); + + // Press/release "=\<" key, enter symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Update shift state, remained in symbols shifted. + updateShiftState(SYMBOLS_SHIFTED); + + // Set capitalize the first character of all words mode. + setAutoCapsMode(CAP_MODE_WORDS); + // Load keyboard, should be in automatic shifted. + loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); + // Update shift state, remained in automatic shifted. + updateShiftState(ALPHABET_AUTOMATIC_SHIFTED); + + // Press/release shift key, enter alphabet. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + // Press/release shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Update shift state, enter to automatic shifted (not alphabet shifted). + updateShiftState(ALPHABET_AUTOMATIC_SHIFTED); + + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Update shift state, remained in alphabet shift locked (not automatic shifted). + updateShiftState(ALPHABET_SHIFT_LOCKED); + // Long press shift key, back to alphabet. + longPressAndReleaseShiftKey(ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCK_SHIFTED, + ALPHABET_UNSHIFTED); + + // Load keyboard, should be in automatic shifted. + loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Update shift state, remained in symbols. + updateShiftState(SYMBOLS_UNSHIFTED); + + // Press/release "=\<" key, enter symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Update shift state, remained in symbols shifted. + updateShiftState(SYMBOLS_SHIFTED); + } + + // Sliding input in alphabet. + public void testSlidingAlphabet() { + // Alphabet -> shift key + letter -> alphabet. + // Press and slide from shift key, enter alphabet shifted. + pressAndSlideFromKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Enter/release letter keys, switch back to alphabet. + pressAndSlideFromKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + stopSlidingOnKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + + // Alphabet -> "?123" key + letter -> alphabet. + // Press and slide from "123?" key, enter symbols. + pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Enter/release into symbol letter keys, switch back to alphabet. + pressAndSlideFromKey('@', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + stopSlidingOnKey('!', SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED); + + // Alphabet shifted -> shift key + letter -> alphabet. + // Press/release shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press and slide from shift key, remain alphabet shifted. + pressAndSlideFromKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Enter/release letter keys, switch back to alphabet (not alphabet shifted). + pressAndSlideFromKey('A', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + stopSlidingOnKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + + // Alphabet shifted -> "?123" key + letter -> alphabet. + // Press/release shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press and slide from "123?" key, enter symbols. + pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Enter/release into symbol letter keys, switch back to alphabet (not alphabet shifted). + pressAndSlideFromKey('@', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + stopSlidingOnKey('!', SYMBOLS_UNSHIFTED, ALPHABET_UNSHIFTED); + + // Alphabet shift locked -> shift key + letter -> alphabet shift locked. + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press and slide from "123?" key, enter symbols. + pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Enter/release into symbol letter keys, switch back to alphabet shift locked. + pressAndSlideFromKey('!', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + stopSlidingOnKey('!', SYMBOLS_UNSHIFTED, ALPHABET_SHIFT_LOCKED); + + // Alphabet shift locked -> "?123" key + letter -> alphabet shift locked. + // Press and slide from shift key, enter alphabet shifted. + pressAndSlideFromKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCKED); + // Enter/release letter keys, switch back to shift locked. + pressAndSlideFromKey('A', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + stopSlidingOnKey('Z', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + } + + // Cancel sliding input in alphabet. + public void testSlidingAlphabetCancel() { + // Alphabet -> shift key + letter -> cancel -> alphabet. + // Press and slide from shift key, enter alphabet shifted. + pressAndSlideFromKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press and slide from shift key, enter alphabet shifted. + pressAndSlideFromKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Enter/release letter key, remains in alphabet shifted. + pressAndSlideFromKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Cancel sliding, switch back to alphabet. + stopSlidingAndCancel(ALPHABET_UNSHIFTED); + + // Alphabet -> "?123" key + letter -> cancel -> alphabet. + // Press and slide from "123?" key, enter symbols. + pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Enter/release into symbol letter key, remains in symbols. + pressAndSlideFromKey('!', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Cancel sliding, switch back to alphabet. + stopSlidingAndCancel(ALPHABET_UNSHIFTED); + + // Alphabet shifted -> shift key + letter -> cancel -> alphabet. + // Press/release shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press and slide from shift key, remain alphabet shifted. + pressAndSlideFromKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Enter/release letter key, remains in alphabet shifted. + pressAndSlideFromKey('Z', ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Cancel sliding, switch back to alphabet (not alphabet shifted). + stopSlidingAndCancel(ALPHABET_UNSHIFTED); + + // Alphabet shifted -> "?123" key + letter -> cancel -> alphabet. + // Press/release shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press and slide from "123?" key, enter symbols. + pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Enter/release into symbol letter key, remains in symbols. + pressAndSlideFromKey('!', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Cancel sliding, switch back to alphabet (not alphabet shifted). + stopSlidingAndCancel(ALPHABET_UNSHIFTED); + + // Alphabet shift locked -> shift key + letter -> cancel -> alphabet shift locked. + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press and slide from "123?" key, enter symbols. + pressAndSlideFromKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Enter/release into symbol letter key, remains in symbols. + pressAndSlideFromKey('!', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Cancel sliding, switch back to alphabet shift locked. + stopSlidingAndCancel( ALPHABET_SHIFT_LOCKED); + + // Alphabet shift locked -> "?123" key + letter -> cancel -> alphabet shift locked. + // Press and slide from shift key, enter alphabet shifted. + pressAndSlideFromKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_SHIFT_LOCKED); + // Enter/release letter key, remains in alphabet shift locked. + pressAndSlideFromKey('Z', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + // Enter/release letter key, switch back to shift locked. + stopSlidingAndCancel(ALPHABET_SHIFT_LOCKED); + } + + // Sliding input in symbols. + public void testSlidingSymbols() { + // Symbols -> "=\<" key + letter -> symbols. + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press and slide from shift key, enter symbols shifted. + pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Enter/release symbol shifted letter keys, switch back to symbols. + pressAndSlideFromKey('|', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + stopSlidingOnKey('~', SYMBOLS_SHIFTED, SYMBOLS_UNSHIFTED); + + // Symbols -> "ABC" key + letter -> Symbols. + // Press and slide from "ABC" key, enter alphabet. + pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Enter/release letter keys, switch back to symbols. + pressAndSlideFromKey('z', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + stopSlidingOnKey('a', ALPHABET_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "ABC" key, switch to alphabet. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + + // Alphabet shifted -> symbols -> "ABC" key + letter -> symbols -> + // alphabet. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Press/release shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press and slide from "ABC" key. + pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Enter/release letter keys, switch back to symbols. + pressAndSlideFromKey('z', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + stopSlidingOnKey('a', ALPHABET_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "ABC" key, switch to alphabet (not alphabet shifted). + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + + // Alphabet shift locked -> symbols -> "ABC" key + letter -> symbols -> + // alphabet shift locked. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press and slide from "ABC" key, enter alphabet shift locked. + pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + // Enter/release letter keys, switch back to symbols. + pressAndSlideFromKey('Z', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + stopSlidingOnKey('A', ALPHABET_SHIFT_LOCKED, SYMBOLS_UNSHIFTED); + // Press/release "ABC" key, switch to alphabet shift locked. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + + // Alphabet shift locked -> symbols -> "=\<" key + letter -> symbols -> + // alphabet shift locked. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press and slide from "=\<" key, enter symbols shifted. + pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Enter/release symbols shift letter keys, switch back to symbols. + pressAndSlideFromKey('|', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + stopSlidingOnKey('~', SYMBOLS_SHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "ABC" key, switch to alphabet shift locked. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + } + + // Cancel sliding input in symbols. + public void testSlidingSymbolsCancel() { + // Symbols -> "=\<" key + letter -> cancel -> symbols. + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press and slide from shift key, enter symbols shifted. + pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Enter/release symbol shifted letter key, remains in symbols shifted. + pressAndSlideFromKey('|', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Cancel sliding, switch back to symbols. + stopSlidingAndCancel(SYMBOLS_UNSHIFTED); + + // Symbols -> "ABC" key + letter -> Symbols. + // Press and slide from "ABC" key, enter alphabet. + pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Enter/release letter keys, remains in alphabet. + pressAndSlideFromKey('z', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Cancel sliding, switch back to symbols. + stopSlidingAndCancel(SYMBOLS_UNSHIFTED); + // Press/release "ABC" key, switch to alphabet. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + + // Alphabet shifted -> symbols -> "ABC" key + letter -> symbols -> + // alphabet. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Press/release shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press and slide from "ABC" key. + pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Enter/release letter key, remains in alphabet. + pressAndSlideFromKey('z', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Cancel sliding, switch back to symbols. + stopSlidingAndCancel(SYMBOLS_UNSHIFTED); + // Press/release "ABC" key, switch to alphabet (not alphabet shifted). + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + + // Alphabet shift locked -> symbols -> "ABC" key + letter -> symbols -> + // alphabet shift locked. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press and slide from "ABC" key, enter alphabet shift locked. + pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + // Enter/release letter key, remains in alphabet shifted. + pressAndSlideFromKey('Z', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + // Cancel sliding, switch back to symbols. + stopSlidingAndCancel(SYMBOLS_UNSHIFTED); + // Press/release "ABC" key, switch to alphabet shift locked. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + + // Alphabet shift locked -> symbols -> "=\<" key + letter -> symbols -> + // alphabet shift locked. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press and slide from "=\<" key, enter symbols shifted. + pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Enter/release symbols shift letter key, remains in symbols shifted. + pressAndSlideFromKey('|', SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Cancel sliding, switch back to symbols. + stopSlidingAndCancel(SYMBOLS_UNSHIFTED); + // Press/release "ABC" key, switch to alphabet shift locked. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + } + + // Sliding input in symbols shifted. + public void testSlidingSymbolsShifted() { + // Symbols shifted -> "?123" + letter -> symbols shifted. + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter into symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press and slide from shift key, enter symbols. + pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Enter/release symbol letter keys, switch back to symbols shifted. + pressAndSlideFromKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + stopSlidingOnKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_SHIFTED); + + // Symbols shifted -> "ABC" key + letter -> symbols shifted. + // Press and slide from "ABC" key, enter alphabet. + pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Enter/release letter keys, switch back to symbols shifted. + pressAndSlideFromKey('z', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + stopSlidingOnKey('a', ALPHABET_UNSHIFTED, SYMBOLS_SHIFTED); + // Press/release "ABC" key, switch to alphabet. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + + // Alphabet shifted -> symbols shifted -> "ABC" + letter -> symbols shifted -> + // alphabet. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Press/release shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter into symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press and slide from "ABC" key. + pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Enter/release letter keys, switch back to symbols shifted. + pressAndSlideFromKey('z', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + stopSlidingOnKey('a', ALPHABET_UNSHIFTED, SYMBOLS_SHIFTED); + // Press/release "ABC" key, switch to alphabet (not alphabet shifted). + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + + // Alphabet shift locked -> symbols shifted -> "ABC" + letter -> symbols shifted -> + // alphabet shift locked. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter into symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press and slide from "ABC" key. + pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + // Enter/release letter keys, switch back to symbols shifted. + pressAndSlideFromKey('Z', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + stopSlidingOnKey('A', ALPHABET_SHIFT_LOCKED, SYMBOLS_SHIFTED); + // Press/release "ABC" key, switch to alphabet shift locked. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + + // Alphabet shift locked -> symbols shifted -> "?123" + letter -> symbols shifted -> + // alphabet shift locked. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter into symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press and slide from "?123" key. + pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Enter/release symbol letter keys, switch back to symbols shifted. + pressAndSlideFromKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + stopSlidingOnKey('1', SYMBOLS_UNSHIFTED, SYMBOLS_SHIFTED); + // Press/release "ABC" key, switch to alphabet shift locked. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + } + + // Cancel sliding input in symbols shifted. + public void testSlidingSymbolsShiftedCancel() { + // Symbols shifted -> "?123" + letter -> symbols shifted. + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter into symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press and slide from shift key, enter symbols. + pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Enter/release symbol letter key, remains in symbols. + pressAndSlideFromKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Cancel sliding, switch back to symbols shifted. + stopSlidingAndCancel(SYMBOLS_SHIFTED); + + // Symbols shifted -> "ABC" key + letter -> symbols shifted. + // Press and slide from "ABC" key, enter alphabet. + pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Enter/release letter key, remains in alphabet. + pressAndSlideFromKey('z', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Cancel sliding, switch back to symbols shifted. + stopSlidingAndCancel(SYMBOLS_SHIFTED); + // Press/release "ABC" key, switch to alphabet. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + + // Alphabet shifted -> symbols shifted -> "ABC" + letter -> symbols shifted -> + // alphabet. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Press/release shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter into symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press and slide from "ABC" key. + pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Enter/release letter key, remains in alphabet. + pressAndSlideFromKey('z', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Cancel sliding, switch back to symbols shifted. + stopSlidingAndCancel(SYMBOLS_SHIFTED); + // Press/release "ABC" key, switch to alphabet (not alphabet shifted). + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + + // Alphabet shift locked -> symbols shifted -> "ABC" + letter -> symbols shifted -> + // alphabet shift locked. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter into symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press and slide from "ABC" key. + pressAndSlideFromKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + // Enter/release letter key, remains in alphabet shift locked. + pressAndSlideFromKey('Z', ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + // Cancel sliding, switch back to symbols shifted. + stopSlidingAndCancel(SYMBOLS_SHIFTED); + // Press/release "ABC" key, switch to alphabet shift locked. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + + // Alphabet shift locked -> symbols shifted -> "?123" + letter -> symbols shifted -> + // alphabet shift locked. + // Load keyboard + loadKeyboard(ALPHABET_UNSHIFTED); + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release "?123" key, enter into symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter into symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press and slide from "?123" key. + pressAndSlideFromKey(CODE_SHIFT, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Enter/release symbol letter key, remains in symbols. + pressAndSlideFromKey('2', SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Cancel sliding, switch back to symbols shifted. + stopSlidingAndCancel(SYMBOLS_SHIFTED); + // Press/release "ABC" key, switch to alphabet shift locked. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + } + + // Change focus to new text field. + public void testChangeFocus() { + // Press/release shift key. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Change focus to new text field. + loadKeyboard(ALPHABET_UNSHIFTED); + + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Change focus to new text field. + loadKeyboard(ALPHABET_UNSHIFTED); + + // Press/release "?123" key. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Change focus to new text field. + loadKeyboard(ALPHABET_UNSHIFTED); + + // Press/release "?123" key. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Change focus to new text field. + loadKeyboard(ALPHABET_UNSHIFTED); + } + + // Change focus to auto caps text field. + public void testChangeFocusAutoCaps() { + // Set capitalize the first character of all words mode. + setAutoCapsMode(CAP_MODE_WORDS); + // Change focus to new text field. + loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); + + // Press/release shift key, enter alphabet. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + // Change focus to new text field. + loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); + + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Change focus to new text field. + loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); + + // Press/release "?123" key. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Change focus to new text field. + loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); + + // Press/release "?123" key. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Change focus to new text field. + loadKeyboard(ALPHABET_AUTOMATIC_SHIFTED); + } + + // Change orientation. + public void testChangeOrientation() { + // Alphabet -> rotate -> alphabet. + updateShiftState(ALPHABET_UNSHIFTED); + // Rotate device, remain in alphabet. + rotateDevice(ALPHABET_UNSHIFTED); + + // Alphabet automatic shifted -> rotate -> automatic shifted. + // Set capitalize the first character of all words mode. + setAutoCapsMode(CAP_MODE_WORDS); + // Press/release auto caps trigger letter to enter alphabet automatic shifted. + pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); + // Rotate device, remain in alphabet. + rotateDevice(ALPHABET_AUTOMATIC_SHIFTED); + setAutoCapsMode(CAP_MODE_OFF); + // Press/release auto caps trigger letter to reset shift state. + pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_AUTOMATIC_SHIFTED, ALPHABET_UNSHIFTED); + + // Alphabet shifted -> rotate -> alphabet shifted. + // Press/release shift key, enter alphabet shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Rotate device, remain in alphabet shifted. + rotateDevice(ALPHABET_MANUAL_SHIFTED); + + // Alphabet shift locked -> rotate -> alphabet shift locked. + // Long press shift key, enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Rotate device, remain in alphabet shift locked. + rotateDevice(ALPHABET_SHIFT_LOCKED); + + // Alphabet shift locked -> symbols -> rotate -> symbols -> + // Alphabet shift locked. + // Press/release "?123" key, enter symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Rotate device, remain in symbols, + rotateDevice(SYMBOLS_UNSHIFTED); + // Press/release "ABC" key, alphabet shift locked state should be maintained. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + + // Alphabet shift locked -> symbols shifted -> rotate -> symbols shifted -> + // Alphabet shift locked. + // Press/release "?123" key, enter symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Rotate device, remain in symbols shifted. + rotateDevice(SYMBOLS_SHIFTED); + // Press/release "ABC" key, alphabet shift locked state should be maintained. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + + // Alphabet shift locked -> symbols shifted -> alphabet shift locked -> rotate -> + // Alphabet shift locked -> symbols. + // Press/release "?123" key, enter symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press/release "ABC" key, enter alphabet shift locked. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_SHIFT_LOCKED, ALPHABET_SHIFT_LOCKED); + // Rotate device, remain in alphabet shift locked. + rotateDevice(ALPHABET_SHIFT_LOCKED); + // Press/release "?123" key, enter symbols (not symbols shifted). + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + + // Alphabet -> symbols shifted -> alphabet -> rotate -> + // Alphabet -> symbols. + loadKeyboard(ALPHABET_UNSHIFTED); + // Press/release "?123" key, enter symbols. + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + // Press/release "=\<" key, enter symbols shifted. + pressAndReleaseKey(CODE_SHIFT, SYMBOLS_SHIFTED, SYMBOLS_SHIFTED); + // Press/release "ABC" key, enter alphabet. + pressAndReleaseKey(CODE_SYMBOL, ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Rotate device, remain in alphabet shift locked. + rotateDevice(ALPHABET_UNSHIFTED); + // Press/release "?123" key, enter symbols (not symbols shifted). + pressAndReleaseKey(CODE_SYMBOL, SYMBOLS_UNSHIFTED, SYMBOLS_UNSHIFTED); + } + + // Rapidly type shift key. + public void testRapidShiftTyping() { + // Press/release shift key + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Rapidly press/release letter key. + secondPressAndReleaseKey('J', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + // Rapidly press/release shift key. + secondPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Rapidly press/release letter key. + secondPressAndReleaseKey('J', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + // Rapidly press/release shift key. + secondPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Rapidly press/release letter key. + secondPressAndReleaseKey('J', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + + // Press/release shift key to enter alphabet manual shifted. + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Press/release shift key + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + // Rapidly press/release letter key. + secondPressAndReleaseKey('j', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Rapidly press/release shift key. + secondPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Rapidly press/release letter key. + secondPressAndReleaseKey('J', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + // Rapidly press/release shift key. + secondPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Rapidly press/release letter key. + secondPressAndReleaseKey('J', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + + // Long press shift key to enter alphabet shift locked. + longPressAndReleaseShiftKey(ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED, + ALPHABET_SHIFT_LOCKED); + // Press/release shift key + pressAndReleaseKey(CODE_SHIFT, ALPHABET_SHIFT_LOCK_SHIFTED, ALPHABET_UNSHIFTED); + // Rapidly press/release letter key. + secondPressAndReleaseKey('j', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Rapidly press/release shift key. + secondPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Rapidly press/release letter key. + secondPressAndReleaseKey('J', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + // Rapidly press/release shift key. + secondPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Rapidly press/release letter key. + secondPressAndReleaseKey('J', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + + // Set capitalize the first character of all words mode. + setAutoCapsMode(CAP_MODE_WORDS); + // Press/release auto caps trigger letter to enter alphabet automatic shifted. + pressAndReleaseKey(CODE_AUTO_CAPS_TRIGGER, ALPHABET_UNSHIFTED, ALPHABET_AUTOMATIC_SHIFTED); + // Press/release shift key + pressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + // Rapidly press/release letter key. + secondPressAndReleaseKey('j', ALPHABET_UNSHIFTED, ALPHABET_UNSHIFTED); + // Rapidly press/release shift key. + secondPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Rapidly press/release letter key. + secondPressAndReleaseKey('J', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + // Rapidly press/release shift key. + secondPressAndReleaseKey(CODE_SHIFT, ALPHABET_MANUAL_SHIFTED, ALPHABET_MANUAL_SHIFTED); + // Rapidly press/release letter key. + secondPressAndReleaseKey('J', ALPHABET_MANUAL_SHIFTED, ALPHABET_UNSHIFTED); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/internal/KeyboardStateTestsBase.java b/tests/src/org/kelar/inputmethod/keyboard/internal/KeyboardStateTestsBase.java new file mode 100644 index 000000000..016578ce6 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/internal/KeyboardStateTestsBase.java @@ -0,0 +1,253 @@ +/* + * Copyright (C) 2012 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 org.kelar.inputmethod.keyboard.internal; + +import android.test.AndroidTestCase; + +import org.kelar.inputmethod.latin.common.Constants; + +public class KeyboardStateTestsBase extends AndroidTestCase + implements MockKeyboardSwitcher.MockConstants { + protected MockKeyboardSwitcher mSwitcher; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + mSwitcher = new MockKeyboardSwitcher(); + mSwitcher.setAutoCapsMode(CAP_MODE_OFF); + + loadKeyboard(ALPHABET_UNSHIFTED); + } + + /** + * Set auto caps mode. + * + * @param autoCaps the auto cap mode. + */ + public void setAutoCapsMode(final int autoCaps) { + mSwitcher.setAutoCapsMode(autoCaps); + } + + private static void assertLayout(final String message, final int expected, final int actual) { + assertTrue(message + ": expected=" + MockKeyboardSwitcher.getLayoutName(expected) + + " actual=" + MockKeyboardSwitcher.getLayoutName(actual), + expected == actual); + } + + /** + * Emulate update keyboard shift state. + * + * @param afterUpdate the keyboard state after updating the keyboard shift state. + */ + public void updateShiftState(final int afterUpdate) { + mSwitcher.updateShiftState(); + assertLayout("afterUpdate", afterUpdate, mSwitcher.getLayoutId()); + } + + /** + * Emulate load default keyboard. + * + * @param afterLoad the keyboard state after loading default keyboard. + */ + public void loadKeyboard(final int afterLoad) { + mSwitcher.loadKeyboard(); + mSwitcher.updateShiftState(); + assertLayout("afterLoad", afterLoad, mSwitcher.getLayoutId()); + } + + /** + * Emulate rotate device. + * + * @param afterRotate the keyboard state after rotating device. + */ + public void rotateDevice(final int afterRotate) { + mSwitcher.saveKeyboardState(); + mSwitcher.loadKeyboard(); + assertLayout("afterRotate", afterRotate, mSwitcher.getLayoutId()); + } + + private void pressKeyWithoutTimerExpire(final int code, final boolean isSinglePointer, + final int afterPress) { + mSwitcher.onPressKey(code, isSinglePointer); + assertLayout("afterPress", afterPress, mSwitcher.getLayoutId()); + } + + /** + * Emulate key press. + * + * @param code the key code to press. + * @param afterPress the keyboard state after pressing the key. + */ + public void pressKey(final int code, final int afterPress) { + mSwitcher.expireDoubleTapTimeout(); + pressKeyWithoutTimerExpire(code, true, afterPress); + } + + /** + * Emulate key release and register. + * + * @param code the key code to release and register + * @param afterRelease the keyboard state after releasing the key. + */ + public void releaseKey(final int code, final int afterRelease) { + mSwitcher.onCodeInput(code); + mSwitcher.onReleaseKey(code, NOT_SLIDING); + assertLayout("afterRelease", afterRelease, mSwitcher.getLayoutId()); + } + + /** + * Emulate key press and release. + * + * @param code the key code to press and release. + * @param afterPress the keyboard state after pressing the key. + * @param afterRelease the keyboard state after releasing the key. + */ + public void pressAndReleaseKey(final int code, final int afterPress, final int afterRelease) { + pressKey(code, afterPress); + releaseKey(code, afterRelease); + } + + /** + * Emulate chording key press. + * + * @param code the chording key code. + * @param afterPress the keyboard state after pressing chording key. + */ + public void chordingPressKey(final int code, final int afterPress) { + mSwitcher.expireDoubleTapTimeout(); + pressKeyWithoutTimerExpire(code, false, afterPress); + } + + /** + * Emulate chording key release. + * + * @param code the cording key code. + * @param afterRelease the keyboard state after releasing chording key. + */ + public void chordingReleaseKey(final int code, final int afterRelease) { + mSwitcher.onCodeInput(code); + mSwitcher.onReleaseKey(code, NOT_SLIDING); + assertLayout("afterRelease", afterRelease, mSwitcher.getLayoutId()); + } + + /** + * Emulate chording key press and release. + * + * @param code the chording key code. + * @param afterPress the keyboard state after pressing chording key. + * @param afterRelease the keyboard state after releasing chording key. + */ + public void chordingPressAndReleaseKey(final int code, final int afterPress, + final int afterRelease) { + chordingPressKey(code, afterPress); + chordingReleaseKey(code, afterRelease); + } + + /** + * Emulate start of the sliding key input. + * + * @param code the key code to start sliding. + * @param afterPress the keyboard state after pressing the key. + * @param afterSlide the keyboard state after releasing the key with sliding input. + */ + public void pressAndSlideFromKey(final int code, final int afterPress, final int afterSlide) { + pressKey(code, afterPress); + mSwitcher.onReleaseKey(code, SLIDING); + assertLayout("afterSlide", afterSlide, mSwitcher.getLayoutId()); + } + + /** + * Emulate end of the sliding key input. + * + * @param code the key code to stop sliding. + * @param afterPress the keyboard state after pressing the key. + * @param afterSlide the keyboard state after releasing the key and stop sliding. + */ + public void stopSlidingOnKey(final int code, final int afterPress, final int afterSlide) { + pressKey(code, afterPress); + mSwitcher.onCodeInput(code); + mSwitcher.onReleaseKey(code, NOT_SLIDING); + mSwitcher.onFinishSlidingInput(); + assertLayout("afterSlide", afterSlide, mSwitcher.getLayoutId()); + } + + /** + * Emulate cancel the sliding key input. + * + * @param afterCancelSliding the keyboard state after canceling sliding input. + */ + public void stopSlidingAndCancel(final int afterCancelSliding) { + mSwitcher.onFinishSlidingInput(); + assertLayout("afterCancelSliding", afterCancelSliding, mSwitcher.getLayoutId()); + } + + /** + * Emulate long press shift key. + * + * @param afterPress the keyboard state after pressing shift key. + * @param afterLongPress the keyboard state after long press fired. + */ + public void longPressShiftKey(final int afterPress, final int afterLongPress) { + // Long press shift key will register {@link Constants#CODE_CAPS_LOCK}. See + // {@link R.xml#key_styles_common} and its baseForShiftKeyStyle. We thus emulate the + // behavior that is implemented in {@link MainKeyboardView#onLongPress(PointerTracker)}. + pressKey(Constants.CODE_SHIFT, afterPress); + mSwitcher.onPressKey(Constants.CODE_CAPSLOCK, true /* isSinglePointer */); + mSwitcher.onCodeInput(Constants.CODE_CAPSLOCK); + assertLayout("afterLongPress", afterLongPress, mSwitcher.getLayoutId()); + } + + /** + * Emulate long press shift key and release. + * + * @param afterPress the keyboard state after pressing shift key. + * @param afterLongPress the keyboard state after long press fired. + * @param afterRelease the keyboard state after shift key is released. + */ + public void longPressAndReleaseShiftKey(final int afterPress, final int afterLongPress, + final int afterRelease) { + // Long press shift key will register {@link Constants#CODE_CAPS_LOCK}. See + // {@link R.xml#key_styles_common} and its baseForShiftKeyStyle. We thus emulate the + // behavior that is implemented in {@link MainKeyboardView#onLongPress(PointerTracker)}. + longPressShiftKey(afterPress, afterLongPress); + releaseKey(Constants.CODE_CAPSLOCK, afterRelease); + } + + /** + * Emulate the second press of the double tap. + * + * @param code the key code to double tap. + * @param afterPress the keyboard state after pressing the second tap. + */ + public void secondPressKey(final int code, final int afterPress) { + pressKeyWithoutTimerExpire(code, true, afterPress); + } + + /** + * Emulate the second tap of the double tap. + * + * @param code the key code to double tap. + * @param afterPress the keyboard state after pressing the second tap. + * @param afterRelease the keyboard state after releasing the second tap. + */ + public void secondPressAndReleaseKey(final int code, final int afterPress, + final int afterRelease) { + secondPressKey(code, afterPress); + releaseKey(code, afterRelease); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/internal/KeyboardTextsSetTests.java b/tests/src/org/kelar/inputmethod/keyboard/internal/KeyboardTextsSetTests.java new file mode 100644 index 000000000..34a16cfb7 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/internal/KeyboardTextsSetTests.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 org.kelar.inputmethod.keyboard.internal; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; + +import android.content.Context; +import android.view.inputmethod.InputMethodInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; + +import org.kelar.inputmethod.latin.RichInputMethodManager; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Locale; + +@SmallTest +@RunWith(AndroidJUnit4.class) +public final class KeyboardTextsSetTests { + // All input method subtypes of LatinIME. + private List<InputMethodSubtype> mAllSubtypesList; + + private Context getContext() { + return InstrumentationRegistry.getTargetContext(); + } + + @Before + public void setUp() throws Exception { + RichInputMethodManager.init(getContext()); + final RichInputMethodManager richImm = RichInputMethodManager.getInstance(); + + final ArrayList<InputMethodSubtype> allSubtypesList = new ArrayList<>(); + final InputMethodInfo imi = richImm.getInputMethodInfoOfThisIme(); + final int subtypeCount = imi.getSubtypeCount(); + for (int index = 0; index < subtypeCount; index++) { + final InputMethodSubtype subtype = imi.getSubtypeAt(index); + allSubtypesList.add(subtype); + } + mAllSubtypesList = Collections.unmodifiableList(allSubtypesList); + } + + // Test that the text {@link KeyboardTextsSet#SWITCH_TO_ALPHA_KEY_LABEL} exists for all + // subtypes. The text is needed to implement Emoji Keyboard, see + // {@link KeyboardSwitcher#setEmojiKeyboard()}. + @Test + public void testSwitchToAlphaKeyLabel() { + final Context context = getContext(); + final KeyboardTextsSet textsSet = new KeyboardTextsSet(); + for (final InputMethodSubtype subtype : mAllSubtypesList) { + final Locale locale = SubtypeLocaleUtils.getSubtypeLocale(subtype); + textsSet.setLocale(locale, context); + final String switchToAlphaKeyLabel = textsSet.getText( + KeyboardTextsSet.SWITCH_TO_ALPHA_KEY_LABEL); + assertNotNull("Switch to alpha key label of " + locale, switchToAlphaKeyLabel); + assertFalse("Switch to alpha key label of " + locale, switchToAlphaKeyLabel.isEmpty()); + } + } + + private static final String[] TEXT_NAMES_FROM_RESOURCE = { + // Labels for action. + "label_go_key", + "label_send_key", + "label_next_key", + "label_done_key", + "label_previous_key", + // Other labels. + "label_pause_key", + "label_wait_key", + }; + + // Test that the text from resources are correctly loaded for all subtypes. + @Test + public void testTextFromResources() { + final Context context = getContext(); + final KeyboardTextsSet textsSet = new KeyboardTextsSet(); + for (final InputMethodSubtype subtype : mAllSubtypesList) { + final Locale locale = SubtypeLocaleUtils.getSubtypeLocale(subtype); + textsSet.setLocale(locale, context); + for (final String name : TEXT_NAMES_FROM_RESOURCE) { + final String text = textsSet.getText(name); + assertNotNull(name + " of " + locale, text); + assertFalse(name + " of " + locale, text.isEmpty()); + } + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/internal/MatrixUtilsTests.java b/tests/src/org/kelar/inputmethod/keyboard/internal/MatrixUtilsTests.java new file mode 100644 index 000000000..2c7d986c9 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/internal/MatrixUtilsTests.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2013 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 org.kelar.inputmethod.keyboard.internal; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; + +import org.kelar.inputmethod.keyboard.internal.MatrixUtils.MatrixOperationFailedException; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@SmallTest +@RunWith(AndroidJUnit4.class) +public class MatrixUtilsTests { + // "run tests" -c org.kelar.inputmethod.keyboard.internal.MatrixUtilsTests + private static final boolean DEBUG = false; + private static final float EPSILON = 0.00001f; + + @Test + public void testMulti() { + final float[][] matrixA = {{1, 2}, {3, 4}}; + final float[][] matrixB = {{5, 6}, {7, 8}}; + final float[][] retval = new float[2][2]; + try { + MatrixUtils.multiply(matrixA, matrixB, retval); + } catch (MatrixOperationFailedException e) { + assertTrue(false); + } + if (DEBUG) { + MatrixUtils.dump("multi", retval); + } + assertEquals(retval[0][0], 19, EPSILON); + assertEquals(retval[0][1], 22, EPSILON); + assertEquals(retval[1][0], 43, EPSILON); + assertEquals(retval[1][1], 50, EPSILON); + } + + @Test + public void testInverse() { + final int N = 4; + final float[][] matrix = + {{1, 2, 3, 4}, {4, 0, 5, 6}, {6, 4, 2, 0}, {6, 4, 2, 1}}; + final float[][] inverse = new float[N][N]; + final float[][] tempMatrix = new float[N][N]; + for (int i = 0; i < N; ++i) { + for (int j = 0; j < N; ++j) { + tempMatrix[i][j] = matrix[i][j]; + } + } + final float[][] retval = new float[N][N]; + try { + MatrixUtils.inverse(tempMatrix, inverse); + } catch (MatrixOperationFailedException e) { + assertTrue(false); + } + try { + MatrixUtils.multiply(matrix, inverse, retval); + } catch (MatrixOperationFailedException e) { + assertTrue(false); + } + for (int i = 0; i < N; ++i) { + for (int j = 0; j < N; ++j) { + assertEquals(((i == j) ? 1.0f : 0.0f), retval[i][j], EPSILON); + } + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/internal/MockKeyboardSwitcher.java b/tests/src/org/kelar/inputmethod/keyboard/internal/MockKeyboardSwitcher.java new file mode 100644 index 000000000..197652783 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/internal/MockKeyboardSwitcher.java @@ -0,0 +1,197 @@ +/* + * Copyright (C) 2012 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 org.kelar.inputmethod.keyboard.internal; + +import android.text.TextUtils; + +import org.kelar.inputmethod.event.Event; +import org.kelar.inputmethod.latin.common.Constants; +import org.kelar.inputmethod.latin.utils.RecapitalizeStatus; + +public class MockKeyboardSwitcher implements KeyboardState.SwitchActions { + public interface MockConstants { + // Argument for {@link KeyboardState#onPressKey} and {@link KeyboardState#onReleaseKey}. + public static final boolean NOT_SLIDING = false; + public static final boolean SLIDING = true; + // Argument for {@link KeyboardState#onEvent}. + public static final boolean SINGLE = true; + public static final boolean MULTI = false; + public static final int CAP_MODE_OFF = Constants.TextUtils.CAP_MODE_OFF; + public static final int CAP_MODE_WORDS = TextUtils.CAP_MODE_WORDS; + public static final int CAP_MODE_CHARACTERS = TextUtils.CAP_MODE_CHARACTERS; + + public static final int CODE_SHIFT = Constants.CODE_SHIFT; + public static final int CODE_SYMBOL = Constants.CODE_SWITCH_ALPHA_SYMBOL; + public static final int CODE_SPACE = Constants.CODE_SPACE; + public static final int CODE_AUTO_CAPS_TRIGGER = Constants.CODE_SPACE; + + public static final int ALPHABET_UNSHIFTED = 0; + public static final int ALPHABET_MANUAL_SHIFTED = 1; + public static final int ALPHABET_AUTOMATIC_SHIFTED = 2; + public static final int ALPHABET_SHIFT_LOCKED = 3; + public static final int ALPHABET_SHIFT_LOCK_SHIFTED = 4; + public static final int SYMBOLS_UNSHIFTED = 5; + public static final int SYMBOLS_SHIFTED = 6; + } + + private int mLayout = MockConstants.ALPHABET_UNSHIFTED; + + private int mAutoCapsMode = MockConstants.CAP_MODE_OFF; + // Following InputConnection's behavior. Simulating InputType.TYPE_TEXT_FLAG_CAP_WORDS. + private int mAutoCapsState = MockConstants.CAP_MODE_OFF; + + private boolean mIsInDoubleTapShiftKeyTimeout; + private int mLongPressTimeoutCode; + + private final KeyboardState mState = new KeyboardState(this); + + public int getLayoutId() { + return mLayout; + } + + public static String getLayoutName(final int layoutId) { + switch (layoutId) { + case MockConstants.ALPHABET_UNSHIFTED: return "ALPHABET_UNSHIFTED"; + case MockConstants.ALPHABET_MANUAL_SHIFTED: return "ALPHABET_MANUAL_SHIFTED"; + case MockConstants.ALPHABET_AUTOMATIC_SHIFTED: return "ALPHABET_AUTOMATIC_SHIFTED"; + case MockConstants.ALPHABET_SHIFT_LOCKED: return "ALPHABET_SHIFT_LOCKED"; + case MockConstants.ALPHABET_SHIFT_LOCK_SHIFTED: return "ALPHABET_SHIFT_LOCK_SHIFTED"; + case MockConstants.SYMBOLS_UNSHIFTED: return "SYMBOLS_UNSHIFTED"; + case MockConstants.SYMBOLS_SHIFTED: return "SYMBOLS_SHIFTED"; + default: return "UNKNOWN<" + layoutId + ">"; + } + } + + public void setAutoCapsMode(final int autoCaps) { + mAutoCapsMode = autoCaps; + mAutoCapsState = autoCaps; + } + + public void expireDoubleTapTimeout() { + mIsInDoubleTapShiftKeyTimeout = false; + } + + @Override + public void setAlphabetKeyboard() { + mLayout = MockConstants.ALPHABET_UNSHIFTED; + } + + @Override + public void setAlphabetManualShiftedKeyboard() { + mLayout = MockConstants.ALPHABET_MANUAL_SHIFTED; + } + + @Override + public void setAlphabetAutomaticShiftedKeyboard() { + mLayout = MockConstants.ALPHABET_AUTOMATIC_SHIFTED; + } + + @Override + public void setAlphabetShiftLockedKeyboard() { + mLayout = MockConstants.ALPHABET_SHIFT_LOCKED; + } + + @Override + public void setAlphabetShiftLockShiftedKeyboard() { + mLayout = MockConstants.ALPHABET_SHIFT_LOCK_SHIFTED; + } + + @Override + public void setSymbolsKeyboard() { + mLayout = MockConstants.SYMBOLS_UNSHIFTED; + } + + @Override + public void setSymbolsShiftedKeyboard() { + mLayout = MockConstants.SYMBOLS_SHIFTED; + } + + @Override + public void setEmojiKeyboard() { + // Just ignore. + } + + @Override + public void requestUpdatingShiftState(final int currentAutoCapsState, + final int currentRecapitalizeState) { + mState.onUpdateShiftState(currentAutoCapsState, currentRecapitalizeState); + } + + @Override + public void startDoubleTapShiftKeyTimer() { + mIsInDoubleTapShiftKeyTimeout = true; + } + + @Override + public void cancelDoubleTapShiftKeyTimer() { + mIsInDoubleTapShiftKeyTimeout = false; + } + + @Override + public boolean isInDoubleTapShiftKeyTimeout() { + return mIsInDoubleTapShiftKeyTimeout; + } + + public void updateShiftState() { + mState.onUpdateShiftState(mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE); + } + + public void loadKeyboard() { + mState.onLoadKeyboard(mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE); + } + + public void saveKeyboardState() { + mState.onSaveKeyboardState(); + } + + public void onPressKey(final int code, final boolean isSinglePointer) { + mState.onPressKey(code, isSinglePointer, mAutoCapsState, + RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE); + } + + public void onReleaseKey(final int code, final boolean withSliding) { + onReleaseKey(code, withSliding, mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE); + } + + public void onReleaseKey(final int code, final boolean withSliding, + final int currentAutoCapsState, final int currentRecapitalizeState) { + mState.onReleaseKey(code, withSliding, currentAutoCapsState, currentRecapitalizeState); + if (mLongPressTimeoutCode == code) { + mLongPressTimeoutCode = 0; + } + } + + public void onCodeInput(final int code) { + if (mAutoCapsMode == MockConstants.CAP_MODE_WORDS) { + if (Constants.isLetterCode(code)) { + mAutoCapsState = (code == MockConstants.CODE_AUTO_CAPS_TRIGGER) + ? mAutoCapsMode : MockConstants.CAP_MODE_OFF; + } + } else { + mAutoCapsState = mAutoCapsMode; + } + final Event event = + Event.createSoftwareKeypressEvent(code /* codePoint */, code /* keyCode */, + Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, + false /* isKeyRepeat */); + mState.onEvent(event, mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE); + } + + public void onFinishSlidingInput() { + mState.onFinishSlidingInput(mAutoCapsState, RecapitalizeStatus.NOT_A_RECAPITALIZE_MODE); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/internal/MoreKeySpecSplitTests.java b/tests/src/org/kelar/inputmethod/keyboard/internal/MoreKeySpecSplitTests.java new file mode 100644 index 000000000..ca7c96a38 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/internal/MoreKeySpecSplitTests.java @@ -0,0 +1,287 @@ +/* + * Copyright (C) 2010 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 org.kelar.inputmethod.keyboard.internal; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import android.content.Context; +import android.content.res.Resources; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; + +import org.kelar.inputmethod.latin.R; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.Arrays; +import java.util.Locale; + +@SmallTest +@RunWith(AndroidJUnit4.class) +public class MoreKeySpecSplitTests { + private static final Locale TEST_LOCALE = Locale.ENGLISH; + private final KeyboardTextsSet mTextsSet = new KeyboardTextsSet(); + + @Before + public void setUp() throws Exception { + final Context targetContext = InstrumentationRegistry.getTargetContext(); + final Resources targetRes = targetContext.getResources(); + final String targetPackageName = targetRes.getResourcePackageName( + R.string.english_ime_name); + mTextsSet.setLocale(TEST_LOCALE, targetRes, targetPackageName); + } + + static <T> void assertArrayEquals(final String message, final T[] expected, final T[] actual) { + if (expected == actual) { + return; + } + if (expected == null || actual == null) { + assertEquals(message, Arrays.toString(expected), Arrays.toString(actual)); + return; + } + if (expected.length != actual.length) { + assertEquals(message + " [length]", Arrays.toString(expected), Arrays.toString(actual)); + return; + } + for (int i = 0; i < expected.length; i++) { + final T e = expected[i]; + final T a = actual[i]; + if (e == a) { + continue; + } + assertEquals(message + " [" + i + "]", e, a); + } + } + + private void assertTextArray(final String message, final String value, + final String ... expectedArray) { + final String resolvedActual = mTextsSet.resolveTextReference(value); + final String[] actual = MoreKeySpec.splitKeySpecs(resolvedActual); + final String[] expected = (expectedArray.length == 0) ? null : expectedArray; + assertArrayEquals(message, expected, actual); + } + + private void assertError(final String message, final String value, final String ... expected) { + try { + assertTextArray(message, value, expected); + fail(message); + } catch (Exception pcpe) { + // success. + } + } + + // \U001d11e: MUSICAL SYMBOL G CLEF + private static final String PAIR1 = "\ud834\udd1e"; + // \U001d122: MUSICAL SYMBOL F CLEF + private static final String PAIR2 = "\ud834\udd22"; + // \U002f8a6: CJK COMPATIBILITY IDEOGRAPH-2F8A6; variant character of \u6148. + private static final String PAIR3 = "\ud87e\udca6"; + private static final String SURROGATE1 = PAIR1 + PAIR2; + private static final String SURROGATE2 = PAIR1 + PAIR2 + PAIR3; + + @Test + public void testSplitZero() { + assertTextArray("Empty string", ""); + assertTextArray("Empty entry", ","); + assertTextArray("Empty entry at beginning", ",a", "a"); + assertTextArray("Empty entry at end", "a,", "a"); + assertTextArray("Empty entry at middle", "a,,b", "a", "b"); + assertTextArray("Empty entries with escape", ",a,b\\,c,,d,", "a", "b\\,c", "d"); + } + + @Test + public void testSplitSingle() { + assertTextArray("Single char", "a", "a"); + assertTextArray("Surrogate pair", PAIR1, PAIR1); + assertTextArray("Single escape", "\\", "\\"); + assertTextArray("Space", " ", " "); + assertTextArray("Single label", "abc", "abc"); + assertTextArray("Single surrogate pairs label", SURROGATE2, SURROGATE2); + assertTextArray("Spaces", " ", " "); + assertTextArray("Spaces in label", "a b c", "a b c"); + assertTextArray("Spaces at beginning of label", " abc", " abc"); + assertTextArray("Spaces at end of label", "abc ", "abc "); + assertTextArray("Label surrounded by spaces", " abc ", " abc "); + assertTextArray("Surrogate pair surrounded by space", + " " + PAIR1 + " ", + " " + PAIR1 + " "); + assertTextArray("Surrogate pair within characters", + "ab" + PAIR2 + "cd", + "ab" + PAIR2 + "cd"); + assertTextArray("Surrogate pairs within characters", + "ab" + SURROGATE1 + "cd", + "ab" + SURROGATE1 + "cd"); + + assertTextArray("Incomplete resource reference 1", "text", "text"); + assertTextArray("Incomplete resource reference 2", "!text", "!text"); + assertTextArray("Incomplete RESOURCE REFERENCE 2", "!TEXT", "!TEXT"); + assertTextArray("Incomplete resource reference 3", "text/", "text/"); + assertTextArray("Incomplete resource reference 4", "!" + SURROGATE2, "!" + SURROGATE2); + } + + @Test + public void testSplitSingleEscaped() { + assertTextArray("Escaped char", "\\a", "\\a"); + assertTextArray("Escaped surrogate pair", "\\" + PAIR1, "\\" + PAIR1); + assertTextArray("Escaped comma", "\\,", "\\,"); + assertTextArray("Escaped comma escape", "a\\,\\", "a\\,\\"); + assertTextArray("Escaped escape", "\\\\", "\\\\"); + assertTextArray("Escaped label", "a\\bc", "a\\bc"); + assertTextArray("Escaped surrogate", "a\\" + PAIR1 + "c", "a\\" + PAIR1 + "c"); + assertTextArray("Escaped label at beginning", "\\abc", "\\abc"); + assertTextArray("Escaped surrogate at beginning", "\\" + SURROGATE2, "\\" + SURROGATE2); + assertTextArray("Escaped label at end", "abc\\", "abc\\"); + assertTextArray("Escaped surrogate at end", SURROGATE2 + "\\", SURROGATE2 + "\\"); + assertTextArray("Escaped label with comma", "a\\,c", "a\\,c"); + assertTextArray("Escaped surrogate with comma", + PAIR1 + "\\," + PAIR2, PAIR1 + "\\," + PAIR2); + assertTextArray("Escaped label with comma at beginning", "\\,bc", "\\,bc"); + assertTextArray("Escaped surrogate with comma at beginning", + "\\," + SURROGATE1, "\\," + SURROGATE1); + assertTextArray("Escaped label with comma at end", "ab\\,", "ab\\,"); + assertTextArray("Escaped surrogate with comma at end", + SURROGATE2 + "\\,", SURROGATE2 + "\\,"); + assertTextArray("Escaped label with successive", "\\,\\\\bc", "\\,\\\\bc"); + assertTextArray("Escaped surrogate with successive", + "\\,\\\\" + SURROGATE1, "\\,\\\\" + SURROGATE1); + assertTextArray("Escaped label with escape", "a\\\\c", "a\\\\c"); + assertTextArray("Escaped surrogate with escape", + PAIR1 + "\\\\" + PAIR2, PAIR1 + "\\\\" + PAIR2); + + assertTextArray("Escaped !text", "\\!text", "\\!text"); + assertTextArray("Escaped !text/", "\\!text/", "\\!text/"); + assertTextArray("Escaped !TEXT/", "\\!TEXT/", "\\!TEXT/"); + assertTextArray("Escaped !text/name", "\\!text/empty_string", "\\!text/empty_string"); + assertTextArray("Escaped !TEXT/NAME", "\\!TEXT/EMPTY_STRING", "\\!TEXT/EMPTY_STRING"); + } + + @Test + public void testSplitMulti() { + assertTextArray("Multiple chars", "a,b,c", "a", "b", "c"); + assertTextArray("Multiple chars", "a,b,\\c", "a", "b", "\\c"); + assertTextArray("Multiple chars and escape at beginning and end", + "\\a,b,\\c\\", "\\a", "b", "\\c\\"); + assertTextArray("Multiple surrogates", PAIR1 + "," + PAIR2 + "," + PAIR3, + PAIR1, PAIR2, PAIR3); + assertTextArray("Multiple chars surrounded by spaces", " a , b , c ", " a ", " b ", " c "); + assertTextArray("Multiple labels", "abc,def,ghi", "abc", "def", "ghi"); + assertTextArray("Multiple surrogated", SURROGATE1 + "," + SURROGATE2, + SURROGATE1, SURROGATE2); + assertTextArray("Multiple labels surrounded by spaces", " abc , def , ghi ", + " abc ", " def ", " ghi "); + } + + @Test + public void testSplitMultiEscaped() { + assertTextArray("Multiple chars with comma", "a,\\,,c", "a", "\\,", "c"); + assertTextArray("Multiple chars with comma surrounded by spaces", " a , \\, , c ", + " a ", " \\, ", " c "); + assertTextArray("Multiple labels with escape", + "\\abc,d\\ef,gh\\i", "\\abc", "d\\ef", "gh\\i"); + assertTextArray("Multiple labels with escape surrounded by spaces", + " \\abc , d\\ef , gh\\i ", " \\abc ", " d\\ef ", " gh\\i "); + assertTextArray("Multiple labels with comma and escape", + "ab\\\\,d\\\\\\,,g\\,i", "ab\\\\", "d\\\\\\,", "g\\,i"); + assertTextArray("Multiple labels with comma and escape surrounded by spaces", + " ab\\\\ , d\\\\\\, , g\\,i ", " ab\\\\ ", " d\\\\\\, ", " g\\,i "); + + assertTextArray("Multiple escaped !text", "\\!,\\!text/empty_string", + "\\!", "\\!text/empty_string"); + assertTextArray("Multiple escaped !TEXT", "\\!,\\!TEXT/EMPTY_STRING", + "\\!", "\\!TEXT/EMPTY_STRING"); + } + + @Test + public void testSplitTextReferenceError() { + assertError("Incomplete text name", "!text/", "!text/"); + assertError("Non existing text", "!text/non_existing"); + } + + @Test + public void testSplitEmptyTextReference() { + // Note that morekeys_q of English locale is empty. + assertTextArray("Empty string", "!text/morekeys_q"); + } + + @Test + public void testLabelReferece() { + assertTextArray("Label time am", "!text/keylabel_time_am", "AM"); + + assertTextArray("More keys for am pm", "!text/morekeys_am_pm", + "!fixedColumnOrder!2", "!hasLabels!", "AM", "PM"); + + assertTextArray("Settings as more key", "!text/keyspec_settings", + "!icon/settings_key|!code/key_settings"); + } + + @Test + public void testUselessUpperCaseSpecifier() { + assertTextArray("EMPTY STRING", + "!TEXT/EMPTY_STRING", "!TEXT/EMPTY_STRING"); + + assertTextArray("SINGLE CHAR", + "!TEXT/SINGLE_CHAR", "!TEXT/SINGLE_CHAR"); + assertTextArray("Escape and SINGLE CHAR", + "\\\\!TEXT/SINGLE_CHAR", "\\\\!TEXT/SINGLE_CHAR"); + + assertTextArray("MULTIPLE CHARS", + "!TEXT/MULTIPLE_CHARS", "!TEXT/MULTIPLE_CHARS"); + + assertTextArray("Literals and RESOURCES", + "1,!TEXT/MULTIPLE_CHARS,z", "1", "!TEXT/MULTIPLE_CHARS", "z"); + assertTextArray("Multiple single RESOURCE chars and LABELS 2", + "!TEXT/SINGLE_CHAR,!TEXT/SINGLE_LABEL,!TEXT/ESCAPED_COMMA_ESCAPE", + "!TEXT/SINGLE_CHAR", "!TEXT/SINGLE_LABEL", "!TEXT/ESCAPED_COMMA_ESCAPE"); + + assertTextArray("INDIRECT", + "!TEXT/INDIRECT_STRING", "!TEXT/INDIRECT_STRING"); + assertTextArray("INDIRECT with literal", + "1,!TEXT/INDIRECT_STRING_WITH_LITERAL,2", + "1", "!TEXT/INDIRECT_STRING_WITH_LITERAL", "2"); + assertTextArray("INDIRECT2", + "!TEXT/INDIRECT2_STRING", "!TEXT/INDIRECT2_STRING"); + + assertTextArray("UPPER INDIRECT", + "!TEXT/upper_INDIRECT_STRING", "!TEXT/upper_INDIRECT_STRING"); + assertTextArray("Upper INDIRECT with literal", + "1,!TEXT/upper_INDIRECT_STRING_WITH_LITERAL,2", + "1", "!TEXT/upper_INDIRECT_STRING_WITH_LITERAL", "2"); + assertTextArray("Upper INDIRECT2", + "!TEXT/upper_INDIRECT2_STRING", "!TEXT/upper_INDIRECT2_STRING"); + + assertTextArray("INFINITE INDIRECTION", + "1,!TEXT/INFINITE_INDIRECTION,2", "1", "!TEXT/INFINITE_INDIRECTION", "2"); + + assertTextArray("Upper INFINITE INDIRECTION", + "1,!TEXT/UPPER_INFINITE_INDIRECTION,2", + "1", "!TEXT/UPPER_INFINITE_INDIRECTION", "2"); + + assertTextArray("LABEL TIME AM", "!TEXT/LABEL_TIME_AM", "!TEXT/LABEL_TIME_AM"); + assertTextArray("MORE KEYS FOR AM OM", "!TEXT/MORE_KEYS_FOR_AM_PM", + "!TEXT/MORE_KEYS_FOR_AM_PM"); + assertTextArray("SETTINGS AS MORE KEY", "!TEXT/SETTINGS_AS_MORE_KEY", + "!TEXT/SETTINGS_AS_MORE_KEY"); + assertTextArray("INDIRECT NAVIGATE ACTIONS AS MORE KEY", + "!TEXT/INDIRECT_NAVIGATE_ACTIONS_AS_MORE_KEY", + "!TEXT/INDIRECT_NAVIGATE_ACTIONS_AS_MORE_KEY"); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/internal/MoreKeySpecStringReferenceTests.java b/tests/src/org/kelar/inputmethod/keyboard/internal/MoreKeySpecStringReferenceTests.java new file mode 100644 index 000000000..0faf9cdc9 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/internal/MoreKeySpecStringReferenceTests.java @@ -0,0 +1,307 @@ +/* + * 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 org.kelar.inputmethod.keyboard.internal; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import android.app.Instrumentation; +import android.content.Context; +import android.content.res.Resources; + +import androidx.test.InstrumentationRegistry; +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; + +import org.kelar.inputmethod.latin.tests.R; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; + +import java.util.Locale; + +@SmallTest +@RunWith(AndroidJUnit4.class) +public class MoreKeySpecStringReferenceTests { + private static final Locale TEST_LOCALE = Locale.ENGLISH; + private final KeyboardTextsSet mTextsSet = new KeyboardTextsSet(); + + @Before + public void setUp() throws Exception { + final Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation(); + final Context testContext = instrumentation.getContext(); + final Resources testRes = testContext.getResources(); + final String testPackageName = testRes.getResourcePackageName(R.string.empty_string); + mTextsSet.setLocale(TEST_LOCALE, testRes, testPackageName); + } + + private void assertTextArray(final String message, final String value, + final String ... expectedArray) { + final String resolvedActual = mTextsSet.resolveTextReference(value); + final String[] actual = MoreKeySpec.splitKeySpecs(resolvedActual); + final String[] expected = (expectedArray.length == 0) ? null : expectedArray; + MoreKeySpecSplitTests.assertArrayEquals(message, expected, actual); + } + + private void assertError(final String message, final String value, final String ... expected) { + try { + assertTextArray(message, value, expected); + fail(message); + } catch (Exception pcpe) { + // success. + } + } + + @Test + public void testResolveNullText() { + assertEquals("resolve null", + mTextsSet.resolveTextReference(null), null); + } + + @Test + public void testResolveEmptyText() { + assertEquals("resolve empty text", + mTextsSet.resolveTextReference("!string/empty_string"), null); + } + + @Test + public void testSplitSingleEscaped() { + assertTextArray("Escaped !string", "\\!string", + "\\!string"); + assertTextArray("Escaped !string/", "\\!string/", + "\\!string/"); + assertTextArray("Escaped !STRING/", "\\!STRING/", + "\\!STRING/"); + assertTextArray("Escaped !string/name", "\\!string/empty_string", + "\\!string/empty_string"); + assertTextArray("Escaped !STRING/NAME", "\\!STRING/EMPTY_STRING", + "\\!STRING/EMPTY_STRING"); + } + + @Test + public void testSplitMultiEscaped() { + assertTextArray("Multiple escaped !string", "\\!,\\!string/empty_string", + "\\!", "\\!string/empty_string"); + assertTextArray("Multiple escaped !STRING", "\\!,\\!STRING/EMPTY_STRING", + "\\!", "\\!STRING/EMPTY_STRING"); + } + + @Test + public void testSplitStringReferenceError() { + assertError("Incomplete resource name", "!string/", "!string/"); + assertError("Non existing resource", "!string/non_existing"); + } + + @Test + public void testSplitEmptyStringReference() { + assertTextArray("Empty string", "!string/empty_string"); + } + + @Test + public void testSplitResourceSingle() { + assertTextArray("Single char", "!string/single_char", + "a"); + assertTextArray("Space", "!string/space", + " "); + assertTextArray("Single label", "!string/single_label", + "abc"); + assertTextArray("Spaces", "!string/spaces", + " "); + assertTextArray("Spaces in label", "!string/spaces_in_label", + "a b c"); + assertTextArray("Spaces at beginning of label", "!string/spaces_at_beginning_of_label", + " abc"); + assertTextArray("Spaces at end of label", "!string/spaces_at_end_of_label", + "abc "); + assertTextArray("label surrounded by spaces", "!string/label_surrounded_by_spaces", + " abc "); + assertTextArray("Escape and single char", "\\\\!string/single_char", + "\\\\a"); + } + + @Test + public void testSplitResourceSingleEscaped() { + assertTextArray("Escaped char", + "!string/escaped_char", "\\a"); + assertTextArray("Escaped comma", + "!string/escaped_comma", "\\,"); + assertTextArray("Escaped comma escape", + "!string/escaped_comma_escape", "a\\,\\"); + assertTextArray("Escaped escape", + "!string/escaped_escape", "\\\\"); + assertTextArray("Escaped label", + "!string/escaped_label", "a\\bc"); + assertTextArray("Escaped label at beginning", + "!string/escaped_label_at_beginning", "\\abc"); + assertTextArray("Escaped label at end", + "!string/escaped_label_at_end", "abc\\"); + assertTextArray("Escaped label with comma", + "!string/escaped_label_with_comma", "a\\,c"); + assertTextArray("Escaped label with comma at beginning", + "!string/escaped_label_with_comma_at_beginning", "\\,bc"); + assertTextArray("Escaped label with comma at end", + "!string/escaped_label_with_comma_at_end", "ab\\,"); + assertTextArray("Escaped label with successive", + "!string/escaped_label_with_successive", "\\,\\\\bc"); + assertTextArray("Escaped label with escape", + "!string/escaped_label_with_escape", "a\\\\c"); + } + + @Test + public void testSplitResourceMulti() { + assertTextArray("Multiple chars", + "!string/multiple_chars", "a", "b", "c"); + assertTextArray("Multiple chars surrounded by spaces", + "!string/multiple_chars_surrounded_by_spaces", + " a ", " b ", " c "); + assertTextArray("Multiple labels", + "!string/multiple_labels", "abc", "def", "ghi"); + assertTextArray("Multiple labels surrounded by spaces", + "!string/multiple_labels_surrounded_by_spaces", " abc ", " def ", " ghi "); + } + + @Test + public void testSplitResourcetMultiEscaped() { + assertTextArray("Multiple chars with comma", + "!string/multiple_chars_with_comma", + "a", "\\,", "c"); + assertTextArray("Multiple chars with comma surrounded by spaces", + "!string/multiple_chars_with_comma_surrounded_by_spaces", + " a ", " \\, ", " c "); + assertTextArray("Multiple labels with escape", + "!string/multiple_labels_with_escape", + "\\abc", "d\\ef", "gh\\i"); + assertTextArray("Multiple labels with escape surrounded by spaces", + "!string/multiple_labels_with_escape_surrounded_by_spaces", + " \\abc ", " d\\ef ", " gh\\i "); + assertTextArray("Multiple labels with comma and escape", + "!string/multiple_labels_with_comma_and_escape", + "ab\\\\", "d\\\\\\,", "g\\,i"); + assertTextArray("Multiple labels with comma and escape surrounded by spaces", + "!string/multiple_labels_with_comma_and_escape_surrounded_by_spaces", + " ab\\\\ ", " d\\\\\\, ", " g\\,i "); + } + + @Test + public void testSplitMultipleResources() { + assertTextArray("Literals and resources", + "1,!string/multiple_chars,z", + "1", "a", "b", "c", "z"); + assertTextArray("Literals and resources and escape at end", + "\\1,!string/multiple_chars,z\\", + "\\1", "a", "b", "c", "z\\"); + assertTextArray("Multiple single resource chars and labels", + "!string/single_char,!string/single_label,!string/escaped_comma", + "a", "abc", "\\,"); + assertTextArray("Multiple single resource chars and labels 2", + "!string/single_char,!string/single_label,!string/escaped_comma_escape", + "a", "abc", "a\\,\\"); + assertTextArray("Multiple multiple resource chars and labels", + "!string/multiple_chars,!string/multiple_labels,!string/multiple_chars_with_comma", + "a", "b", "c", "abc", "def", "ghi", "a", "\\,", "c"); + assertTextArray("Concatenated resources", + "!string/multiple_chars!string/multiple_labels!string/multiple_chars_with_comma", + "a", "b", "cabc", "def", "ghia", "\\,", "c"); + assertTextArray("Concatenated resource and literal", + "abc!string/multiple_labels", + "abcabc", "def", "ghi"); + } + + @Test + public void testSplitIndirectReference() { + assertTextArray("Indirect", + "!string/indirect_string", "a", "b", "c"); + assertTextArray("Indirect with literal", + "1,!string/indirect_string_with_literal,2", "1", "x", "a", "b", "c", "y", "2"); + assertTextArray("Indirect2", + "!string/indirect2_string", "a", "b", "c"); + } + + @Test + public void testSplitInfiniteIndirectReference() { + assertError("Infinite indirection", + "1,!string/infinite_indirection,2", "1", "infinite", "<infinite>", "loop", "2"); + } + + @Test + public void testLabelReferece() { + assertTextArray("Indirect naviagte actions as more key", + "!string/keyspec_indirect_navigate_actions", + "!fixedColumnOrder!2", + "!hasLabels!", "ActionPrevious|!code/key_action_previous", + "!hasLabels!", "ActionNext|!code/key_action_next"); + } + + @Test + public void testUselessUpperCaseSpecifier() { + assertTextArray("EMPTY STRING", + "!STRING/EMPTY_STRING", "!STRING/EMPTY_STRING"); + + assertTextArray("SINGLE CHAR", + "!STRING/SINGLE_CHAR", "!STRING/SINGLE_CHAR"); + assertTextArray("Escape and SINGLE CHAR", + "\\\\!STRING/SINGLE_CHAR", "\\\\!STRING/SINGLE_CHAR"); + + assertTextArray("MULTIPLE CHARS", + "!STRING/MULTIPLE_CHARS", "!STRING/MULTIPLE_CHARS"); + + assertTextArray("Literals and RESOURCES", + "1,!STRING/MULTIPLE_CHARS,z", "1", "!STRING/MULTIPLE_CHARS", "z"); + assertTextArray("Multiple single RESOURCE chars and LABELS 2", + "!STRING/SINGLE_CHAR,!STRING/SINGLE_LABEL,!STRING/ESCAPED_COMMA_ESCAPE", + "!STRING/SINGLE_CHAR", "!STRING/SINGLE_LABEL", "!STRING/ESCAPED_COMMA_ESCAPE"); + + assertTextArray("INDIRECT", + "!STRING/INDIRECT_STRING", "!STRING/INDIRECT_STRING"); + assertTextArray("INDIRECT with literal", + "1,!STRING/INDIRECT_STRING_WITH_LITERAL,2", + "1", "!STRING/INDIRECT_STRING_WITH_LITERAL", "2"); + assertTextArray("INDIRECT2", + "!STRING/INDIRECT2_STRING", "!STRING/INDIRECT2_STRING"); + + assertTextArray("Upper indirect", + "!string/upper_indirect_string", "!STRING/MULTIPLE_CHARS"); + assertTextArray("Upper indirect with literal", + "1,!string/upper_indirect_string_with_literal,2", + "1", "x", "!STRING/MULTIPLE_CHARS", "y", "2"); + assertTextArray("Upper indirect2", + "!string/upper_indirect2_string", "!STRING/UPPER_INDIRECT_STRING"); + + assertTextArray("UPPER INDIRECT", + "!STRING/upper_INDIRECT_STRING", "!STRING/upper_INDIRECT_STRING"); + assertTextArray("Upper INDIRECT with literal", + "1,!STRING/upper_INDIRECT_STRING_WITH_LITERAL,2", + "1", "!STRING/upper_INDIRECT_STRING_WITH_LITERAL", "2"); + assertTextArray("Upper INDIRECT2", + "!STRING/upper_INDIRECT2_STRING", "!STRING/upper_INDIRECT2_STRING"); + + assertTextArray("INFINITE INDIRECTION", + "1,!STRING/INFINITE_INDIRECTION,2", "1", "!STRING/INFINITE_INDIRECTION", "2"); + + assertTextArray("Upper infinite indirection", + "1,!string/upper_infinite_indirection,2", + "1", "infinite", "!STRING/INFINITE_INDIRECTION", "loop", "2"); + assertTextArray("Upper INFINITE INDIRECTION", + "1,!STRING/UPPER_INFINITE_INDIRECTION,2", + "1", "!STRING/UPPER_INFINITE_INDIRECTION", "2"); + + assertTextArray("INDIRECT NAVIGATE ACTIONS AS MORE KEY", + "!STRING/INDIRECT_NAVIGATE_ACTIONS_AS_MORE_KEY", + "!STRING/INDIRECT_NAVIGATE_ACTIONS_AS_MORE_KEY"); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/internal/MoreKeySpecTests.java b/tests/src/org/kelar/inputmethod/keyboard/internal/MoreKeySpecTests.java new file mode 100644 index 000000000..b56308f5d --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/internal/MoreKeySpecTests.java @@ -0,0 +1,378 @@ +/* + * Copyright (C) 2010 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 org.kelar.inputmethod.keyboard.internal; + +import static org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet.ICON_UNDEFINED; +import static org.kelar.inputmethod.latin.common.Constants.CODE_UNSPECIFIED; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Arrays; +import java.util.Locale; + +@SmallTest +public final class MoreKeySpecTests extends KeySpecParserTestsBase { + @Override + protected void assertParser(final String message, final String moreKeySpec, + final String expectedLabel, final String expectedOutputText, final int expectedIconId, + final int expectedCode) { + final String labelResolved = mTextsSet.resolveTextReference(moreKeySpec); + final MoreKeySpec spec = new MoreKeySpec( + labelResolved, false /* needsToUpperCase */, Locale.US); + assertEquals(message + " [label]", expectedLabel, spec.mLabel); + assertEquals(message + " [ouptputText]", expectedOutputText, spec.mOutputText); + assertEquals(message + " [icon]", + KeyboardIconsSet.getIconName(expectedIconId), + KeyboardIconsSet.getIconName(spec.mIconId)); + assertEquals(message + " [code]", + Constants.printableCode(expectedCode), + Constants.printableCode(spec.mCode)); + } + + // TODO: Move this method to {@link KeySpecParserBase}. + public void testEmptySpec() { + assertParserError("Null spec", null, + null, null, ICON_UNDEFINED, CODE_UNSPECIFIED); + assertParserError("Empty spec", "", + null, null, ICON_UNDEFINED, CODE_UNSPECIFIED); + } + + private static void assertArrayEquals(final String message, final Object[] expected, + final Object[] actual) { + if (expected == actual) { + return; + } + if (expected == null || actual == null) { + assertEquals(message, Arrays.toString(expected), Arrays.toString(actual)); + return; + } + if (expected.length != actual.length) { + assertEquals(message + " [length]", Arrays.toString(expected), Arrays.toString(actual)); + return; + } + for (int i = 0; i < expected.length; i++) { + assertEquals(message + " [" + i + "]", + Arrays.toString(expected), Arrays.toString(actual)); + } + } + + private static void assertInsertAdditionalMoreKeys(final String message, + final String[] moreKeys, final String[] additionalMoreKeys, final String[] expected) { + final String[] actual = MoreKeySpec.insertAdditionalMoreKeys(moreKeys, additionalMoreKeys); + assertArrayEquals(message, expected, actual); + } + + @SuppressWarnings("static-method") + public void testEmptyEntry() { + assertInsertAdditionalMoreKeys("null more keys and null additons", + null, + null, + null); + assertInsertAdditionalMoreKeys("null more keys and empty additons", + null, + new String[0], + null); + assertInsertAdditionalMoreKeys("empty more keys and null additons", + new String[0], + null, + null); + assertInsertAdditionalMoreKeys("empty more keys and empty additons", + new String[0], + new String[0], + null); + + assertInsertAdditionalMoreKeys("filter out empty more keys", + new String[] { null, "a", "", "b", null }, + null, + new String[] { "a", "b" }); + assertInsertAdditionalMoreKeys("filter out empty additons", + new String[] { "a", "%", "b", "%", "c", "%", "d" }, + new String[] { null, "A", "", "B", null }, + new String[] { "a", "A", "b", "B", "c", "d" }); + } + + @SuppressWarnings("static-method") + public void testInsertAdditionalMoreKeys() { + // Escaped marker. + assertInsertAdditionalMoreKeys("escaped marker", + new String[] { "\\%", "%-)" }, + new String[] { "1", "2" }, + new String[] { "1", "2", "\\%", "%-)" }); + + // 0 more key. + assertInsertAdditionalMoreKeys("null & null", null, null, null); + assertInsertAdditionalMoreKeys("null & 1 additon", + null, + new String[] { "1" }, + new String[] { "1" }); + assertInsertAdditionalMoreKeys("null & 2 additons", + null, + new String[] { "1", "2" }, + new String[] { "1", "2" }); + + // 0 additional more key. + assertInsertAdditionalMoreKeys("1 more key & null", + new String[] { "A" }, + null, + new String[] { "A" }); + assertInsertAdditionalMoreKeys("2 more keys & null", + new String[] { "A", "B" }, + null, + new String[] { "A", "B" }); + + // No marker. + assertInsertAdditionalMoreKeys("1 more key & 1 addtional & no marker", + new String[] { "A" }, + new String[] { "1" }, + new String[] { "1", "A" }); + assertInsertAdditionalMoreKeys("1 more key & 2 addtionals & no marker", + new String[] { "A" }, + new String[] { "1", "2" }, + new String[] { "1", "2", "A" }); + assertInsertAdditionalMoreKeys("2 more keys & 1 addtional & no marker", + new String[] { "A", "B" }, + new String[] { "1" }, + new String[] { "1", "A", "B" }); + assertInsertAdditionalMoreKeys("2 more keys & 2 addtionals & no marker", + new String[] { "A", "B" }, + new String[] { "1", "2" }, + new String[] { "1", "2", "A", "B" }); + + // 1 marker. + assertInsertAdditionalMoreKeys("1 more key & 1 additon & marker at head", + new String[] { "%", "A" }, + new String[] { "1" }, + new String[] { "1", "A" }); + assertInsertAdditionalMoreKeys("1 more key & 1 additon & marker at tail", + new String[] { "A", "%" }, + new String[] { "1" }, + new String[] { "A", "1" }); + assertInsertAdditionalMoreKeys("2 more keys & 1 additon & marker at middle", + new String[] { "A", "%", "B" }, + new String[] { "1" }, + new String[] { "A", "1", "B" }); + + // 1 marker & excess additional more keys. + assertInsertAdditionalMoreKeys("1 more key & 2 additons & marker at head", + new String[] { "%", "A", "B" }, + new String[] { "1", "2" }, + new String[] { "1", "A", "B", "2" }); + assertInsertAdditionalMoreKeys("1 more key & 2 additons & marker at tail", + new String[] { "A", "B", "%" }, + new String[] { "1", "2" }, + new String[] { "A", "B", "1", "2" }); + assertInsertAdditionalMoreKeys("2 more keys & 2 additons & marker at middle", + new String[] { "A", "%", "B" }, + new String[] { "1", "2" }, + new String[] { "A", "1", "B", "2" }); + + // 2 markers. + assertInsertAdditionalMoreKeys("0 more key & 2 addtional & 2 markers", + new String[] { "%", "%" }, + new String[] { "1", "2" }, + new String[] { "1", "2" }); + assertInsertAdditionalMoreKeys("1 more key & 2 addtional & 2 markers at head", + new String[] { "%", "%", "A" }, + new String[] { "1", "2" }, + new String[] { "1", "2", "A" }); + assertInsertAdditionalMoreKeys("1 more key & 2 addtional & 2 markers at tail", + new String[] { "A", "%", "%" }, + new String[] { "1", "2" }, + new String[] { "A", "1", "2" }); + assertInsertAdditionalMoreKeys("2 more keys & 2 addtional & 2 markers at middle", + new String[] { "A", "%", "%", "B" }, + new String[] { "1", "2" }, + new String[] { "A", "1", "2", "B" }); + assertInsertAdditionalMoreKeys("2 more keys & 2 addtional & 2 markers at head & middle", + new String[] { "%", "A", "%", "B" }, + new String[] { "1", "2" }, + new String[] { "1", "A", "2", "B" }); + assertInsertAdditionalMoreKeys("2 more keys & 2 addtional & 2 markers at head & tail", + new String[] { "%", "A", "B", "%" }, + new String[] { "1", "2" }, + new String[] { "1", "A", "B", "2" }); + assertInsertAdditionalMoreKeys("2 more keys & 2 addtional & 2 markers at middle & tail", + new String[] { "A", "%", "B", "%" }, + new String[] { "1", "2" }, + new String[] { "A", "1", "B", "2" }); + + // 2 markers & excess additional more keys. + assertInsertAdditionalMoreKeys("0 more key & 2 additons & 2 markers", + new String[] { "%", "%" }, + new String[] { "1", "2", "3" }, + new String[] { "1", "2", "3" }); + assertInsertAdditionalMoreKeys("1 more key & 2 additons & 2 markers at head", + new String[] { "%", "%", "A" }, + new String[] { "1", "2", "3" }, + new String[] { "1", "2", "A", "3" }); + assertInsertAdditionalMoreKeys("1 more key & 2 additons & 2 markers at tail", + new String[] { "A", "%", "%" }, + new String[] { "1", "2", "3" }, + new String[] { "A", "1", "2", "3" }); + assertInsertAdditionalMoreKeys("2 more keys & 2 additons & 2 markers at middle", + new String[] { "A", "%", "%", "B" }, + new String[] { "1", "2", "3" }, + new String[] { "A", "1", "2", "B", "3" }); + assertInsertAdditionalMoreKeys("2 more keys & 2 additons & 2 markers at head & middle", + new String[] { "%", "A", "%", "B" }, + new String[] { "1", "2", "3" }, + new String[] { "1", "A", "2", "B", "3" }); + assertInsertAdditionalMoreKeys("2 more keys & 2 additons & 2 markers at head & tail", + new String[] { "%", "A", "B", "%" }, + new String[] { "1", "2", "3" }, + new String[] { "1", "A", "B", "2", "3" }); + assertInsertAdditionalMoreKeys("2 more keys & 2 additons & 2 markers at middle & tail", + new String[] { "A", "%", "B", "%" }, + new String[] { "1", "2", "3" }, + new String[] { "A", "1", "B", "2", "3" }); + + // 0 addtional more key and excess markers. + assertInsertAdditionalMoreKeys("0 more key & null & excess marker", + new String[] { "%" }, + null, + null); + assertInsertAdditionalMoreKeys("1 more key & null & excess marker at head", + new String[] { "%", "A" }, + null, + new String[] { "A" }); + assertInsertAdditionalMoreKeys("1 more key & null & excess marker at tail", + new String[] { "A", "%" }, + null, + new String[] { "A" }); + assertInsertAdditionalMoreKeys("2 more keys & null & excess marker at middle", + new String[] { "A", "%", "B" }, + null, + new String[] { "A", "B" }); + assertInsertAdditionalMoreKeys("2 more keys & null & excess markers", + new String[] { "%", "A", "%", "B", "%" }, + null, + new String[] { "A", "B" }); + + // Excess markers. + assertInsertAdditionalMoreKeys("0 more key & 1 additon & excess marker", + new String[] { "%", "%" }, + new String[] { "1" }, + new String[] { "1" }); + assertInsertAdditionalMoreKeys("1 more key & 1 additon & excess marker at head", + new String[] { "%", "%", "A" }, + new String[] { "1" }, + new String[] { "1", "A" }); + assertInsertAdditionalMoreKeys("1 more key & 1 additon & excess marker at tail", + new String[] { "A", "%", "%" }, + new String[] { "1" }, + new String[] { "A", "1" }); + assertInsertAdditionalMoreKeys("2 more keys & 1 additon & excess marker at middle", + new String[] { "A", "%", "%", "B" }, + new String[] { "1" }, + new String[] { "A", "1", "B" }); + assertInsertAdditionalMoreKeys("2 more keys & 1 additon & excess markers", + new String[] { "%", "A", "%", "B", "%" }, + new String[] { "1" }, + new String[] { "1", "A", "B" }); + assertInsertAdditionalMoreKeys("2 more keys & 2 additons & excess markers", + new String[] { "%", "A", "%", "B", "%" }, + new String[] { "1", "2" }, + new String[] { "1", "A", "2", "B" }); + assertInsertAdditionalMoreKeys("2 more keys & 3 additons & excess markers", + new String[] { "%", "A", "%", "%", "B", "%" }, + new String[] { "1", "2", "3" }, + new String[] { "1", "A", "2", "3", "B" }); + } + + private static final String HAS_LABEL = "!hasLabel!"; + private static final String NEEDS_DIVIDER = "!needsDividers!"; + private static final String AUTO_COLUMN_ORDER = "!autoColumnOrder!"; + private static final String FIXED_COLUMN_ORDER = "!fixedColumnOrder!"; + + private static void assertGetBooleanValue(final String message, final String key, + final String[] moreKeys, final String[] expected, final boolean expectedValue) { + final String[] actual = Arrays.copyOf(moreKeys, moreKeys.length); + final boolean actualValue = MoreKeySpec.getBooleanValue(actual, key); + assertEquals(message + " [value]", expectedValue, actualValue); + assertArrayEquals(message, expected, actual); + } + + @SuppressWarnings("static-method") + public void testGetBooleanValue() { + assertGetBooleanValue("Has label", HAS_LABEL, + new String[] { HAS_LABEL, "a", "b", "c" }, + new String[] { null, "a", "b", "c" }, true); + // Upper case specification will not work. + assertGetBooleanValue("HAS LABEL", HAS_LABEL, + new String[] { HAS_LABEL.toUpperCase(Locale.ROOT), "a", "b", "c" }, + new String[] { "!HASLABEL!", "a", "b", "c" }, false); + + assertGetBooleanValue("No has label", HAS_LABEL, + new String[] { "a", "b", "c" }, + new String[] { "a", "b", "c" }, false); + assertGetBooleanValue("No has label with fixed clumn order", HAS_LABEL, + new String[] { FIXED_COLUMN_ORDER + "3", "a", "b", "c" }, + new String[] { FIXED_COLUMN_ORDER + "3", "a", "b", "c" }, false); + + // Upper case specification will not work. + assertGetBooleanValue("Multiple has label", HAS_LABEL, + new String[] { + "a", HAS_LABEL.toUpperCase(Locale.ROOT), "b", "c", HAS_LABEL, "d" }, + new String[] { + "a", "!HASLABEL!", "b", "c", null, "d" }, true); + // Upper case specification will not work. + assertGetBooleanValue("Multiple has label with needs dividers", HAS_LABEL, + new String[] { + "a", HAS_LABEL, "b", NEEDS_DIVIDER, HAS_LABEL.toUpperCase(Locale.ROOT), "d" }, + new String[] { + "a", null, "b", NEEDS_DIVIDER, "!HASLABEL!", "d" }, true); + } + + private static void assertGetIntValue(final String message, final String key, + final int defaultValue, final String[] moreKeys, final String[] expected, + final int expectedValue) { + final String[] actual = Arrays.copyOf(moreKeys, moreKeys.length); + final int actualValue = MoreKeySpec.getIntValue(actual, key, defaultValue); + assertEquals(message + " [value]", expectedValue, actualValue); + assertArrayEquals(message, expected, actual); + } + + @SuppressWarnings("static-method") + public void testGetIntValue() { + assertGetIntValue("Fixed column order 3", FIXED_COLUMN_ORDER, -1, + new String[] { FIXED_COLUMN_ORDER + "3", "a", "b", "c" }, + new String[] { null, "a", "b", "c" }, 3); + // Upper case specification will not work. + assertGetIntValue("FIXED COLUMN ORDER 3", FIXED_COLUMN_ORDER, -1, + new String[] { FIXED_COLUMN_ORDER.toUpperCase(Locale.ROOT) + "3", "a", "b", "c" }, + new String[] { "!FIXEDCOLUMNORDER!3", "a", "b", "c" }, -1); + + assertGetIntValue("No fixed column order", FIXED_COLUMN_ORDER, -1, + new String[] { "a", "b", "c" }, + new String[] { "a", "b", "c" }, -1); + assertGetIntValue("No fixed column order with auto column order", FIXED_COLUMN_ORDER, -1, + new String[] { AUTO_COLUMN_ORDER + "5", "a", "b", "c" }, + new String[] { AUTO_COLUMN_ORDER + "5", "a", "b", "c" }, -1); + + assertGetIntValue("Multiple fixed column order 3,5", FIXED_COLUMN_ORDER, -1, + new String[] { FIXED_COLUMN_ORDER + "3", "a", FIXED_COLUMN_ORDER + "5", "b" }, + new String[] { null, "a", null, "b" }, 3); + // Upper case specification will not work. + assertGetIntValue("Multiple fixed column order 5,3 with has label", FIXED_COLUMN_ORDER, -1, + new String[] { + FIXED_COLUMN_ORDER.toUpperCase(Locale.ROOT) + "5", HAS_LABEL, "a", + FIXED_COLUMN_ORDER + "3", "b" }, + new String[] { "!FIXEDCOLUMNORDER!5", HAS_LABEL, "a", null, "b" }, 3); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/internal/PointerTrackerQueueTests.java b/tests/src/org/kelar/inputmethod/keyboard/internal/PointerTrackerQueueTests.java new file mode 100644 index 000000000..e491ca955 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/internal/PointerTrackerQueueTests.java @@ -0,0 +1,342 @@ +/* + * Copyright (C) 2012 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 org.kelar.inputmethod.keyboard.internal; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@SmallTest +@RunWith(AndroidJUnit4.class) +public class PointerTrackerQueueTests { + public static class Element implements PointerTrackerQueue.Element { + public static int sPhantomUpCount; + public static final long NOT_HAPPENED = -1; + + public final int mId; + public boolean mIsModifier; + public boolean mIsInDraggingFinger; + public long mPhantomUpEventTime = NOT_HAPPENED; + + public Element(int id) { + mId = id; + } + + @Override + public boolean isModifier() { + return mIsModifier; + } + + @Override + public boolean isInDraggingFinger() { + return mIsInDraggingFinger; + } + + @Override + public void onPhantomUpEvent(long eventTime) { + sPhantomUpCount++; + mPhantomUpEventTime = eventTime + sPhantomUpCount; + } + + @Override + public void cancelTrackingForAction() {} + + @Override + public String toString() { + return Integer.toString(mId); + } + } + + private final Element mElement1 = new Element(1); + private final Element mElement2 = new Element(2); + private final Element mElement3 = new Element(3); + private final Element mElement4 = new Element(4); + private final PointerTrackerQueue mQueue = new PointerTrackerQueue(); + + @Test + public void testEmpty() { + assertEquals(0, mQueue.size()); + assertEquals("[]", mQueue.toString()); + } + + @Test + public void testAdd() { + mQueue.add(mElement1); + assertEquals(1, mQueue.size()); + assertEquals("[1]", mQueue.toString()); + mQueue.add(mElement2); + assertEquals(2, mQueue.size()); + assertEquals("[1 2]", mQueue.toString()); + mQueue.add(mElement3); + assertEquals(3, mQueue.size()); + assertEquals("[1 2 3]", mQueue.toString()); + mQueue.add(mElement4); + assertEquals(4, mQueue.size()); + assertEquals("[1 2 3 4]", mQueue.toString()); + } + + @Test + public void testRemove() { + Element.sPhantomUpCount = 0; + + mQueue.add(mElement1); + mQueue.add(mElement2); + mQueue.add(mElement3); + mQueue.add(mElement4); + + mQueue.remove(mElement2); + assertEquals(3, mQueue.size()); + assertEquals("[1 3 4]", mQueue.toString()); + mQueue.remove(mElement4); + assertEquals(2, mQueue.size()); + assertEquals("[1 3]", mQueue.toString()); + mQueue.remove(mElement4); + assertEquals(2, mQueue.size()); + assertEquals("[1 3]", mQueue.toString()); + mQueue.remove(mElement1); + assertEquals(1, mQueue.size()); + assertEquals("[3]", mQueue.toString()); + mQueue.remove(mElement3); + assertEquals(0, mQueue.size()); + assertEquals("[]", mQueue.toString()); + mQueue.remove(mElement1); + assertEquals(0, mQueue.size()); + assertEquals("[]", mQueue.toString()); + + assertEquals(0, Element.sPhantomUpCount); + assertEquals(Element.NOT_HAPPENED, mElement1.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement2.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement3.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement4.mPhantomUpEventTime); + } + + @Test + public void testAddAndRemove() { + Element.sPhantomUpCount = 0; + + mQueue.add(mElement1); + mQueue.add(mElement2); + mQueue.add(mElement3); + mQueue.add(mElement4); + + mQueue.remove(mElement2); + assertEquals(3, mQueue.size()); + assertEquals("[1 3 4]", mQueue.toString()); + mQueue.remove(mElement4); + assertEquals(2, mQueue.size()); + assertEquals("[1 3]", mQueue.toString()); + mQueue.add(mElement2); + assertEquals(3, mQueue.size()); + assertEquals("[1 3 2]", mQueue.toString()); + mQueue.remove(mElement4); + assertEquals(3, mQueue.size()); + assertEquals("[1 3 2]", mQueue.toString()); + mQueue.remove(mElement1); + assertEquals(2, mQueue.size()); + assertEquals("[3 2]", mQueue.toString()); + mQueue.add(mElement1); + assertEquals(3, mQueue.size()); + assertEquals("[3 2 1]", mQueue.toString()); + mQueue.remove(mElement3); + assertEquals(2, mQueue.size()); + assertEquals("[2 1]", mQueue.toString()); + mQueue.remove(mElement1); + assertEquals(1, mQueue.size()); + assertEquals("[2]", mQueue.toString()); + + assertEquals(Element.NOT_HAPPENED, mElement1.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement2.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement3.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement4.mPhantomUpEventTime); + } + + @Test + public void testReleaseAllPointers() { + mElement2.mIsModifier = true; + mQueue.add(mElement1); + mQueue.add(mElement2); + mQueue.add(mElement3); + mQueue.add(mElement4); + + final long eventTime = 123; + Element.sPhantomUpCount = 0; + mQueue.releaseAllPointers(eventTime); + assertEquals(4, Element.sPhantomUpCount); + assertEquals(0, mQueue.size()); + assertEquals("[]", mQueue.toString()); + assertEquals(eventTime + 1, mElement1.mPhantomUpEventTime); + assertEquals(eventTime + 2, mElement2.mPhantomUpEventTime); + assertEquals(eventTime + 3, mElement3.mPhantomUpEventTime); + assertEquals(eventTime + 4, mElement4.mPhantomUpEventTime); + } + + @Test + public void testReleaseAllPointersOlderThanFirst() { + mElement2.mIsModifier = true; + mQueue.add(mElement1); + mQueue.add(mElement2); + mQueue.add(mElement3); + + final long eventTime = 123; + Element.sPhantomUpCount = 0; + mQueue.releaseAllPointersOlderThan(mElement1, eventTime); + assertEquals(0, Element.sPhantomUpCount); + assertEquals(3, mQueue.size()); + assertEquals("[1 2 3]", mQueue.toString()); + assertEquals(Element.NOT_HAPPENED, mElement1.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement2.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement3.mPhantomUpEventTime); + } + + @Test + public void testReleaseAllPointersOlderThanLast() { + mElement2.mIsModifier = true; + mQueue.add(mElement1); + mQueue.add(mElement2); + mQueue.add(mElement3); + mQueue.add(mElement4); + + final long eventTime = 123; + Element.sPhantomUpCount = 0; + mQueue.releaseAllPointersOlderThan(mElement4, eventTime); + assertEquals(2, Element.sPhantomUpCount); + assertEquals(2, mQueue.size()); + assertEquals("[2 4]", mQueue.toString()); + assertEquals(eventTime + 1, mElement1.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement2.mPhantomUpEventTime); + assertEquals(eventTime + 2, mElement3.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement4.mPhantomUpEventTime); + } + + @Test + public void testReleaseAllPointersOlderThanWithoutModifierMiddle() { + mQueue.add(mElement1); + mQueue.add(mElement2); + mQueue.add(mElement3); + mQueue.add(mElement4); + + final long eventTime = 123; + Element.sPhantomUpCount = 0; + mQueue.releaseAllPointersOlderThan(mElement3, eventTime); + assertEquals(2, Element.sPhantomUpCount); + assertEquals(2, mQueue.size()); + assertEquals("[3 4]", mQueue.toString()); + assertEquals(eventTime + 1, mElement1.mPhantomUpEventTime); + assertEquals(eventTime + 2, mElement2.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement3.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement4.mPhantomUpEventTime); + } + + @Test + public void testReleaseAllPointersOlderThanWithoutModifierLast() { + mQueue.add(mElement1); + mQueue.add(mElement2); + mQueue.add(mElement3); + mQueue.add(mElement4); + + final long eventTime = 123; + Element.sPhantomUpCount = 0; + mQueue.releaseAllPointersOlderThan(mElement4, eventTime); + assertEquals(3, Element.sPhantomUpCount); + assertEquals(1, mQueue.size()); + assertEquals("[4]", mQueue.toString()); + assertEquals(eventTime + 1, mElement1.mPhantomUpEventTime); + assertEquals(eventTime + 2, mElement2.mPhantomUpEventTime); + assertEquals(eventTime + 3, mElement3.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement4.mPhantomUpEventTime); + } + + @Test + public void testReleaseAllPointersExcept() { + mElement2.mIsModifier = true; + mQueue.add(mElement1); + mQueue.add(mElement2); + mQueue.add(mElement3); + mQueue.add(mElement4); + + final long eventTime = 123; + Element.sPhantomUpCount = 0; + mQueue.releaseAllPointersExcept(mElement3, eventTime); + assertEquals(3, Element.sPhantomUpCount); + assertEquals(1, mQueue.size()); + assertEquals("[3]", mQueue.toString()); + assertEquals(eventTime + 1, mElement1.mPhantomUpEventTime); + assertEquals(eventTime + 2, mElement2.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement3.mPhantomUpEventTime); + assertEquals(eventTime + 3, mElement4.mPhantomUpEventTime); + } + + @Test + public void testHasModifierKeyOlderThan() { + Element.sPhantomUpCount = 0; + assertFalse("hasModifierKeyOlderThan empty", mQueue.hasModifierKeyOlderThan(mElement1)); + + mQueue.add(mElement1); + mQueue.add(mElement2); + mQueue.add(mElement3); + mQueue.add(mElement4); + + assertFalse(mQueue.hasModifierKeyOlderThan(mElement1)); + assertFalse(mQueue.hasModifierKeyOlderThan(mElement2)); + assertFalse(mQueue.hasModifierKeyOlderThan(mElement3)); + assertFalse(mQueue.hasModifierKeyOlderThan(mElement4)); + + mElement2.mIsModifier = true; + assertFalse(mQueue.hasModifierKeyOlderThan(mElement1)); + assertFalse(mQueue.hasModifierKeyOlderThan(mElement2)); + assertTrue(mQueue.hasModifierKeyOlderThan(mElement3)); + assertTrue(mQueue.hasModifierKeyOlderThan(mElement4)); + + assertEquals(0, Element.sPhantomUpCount); + assertEquals(4, mQueue.size()); + assertEquals("[1 2 3 4]", mQueue.toString()); + assertEquals(Element.NOT_HAPPENED, mElement1.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement2.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement3.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement4.mPhantomUpEventTime); + } + + @Test + public void testIsAnyInDraggingFinger() { + Element.sPhantomUpCount = 0; + assertFalse(mQueue.isAnyInDraggingFinger()); + + mQueue.add(mElement1); + mQueue.add(mElement2); + mQueue.add(mElement3); + mQueue.add(mElement4); + + assertFalse(mQueue.isAnyInDraggingFinger()); + + mElement3.mIsInDraggingFinger = true; + assertTrue(mQueue.isAnyInDraggingFinger()); + + assertEquals(0, Element.sPhantomUpCount); + assertEquals(4, mQueue.size()); + assertEquals("[1 2 3 4]", mQueue.toString()); + assertEquals(Element.NOT_HAPPENED, mElement1.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement2.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement3.mPhantomUpEventTime); + assertEquals(Element.NOT_HAPPENED, mElement4.mPhantomUpEventTime); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/internal/SmoothingUtilsTests.java b/tests/src/org/kelar/inputmethod/keyboard/internal/SmoothingUtilsTests.java new file mode 100644 index 000000000..4de2dda81 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/internal/SmoothingUtilsTests.java @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2013 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 org.kelar.inputmethod.keyboard.internal; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import androidx.test.filters.SmallTest; +import androidx.test.runner.AndroidJUnit4; + +import org.kelar.inputmethod.keyboard.internal.MatrixUtils.MatrixOperationFailedException; + +import org.junit.Test; +import org.junit.runner.RunWith; + +@SmallTest +@RunWith(AndroidJUnit4.class) +public class SmoothingUtilsTests { + // "run tests" -c org.kelar.inputmethod.keyboard.internal.SmoothingUtilsTests + private static final boolean DEBUG = false; + + @Test + public void testGet3DParamaters() { + final float[] xs = new float[] {0, 1, 2, 3, 4}; + final float[] ys = new float[] {1, 4, 15, 40, 85}; // y = x^3 + x^2 + x + 1 + final float[][] retval = new float[4][1]; + try { + SmoothingUtils.get3DParameters(xs, ys, retval); + if (DEBUG) { + MatrixUtils.dump("3d", retval); + } + for (int i = 0; i < 4; ++i) { + assertEquals(retval[i][0], 1.0f, 0.001f); + } + } catch (MatrixOperationFailedException e) { + assertTrue(false); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Arabic.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Arabic.java new file mode 100644 index 000000000..c0d267a0a --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Arabic.java @@ -0,0 +1,349 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.Symbols.RtlSymbols; +import org.kelar.inputmethod.keyboard.layout.SymbolsShifted.RtlSymbolsShifted; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Locale; + +public final class Arabic extends LayoutBase { + private static final String LAYOUT_NAME = "arabic"; + + public Arabic(final Locale locale) { + super(new ArabicCustomizer(locale), ArabicSymbols.class, ArabicSymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class ArabicCustomizer extends LayoutCustomizer { + 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", SETTINGS_KEY)); + } + // U+060C: "،" ARABIC COMMA + // U+061F: "؟" ARABIC QUESTION MARK + // U+061B: "؛" ARABIC SEMICOLON + return joinKeys(key("\u060C", joinMoreKeys( + ":", "!", "\u061F", "\u061B", "-", "\"", "'", SETTINGS_KEY))); + } + + @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(".", getPunctuationMoreKeys(isPhone))); + } + + @Override + public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { + return ARABIC_DIACRITICS; + } + + // U+0623: "أ" ARABIC LETTER ALEF WITH HAMZA ABOVE + // U+200C: ZERO WIDTH NON-JOINER + // U+0628: "ب" ARABIC LETTER BEH + // U+062C: "ج" ARABIC LETTER JEEM + 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); + 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; + } + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + // U+0626: "ئ" ARABIC LETTER YEH WITH HAMZA ABOVE + builder.insertKeysAtRow(3, 2, "\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 + "\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 + // U+0646: "ن" ARABIC LETTER NOON + // U+0645: "م" ARABIC LETTER MEEM + "\u062A", "\u0646", "\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 + "\u0637") + .setKeysOfRow(3, + // 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(",", "\u060C") + // 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(",", "\u060C") + .build(); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/ArmenianPhonetic.java b/tests/src/org/kelar/inputmethod/keyboard/layout/ArmenianPhonetic.java new file mode 100644 index 000000000..94a5bf40c --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/ArmenianPhonetic.java @@ -0,0 +1,211 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Locale; + +/** + * The Armenian Phonetic alphabet keyboard. + */ +public final class ArmenianPhonetic extends LayoutBase { + private static final String LAYOUT_NAME = "armenian_phonetic"; + + public ArmenianPhonetic(final Locale locale) { + super(new ArmenianPhoneticCustomizer(locale), ArmenianSymbols.class, + ArmenianSymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class ArmenianPhoneticCustomizer extends LayoutCustomizer { + ArmenianPhoneticCustomizer(final Locale locale) { super(locale); } + + @Override + public int getNumberOfRows() { return 5; } + + @Override + public ExpectedKey getAlphabetKey() { return ARMENIAN_ALPHABET_KEY; } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + if (isPhone) { + return EMPTY_KEYS; + } + // U+055C: "՜" ARMENIAN EXCLAMATION MARK + // U+00A1: "¡" INVERTED EXCLAMATION MARK + // U+055E: "՞" ARMENIAN QUESTION MARK + // U+00BF: "¿" INVERTED QUESTION MARK + return joinKeys(key("!", joinMoreKeys("\u055C", "\u00A1")), + key("?", joinMoreKeys("\u055E", "\u00BF")), + SHIFT_KEY); + } + + @Override + public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) { + // U+055D: "՝" ARMENIAN COMMA + return isPhone ? joinKeys(key("\u055D", SETTINGS_KEY)) + : joinKeys(key("\u055D", SETTINGS_KEY)); + } + + @Override + public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) { + // U+0589: "։" ARMENIAN FULL STOP + final ExpectedKey fullStopKey = key("\u0589", getPunctuationMoreKeys(isPhone)); + return joinKeys(fullStopKey); + } + + @Override + public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { + return ARMENIAN_PUNCTUATION_MORE_KEYS; + } + + // U+0531: "Ա" ARMENIAN CAPITAL LETTER AYB + // U+0532: "Բ" ARMENIAN CAPITAL LETTER BEN + // U+0533: "Գ" ARMENIAN CAPITAL LETTER GIM + private static final ExpectedKey ARMENIAN_ALPHABET_KEY = key( + "\u0531\u0532\u0533", Constants.CODE_SWITCH_ALPHA_SYMBOL); + + // U+055E: "՞" ARMENIAN QUESTION MARK + // U+055C: "՜" ARMENIAN EXCLAMATION MARK + // U+055A: "՚" ARMENIAN APOSTROPHE + // U+0559: "ՙ" ARMENIAN MODIFIER LETTER LEFT HALF RING + // U+055D: "՝" ARMENIAN COMMA + // U+055B: "՛" ARMENIAN EMPHASIS MARK + // U+058A: "֊" ARMENIAN HYPHEN + // U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK + // U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK + // U+055F: "՟" ARMENIAN ABBREVIATION MARK + private static final ExpectedKey[] ARMENIAN_PUNCTUATION_MORE_KEYS = joinMoreKeys( + ",", "\u055E", "\u055C", ".", "\u055A", "\u0559", "?", "!", + "\u055D", "\u055B", "\u058A", "\u00BB", "\u00AB", "\u055F", ";", ":"); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + if (isPhone) { + // U+056D: "խ" ARMENIAN SMALL LETTER XEH + // U+0577: "շ" ARMENIAN SMALL LETTER SHA + builder.addKeysOnTheRightOfRow(3, "\u056D") + .addKeysOnTheRightOfRow(4, "\u0577"); + } else { + // U+056D: "խ" ARMENIAN SMALL LETTER XEH + // U+0577: "շ" ARMENIAN SMALL LETTER SHA + builder.addKeysOnTheRightOfRow(2, "\u056D") + .addKeysOnTheRightOfRow(3, "\u0577"); + } + return builder.build(); + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0567: "է" ARMENIAN SMALL LETTER EH + key("\u0567", moreKey("1")), + // U+0569: "թ" ARMENIAN SMALL LETTER TO + key("\u0569", moreKey("2")), + // U+0583: "փ" ARMENIAN SMALL LETTER PIWR + key("\u0583", moreKey("3")), + // U+0571: "ձ" ARMENIAN SMALL LETTER JA + key("\u0571", moreKey("4")), + // U+057B: "ջ" ARMENIAN SMALL LETTER JHEH + key("\u057B", moreKey("5")), + // U+0580: "ր" ARMENIAN SMALL LETTER REH + key("\u0580", moreKey("6")), + // U+0579: "չ" ARMENIAN SMALL LETTER CHA + key("\u0579", moreKey("7")), + // U+0573: "ճ" ARMENIAN SMALL LETTER CHEH + key("\u0573", moreKey("8")), + // U+056A: "ժ" ARMENIAN SMALL LETTER ZHE + key("\u056A", moreKey("9")), + // U+056E: "ծ" ARMENIAN SMALL LETTER CA + key("\u056E", moreKey("0"))) + .setKeysOfRow(2, + // U+0584: "ք" ARMENIAN SMALL LETTER KEH + // U+0578: "ո" ARMENIAN SMALL LETTER VO + "\u0584", "\u0578", + // U+0565: "ե" ARMENIAN SMALL LETTER ECH + // U+0587: "և" ARMENIAN SMALL LIGATURE ECH YIWN + key("\u0565", moreKey("\u0587")), + // U+057C: "ռ" ARMENIAN SMALL LETTER RA + // U+057F: "տ" ARMENIAN SMALL LETTER TIWN + // U+0568: "ը" ARMENIAN SMALL LETTER ET + // U+0582: "ւ" ARMENIAN SMALL LETTER YIWN + // U+056B: "ի" ARMENIAN SMALL LETTER INI + // U+0585: "օ" ARMENIAN SMALL LETTER OH + // U+057A: "պ" ARMENIAN SMALL LETTER PEH + "\u057C", "\u057F", "\u0568", "\u0582", "\u056B", "\u0585", "\u057A") + .setKeysOfRow(3, + // U+0561: "ա" ARMENIAN SMALL LETTER AYB + // U+057D: "ս" ARMENIAN SMALL LETTER SEH + // U+0564: "դ" ARMENIAN SMALL LETTER DA + // U+0586: "ֆ" ARMENIAN SMALL LETTER FEH + // U+0563: "գ" ARMENIAN SMALL LETTER GIM + // U+0570: "հ" ARMENIAN SMALL LETTER HO + // U+0575: "յ" ARMENIAN SMALL LETTER YI + // U+056F: "կ" ARMENIAN SMALL LETTER KEN + // U+056C: "լ" ARMENIAN SMALL LETTER LIWN + "\u0561", "\u057D", "\u0564", "\u0586", "\u0563", "\u0570", "\u0575", "\u056F", + "\u056C") + .setKeysOfRow(4, + // U+0566: "զ" ARMENIAN SMALL LETTER ZA + // U+0572: "ղ" ARMENIAN SMALL LETTER GHAD + // U+0581: "ց" ARMENIAN SMALL LETTER CO + // U+057E: "վ" ARMENIAN SMALL LETTER VEW + // U+0562: "բ" ARMENIAN SMALL LETTER BEN + // U+0576: "ն" ARMENIAN SMALL LETTER NOW + // U+0574: "մ" ARMENIAN SMALL LETTER MEN + "\u0566", "\u0572", "\u0581", "\u057E", "\u0562", "\u0576", "\u0574") + .build(); + + private static final class ArmenianSymbols extends Symbols { + public ArmenianSymbols(final LayoutCustomizer customizer) { super(customizer); } + + @Override + public ExpectedKey[][] getLayout(final boolean isPhone) { + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder( + super.getLayout(isPhone)); + // U+055D: "՝" ARMENIAN COMMA + builder.replaceKeyOfLabel(",", "\u055D"); + // U+055C: "՜" ARMENIAN EXCLAMATION MARK + // U+00A1: "¡" INVERTED EXCLAMATION MARK + // U+055E: "՞" ARMENIAN QUESTION MARK + // U+00BF: "¿" INVERTED QUESTION MARK + builder.setMoreKeysOf("!", "\u055C", "\u00A1") + .setMoreKeysOf("?", "\u055E", "\u00BF"); + return builder.build(); + } + } + + private static final class ArmenianSymbolsShifted extends SymbolsShifted { + public ArmenianSymbolsShifted(final LayoutCustomizer customizer) { super(customizer); } + + @Override + public ExpectedKey[][] getLayout(final boolean isPhone) { + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder( + super.getLayout(isPhone)); + // U+055D: "՝" ARMENIAN COMMA + builder.replaceKeyOfLabel(",", "\u055D"); + return builder.build(); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Azerty.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Azerty.java new file mode 100644 index 000000000..c7df7eb9f --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Azerty.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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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, "?"); + } + 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", additionalMoreKey("1")), + key("z", additionalMoreKey("2")), + key("e", additionalMoreKey("3")), + key("r", additionalMoreKey("4")), + key("t", additionalMoreKey("5")), + key("y", additionalMoreKey("6")), + key("u", additionalMoreKey("7")), + key("i", additionalMoreKey("8")), + key("o", additionalMoreKey("9")), + key("p", additionalMoreKey("0"))) + .setKeysOfRow(2, "q", "s", "d", "f", "g", "h", "j", "k", "l", "m") + .setKeysOfRow(3, "w", "x", "c", "v", "b", "n", ROW3_QUOTE) + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Bengali.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Bengali.java new file mode 100644 index 000000000..fa62ffc30 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Bengali.java @@ -0,0 +1,164 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +/** + * The Bengali keyboard. + */ +public final class Bengali extends LayoutBase { + private static final String LAYOUT_NAME = "bengali"; + + public Bengali(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) { + return null; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0994: "ঔ" BENGALI LETTER AU + // U+09CC: "ৌ" BENGALI VOWEL SIGN AU + // U+09E7: "১" BENGALI DIGIT ONE + key("\u0994", joinMoreKeys("\u09CC", "\u09E7", "1")), + // U+0990: "ঐ" BENGALI LETTER AI + // U+09C8: "ৈ" BENGALI VOWEL SIGN AI + // U+09E8: "২" BENGALI DIGIT TWO + key("\u0990", joinMoreKeys("\u09C8", "\u09E8", "2")), + // U+0986: "আ" BENGALI LETTER AA + // U+09BE: "া" BENGALI VOWEL SIGN AA + // U+09E9: "৩" BENGALI DIGIT THREE + key("\u0986", joinMoreKeys("\u09BE", "\u09E9", "3")), + // U+0988: "ঈ" BENGALI LETTER II + // U+09C0: "ী" BENGALI VOWEL SIGN II + // U+09EA: "৪" BENGALI DIGIT FOUR + key("\u0988", joinMoreKeys("\u09C0", "\u09EA", "4")), + // U+098A: "ঊ" BENGALI LETTER UU + // U+09C2: "ূ" BENGALI VOWEL SIGN UU + // U+09EB: "৫" BENGALI DIGIT FIVE + key("\u098A", joinMoreKeys("\u09C2", "\u09EB", "5")), + // U+09AC: "ব" BENGALI LETTER BA + // U+09AD: "ভ" BENGALI LETTER BHA + // U+09EC: "৬" BENGALI DIGIT SIX + key("\u09AC", joinMoreKeys("\u09AD", "\u09EC", "6")), + // U+09B9: "হ" BENGALI LETTER HA + // U+09ED: "৭" BENGALI DIGIT SEVEN + key("\u09B9", joinMoreKeys("\u09ED", "7")), + // U+0997: "গ" BENGALI LETTER GA + // U+0998: "ঘ" BENGALI LETTER GHA + // U+09EE: "৮" BENGALI DIGIT EIGHT + key("\u0997", joinMoreKeys("\u0998", "\u09EE", "8")), + // U+09A6: "দ" BENGALI LETTER DA + // U+09A7: "ধ" BENGALI LETTER DHA + // U+09EF: "৯" BENGALI DIGIT NINE + key("\u09A6", joinMoreKeys("\u09A7", "\u09EF", "9")), + // U+099C: "জ" BENGALI LETTER JA + // U+099D: "ঝ" BENGALI LETTER JHA + // U+099C/U+09CD/U+099E: + // "জ্ঞ" BENGALI LETTER JA/BENGALI SIGN VIRAMA/BENGALI LETTER NYA + // U+09E6: "০" BENGALI DIGIT ZERO + key("\u099C", joinMoreKeys("\u099D", "\u099C\u09CD\u099E", "\u09E6", "0")), + // U+09A1: "ড" BENGALI LETTER DDA + // U+09A1/U+09BC: "ড়" BENGALI LETTER DDA/BENGALI SIGN NUKTA + key("\u09A1", moreKey("\u09A1\u09BC"))) + .setKeysOfRow(2, + // U+0993: "ও" BENGALI LETTER O + // U+09CB: "ো" BENGALI VOWEL SIGN O + key("\u0993", moreKey("\u09CB")), + // U+098F: "এ" BENGALI LETTER E + // U+09C7: "ে" BENGALI VOWEL SIGN E + key("\u098F", moreKey("\u09C7")), + // U+0985: "অ" BENGALI LETTER A + // U+09CD: "্" BENGALI SIGN VIRAMA + key("\u0985", moreKey("\u09CD")), + // U+0987: "ই" BENGALI LETTER I + // U+09BF: "ি" BENGALI VOWEL SIGN I + key("\u0987", moreKey("\u09BF")), + // U+0989: "উ" BENGALI LETTER U + // U+09C1: "ু" BENGALI VOWEL SIGN U + key("\u0989", moreKey("\u09C1")), + // U+09AA: "প" BENGALI LETTER PA + // U+09AB: "ফ" BENGALI LETTER PHA + key("\u09AA", moreKey("\u09AB")), + // U+09B0: "র" BENGALI LETTER RA + // U+09C3: "ৃ" BENGALI VOWEL SIGN VOCALIC R + // U+098B: "ঋ" BENGALI LETTER VOCALIC R + // U+09A4/U+09CD/U+09B0: + // "ত্র" BENGALI LETTER TA/BENGALI SIGN VIRAMA/BENGALI LETTER RA + key("\u09B0", joinMoreKeys("\u09C3", "\u098B", "\u09A4\u09CD\u09B0")), + // U+0995: "ক" BENGALI LETTER KA + // U+0996: "খ" BENGALI LETTER KHA + key("\u0995", moreKey("\u0996")), + // U+09A4: "ত" BENGALI LETTER TA + // U+09CE: "ৎ" BENGALI LETTER KHANDA TA + // U+09A5: "থ" BENGALI LETTER THA + // U+09A4/U+09CD/U+09A4: + // "ত্ত" BENGALI LETTER TA/BENGALI SIGN VIRAMA/BENGALI LETTER TA + key("\u09A4", joinMoreKeys("\u09CE", "\u09A5", "\u09A4\u09CD\u09A4")), + // U+099A: "চ" BENGALI LETTER CA + // U+099B: "ছ" BENGALI LETTER CHA + key("\u099A", moreKey("\u099B")), + // U+099F: "ট" BENGALI LETTER TTA + // U+09A0: "ঠ" BENGALI LETTER TTHA + key("\u099F", moreKey("\u09A0"))) + .setKeysOfRow(3, + // U+0981: "ঁ" BENGALI SIGN CANDRABINDU + // U+0983: "ঃ" BENGALI SIGN VISARGA + // U+0982: "ং" BENGALI SIGN ANUSVARA + key("\u0981", joinMoreKeys("\u0983", "\u0982")), + // U+09A2: "ঢ" BENGALI LETTER DDHA + // U+09A2/U+09BC: "ঢ়" BENGALI LETTER DDHA/BENGALI SIGN NUKTA + key("\u09A2", moreKey("\u09A2\u09BC")), + // U+09AE: "ম" BENGALI LETTER MA + "\u09AE", + // U+09A8: "ন" BENGALI LETTER NA + // U+09A3: "ণ" BENGALI LETTER NNA + key("\u09A8", moreKey("\u09A3")), + // U+099E: "ঞ" BENGALI LETTER NYA + // U+0999: "ঙ" BENGALI LETTER NGA + // U+099E/U+09CD/U+099C: + // "ঞ্জ" BENGALI LETTER NYA/BENGALI SIGN VIRAMA/BENGALI LETTER JA + key("\u099E", joinMoreKeys("\u0999", "\u099E\u09CD\u099C")), + // U+09B2: "ল" BENGALI LETTER LA + "\u09B2", + // U+09B7: "ষ" BENGALI LETTER SSA + // U+0995/U+09CD/U+09B7: + // "ক্ষ" BENGALI LETTER KA/BENGALI SIGN VIRAMA/BENGALI LETTER SSA + key("\u09B7", moreKey("\u0995\u09CD\u09B7")), + // U+09B8: "স" BENGALI LETTER SA + // U+09B6: "শ" BENGALI LETTER SHA + key("\u09B8", moreKey("\u09B6")), + // U+09DF: "য়" BENGALI LETTER YYA + // U+09AF: "য" BENGALI LETTER YA + key("\u09DF", moreKey("\u09AF")), + // U+0964: "।" DEVANAGARI DANDA + // U+0965: "॥" DEVANAGARI DOUBLE DANDA + key("\u0964", moreKey("\u0965"))) + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/BengaliAkkhor.java b/tests/src/org/kelar/inputmethod/keyboard/layout/BengaliAkkhor.java new file mode 100644 index 000000000..765c698f6 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/BengaliAkkhor.java @@ -0,0 +1,497 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +/** + * The Bengali Akkhor keyboard. + */ +public final class BengaliAkkhor extends LayoutBase { + private static final String LAYOUT_NAME = "bengali_akkhor"; + + public BengaliAkkhor(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + @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+09A7: "ধ" BENGALI LETTER DHA + // U+09E7: "১" BENGALI DIGIT ONE + // U+09A7/U+09CD/U+09AC: + // "ধ্ব্র" BENGALI LETTER DHA/BENGALI SIGN VIRAMA/BENGALI LETTER BA + // U+09A7/U+09CD/U+09AF: + // "ধ্য্র" BENGALI LETTER DHA/BENGALI SIGN VIRAMA/BENGALI LETTER YA + // U+09A7/U+09CD/U+09B0: + // "ধ্র" BENGALI LETTER DHA/BENGALI SIGN VIRAMA/BENGALI LETTER RA + key("\u09A7", joinMoreKeys("\u09E7", "\u09A7\u09CD\u09AC", "\u09A7\u09CD\u09AF", + "\u09A7\u09CD\u09B0")), + // U+09A5: "থ" BENGALI LETTER THA + // U+09E8: "২" BENGALI DIGIT TWO + // U+09A5/U+09CD/U+09AF: + // "থ্য" BENGALI LETTER THA/BENGALI SIGN VIRAMA/BENGALI LETTER YA + // U+09A5/U+09CD/U+09B0: + // "থ্র" BENGALI LETTER THA/BENGALI SIGN VIRAMA/BENGALI LETTER RA + key("\u09A5", joinMoreKeys("\u09E8", "\u09A5\u09CD\u09AF", + "\u09A5\u09CD\u09B0")), + // U+09C7: "ে" BENGALI VOWEL SIGN E + // U+09E9: "৩" BENGALI DIGIT THREE + // U+098F: "এ" BENGALI LETTER E + key("\u09C7", joinMoreKeys("\u09E9", "\u098F")), + // U+09B0: "র" BENGALI LETTER RA + // U+09EA: "৪" BENGALI DIGIT FOUR + key("\u09B0", joinMoreKeys("\u09EA")), + // U+09A4: "ত" BENGALI LETTER TA + // U+09EB: "৫" BENGALI DIGIT FIVE + // U+09CE: "ৎ" BENGALI LETTER KHANDA TA + // U+09A4/U+09CD/U+09A4: + // "ত্ত" BENGALI LETTER TA/BENGALI SIGN VIRAMA/BENGALI LETTER TA + // U+09A4/U+09CD/U+09A8: + // "ত্ন" BENGALI LETTER TA/BENGALI SIGN VIRAMA/BENGALI LETTER NA + // U+09A4/U+09CD/U+09AC: + // "ত্ব" BENGALI LETTER TA/BENGALI SIGN VIRAMA/BENGALI LETTER BA + // U+09A4/U+09CD/U+09AE: + // "ত্ম" BENGALI LETTER TA/BENGALI SIGN VIRAMA/BENGALI LETTER MA + key("\u09A4", joinMoreKeys("\u09EB", "\u09CE", "\u09A4\u09CD\u09A4", + "\u09A4\u09CD\u09A8", "\u09A4\u09CD\u09AC", "\u09A4\u09CD\u09AE")), + // U+09DF: "য়" BENGALI LETTER YYA + // U+09EC: "৬" BENGALI DIGIT SIX + key("\u09DF", joinMoreKeys("\u09EC")), + // U+09C1: "ু" BENGALI VOWEL SIGN U + // U+09ED: "৭" BENGALI DIGIT SEVEN + // U+0989: "উ" BENGALI LETTER U + key("\u09C1", joinMoreKeys("\u09ED", "\u0989")), + // U+09BF: "ি" BENGALI VOWEL SIGN I + // U+09EE: "৮" BENGALI DIGIT EIGHT + // U+0987: "ই BENGALI LETTER I + key("\u09Bf", joinMoreKeys("\u09EE", "\u0987")), + // U+09CB: "ো" BENGALI VOWEL SIGN O + // U+09EF: "৯" BENGALI DIGIT NINE + // U+0993: "ও" BENGALI LETTER O + key("\u09CB", joinMoreKeys("\u09EF", "\u0993")), + // U+09AA: "প" BENGALI LETTER PA + // U+09E6: "০" BENGALI DIGIT ZERO + // U+09AA/U+09CD/U+09A4: + // "প্ত" BENGALI LETTER PA/BENGALI SIGN VIRAMA/BENGALI LETTER TA + // U+09AA/U+09CD/U+09A8: + // "প্ন" BENGALI LETTER PA/BENGALI SIGN VIRAMA/BENGALI LETTER NA + // U+09AA/U+09CD/U+09AA: + // "প্প" BENGALI LETTER PA/BENGALI SIGN VIRAMA/BENGALI LETTER PA + // U+09AA/U+09CD/U+09AF: + // "প্য" BENGALI LETTER PA/BENGALI SIGN VIRAMA/BENGALI LETTER YA + // U+09AA/U+09CD/U+09B0: + // "প্র" BENGALI LETTER PA/BENGALI SIGN VIRAMA/BENGALI LETTER RA + // U+09AA/U+09CD/U+09B2: + // "প্ল" BENGALI LETTER PA/BENGALI SIGN VIRAMA/BENGALI LETTER LA + // U+09AA/U+09CD/U+09B8: + // "প্স" BENGALI LETTER PA/BENGALI SIGN VIRAMA/BENGALI LETTER SA + key("\u09AA", joinMoreKeys("\u09E6", "\u09AA\u09CD\u09A4", "\u09AA\u09CD\u09A8", + "\u09AA\u09CD\u09AA", "\u09AA\u09CD\u09AF", "\u09AA\u09CD\u09B0", + "\u09AA\u09CD\u09B2", "\u09AA\u09CD\u09B8")), + // U+0986: "আ" BENGALI LETTER AA + key("\u0986")) + .setKeysOfRow(2, + // U+09BE: "া BENGALI VOWEL SIGN AA + // U+0986: "আ" BENGALI LETTER AA + key("\u09BE", moreKey("\u0986")), + // U+09B8: "স" BENGALI LETTER SA + // U+09B8/U+09CD/U+09AC: + // "স্ব" BENGALI LETTER SA/BENGALI SIGN VIRAMA/BENGALI LETTER BA + // U+09B8/U+09CD/U+09A4: + // "স্ত" BENGALI LETTER SA/BENGALI SIGN VIRAMA/BENGALI LETTER TA + // U+09B8/U+09CD/U+099F: + // "স্ট" BENGALI LETTER SA/BENGALI SIGN VIRAMA/BENGALI LETTER TTA + // U+09B8/U+09CD/U+0995: + // "স্ক" BENGALI LETTER SA/BENGALI SIGN VIRAMA/BENGALI LETTER KA + // U+09B8/U+09CD/U+09AA: + // "স্প" BENGALI LETTER SA/BENGALI SIGN VIRAMA/BENGALI LETTER PA + key("\u09B8", joinMoreKeys("\u09B8\u09CD\u09AC", "\u09B8\u09CD\u09A4", + "\u09B8\u09CD\u099F", "\u09B8\u09CD\u0995", "\u09B8\u09CD\u09AA")), + // U+09A6: "দ" BENGALI LETTER DA + // U+09A6/U+09CD/U+09A6: + // "দ্দ" BENGALI LETTER DA/BENGALI SIGN VIRAMA/BENGALI LETTER DA + // U+09A6/U+09CD/U+09A7: + // "দ্ধ" BENGALI LETTER DA/BENGALI SIGN VIRAMA/BENGALI LETTER DHA + // U+09A6/U+09CD/U+09AC: + // "দ্ব" BENGALI LETTER DA/BENGALI SIGN VIRAMA/BENGALI LETTER BA + // U+09A6/U+09CD/U+09AD: + // "দ্ভ" BENGALI LETTER DA/BENGALI SIGN VIRAMA/BENGALI LETTER BHA + // U+09A6/U+09CD/U+09AE: + // "দ্ম" BENGALI LETTER DA/BENGALI SIGN VIRAMA/BENGALI LETTER MA + // U+09A6/U+09CD/U+09AF: + // "দ্য" BENGALI LETTER DA/BENGALI SIGN VIRAMA/BENGALI LETTER YA + // U+09A6/U+09CD/U+09B0: + // "দ্র" BENGALI LETTER DA/BENGALI SIGN VIRAMA/BENGALI LETTER RA + key("\u09A6", joinMoreKeys("\u09A6\u09CD\u09A6", "\u09A6\u09CD\u09A7", + "\u09A6\u09CD\u09AC", "\u09A6\u09CD\u09AD", "\u09A6\u09CD\u09AE", + "\u09A6\u09CD\u09AF", "\u09A6\u09CD\u09B0")), + // U+09C3: "ৃ" BENGALI VOWEL SIGN VOCALIC R + // U+098B: "ঋ" BENGALI LETTER VOCALIC R + key("\u09C3", moreKey("\u098B")), + // U+0997: "গ" BENGALI LETTER GA + // U+0997/U+09CD/U+09A7: + // "গ্ধ" BENGALI LETTER GA/BENGALI SIGN VIRAMA/BENGALI LETTER DH A + // U+0997/U+09CD/U+09B0: + // "গ্র" BENGALI LETTER GA/BENGALI SIGN VIRAMA/BENGALI LETTER RA + // U+0997/U+09CD/U+09B2: + // "গ্ল" BENGALI LETTER GA/BENGALI SIGN VIRAMA/BENGALI LETTER LA + // U+0997/U+09CD/U+09A8: + // "গ্ন" BENGALI LETTER GA/BENGALI SIGN VIRAMA/BENGALI LETTER NA + key("\u0997", joinMoreKeys("\u0997\u09CD\u09A7", "\u0997\u09CD\u09B0", + "\u0997\u09CD\u09B2", "\u0997\u09CD\u09A8")), + // U+09CD: "্" BENGALI SIGN VIRAMA + key("\u09CD"), + // U+099C: "জ" BENGALI LETTER JA + // U+099C/U+09CD/U+099E: + // "জ্ঞ" BENGALI LETTER JA/BENGALI SIGN VIRAMA/BENGALI LETTER NYA + // U+099C/U+09CD/U+099C: + // "জ্জ" BENGALI LETTER JA/BENGALI SIGN VIRAMA/BENGALI LETTER JA + // U+099C/U+09CD/U+09AF: + // "জ্ব" BENGALI LETTER JA/BENGALI SIGN VIRAMA/BENGALI LETTER YA + // U+099C/U+09CD/U+09AC: + // "জ্য" BENGALI LETTER JA/BENGALI SIGN VIRAMA/BENGALI LETTER BA + // U+099C/U+09CD/U+09B0: + // "জ্র" BENGALI LETTER JA/BENGALI SIGN VIRAMA/BENGALI LETTER RA + key("\u099C", joinMoreKeys("\u099C\u09CD\u099E", "\u099C\u09CD\u099C", + "\u099C\u09CD\u09AF", "\u099C\u09CD\u09AC", "\u099C\u09CD\u09B0")), + // U+0995: "ক" BENGALI LETTER KA + // U+0995/U+09CD/U+09B7: + // "ক্ষ" BENGALI LETTER KA/BENGALI SIGN VIRAMA/BENGALI LETTER SSA + // U+0995/U+09CD/U+0995: + // "ক্ক" BENGALI LETTER KA/BENGALI SIGN VIRAMA/BENGALI LETTER KA + // U+0995/U+09CD/U+099F: + // "ক্ট" BENGALI LETTER KA/BENGALI SIGN VIRAMA/BENGALI LETTER TTA + // U+0995/U+09CD/U+09A4: + // "ক্ত" BENGALI LETTER KA/BENGALI SIGN VIRAMA/BENGALI LETTER TA + // U+0995/U+09CD/U+09B0: + // "ক্র" BENGALI LETTER KA/BENGALI SIGN VIRAMA/BENGALI LETTER RA + // U+0995/U+09CD/U+09B8: + // "ক্স" BENGALI LETTER KA/BENGALI SIGN VIRAMA/BENGALI LETTER SA + // U+0995/U+09CD/U+09B2: + // "ক্ল" BENGALI LETTER KA/BENGALI SIGN VIRAMA/BENGALI LETTER LA + key("\u0995", joinMoreKeys("\u0995\u09CD\u09B7", "\u0995\u09CD\u0995", + "\u0995\u09CD\u099F", "\u0995\u09CD\u09A4", "\u0995\u09CD\u09B0", + "\u0995\u09CD\u09B8", "\u0995\u09CD\u09B2")), + // U+09B2: "ল" BENGALI LETTER LA + // U+09B2/U+09CD/U+0995: + // "ল্ক" BENGALI LETTER LA/BENGALI SIGN VIRAMA/BENGALI LETTER KA + // U+09B2/U+09CD/U+0997: + // "ল্গ" BENGALI LETTER LA/BENGALI SIGN VIRAMA/BENGALI LETTER GA + // U+09B2/U+09CD/U+099F: + // "ল্ট" BENGALI LETTER LA/BENGALI SIGN VIRAMA/BENGALI LETTER TTA + // U+09B2/U+09CD/U+09A1: + // "ল্ড" BENGALI LETTER LA/BENGALI SIGN VIRAMA/BENGALI LETTER DDA + // U+09B2/U+09CD/U+09A4: + // "ল্ত" BENGALI LETTER LA/BENGALI SIGN VIRAMA/BENGALI LETTER TA + // U+09B2/U+09CD/U+09A6: + // "ল্দ" BENGALI LETTER LA/BENGALI SIGN VIRAMA/BENGALI LETTER DA + // U+09B2/U+09CD/U+09A7: + // "ল্ধ" BENGALI LETTER LA/BENGALI SIGN VIRAMA/BENGALI LETTER DHA + // U+09B2/U+09CD/U+09AA: + // "ল্প" BENGALI LETTER LA/BENGALI SIGN VIRAMA/BENGALI LETTER PA + // U+09B2/U+09CD/U+09AB: + // "ল্ফ" BENGALI LETTER LA/BENGALI SIGN VIRAMA/BENGALI LETTER PHA + // U+09B2/U+09CD/U+09AC: + // "ল্ব" BENGALI LETTER LA/BENGALI SIGN VIRAMA/BENGALI LETTER BA + // U+09B2/U+09CD/U+09AE: + // "ল্ম" BENGALI LETTER LA/BENGALI SIGN VIRAMA/BENGALI LETTER MA + // U+09B2/U+09CD/U+09B2: + // "ল্ল" BENGALI LETTER LA/BENGALI SIGN VIRAMA/BENGALI LETTER LA + key("\u09B2", joinMoreKeys("\u09B2\u09CD\u0995", "\u09B2\u09CD\u0997", + "\u09B2\u09CD\u099F", "\u09B2\u09CD\u09A1", "\u09B2\u09CD\u09A4", + "\u09B2\u09CD\u09A6", "\u09B2\u09CD\u09A7", "\u09B2\u09CD\u09AA", + "\u09B2\u09CD\u09AB", "\u09B2\u09CD\u09AC", "\u09B2\u09CD\u09AE", + "\u09B2\u09CD\u09B2")), + // U+0987: "ই" BENGALI LETTER I + key("\u0987"), + // U+0989: "উ" BENGALI LETTER U + key("\u0989")) + .setKeysOfRow(3, + // U+09AF: "য" BENGALI LETTER YA + // U+09CD/U+09AF: "্য" BENGALI SIGN VIRAMA/BENGALI LETTER YA + key("\u09AF", moreKey("\u09CD\u09AF")), + // U+09B7: "ষ" BENGALI LETTER SSA + // U+09B7/U+09CD/U+0995: + // "ষ্ক" BENGALI LETTER SSA/BENGALI SIGN VIRAMA/BENGALI LETTER KA + // U+09B7/U+09CD/U+099F: + // "ষ্ট" BENGALI LETTER SSA/BENGALI SIGN VIRAMA/BENGALI LETTER TTA + // U+09B7/U+09CD/U+09A0: + // "ষ্ঠ" BENGALI LETTER SSA/BENGALI SIGN VIRAMA/BENGALI LETTER TTHA + // U+09B7/U+09CD/U+09A3: + // "ষ্ণ" BENGALI LETTER SSA/BENGALI SIGN VIRAMA/BENGALI LETTER NNA + // U+09B7/U+09CD/U+09AA: + // "ষ্প" BENGALI LETTER SSA/BENGALI SIGN VIRAMA/BENGALI LETTER PA + // U+09B7/U+09CD/U+09AB: + // "ষ্ফ" BENGALI LETTER SSA/BENGALI SIGN VIRAMA/BENGALI LETTER PHA + // U+09B7/U+09CD/U+09AE: + // "ষ্ম" BENGALI LETTER SSA/BENGALI SIGN VIRAMA/BENGALI LETTER MA + key("\u09B7", joinMoreKeys("\u09B7\u09CD\u0995", "\u09B7\u09CD\u099F", + "\u09B7\u09CD\u09A0", "\u09B7\u09CD\u09A3", "\u09B7\u09CD\u09AA", + "\u09B7\u09CD\u09AB", "\u09B7\u09CD\u09AE")), + // U+099A: "চ" BENGALI LETTER CA + // U+099A/U+09CD/U+099A: + // "চ্চ" BENGALI LETTER CA/BENGALI SIGN VIRAMA/BENGALI LETTER CA + // U+099A/U+09CD/U+099B: + // "চ্ছ" BENGALI LETTER CA/BENGALI SIGN VIRAMA/BENGALI LETTER CHA + key("\u099A", joinMoreKeys("\u099A\u09CD\u099A", "\u099A\u09CD\u099B")), + // U+09AD: "ভ" BENGALI LETTER BHA + // U+09AD/U+09CD/U+09AF: + // "ভ্" BENGALI LETTER BHA/BENGALI SIGN VIRAMA/BENGALI LETTER YA + // U+09AD/U+09CD/U+09B0: + // "ভ্র" BENGALI LETTER BHA/BENGALI SIGN VIRAMA/BENGALI LETTER RA + // U+09AD/U+09CD/U+09B2: + // "ভ্ল" BENGALI LETTER BHA/BENGALI SIGN VIRAMA/BENGALI LETTER LA + key("\u09AD", joinMoreKeys("\u09AD\u09CD\u09AF", "\u09AD\u09CD\u09B0", + "\u09AD\u09CD\u09B2")), + // U+09AC: "ব" BENGALI LETTER BA + // U+09CD/U+09AC: "্ব" BENGALI SIGN VIRAMA/BENGALI LETTER BA + // U+09AC/U+09CD/U+09B0: + // "ব্র" BENGALI LETTER BA/BENGALI SIGN VIRAMA/BENGALI LETTER RA + // U+09AC/U+09CD/U+099C: + // "ব্জ" BENGALI LETTER BA/BENGALI SIGN VIRAMA/BENGALI LETTER JA + // U+09AC/U+09CD/U+09A6: + // "ব্দ" BENGALI LETTER BA/BENGALI SIGN VIRAMA/BENGALI LETTER DA + // U+09AC/U+09CD/U+09A7: + // "ব্ধ" BENGALI LETTER BA/BENGALI SIGN VIRAMA/BENGALI LETTER DHA + // U+09AC/U+09CD/U+09AC: + // "ব্ব" BENGALI LETTER BA/BENGALI SIGN VIRAMA/BENGALI LETTER BA + // U+09AC/U+09CD/U+09B2: + // "ব্ল" BENGALI LETTER BA/BENGALI SIGN VIRAMA/BENGALI LETTER LA + // U+09F1: "ৱ" BENGALI LETTER RA WITH MIDDLE DIAGONAL + // U+09F0: "ৰ" BENGALI LETTER RA WITH LOWER DIAGONAL + key("\u09AC", joinMoreKeys("\u09CD\u09AC", "\u09AC\u09CD\u09B0", + "\u09AC\u09CD\u099C", "\u09AC\u09CD\u09A6", "\u09AC\u09CD\u09A7", + "\u09AC\u09CD\u09AC", "\u09AC\u09CD\u09B2", "\u09F1", "\u09F0")), + // U+09A8: "ন" BENGALI LETTER NA + // U+09A8/U+09CD/U+09A4: + // "ন্ত" BENGALI LETTER NA/BENGALI SIGN VIRAMA/BENGALI LETTER TA + // U+09A8/U+09CD/U+09A5: + // "ন্থ" BENGALI LETTER NA/BENGALI SIGN VIRAMA/BENGALI LETTER THA + // U+09A8/U+09CD/U+099F: + // "ন্ট" BENGALI LETTER NA/BENGALI SIGN VIRAMA/BENGALI LETTER TTA + // U+09A8/U+09CD/U+09A6: + // "ন্দ" BENGALI LETTER NA/BENGALI SIGN VIRAMA/BENGALI LETTER DA + // U+09A8/U+09CD/U+09A7: + // "ন্ধ" BENGALI LETTER NA/BENGALI SIGN VIRAMA/BENGALI LETTER DHA + // U+09A8/U+09CD/U+09A1: + // "ন্ড" BENGALI LETTER NA/BENGALI SIGN VIRAMA/BENGALI LETTER DDA + // U+09A8/U+09CD/U+09A8: + // "ন্ন" BENGALI LETTER NA/BENGALI SIGN VIRAMA/BENGALI LETTER NA + // U+09A8/U+09CD/U+09AC: + // "ন্ব" BENGALI LETTER NA/BENGALI SIGN VIRAMA/BENGALI LETTER BA + // U+09A8/U+09CD/U+09AE: + // "ন্ম" BENGALI LETTER NA/BENGALI SIGN VIRAMA/BENGALI LETTER MA + // U+09A8/U+09CD/U+09B8: + // "ন্স" BENGALI LETTER NA/BENGALI SIGN VIRAMA/BENGALI LETTER SA + key("\u09A8", joinMoreKeys("\u09A8\u09CD\u09A4", "\u09A8\u09CD\u09A5", + "\u09A8\u09CD\u099F", "\u09A8\u09CD\u09A6", "\u09A8\u09CD\u09A7", + "\u09A8\u09CD\u09A1", "\u09A8\u09CD\u09A8", "\u09A8\u09CD\u09AC", + "\u09A8\u09CD\u09AE", "\u09A8\u09CD\u09B8")), + // U+09AE: "ম" BENGALI LETTER MA + // U+09AE/U+09CD/U+09A8: + // "ম্ন" BENGALI LETTER MA/BENGALI SIGN VIRAMA/BENGALI LETTER NA + // U+09AE/U+09CD/U+09AA: + // "ম্প" BENGALI LETTER MA/BENGALI SIGN VIRAMA/BENGALI LETTER PA + // U+09AE/U+09CD/U+09AC: + // "ম্ব" BENGALI LETTER MA/BENGALI SIGN VIRAMA/BENGALI LETTER BA + // U+09AE/U+09CD/U+09AD: + // "ম্ভ" BENGALI LETTER MA/BENGALI SIGN VIRAMA/BENGALI LETTER BHA + // U+09AE/U+09CD/U+09AE: + // "ম্ম" BENGALI LETTER MA/BENGALI SIGN VIRAMA/BENGALI LETTER MA + // U+09AE/U+09CD/U+09B0: + // "ম্র" BENGALI LETTER MA/BENGALI SIGN VIRAMA/BENGALI LETTER RA + // U+09AE/U+09CD/U+09B2: + // "ম্ল" BENGALI LETTER MA/BENGALI SIGN VIRAMA/BENGALI LETTER LA + key("\u09AE", joinMoreKeys("\u09AE\u09CD\u09A8", "\u09AE\u09CD\u09AA", + "\u09AE\u09CD\u09AC", "\u09AE\u09CD\u09AD", "\u09AE\u09CD\u09AE", + "\u09AE\u09CD\u09B0", "\u09AE\u09CD\u09B2")), + // U+098F: "এ" BENGALI LETTER E + key("\u098F"), + // U+0993: "ও" BENGALI LETTER O + key("\u0993")) + .build(); + + private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+09A2: "ঢ" BENGALI LETTER DDHA + key("\u09A2"), + // U+09A0: "ঠ" BENGALI LETTER TTHA + key("\u09A0"), + // U+09C8: "ৈ" BENGALI VOWEL SIGN AI + // U+0990: "ঐ" BENGALI LETTER AI + key("\u09C8", moreKey("\u0990")), + // U+09DC: "ড়" BENGALI LETTER RRA + // U+09BC: "়" BENGALI SIGN NUKTA + key("\u09DC", moreKey("\u09BC")), + // U+099F: "ট" BENGALI LETTER TTA + // U+09F3: "৳" BENGALI RUPEE SIGN + // U+099F/U+09CD/U+099F: + // "ট্ট" BENGALI LETTER TTA/BENGALI SIGN VIRAMA/BENGALI LETTER TTA + // U+099F/U+09CD/U+09AC: + // "ট্ব" BENGALI LETTER TTA/BENGALI SIGN VIRAMA/BENGALI LETTER BA + // U+099F/U+09CD/U+09AE: + // "ট্ম" BENGALI LETTER TTA/BENGALI SIGN VIRAMA/BENGALI LETTER MA + key("\u099F", joinMoreKeys("\u09F3", "\u099F\u09CD\u099F", "\u099F\u09CD\u09AC", + "\u099F\u09CD\u09AE")), + // U+099E: "ঞ" BENGALI LETTER NYA + // U+099E/U+09CD/U+099A: + // "ঞ্চ" BENGALI LETTER NYA/BENGALI SIGN VIRAMA/BENGALI LETTER CA + // U+099E/U+09CD/U+099B: + // "ঞ্ছ" BENGALI LETTER NYA/BENGALI SIGN VIRAMA/BENGALI LETTER CHA + // U+099E/U+09CD/U+099C: + // "ঞ্জ" BENGALI LETTER NYA/BENGALI SIGN VIRAMA/BENGALI LETTER JA + key("\u099E", joinMoreKeys("\u099E\u09CD\u099A", "\u099E\u09CD\u099B", + "\u099E\u09CD\u099C")), + // U+09C2: "ূ" BENGALI VOWEL SIGN UU + // U+098A: "ঊ" BENGALI LETTER UU + key("\u09C2", moreKey("\u098A")), + // U+09C0: "ী" BENGALI VOWEL SIGN II + // U+0988: "ঈ" BENGALI LETTER II + key("\u09C0", moreKey("\u0988")), + // U+09CC: "ৌ" BENGALI VOWEL SIGN AU + // U+099A: "ঔ" BENGALI LETTER CA + // U+09D7: "ৗ" BENGALI AU LENGTH MARK + key("\u09CC", joinMoreKeys("\u099A", "\u09D7")), + // U+09AB: "ফ" BENGALI LETTER PHA + // U+09AB/U+09CD/U+099F: + // "ফ্ট" BENGALI LETTER PHA/BENGALI SIGN VIRAMA/BENGALI LETTER TTA + // U+09AB/U+09CD/U+09AF: + // "ফ্য" BENGALI LETTER PHA/BENGALI SIGN VIRAMA/BENGALI LETTER YA + // U+09AB/U+09CD/U+09B0: + // "ফ্র" BENGALI LETTER PHA/BENGALI SIGN VIRAMA/BENGALI LETTER RA + // U+09AB/U+09CD/U+09B2: + // "ফ্ল" BENGALI LETTER PHA/BENGALI SIGN VIRAMA/BENGALI LETTER LA + key("\u09AB", joinMoreKeys("\u09AB\u09CD\u099F", "\u09AB\u09CD\u09AF", + "\u09AB\u09CD\u09B0", "\u09AB\u09CD\u09B2")), + // U+098B: "ঋ" BENGALI LETTER VOCALIC R + // U+098C: "ঌ" BENGALI LETTER VOCALIC L + // U+09E1: "ৡ" BENGALI LETTER VOCALIC LL + // U+09F4: "৴" BENGALI CURRENCY NUMERATOR ONE + // U+09F5: "৵" BENGALI CURRENCY NUMERATOR TWO + // U+09F6: "৶" BENGALI CURRENCY NUMERATOR THREE + // U+09E2: " ৢ" BENGALI VOWEL SIGN VOCALIC L + // U+09E3: " ৣ" BENGALI VOWEL SIGN VOCALIC LL + key("\u098B", joinMoreKeys("\u098C", "\u09E1", "\u09F4", "\u09F5", "\u09F6", + "\u09E2", "\u09E3"))) + .setKeysOfRow(2, + // U+0985: "অ" BENGALI LETTER A + key("\u0985"), + // U+09B6: "শ" BENGALI LETTER SHA + // U+09B6/U+09CD/U+099A: + // "শ্চ" BENGALI LETTER SHA/BENGALI SIGN VIRAMA/BENGALI LETTER CA + // U+09B6/U+09CD/U+099B: + // "শ্ছ" BENGALI LETTER SHA/BENGALI SIGN VIRAMA/BENGALI LETTER CHA + // U+09B6/U+09CD/U+09A4: + // "শ্ত" BENGALI LETTER SHA/BENGALI SIGN VIRAMA/BENGALI LETTER TA + // U+09B6/U+09CD/U+09A8: + // "শ্ন" BENGALI LETTER SHA/BENGALI SIGN VIRAMA/BENGALI LETTER NA + // U+09B6/U+09CD/U+09AC: + // "শ্ব" BENGALI LETTER SHA/BENGALI SIGN VIRAMA/BENGALI LETTER BA + // U+09B6/U+09CD/U+09AE: + // "শ্ম" BENGALI LETTER SHA/BENGALI SIGN VIRAMA/BENGALI LETTER MA + // U+09B6/U+09CD/U+09B0: + // "শ্র" BENGALI LETTER SHA/BENGALI SIGN VIRAMA/BENGALI LETTER RA + // U+09B6/U+09CD/U+09B2: + // "শ্ল" BENGALI LETTER SHA/BENGALI SIGN VIRAMA/BENGALI LETTER LA + key("\u09B6", joinMoreKeys("\u09B6\u09CD\u099A", "\u09B6\u09CD\u099B", + "\u09B6\u09CD\u09A4", "\u09B6\u09CD\u09A8", "\u09B6\u09CD\u09AC", + "\u09B6\u09CD\u09AE", "\u09B6\u09CD\u09B0", "\u09B6\u09CD\u09B2")), + // U+09A1: "ড" BENGALI LETTER DDA + // U+09A1/U+09CD/U+09A1: + // "ড্ড" BENGALI LETTER DDA/BENGALI SIGN VIRAMA/BENGALI LETTER DDA + key("\u09A1", moreKey("\u09A1\u09CD\u09A1")), + // U+09DD: "ঢ়" BENGALI LETTER RHA + key("\u09DD"), + // U+0998: "ঘ" BENGALI LETTER GHA + key("\u0998"), + // U+09B9: "হ" BENGALI LETTER HA + // U+09BD: "ঽ" BENGALI SIGN AVAGRAHA + // U+09B9/U+09CD/U+09A3: + // "হ্ণ" BENGALI LETTER HA/BENGALI SIGN VIRAMA/BENGALI LETTER NNA + // U+09B9/U+09CD/U+09A8: + // "হ্ন" BENGALI LETTER HA/BENGALI SIGN VIRAMA/BENGALI LETTER NA + // U+09B9/U+09CD/U+09AC: + // "হ্ব" BENGALI LETTER HA/BENGALI SIGN VIRAMA/BENGALI LETTER BA + // U+09B9/U+09CD/U+09AE: + // "হ্ম" BENGALI LETTER HA/BENGALI SIGN VIRAMA/BENGALI LETTER MA + // U+09B9/U+09CD/U+09B0: + // "হ্র" BENGALI LETTER HA/BENGALI SIGN VIRAMA/BENGALI LETTER RA + // U+09B9/U+09CD/U+09B2: + // "হ্ল" BENGALI LETTER HA/BENGALI SIGN VIRAMA/BENGALI LETTER LA + key("\u09B9", joinMoreKeys("\u09BD", "\u09B9\u09CD\u09A3", "\u09B9\u09CD\u09A8", + "\u09B9\u09CD\u09AC", "\u09B9\u09CD\u09AE", "\u09B9\u09CD\u09B0", + "\u09B9\u09CD\u09B2")), + // U+099D: "ঝ" BENGALI LETTER JHA + key("\u099D"), + // U+0996: "খ" BENGALI LETTER KHA + key("\u0996"), + // U+09CE: "ৎ" BENGALI LETTER KHANDA TA + key("\u09CE"), + // U+0988: "ঈ" BENGALI LETTER II + key("\u0988"), + // U+098A: "ঊ" BENGALI LETTER UU + key("\u098A")) + .setKeysOfRow(3, + // U+0964: "।" DEVANAGARI DANDA + // U+0965: "॥" DEVANAGARI DOUBLE DANDA + key("\u0964", moreKey("\u0965")), + // U+0999: "ঙ BENGALI LETTER NGA + // U+0999/U+09CD/U+0995: "ঙ্ক" + // U+0999/U+09CD/U+0996: "ঙ্খ" + // U+0999/U+09CD/U+0997: "ঙ্গ" + key("\u0999", joinMoreKeys("\u0999\u09CD\u0995", "\u0999\u09CD\u0996", + "\u0999\u09CD\u0997")), + // U+099B: "ছ" BENGALI LETTER CHA + key("\u099B"), + // U+0983: "ঃ" BENGALI SIGN VISARGA + key("\u0983"), + // U+0981: "ঁ" BENGALI SIGN CANDRABINDU + key("\u0981"), + // U+09A3: "ণ" BENGALI LETTER NNA + // U+09A3/U+09CD/U+099F: + // "ণ্ট" BENGALI LETTER NNA/BENGALI SIGN VIRAMA/BENGALI LETTER TT/A + // U+09A3/U+09CD/U+09A1: + // "ণ্ড" BENGALI LETTER NNA/BENGALI SIGN VIRAMA/BENGALI LETTER DDA + // U+09A3/U+09CD/U+09A3: + // "ণ্ণ" BENGALI LETTER NNA/BENGALI SIGN VIRAMA/BENGALI LETTER NN + key("\u09A3", joinMoreKeys("\u09A3\u09CD\u099F", "\u09A3\u09CD\u09A1", + "\u09A3\u09CD\u09A3")), + // U+0982: "ং" BENGALI SIGN ANUSVARA + key("\u0982"), + // U+0990: "ঐ" BENGALI LETTER AI + key("\u0990"), + // U+0994: "ঔ" BENGALI LETTER AU + key("\u0994")) + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Bulgarian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Bulgarian.java new file mode 100644 index 000000000..99c15d281 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Bulgarian.java @@ -0,0 +1,106 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.EastSlavicCustomizer; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 Locale locale) { + super(new BulgarianCustomizer(locale), Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class BulgarianCustomizer extends LayoutCustomizer { + private final EastSlavicCustomizer mEastSlavicCustomizer; + + 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 + "\u0447") + .setKeysOfRow(2, + // U+0430: "а" CYRILLIC SMALL LETTER A + // U+0441: "с" CYRILLIC SMALL LETTER ES + // U+0434: "д" CYRILLIC SMALL LETTER DE + // U+0444: "ф" CYRILLIC SMALL LETTER EF + // U+0433: "г" CYRILLIC SMALL LETTER GHE + // U+0445: "х" CYRILLIC SMALL LETTER HA + // U+0439: "й" CYRILLIC SMALL LETTER SHORT I + // U+043A: "к" CYRILLIC SMALL LETTER KA + // U+043B: "л" CYRILLIC SMALL LETTER EL + // U+0448: "ш" CYRILLIC SMALL LETTER SHA + // U+0449: "щ" CYRILLIC SMALL LETTER SHCHA + "\u0430", "\u0441", "\u0434", "\u0444", "\u0433", "\u0445", "\u0439", "\u043A", + "\u043B", "\u0448", "\u0449") + .setKeysOfRow(3, + // U+0437: "з" CYRILLIC SMALL LETTER ZE + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+0446: "ц" CYRILLIC SMALL LETTER TSE + // U+0436: "ж" CYRILLIC SMALL LETTER ZHE + // U+0431: "б" CYRILLIC SMALL LETTER BE + // U+043D: "н" CYRILLIC SMALL LETTER EN + // U+043C: "м" CYRILLIC SMALL LETTER EM + // U+044E: "ю" CYRILLIC SMALL LETTER YU + "\u0437", "\u044C", "\u0446", "\u0436", "\u0431", "\u043D", "\u043C", "\u044E") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/BulgarianBds.java b/tests/src/org/kelar/inputmethod/keyboard/layout/BulgarianBds.java new file mode 100644 index 000000000..cba635e75 --- /dev/null +++ b/tests/src/org/kelar/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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.EastSlavicCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 Locale locale) { + super(new BulgarianBdsCustomizer(locale), Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class BulgarianBdsCustomizer extends EastSlavicCustomizer { + 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 + "\u0431") + .setKeysOfRow(2, + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+044F: "я" CYRILLIC SMALL LETTER YA + // U+0430: "а" CYRILLIC SMALL LETTER A + // U+043E: "о" CYRILLIC SMALL LETTER O + // U+0436: "ж" CYRILLIC SMALL LETTER ZHE + // U+0433: "г" CYRILLIC SMALL LETTER GHE + // U+0442: "т" CYRILLIC SMALL LETTER TE + // U+043D: "н" CYRILLIC SMALL LETTER EN + // U+0432: "в" CYRILLIC SMALL LETTER VE + // U+043C: "м" CYRILLIC SMALL LETTER EM + // U+0447: "ч" CYRILLIC SMALL LETTER CHE + "\u044C", "\u044F", "\u0430", "\u043E", "\u0436", "\u0433", "\u0442", "\u043D", + "\u0432", "\u043C", "\u0447") + .setKeysOfRow(3, + // U+044E: "ю" CYRILLIC SMALL LETTER YU + // U+0439: "й" CYRILLIC SMALL LETTER SHORT I + // U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN + // U+044D: "э" CYRILLIC SMALL LETTER E + // U+0444: "ф" CYRILLIC SMALL LETTER EF + // U+0445: "х" CYRILLIC SMALL LETTER HA + // U+043F: "п" CYRILLIC SMALL LETTER PE + // U+0440: "р" CYRILLIC SMALL LETTER ER + // U+043B: "л" CYRILLIC SMALL LETTER EL + "\u044E", "\u0439", "\u044A", "\u044D", "\u0444", "\u0445", "\u043F", "\u0440", + "\u043B") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Colemak.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Colemak.java new file mode 100644 index 000000000..fa64f80e3 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Colemak.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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +/** + * The Colemak alphabet keyboard. + */ +public final class Colemak extends LayoutBase { + private static final String LAYOUT_NAME = "colemak"; + + public Colemak(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + getCustomizer().setAccentedLetters(builder); + builder.replaceKeyOfLabel(ROW1_10, key(";", additionalMoreKey("0"), moreKey(":"))); + 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(ROW1_10, key(":", additionalMoreKey("0"))); + } + builder.toUpperCase(getLocale()); + return builder.build(); + } + + private static final String ROW1_10 = "ROW1_10"; + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + key("q", additionalMoreKey("1")), + key("w", additionalMoreKey("2")), + key("f", additionalMoreKey("3")), + key("p", additionalMoreKey("4")), + key("g", additionalMoreKey("5")), + key("j", additionalMoreKey("6")), + key("l", additionalMoreKey("7")), + key("u", additionalMoreKey("8")), + key("y", additionalMoreKey("9")), + ROW1_10) + .setKeysOfRow(2, "a", "r", "s", "t", "d", "h", "n", "e", "i", "o") + .setKeysOfRow(3, "z", "x", "c", "v", "b", "k", "m") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/DevanagariLetterConstants.java b/tests/src/org/kelar/inputmethod/keyboard/layout/DevanagariLetterConstants.java new file mode 100644 index 000000000..1d2f7f46d --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/DevanagariLetterConstants.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 org.kelar.inputmethod.keyboard.layout; + +import android.os.Build; + +/** + * This class offers label strings of Devanagari letters that need the dotted circle to draw + * its glyph. + */ +class DevanagariLetterConstants { + private static final boolean NEEDS_DOTTED_CIRCLE = + Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN; + // U+25CC: "◌" DOTTED CIRCLE + private static final String DOTTED_CIRCLE = NEEDS_DOTTED_CIRCLE ? "\u25CC" : ""; + + // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU + static final String SIGN_CANDRABINDU = DOTTED_CIRCLE + "\u0901"; + // U+0902: "ं" DEVANAGARI SIGN ANUSVARA + static final String SIGN_ANUSVARA = DOTTED_CIRCLE + "\u0902"; + // U+0903: "ः" DEVANAGARI SIGN VISARGA + static final String SIGN_VISARGA = DOTTED_CIRCLE + "\u0903"; + // U+093C: "़" DEVANAGARI SIGN NUKTA + static final String SIGN_NUKTA = DOTTED_CIRCLE + "\u093C"; + // U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA + static final String SIGN_AVAGRAHA = DOTTED_CIRCLE + "\u093D"; + // U+093E: "ा" DEVANAGARI VOWEL SIGN AA + static final String VOWEL_SIGN_AA = DOTTED_CIRCLE + "\u093E"; + // U+093F: "ि" DEVANAGARI VOWEL SIGN I + static final String VOWEL_SIGN_I = DOTTED_CIRCLE + "\u093F"; + // U+0940: "ी" DEVANAGARI VOWEL SIGN II + static final String VOWEL_SIGN_II = DOTTED_CIRCLE + "\u0940"; + // U+0941: "ु" DEVANAGARI VOWEL SIGN U + static final String VOWEL_SIGN_U = DOTTED_CIRCLE + "\u0941"; + // U+0942: "ू" DEVANAGARI VOWEL SIGN UU + static final String VOWEL_SIGN_UU = DOTTED_CIRCLE + "\u0942"; + // U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R + static final String VOWEL_SIGN_VOCALIC_R = DOTTED_CIRCLE + "\u0943"; + // U+0944: "ॄ" DEVANAGARI VOWEL SIGN VOCALIC RR + static final String VOWEL_SIGN_VOCALIC_RR = DOTTED_CIRCLE + "\u0944"; + // U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E + static final String VOWEL_SIGN_CANDRA_E = DOTTED_CIRCLE + "\u0945"; + // U+0947: "े" DEVANAGARI VOWEL SIGN E + static final String VOWEL_SIGN_E = DOTTED_CIRCLE + "\u0947"; + // U+0948: "ै" DEVANAGARI VOWEL SIGN AI + static final String VOWEL_SIGN_AI = DOTTED_CIRCLE + "\u0948"; + // U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O + static final String VOWEL_SIGN_CANDRA_O = DOTTED_CIRCLE + "\u0949"; + // U+094A: "ॊ" DEVANAGARI VOWEL SIGN SHORT O + static final String VOWEL_SIGN_SHORT_O = DOTTED_CIRCLE + "\u094A"; + // U+094B: "ो" DEVANAGARI VOWEL SIGN O + static final String VOWEL_SIGN_O = DOTTED_CIRCLE + "\u094B"; + // U+094C: "ौ" DEVANAGARI VOWEL SIGN AU + static final String VOWEL_SIGN_AU = DOTTED_CIRCLE + "\u094C"; + // U+094D: "्" DEVANAGARI SIGN VIRAMA + static final String SIGN_VIRAMA = DOTTED_CIRCLE + "\u094D"; + // U+0970: "॰" DEVANAGARI ABBREVIATION SIGN + static final String ABBREVIATION_SIGN = DOTTED_CIRCLE + "\u0970"; + // U+097D: "ॽ" DEVANAGARI LETTER GLOTTAL STOP + static final String LETTER_GLOTTAL_STOP = DOTTED_CIRCLE + "\u097D"; +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Dvorak.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Dvorak.java new file mode 100644 index 000000000..9795427de --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Dvorak.java @@ -0,0 +1,121 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +/** + * The Dvorak alphabet keyboard. + */ +public class Dvorak extends LayoutBase { + private static final String LAYOUT_NAME = "dvorak"; + + public Dvorak(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + @Override + public ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { + return ALPHABET_COMMON; + } + + /** + * Get the left most key of the first row. + * @param isPhone true if requesting phone's keys. + * @param elementId the element id of the requesting shifted mode. + * @return the left most key of the first row. + */ + protected ExpectedKey getRow1_1Key(final boolean isPhone, final int elementId) { + if (elementId == KeyboardId.ELEMENT_ALPHABET + || elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) { + return key("'", joinMoreKeys(additionalMoreKey("1"), "!", "\"")); + } + return key("\"", additionalMoreKey("1")); + } + + /** + * Get the 2nd left key of the first row. + * @param isPhone true if requesting phone's keys. + * @param elementId the element id of the requesting shifted mode. + * @return the 2nd left key of the first row. + */ + protected ExpectedKey getRow1_2Key(final boolean isPhone, final int elementId) { + if (elementId == KeyboardId.ELEMENT_ALPHABET + || elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) { + return key(",", joinMoreKeys(additionalMoreKey("2"), "?", "<")); + } + return key("<", additionalMoreKey("2")); + } + + /** + * Get the 3rd left key of the first row. + * @param isPhone true if requesting phone's keys. + * @param elementId the element id of the requesting shifted mode. + * @return the 3rd left key of the first row. + */ + protected ExpectedKey getRow1_3Key(final boolean isPhone, final int elementId) { + if (elementId == KeyboardId.ELEMENT_ALPHABET + || elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) { + return key(".", joinMoreKeys(additionalMoreKey("3"), ">")); + } + return key(">", additionalMoreKey("3")); + } + + @Override + public ExpectedKey[][] getLayout(final boolean isPhone, final int elementId) { + if (elementId == KeyboardId.ELEMENT_SYMBOLS + || elementId == KeyboardId.ELEMENT_SYMBOLS_SHIFTED) { + return super.getLayout(isPhone, elementId); + } + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder( + getCommonAlphabetLayout(isPhone)); + builder.replaceKeyOfLabel(ROW1_1, getRow1_1Key(isPhone, elementId)) + .replaceKeyOfLabel(ROW1_2, getRow1_2Key(isPhone, elementId)) + .replaceKeyOfLabel(ROW1_3, getRow1_3Key(isPhone, elementId)); + convertCommonLayoutToKeyboard(builder, isPhone); + getCustomizer().setAccentedLetters(builder); + if (elementId != KeyboardId.ELEMENT_ALPHABET) { + builder.toUpperCase(getLocale()); + builder.replaceKeysOfAll(SHIFT_KEY, SHIFTED_SHIFT_KEY); + } + return builder.build(); + } + + public static final String ROW1_1 = "ROW1_1"; + public static final String ROW1_2 = "ROW1_2"; + public static final String ROW1_3 = "ROW1_3"; + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + ROW1_1, ROW1_2, ROW1_3, + key("p", additionalMoreKey("4")), + key("y", additionalMoreKey("5")), + key("f", additionalMoreKey("6")), + key("g", additionalMoreKey("7")), + key("c", additionalMoreKey("8")), + key("r", additionalMoreKey("9")), + key("l", additionalMoreKey("0"))) + .setKeysOfRow(2, "a", "o", "e", "u", "i", "d", "h", "t", "n", "s") + .setKeysOfRow(3, "j", "k", "x", "b", "m", "w", "v") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/EastSlavic.java b/tests/src/org/kelar/inputmethod/keyboard/layout/EastSlavic.java new file mode 100644 index 000000000..e4bbcc24f --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/EastSlavic.java @@ -0,0 +1,88 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +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; } + + @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", additionalMoreKey("1")), + // U+0446: "ц" CYRILLIC SMALL LETTER TSE + key("\u0446", additionalMoreKey("2")), + // U+0439: "й" CYRILLIC SMALL LETTER SHORT I + key("\u0443", additionalMoreKey("3")), + // U+043A: "к" CYRILLIC SMALL LETTER KA + key("\u043A", additionalMoreKey("4")), + // U+0435: "е" CYRILLIC SMALL LETTER IE + key("\u0435", additionalMoreKey("5")), + // U+043D: "н" CYRILLIC SMALL LETTER EN + key("\u043D", additionalMoreKey("6")), + // U+0433: "г" CYRILLIC SMALL LETTER GHE + key("\u0433", additionalMoreKey("7")), + // U+0448: "ш" CYRILLIC SMALL LETTER SHA + key("\u0448", additionalMoreKey("8")), + key(ROW1_9, additionalMoreKey("9")), + // U+0437: "з" CYRILLIC SMALL LETTER ZE + key("\u0437", additionalMoreKey("0")), + // U+0445: "х" CYRILLIC SMALL LETTER HA + "\u0445") + .setKeysOfRow(2, + // U+0444: "ф" CYRILLIC SMALL LETTER EF + // U+0432: "в" CYRILLIC SMALL LETTER VE + // U+0430: "а" CYRILLIC SMALL LETTER A + // U+043F: "п" CYRILLIC SMALL LETTER PE + // U+0440: "р" CYRILLIC SMALL LETTER ER + // U+043E: "о" CYRILLIC SMALL LETTER O + // U+043B: "л" CYRILLIC SMALL LETTER EL + // U+0434: "д" CYRILLIC SMALL LETTER DE + // U+0436: "ж" CYRILLIC SMALL LETTER ZHE + "\u0444", ROW2_2, "\u0432", "\u0430", "\u043F", "\u0440", "\u043E", "\u043B", + "\u0434", "\u0436", ROW2_11) + .setKeysOfRow(3, + // U+044F: "я" CYRILLIC SMALL LETTER YA + // U+0447: "ч" CYRILLIC SMALL LETTER CHE + // U+0441: "с" CYRILLIC SMALL LETTER ES + // U+043C: "м" CYRILLIC SMALL LETTER EM + // U+0442: "т" CYRILLIC SMALL LETTER TE + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+0431: "б" CYRILLIC SMALL LETTER BE + // U+044E: "ю" CYRILLIC SMALL LETTER YU + "\u044F", "\u0447", "\u0441", "\u043C", ROW3_5, "\u0442", "\u044C", "\u0431", + "\u044E") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Farsi.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Farsi.java new file mode 100644 index 000000000..d942600e0 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Farsi.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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.Symbols.RtlSymbols; +import org.kelar.inputmethod.keyboard.layout.SymbolsShifted.RtlSymbolsShifted; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Locale; + +public final class Farsi extends LayoutBase { + private static final String LAYOUT_NAME = "farsi"; + + public Farsi(final Locale locale) { + super(new FarsiCustomizer(locale), FarsiSymbols.class, FarsiSymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class FarsiCustomizer extends LayoutCustomizer { + FarsiCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getAlphabetKey() { return FARSI_ALPHABET_KEY; } + + @Override + public ExpectedKey getSymbolsKey() { return FARSI_SYMBOLS_KEY; } + + @Override + public ExpectedKey getBackToSymbolsKey() { return FARSI_BACK_TO_SYMBOLS_KEY; } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_RIAL; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + @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", SETTINGS_KEY)); + } + // U+060C: "،" ARABIC COMMA + // U+061F: "؟" ARABIC QUESTION MARK + // U+061B: "؛" ARABIC SEMICOLON + return joinKeys(key("\u060C", joinMoreKeys( + ":", "!", "\u061F", "\u061B", "-", RtlSymbols.DOUBLE_ANGLE_QUOTES_LR_RTL, + SETTINGS_KEY))); + } + + @Override + public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) { + if (isPhone) { + return super.getKeysRightToSpacebar(isPhone); + } + return joinKeys(key(".", getPunctuationMoreKeys(isPhone))); + } + + @Override + public ExpectedKey[] getSpaceKeys(final boolean isPhone) { + return joinKeys(LANGUAGE_SWITCH_KEY, SPACE_KEY, key(ZWNJ_KEY, ZWJ_KEY)); + } + + @Override + public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { + return FARSI_DIACRITICS; + } + + // U+0627: "ا" ARABIC LETTER ALEF + // U+200C: ZERO WIDTH NON-JOINER + // U+0628: "ب" ARABIC LETTER BEH + // U+067E: "پ" ARABIC LETTER PEH + private static final ExpectedKey FARSI_ALPHABET_KEY = key( + "\u0627\u200C\u0628\u200C\u067E", Constants.CODE_SWITCH_ALPHA_SYMBOL); + // U+06F3: "۳" EXTENDED ARABIC-INDIC DIGIT THREE + // U+06F2: "۲" EXTENDED ARABIC-INDIC DIGIT TWO + // U+06F1: "۱" EXTENDED ARABIC-INDIC DIGIT ONE + // U+061F: "؟" ARABIC QUESTION MARK + private static final ExpectedKey FARSI_SYMBOLS_KEY = key( + "\u06F3\u06F2\u06F1\u061F", Constants.CODE_SWITCH_ALPHA_SYMBOL); + private static final ExpectedKey FARSI_BACK_TO_SYMBOLS_KEY = key( + "\u06F3\u06F2\u06F1\u061F", Constants.CODE_SHIFT); + // U+FDFC: "﷼" RIAL SIGN + private static final ExpectedKey CURRENCY_RIAL = key("\uFDFC", + Symbols.CURRENCY_GENERIC_MORE_KEYS); + private static final ExpectedKey[] FARSI_DIACRITICS = { + // U+0655: "ٕ" ARABIC HAMZA BELOW + // U+0652: "ْ" ARABIC SUKUN + // U+0651: "ّ" ARABIC SHADDA + // U+064C: "ٌ" ARABIC DAMMATAN + // U+064D: "ٍ" ARABIC KASRATAN + // U+064B: "ً" ARABIC FATHATAN + // U+0654: "ٔ" ARABIC HAMZA ABOVE + // U+0656: "ٖ" ARABIC SUBSCRIPT ALEF + // U+0670: "ٰ" ARABIC LETTER SUPERSCRIPT ALEF + // U+0653: "ٓ" ARABIC MADDAH ABOVE + // U+064F: "ُ" ARABIC DAMMA + // U+0650: "ِ" ARABIC KASRA + // U+064E: "َ" ARABIC FATHA + // U+0640: "ـ" ARABIC TATWEEL + moreKey(" \u0655", "\u0655"), moreKey(" \u0652", "\u0652"), + moreKey(" \u0651", "\u0651"), moreKey(" \u064C", "\u064C"), + moreKey(" \u064D", "\u064D"), moreKey(" \u064B", "\u064B"), + moreKey(" \u0654", "\u0654"), moreKey(" \u0656", "\u0656"), + moreKey(" \u0670", "\u0670"), moreKey(" \u0653", "\u0653"), + moreKey(" \u064F", "\u064F"), moreKey(" \u0650", "\u0650"), + moreKey(" \u064E", "\u064E"), moreKey("\u0640\u0640\u0640", "\u0640") + }; + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { + if (isPhone) { + return ALPHABET_COMMON; + } + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + // U+0622: "آ" ARABIC LETTER ALEF WITH MADDA ABOVE + builder.insertKeysAtRow(3, 10, "\u0622"); + 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+06F1: "۱" EXTENDED ARABIC-INDIC DIGIT ONE + key("\u0636", joinMoreKeys("\u06F1", "1")), + // U+0635: "ص" ARABIC LETTER SAD + // U+06F2: "۲" EXTENDED ARABIC-INDIC DIGIT TWO + key("\u0635", joinMoreKeys("\u06F2", "2")), + // U+062B: "ث" ARABIC LETTER THEH + // U+06F3: "۳" EXTENDED ARABIC-INDIC DIGIT THREE + key("\u062B", joinMoreKeys("\u06F3", "3")), + // U+0642: "ق" ARABIC LETTER QAF + // U+06F4: "۴" EXTENDED ARABIC-INDIC DIGIT FOUR + key("\u0642", joinMoreKeys("\u06F4", "4")), + // U+0641: "ف" ARABIC LETTER FEH + // U+06F5: "۵" EXTENDED ARABIC-INDIC DIGIT FIVE + key("\u0641", joinMoreKeys("\u06F5", "5")), + // U+063A: "غ" ARABIC LETTER GHAIN + // U+06F6: "۶" EXTENDED ARABIC-INDIC DIGIT SIX + key("\u063A", joinMoreKeys("\u06F6", "6")), + // U+0639: "ع" ARABIC LETTER AIN + // U+06F7: "۷" EXTENDED ARABIC-INDIC DIGIT SEVEN + key("\u0639", joinMoreKeys("\u06F7", "7")), + // U+0647: "ه" ARABIC LETTER HEH + // U+FEEB: "ﻫ" ARABIC LETTER HEH INITIAL FORM + // U+0647/U+200D: ARABIC LETTER HEH + ZERO WIDTH JOINER + // U+0647/U+0654: ARABIC LETTER HEH + ARABIC HAMZA ABOVE + // U+0629: "ة" ARABIC LETTER TEH MARBUTA + // U+06F8: "۸" EXTENDED ARABIC-INDIC DIGIT EIGHT + key("\u0647", joinMoreKeys(moreKey("\uFEEB", "\u0647\u200D"), "\u0647\u0654", + "\u0629", "\u06F8", "8")), + // U+062E: "خ" ARABIC LETTER KHAH + // U+06F9: "۹" EXTENDED ARABIC-INDIC DIGIT NINE + key("\u062E", joinMoreKeys("\u06F9", "9")), + // U+062D: "ح" ARABIC LETTER HAH + // U+06F0: "۰" EXTENDED ARABIC-INDIC DIGIT ZERO + key("\u062D", joinMoreKeys("\u06F0", "0")), + // U+062C: "ج" ARABIC LETTER JEEM + "\u062C") + .setKeysOfRow(2, + // U+0634: "ش" ARABIC LETTER SHEEN + // U+0633: "س" ARABIC LETTER SEEN + "\u0634", "\u0633", + // U+06CC: "ی" ARABIC LETTER FARSI YEH + // U+0626: "ئ" ARABIC LETTER YEH WITH HAMZA ABOVE + // U+064A: "ي" ARABIC LETTER YEH + // U+FBE8: "ﯨ" ARABIC LETTER UIGHUR KAZAKH KIRGHIZ ALEF MAKSURA INITIAL FORM + // U+0649: "ى" ARABIC LETTER ALEF MAKSURA + key("\u06CC", joinMoreKeys("\u0626", "\u064A", moreKey("\uFBE8", "\u0649"))), + // U+0628: "ب" ARABIC LETTER BEH + // U+0644: "ل" ARABIC LETTER LAM + "\u0628", "\u0644", + // U+0627: "ا" ARABIC LETTER ALEF + // U+0671: "ٱ" ARABIC LETTER ALEF WASLA + // U+0621: "ء" ARABIC LETTER HAMZA + // U+0622: "آ" ARABIC LETTER ALEF WITH MADDA ABOVE + // U+0623: "أ" ARABIC LETTER ALEF WITH HAMZA ABOVE + // U+0625: "إ" ARABIC LETTER ALEF WITH HAMZA BELOW + key("\u0627", joinMoreKeys("\u0671", "\u0621", "\u0622", "\u0623", "\u0625")), + // U+062A: "ت" ARABIC LETTER TEH + // U+0629: "ة": ARABIC LETTER TEH MARBUTA + key("\u062A", moreKey("\u0629")), + // U+0646: "ن" ARABIC LETTER NOON + // U+0645: "م" ARABIC LETTER MEEM + "\u0646", "\u0645", + // U+06A9: "ک" ARABIC LETTER KEHEH + // U+0643: "ك" ARABIC LETTER KAF + key("\u06A9", moreKey("\u0643")), + // U+06AF: "گ" ARABIC LETTER GAF + "\u06AF") + .setKeysOfRow(3, + // U+0638: "ظ" ARABIC LETTER ZAH + // U+0637: "ط" ARABIC LETTER TAH + // U+0698: "ژ" ARABIC LETTER JEH + // U+0632: "ز" ARABIC LETTER ZAIN + // U+0631: "ر" ARABIC LETTER REH + // U+0630: "ذ" ARABIC LETTER THAL + // U+062F: "د" ARABIC LETTER DAL + // U+067E: "پ" ARABIC LETTER PEH + "\u0638", "\u0637", "\u0698", "\u0632", "\u0631", "\u0630", "\u062F", "\u067E", + // U+0648: "و" ARABIC LETTER WAW + // U+0624: "ؤ" ARABIC LETTER WAW WITH HAMZA ABOVE + key("\u0648", moreKey("\u0624")), + // U+0686: "چ" ARABIC LETTER TCHEH + "\u0686") + .build(); + + private static class FarsiSymbols extends RtlSymbols { + public FarsiSymbols(final LayoutCustomizer customizer) { + super(customizer); + } + + @Override + public ExpectedKey[][] getLayout(final boolean isPhone) { + return new ExpectedKeyboardBuilder(super.getLayout(isPhone)) + // U+06F1: "۱" EXTENDED 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("\u06F1", + joinMoreKeys("1", "\u00B9", "\u00BD", "\u2153", "\u00BC", "\u215B"))) + // U+06F2: "۲" EXTENDED ARABIC-INDIC DIGIT TWO + // U+00B2: "²" SUPERSCRIPT TWO + // U+2154: "⅔" VULGAR FRACTION TWO THIRDS + .replaceKeyOfLabel("2", key("\u06F2", joinMoreKeys("2", "\u00B2", "\u2154"))) + // U+06F3: "۳" EXTENDED ARABIC-INDIC DIGIT THREE + // U+00B3: "³" SUPERSCRIPT THREE + // U+00BE: "¾" VULGAR FRACTION THREE QUARTERS + // U+215C: "⅜" VULGAR FRACTION THREE EIGHTHS + .replaceKeyOfLabel("3", key("\u06F3", + joinMoreKeys("3", "\u00B3", "\u00BE", "\u215C"))) + // U+06F4: "۴" EXTENDED ARABIC-INDIC DIGIT FOUR + // U+2074: "⁴" SUPERSCRIPT FOUR + .replaceKeyOfLabel("4", key("\u06F4", joinMoreKeys("4", "\u2074"))) + // U+06F5: "۵" EXTENDED ARABIC-INDIC DIGIT FIVE + // U+215D: "⅝" VULGAR FRACTION FIVE EIGHTHS + .replaceKeyOfLabel("5", key("\u06F5", joinMoreKeys("5", "\u215D"))) + // U+06F6: "۶" EXTENDED ARABIC-INDIC DIGIT SIX + .replaceKeyOfLabel("6", key("\u06F6", moreKey("6"))) + // U+06F7: "۷" EXTENDED ARABIC-INDIC DIGIT SEVEN + // U+215E: "⅞" VULGAR FRACTION SEVEN EIGHTHS + .replaceKeyOfLabel("7", key("\u06F7", joinMoreKeys("7", "\u215E"))) + // U+06F8: "۸" EXTENDED ARABIC-INDIC DIGIT EIGHT + .replaceKeyOfLabel("8", key("\u06F8", moreKey("8"))) + // U+06F9: "۹" EXTENDED ARABIC-INDIC DIGIT NINE + .replaceKeyOfLabel("9", key("\u06F9", moreKey("9"))) + // U+066C: "٬" ARABIC THOUSANDS SEPARATOR + .replaceKeyOfLabel("@", key("\u066C", moreKey("@"))) + // U+066B: "٫" ARABIC DECIMAL SEPARATOR + .replaceKeyOfLabel("#", key("\u066B", moreKey("#"))) + // U+06F0: "۰" EXTENDED 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("\u06F0", + joinMoreKeys("0", "\u066B", "\u066C", "\u207F", "\u2205"))) + // U+066A: "٪" ARABIC PERCENT SIGN + // U+2030: "‰" PER MILLE SIGN + .replaceKeyOfLabel("%", key("\u066A", joinMoreKeys("%", "\u2030"))) + // U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK + // U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK + // U+2264: "≤" LESS-THAN OR EQUAL TO + .replaceKeyOfLabel("\"", key("\u00AB", "\u00BB", joinMoreKeys( + DOUBLE_QUOTES_9LR, DOUBLE_ANGLE_QUOTES_LR_RTL))) + // U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK + // U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK + // U+2265: "≥" GREATER-THAN EQUAL TO + .replaceKeyOfLabel("'", key("\u00BB", "\u00AB", joinMoreKeys( + SINGLE_QUOTES_9LR, SINGLE_ANGLE_QUOTES_LR_RTL))) + // 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(",", "\u060C") + // 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 FarsiSymbolsShifted extends RtlSymbolsShifted { + public FarsiSymbolsShifted(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(",", "\u060C") + // U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK + // U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK + // U+2264: "≤" LESS-THAN OR EQUAL TO + .replaceKeyOfLabel("<", key("\u00AB", "\u00BB", + moreKey("\u2039", "\u203A"), moreKey("\u2264", "\u2265"), + moreKey("<", ">"))) + // U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK + // U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK + // U+2265: "≥" GREATER-THAN EQUAL TO + .replaceKeyOfLabel(">", key("\u00BB", "\u00AB", + moreKey("\u203A", "\u2039"), moreKey("\u2265", "\u2264"), + moreKey(">", "<"))) + .build(); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Georgian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Georgian.java new file mode 100644 index 000000000..e658e1ca0 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Georgian.java @@ -0,0 +1,164 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Locale; + +/** + * The Georgian alphabet keyboard. + */ +public final class Georgian extends LayoutBase { + private static final String LAYOUT_NAME = "georgian"; + + public Georgian(final Locale locale) { + super(new GeorgianCustomizer(locale), Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class GeorgianCustomizer extends LayoutCustomizer { + GeorgianCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getAlphabetKey() { return GEORGIAN_ALPHABET_KEY; } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_R9L; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_R9L; } + + // U+10D0: "ა" GEORGIAN LETTER AN + // U+10D1: "ბ" GEORGIAN LETTER BAN + // U+10D2: "გ" GEORGIAN LETTER GAN + private static final ExpectedKey GEORGIAN_ALPHABET_KEY = key( + "\u10D0\u10D1\u10D2", Constants.CODE_SWITCH_ALPHA_SYMBOL); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { + return ALPHABET_COMMON; + } + + @Override + public ExpectedKey[][] getCommonAlphabetShiftLayout(final 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+10E5: "ქ" GEORGIAN LETTER GHAN + key("\u10E5", moreKey("1")), + // U+10EC: "წ" GEORGIAN LETTER CIL + key("\u10EC", moreKey("2")), + // U+10D4: "ე" GEORGIAN LETTER EN + // U+10F1: "ჱ" GEORGIAN LETTER HE + key("\u10D4", joinMoreKeys("3", "\u10F1")), + // U+10E0: "რ" GEORGIAN LETTER RAE + key("\u10E0", moreKey("4")), + // U+10E2: "ტ" GEORGIAN LETTER TAR + key("\u10E2", moreKey("5")), + // U+10E7: "ყ" GEORGIAN LETTER QAR + // U+10F8: "ჸ" GEORGIAN LETTER ELIFI + key("\u10E7", joinMoreKeys("6", "\u10F8")), + // U+10E3: "უ" GEORGIAN LETTER UN + key("\u10E3", moreKey("7")), + // U+10D8: "ი" GEORGIAN LETTER IN + // U+10F2: "ჲ" GEORGIAN LETTER HIE + key("\u10D8", joinMoreKeys("8", "\u10F2")), + // U+10DD: "ო" GEORGIAN LETTER ON + key("\u10DD", moreKey("9")), + // U+10DE: "პ" GEORGIAN LETTER PAR + key("\u10DE", moreKey("0"))) + .setKeysOfRow(2, + // U+10D0: "ა" GEORGIAN LETTER AN + // U+10FA: "ჺ" GEORGIAN LETTER AIN + key("\u10D0", moreKey("\u10FA")), + // U+10E1: "ს" GEORGIAN LETTER SAN + // U+10D3: "დ" GEORGIAN LETTER DON + "\u10E1", "\u10D3", + // U+10E4: "ფ" GEORGIAN LETTER PHAR + // U+10F6: "ჶ" GEORGIAN LETTER FI + key("\u10E4", moreKey("\u10F6")), + // U+10D2: "გ" GEORGIAN LETTER GAN + // U+10F9: "ჹ" GEORGIAN LETTER TURNED GAN + key("\u10D2", moreKey("\u10F9")), + // U+10F0: "ჰ" GEORGIAN LETTER HAE + // U+10F5: "ჵ" GEORGIAN LETTER HOE + key("\u10F0", moreKey("\u10F5")), + // U+10EF: "ჯ" GEORGIAN LETTER JHAN + // U+10F7: "ჷ" GEORGIAN LETTER YN + key("\u10EF", moreKey("\u10F7")), + // U+10D9: "კ" GEORGIAN LETTER KAN + // U+10DA: "ლ" GEORGIAN LETTER LAS + "\u10D9", "\u10DA") + .setKeysOfRow(3, + // U+10D6: "ზ" GEORGIAN LETTER ZEN + "\u10D6", + // U+10EE: "ხ" GEORGIAN LETTER XAN + // U+10F4: "ჴ" GEORGIAN LETTER HAR + key("\u10EE", moreKey("\u10F4")), + // U+10EA: "ც" GEORGIAN LETTER CAN + "\u10EA", + // U+10D5: "ვ" GEORGIAN LETTER VIN + // U+10F3: "ჳ" GEORGIAN LETTER WE + key("\u10D5", moreKey("\u10F3")), + // U+10D1: "ბ" GEORGIAN LETTER BAN + "\u10D1", + // U+10DC: "ნ" GEORGIAN LETTER NAR + // U+10FC: "ჼ" MODIFIER LETTER GEORGIAN NAR + key("\u10DC", moreKey("\u10FC")), + // U+10DB: "მ" GEORGIAN LETTER MAN + "\u10DB") + .build(); + + private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + key("Q", moreKey("1")), + // U+10ED: "ჭ" GEORGIAN LETTER CHAR + key("\u10ED", moreKey("2")), + key("E", moreKey("3")), + // U+10E6: "ღ" GEORGIAN LETTER GHAN + key("\u10E6", moreKey("4")), + // U+10D7: "თ" GEORGIAN LETTER TAN + key("\u10D7", moreKey("5")), + key("Y", moreKey("6")), + key("U", moreKey("7")), + key("I", moreKey("8")), + key("O", moreKey("9")), + key("P", moreKey("0"))) + .setKeysOfRow(2, + // U+10E8: "შ" GEORGIAN LETTER SHIN + // U+10DF: "ჟ" GEORGIAN LETTER ZHAR + "A", "\u10E8", "D", "F", "G", "H", "\u10DF", "K", "L") + .setKeysOfRow(3, + // U+10EB: "ძ" GEORGIAN LETTER JIL + // U+10E9: "ჩ" GEORGIAN LETTER CHIN + "\u10EB", "X", "\u10E9", "V", "B", "N", "M") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Greek.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Greek.java new file mode 100644 index 000000000..e646fc663 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Greek.java @@ -0,0 +1,140 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.layout.customizer.EuroCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import org.kelar.inputmethod.latin.common.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 Locale locale) { + super(new GreekCustomizer(locale), Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class GreekCustomizer extends EuroCustomizer { + 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("\u03AD", "3")), + // 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("\u03CD", "6", "\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("\u03AF", "8", "\u03CA", "\u0390")), + // U+03BF: "ο" GREEK SMALL LETTER OMICRON + // U+03CC: "ό" GREEK SMALL LETTER OMICRON WITH TONOS + key("\u03BF", joinMoreKeys("\u03CC", "9")), + // 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 + // U+03B4: "δ" GREEK SMALL LETTER DELTA + // U+03C6: "φ" GREEK SMALL LETTER PHI + // U+03B3: "γ" GREEK SMALL LETTER GAMMA + "\u03C3", "\u03B4", "\u03C6", "\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 + // U+03BA: "κ" GREEK SMALL LETTER KAPPA + // U+03BB: "λ" GREEK SMALL LETTER LAMDA + "\u03BE", "\u03BA", "\u03BB") + .setKeysOfRow(3, + // U+03B6: "ζ" GREEK SMALL LETTER ZETA + // U+03C7: "χ" GREEK SMALL LETTER CHI + // U+03C8: "ψ" GREEK SMALL LETTER PSI + "\u03B6", "\u03C7", "\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 + // U+03BD: "ν" GREEK SMALL LETTER NU + // U+03BC: "μ" GREEK SMALL LETTER MU + "\u03B2", "\u03BD", "\u03BC") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Hebrew.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Hebrew.java new file mode 100644 index 000000000..5adb50ddc --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Hebrew.java @@ -0,0 +1,186 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.Symbols.RtlSymbols; +import org.kelar.inputmethod.keyboard.layout.SymbolsShifted.RtlSymbolsShifted; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Locale; + +public final class Hebrew extends LayoutBase { + private static final String LAYOUT_NAME = "hebrew"; + + public Hebrew(final Locale locale) { + super(new HebrewCustomizer(locale), HebrewSymbols.class, RtlSymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class HebrewCustomizer extends LayoutCustomizer { + HebrewCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getAlphabetKey() { return HEBREW_ALPHABET_KEY; } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_NEW_SHEQEL; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + @Override + public ExpectedKey[] getDoubleQuoteMoreKeys() { return Symbols.DOUBLE_QUOTES_LR9; } + + @Override + public ExpectedKey[] getSingleQuoteMoreKeys() { return Symbols.SINGLE_QUOTES_LR9; } + + @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 isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS; + } + + @Override + public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { + return isPhone ? RTL_PHONE_PUNCTUATION_MORE_KEYS + : RTL_TABLET_PUNCTUATION_MORE_KEYS; + } + + // U+05D0: "א" HEBREW LETTER ALEF + // U+05D1: "ב" HEBREW LETTER BET + // U+05D2: "ג" HEBREW LETTER GIMEL + private static final ExpectedKey HEBREW_ALPHABET_KEY = key( + "\u05D0\u05D1\u05D2", Constants.CODE_SWITCH_ALPHA_SYMBOL); + // U+20AA: "₪" NEW SHEQEL SIGN + private static final ExpectedKey CURRENCY_NEW_SHEQEL = key("\u20AA", + Symbols.CURRENCY_GENERIC_MORE_KEYS); + private static final ExpectedKey[] RTL_PHONE_PUNCTUATION_MORE_KEYS = joinKeys( + ",", "?", "!", "#", key(")", "("), key("(", ")"), "/", ";", + "'", "@", ":", "-", "\"", "+", "%", "&"); + // Punctuation more keys for tablet form factor. + private static final ExpectedKey[] RTL_TABLET_PUNCTUATION_MORE_KEYS = joinKeys( + ",", "'", "#", key(")", "("), key("(", ")"), "/", ";", + "@", ":", "-", "\"", "+", "%", "&"); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(final boolean isPhone, final int elementId) { + return null; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + key("'", joinMoreKeys("1", "\"")), + key("-", joinMoreKeys("2", "_")), + // U+05E7: "ק" HEBREW LETTER QOF + key("\u05E7", moreKey("3")), + // U+05E8: "ר" HEBREW LETTER RESH + key("\u05E8", moreKey("4")), + // U+05D0: "א" HEBREW LETTER ALEF + key("\u05D0", moreKey("5")), + // U+05D8: "ט" HEBREW LETTER TET + key("\u05D8", moreKey("6")), + // U+05D5: "ו" HEBREW LETTER VAV + key("\u05D5", moreKey("7")), + // U+05DF: "ן" HEBREW LETTER FINAL NUN + key("\u05DF", moreKey("8")), + // U+05DD: "ם" HEBREW LETTER FINAL MEM + key("\u05DD", moreKey("9")), + // U+05E4: "פ" HEBREW LETTER PE + key("\u05E4", moreKey("0"))) + .setKeysOfRow(2, + // U+05E9: "ש" HEBREW LETTER SHIN + // U+05D3: "ד" HEBREW LETTER DALET + "\u05E9", "\u05D3", + // U+05D2: "ג" HEBREW LETTER GIMEL + // U+05D2 U+05F3: "ג׳" HEBREW LETTER GIMEL + HEBREW PUNCTUATION GERESH + key("\u05D2", moreKey("\u05D2\u05F3")), + // U+05DB: "כ" HEBREW LETTER KAF + // U+05E2: "ע" HEBREW LETTER AYIN + "\u05DB", "\u05E2", + // U+05D9: "י" HEBREW LETTER YOD + // U+05F2 U+05B7: "ײַ" HEBREW LIGATURE YIDDISH DOUBLE YOD + HEBREW POINT PATAH + key("\u05D9", moreKey("\u05F2\u05B7")), + // U+05D7: "ח" HEBREW LETTER HET + // U+05D7 U+05F3: "ח׳" HEBREW LETTER HET + HEBREW PUNCTUATION GERESH + key("\u05D7", moreKey("\u05D7\u05F3")), + // U+05DC: "ל" HEBREW LETTER LAMED + // U+05DA: "ך" HEBREW LETTER FINAL KAF + // U+05E3: "ף" HEBREW LETTER FINAL PE + "\u05DC", "\u05DA", "\u05E3") + .setKeysOfRow(3, + // U+05D6: "ז" HEBREW LETTER ZAYIN + // U+05D6 U+05F3: "ז׳" HEBREW LETTER ZAYIN + HEBREW PUNCTUATION GERESH + key("\u05D6", moreKey("\u05D6\u05F3")), + // U+05E1: "ס" HEBREW LETTER SAMEKH + // U+05D1: "ב" HEBREW LETTER BET + // U+05D4: "ה" HEBREW LETTER HE + // U+05E0: "נ" HEBREW LETTER NUN + // U+05DE: "מ" HEBREW LETTER MEM + "\u05E1", "\u05D1", "\u05D4", "\u05E0", "\u05DE", + // U+05E6: "צ" HEBREW LETTER TSADI + // U+05E6 U+05F3: "צ׳" HEBREW LETTER TSADI + HEBREW PUNCTUATION GERESH + key("\u05E6", moreKey("\u05E6\u05F3")), + // U+05EA: "ת" HEBREW LETTER TAV + // U+05EA U+05F3: "ת׳" HEBREW LETTER TAV + HEBREW PUNCTUATION GERESH + key("\u05EA", moreKey("\u05EA\u05F3")), + // U+05E5: "ץ" HEBREW LETTER FINAL TSADI + // U+05E5 U+05F3: "ץ׳" HEBREW LETTER FINAL TSADI + HEBREW PUNCTUATION GERESH + key("\u05E5", moreKey("\u05E5\u05F3"))) + .build(); + + private static class HebrewSymbols extends RtlSymbols { + public HebrewSymbols(final LayoutCustomizer customizer) { + super(customizer); + } + + @Override + public ExpectedKey[][] getLayout(final boolean isPhone) { + return new ExpectedKeyboardBuilder(super.getLayout(isPhone)) + // U+00B1: "±" PLUS-MINUS SIGN + // U+FB29: "﬩" HEBREW LETTER ALTERNATIVE PLUS SIGN + .setMoreKeysOf("+", "\u00B1", "\uFB29") + // U+2605: "★" BLACK STAR + .setMoreKeysOf("*", "\u2605") + .build(); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Hindi.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Hindi.java new file mode 100644 index 000000000..25021e72d --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Hindi.java @@ -0,0 +1,332 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import static org.kelar.inputmethod.keyboard.layout.DevanagariLetterConstants.*; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +/** + * 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; } + + @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(VOWEL_SIGN_AU, "\u094C", joinMoreKeys( + moreKey(VOWEL_SIGN_AU + "\u0902", "\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(VOWEL_SIGN_AI, "\u0948", joinMoreKeys( + moreKey(VOWEL_SIGN_AI + "\u0902", "\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(VOWEL_SIGN_AA, "\u093E", joinMoreKeys( + moreKey(VOWEL_SIGN_AA + "\u0902", "\u093E\u0902"), + moreKey(VOWEL_SIGN_AA + "\u0901", "\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(VOWEL_SIGN_II, "\u0940", joinMoreKeys( + moreKey(VOWEL_SIGN_II + "\u0902", "\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(VOWEL_SIGN_UU, "\u0942", joinMoreKeys( + moreKey(VOWEL_SIGN_UU + "\u0902", "\u0942\u0902"), + moreKey(VOWEL_SIGN_UU + "\u0901", "\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(VOWEL_SIGN_O, "\u094B", joinMoreKeys( + moreKey(VOWEL_SIGN_O + "\u0902", "\u094B\u0902"), + moreKey(VOWEL_SIGN_CANDRA_O, "\u0949"), + moreKey(VOWEL_SIGN_SHORT_O, "\u094A"))), + // U+0947: "े" DEVANAGARI VOWEL SIGN E + // U+0947/U+0902: "ें" DEVANAGARI VOWEL SIGN E/DEVANAGARI SIGN ANUSVARA + key(VOWEL_SIGN_E, "\u0947", + moreKey(VOWEL_SIGN_E + "\u0902", "\u0947\u0902")), + // U+094D: "्" DEVANAGARI SIGN VIRAMA + key(SIGN_VIRAMA, "\u094D"), + // U+093F: "ि" DEVANAGARI VOWEL SIGN I + // U+093F/U+0902: "िं" DEVANAGARI VOWEL SIGN I/DEVANAGARI SIGN ANUSVARA + key(VOWEL_SIGN_I, "\u093F", + moreKey("\u093F" + SIGN_ANUSVARA, "\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(VOWEL_SIGN_U, "\u0941", joinMoreKeys( + moreKey(VOWEL_SIGN_U + "\u0902", "\u0941\u0902"), + moreKey(VOWEL_SIGN_U + "\u0901", "\u0941\u0901"))), + // U+092A: "प" DEVANAGARI LETTER PA + "\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 + // U+091F: "ट" DEVANAGARI LETTER TTA + "\u091A","\u091F") + .setKeysOfRow(3, + // U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O + key(VOWEL_SIGN_CANDRA_O, "\u0949"), + // U+0902: "ं" DEVANAGARI SIGN ANUSVARA + key(SIGN_ANUSVARA, "\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 + "\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 + "\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(SIGN_NUKTA, "\u093C", joinMoreKeys( + moreKey(LETTER_GLOTTAL_STOP, "\u097D"), + moreKey(ABBREVIATION_SIGN, "\u0970"), + moreKey(SIGN_AVAGRAHA, "\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 + // U+0903: "ः" DEVANAGARI SIGN VISARGA + // U+0918: "घ" DEVANAGARI LETTER GHA + "\u092D", key(SIGN_VISARGA, "\u0903"), "\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 + // U+0922: "ढ" DEVANAGARI LETTER DDHA + "\u091D", "\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 + // U+091B: "छ" DEVANAGARI LETTER CHA + // U+0920: "ठ" DEVANAGARI LETTER TTHA + "\u0925", "\u091B", "\u0920") + .setKeysOfRow(3, + // U+0911: "ऑ" DEVANAGARI LETTER CANDRA O + "\u0911", + // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU + // U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E + key(SIGN_CANDRABINDU, "\u0901", moreKey(VOWEL_SIGN_CANDRA_E, "\u0945")), + // U+0923: "ण" DEVANAGARI LETTER NNA + // U+0929: "ऩ" DEVANAGARI LETTER NNNA + "\u0923", "\u0929", + // U+0933: "ळ" DEVANAGARI LETTER LLA + // U+0934: "ऴ" DEVANAGARI LETTER LLLA + key("\u0933", moreKey("\u0934")), + // U+0936: "श" DEVANAGARI LETTER SHA + // U+0937: "ष" DEVANAGARI LETTER SSA + "\u0936", "\u0937", + // U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R + // U+0944: "ॄ" DEVANAGARI VOWEL SIGN VOCALIC RR + key(VOWEL_SIGN_VOCALIC_R, "\u0943", moreKey(VOWEL_SIGN_VOCALIC_RR, "\u0944")), + // U+091E: "ञ" DEVANAGARI LETTER NYA + "\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/org/kelar/inputmethod/keyboard/layout/HindiCompact.java b/tests/src/org/kelar/inputmethod/keyboard/layout/HindiCompact.java new file mode 100644 index 000000000..253447dfe --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/HindiCompact.java @@ -0,0 +1,180 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import static org.kelar.inputmethod.keyboard.layout.DevanagariLetterConstants.*; + +import org.kelar.inputmethod.keyboard.layout.Hindi.HindiSymbols; +import org.kelar.inputmethod.keyboard.layout.customizer.HindiCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * The Hindi Compact keyboard. + */ +public final class HindiCompact extends LayoutBase { + private static final String LAYOUT_NAME = "hindi_compact"; + + public HindiCompact(final Locale locale) { + super(new HindiCompactCustomizer(locale), HindiSymbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class HindiCompactCustomizer extends HindiCustomizer { + HindiCompactCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) { + return EMPTY_KEYS; + } + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) { + return null; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0914: "औ" DEVANAGARI LETTER AU + // U+094C: "ौ" DEVANAGARI VOWEL SIGN AU + // U+0967: "१" DEVANAGARI DIGIT ONE + key("\u0914", joinMoreKeys(moreKey(VOWEL_SIGN_AU, "\u094C"), "\u0967", "1")), + // U+0910: "ऐ" DEVANAGARI LETTER AI + // U+0948: "ै" DEVANAGARI VOWEL SIGN AI + // U+0968: "२" DEVANAGARI DIGIT TWO + key("\u0910", joinMoreKeys(moreKey(VOWEL_SIGN_AI, "\u0948"), "\u0968", "2")), + // U+0906: "आ" DEVANAGARI LETTER AA + // U+093E: "ा" DEVANAGARI VOWEL SIGN AA + // U+0969: "३" DEVANAGARI DIGIT THREE + key("\u0906", joinMoreKeys(moreKey(VOWEL_SIGN_AA, "\u093E"), "\u0969", "3")), + // U+0908: "ई" DEVANAGARI LETTER II + // U+0940: "ी" DEVANAGARI VOWEL SIGN II + // U+096A: "४" DEVANAGARI DIGIT FOUR + key("\u0908", joinMoreKeys(moreKey(VOWEL_SIGN_II, "\u0940"), "\u096A", "4")), + // U+090A: "ऊ" DEVANAGARI LETTER UU + // U+0942: "ू" DEVANAGARI VOWEL SIGN UU + // U+096B: "५" DEVANAGARI DIGIT FIVE + key("\u090A", joinMoreKeys(moreKey(VOWEL_SIGN_UU, "\u0942"), "\u096B", "5")), + // U+092C: "ब" DEVANAGARI LETTER BA + // U+092D: "भ" DEVANAGARI LETTER BHA + // U+096C: "६" DEVANAGARI DIGIT SIX + key("\u092C", joinMoreKeys("\u092D", "\u096C", "6")), + // U+0939: "ह" DEVANAGARI LETTER HA + // U+096D: "७" DEVANAGARI DIGIT SEVEN + key("\u0939", joinMoreKeys("\u096D", "7")), + // U+0917: "ग" DEVANAGARI LETTER GA + // U+0918: "घ" DEVANAGARI LETTER GHA + // U+096E: "८" DEVANAGARI DIGIT EIGHT + key("\u0917", joinMoreKeys("\u0918", "\u096E", "8")), + // U+0926: "द" DEVANAGARI LETTER DA + // U+0927: "ध" DEVANAGARI LETTER DHA + // U+096F: "९" DEVANAGARI DIGIT NINE + key("\u0926", joinMoreKeys("\u0927", "\u096F", "9")), + // U+091C: "ज" DEVANAGARI LETTER JA + // U+091D: "झ" DEVANAGARI LETTER JHA + // U+091C/U+094D/U+091E: + // "ज्ञ" DEVANAGARI LETTER JA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER NYA + // U+0966: "०" DEVANAGARI DIGIT ZERO + key("\u091C", joinMoreKeys("\u091D", "\u091C\u094D\u091E", "\u0966", "0")), + // U+0921: "ड" DEVANAGARI LETTER DDA + // U+0922: "ढ" DEVANAGARI LETTER DDHA + key("\u0921", moreKey("\u0922"))) + .setKeysOfRow(2, + // U+0913: "ओ" DEVANAGARI LETTER O + // U+094B: "ो" DEVANAGARI VOWEL SIGN O + key("\u0913", moreKey(VOWEL_SIGN_O, "\u094B")), + // U+090F: "ए" DEVANAGARI LETTER E + // U+0947: "े" DEVANAGARI VOWEL SIGN E + key("\u090F", moreKey(VOWEL_SIGN_E, "\u0947")), + // U+0905: "अ" DEVANAGARI LETTER A + // U+094D: "्" DEVANAGARI SIGN VIRAMA + key("\u0905", moreKey(SIGN_VIRAMA, "\u094D")), + // U+0907: "इ" DEVANAGARI LETTER I + // U+093F: "ि" DEVANAGARI VOWEL SIGN I + key("\u0907", moreKey(VOWEL_SIGN_I, "\u093F")), + // U+0909: "उ" DEVANAGARI LETTER U + // U+0941: "ु" DEVANAGARI VOWEL SIGN U + key("\u0909", moreKey(VOWEL_SIGN_U, "\u0941")), + // U+092A: "प" DEVANAGARI LETTER PA + // U+092B: "फ" DEVANAGARI LETTER PHA + key("\u092A", moreKey("\u092B")), + // U+0930: "र" DEVANAGARI LETTER RA + // U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R + // U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R + key("\u0930", joinMoreKeys("\u090B", moreKey(VOWEL_SIGN_VOCALIC_R, "\u0943"))), + // U+0915: "क" DEVANAGARI LETTER KA + // U+0916: "ख" DEVANAGARI LETTER KHA + key("\u0915", moreKey("\u0916")), + // U+0924: "त" DEVANAGARI LETTER TA + // U+0925: "थ" DEVANAGARI LETTER THA + // U+0924/U+094D/U+0930: + // "त्र" DEVANAGARI LETTER TA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA + key("\u0924", joinMoreKeys("\u0925", "\u0924\u094D\u0930")), + // U+091A: "च" DEVANAGARI LETTER CA + // U+091B: "छ" DEVANAGARI LETTER CHA + key("\u091A", moreKey("\u091B")), + // U+091F: "ट" DEVANAGARI LETTER TTA + // U+0920: "ठ" DEVANAGARI LETTER TTHA + key("\u091F", moreKey("\u0920"))) + .setKeysOfRow(3, + // U+0911: "ऑ" DEVANAGARI LETTER CANDRA O + // U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O + key("\u0911", moreKey(VOWEL_SIGN_CANDRA_O, "\u0949")), + // U+094D: "्" DEVANAGARI SIGN VIRAMA + // U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E + // U+090D: "ऍ" DEVANAGARI LETTER CANDRA E + key(SIGN_VIRAMA, "\u094D", joinMoreKeys( + moreKey(VOWEL_SIGN_CANDRA_E, "\u0945"), "\u090D")), + // U+0902: "ं" DEVANAGARI SIGN ANUSVARA + // U+0903: "ः" DEVANAGARI SIGN VISARGA + // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU + // U+093C: "़" DEVANAGARI SIGN NUKTA + key(SIGN_ANUSVARA, "\u0902", joinMoreKeys( + moreKey(SIGN_VISARGA, "\u0903"), + moreKey(SIGN_CANDRABINDU, "\u0901"), + moreKey(SIGN_NUKTA, "\u093C"))), + // U+092E: "म" DEVANAGARI LETTER MA + // U+0950: "ॐ" DEVANAGARI OM + key("\u092E", moreKey("\u0950")), + // U+0928: "न" DEVANAGARI LETTER NA + // U+0923: "ण" DEVANAGARI LETTER NNA + // U+091E: "ञ" DEVANAGARI LETTER NYA + // U+0919: "ङ" DEVANAGARI LETTER NGA + key("\u0928", joinMoreKeys("\u0923", "\u091E", "\u0919")), + // U+0935: "व" DEVANAGARI LETTER VA + // U+0932: "ल" DEVANAGARI LETTER LA + "\u0935", "\u0932", + // U+0938: "स" DEVANAGARI LETTER SA + // U+0936: "श" DEVANAGARI LETTER SHA + // U+0937: "ष" DEVANAGARI LETTER SSA + // U+0936/U+094D/U+0930: + // "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA + key("\u0938", joinMoreKeys("\u0936", "\u0937", "\u0936\u094D\u0930")), + // U+092F: "य" DEVANAGARI LETTER YA + // U+0915/U+094D/U+0937: + // "क्ष" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER SSA + "\u092F", "\u0915\u094D\u0937") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Kannada.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Kannada.java new file mode 100644 index 000000000..b7e843314 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Kannada.java @@ -0,0 +1,199 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Locale; + +/** + * The Kannada keyboard. + */ +public final class Kannada extends LayoutBase { + private static final String LAYOUT_NAME = "kannada"; + + public Kannada(final Locale locale) { + super(new KannadaCustomizer(locale), Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class KannadaCustomizer extends LayoutCustomizer { + KannadaCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getAlphabetKey() { return KANNADA_ALPHABET_KEY; } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + @Override + public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) { + return EMPTY_KEYS; + } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS; + } + + @Override + public ExpectedKey[] getSpaceKeys(final boolean isPhone) { + return joinKeys(LANGUAGE_SWITCH_KEY, SPACE_KEY, key(ZWNJ_KEY, ZWJ_KEY)); + } + + // U+0C85: "ಅ" KANNADA LETTER A + // U+0C86: "ಆ" KANNADA LETTER AA + // U+0C87: "ಇ" KANNADA LETTER I + private static final ExpectedKey KANNADA_ALPHABET_KEY = key( + "\u0C85\u0C86\u0C87", Constants.CODE_SWITCH_ALPHA_SYMBOL); + + // U+20B9: "₹" INDIAN RUPEE SIGN + private static final ExpectedKey CURRENCY_RUPEE = key("\u20B9", + Symbols.CURRENCY_GENERIC_MORE_KEYS); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) { + return null; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0CCC: "ೌ" KANNADA VOWEL SIGN AU + // U+0C94: "ಔ" KANNADA LETTER AU + // U+0CE7: "೧" KANNADA DIGIT ONE + key("\u0CCC", joinMoreKeys("\u0C94", "\u0CE7", "1")), + // U+0CC8: "ೈ" KANNADA VOWEL SIGN AI + // U+0C90: "ಐ" KANNADA LETTER AI + // U+0CE8: "೨" KANNADA DIGIT TWO + key("\u0CC8", joinMoreKeys("\u0C90", "\u0CE8", "2")), + // U+0CBE: "ಾ" KANNADA VOWEL SIGN AA + // U+0C86: "ಆ" KANNADA LETTER AA + // U+0CE9: "೩" KANNADA DIGIT THREE + key("\u0CBE", joinMoreKeys("\u0C86", "\u0CE9", "3")), + // U+0CC0: "ೀ" KANNADA VOWEL SIGN II + // U+0C88: "ಈ" KANNADA LETTER II + // U+0CEA: "೪" KANNADA DIGIT FOUR + key("\u0CC0", joinMoreKeys("\u0C88", "\u0CEA", "4")), + // U+0CC2: "ೂ" KANNADA VOWEL SIGN UU + // U+0C8A: "ಊ" KANNADA LETTER UU + // U+0CEB: "೫" KANNADA DIGIT FIVE + key("\u0CC2", joinMoreKeys("\u0C8A", "\u0CEB", "5")), + // U+0CAC: "ಬ" KANNADA LETTER BA + // U+0CAD: "ಭ" KANNADA LETTER BHA + // U+0CEC: "೬" KANNADA DIGIT SIX + key("\u0CAC", joinMoreKeys("\u0CAD", "\u0CEC", "6")), + // U+0CB9: "ಹ" KANNADA LETTER HA + // U+0C99: "ಙ" KANNADA LETTER NGA + // U+0CED: "೭" KANNADA DIGIT SEVEN + key("\u0CB9", joinMoreKeys("\u0C99", "\u0CED", "7")), + // U+0C97: "ಗ" KANNADA LETTER GA + // U+0C98: "ಘ" KANNADA LETTER GHA + // U+0CEE: "೮" KANNADA DIGIT EIGHT + key("\u0C97", joinMoreKeys("\u0C98", "\u0CEE", "8")), + // U+0CA6: "ದ" KANNADA LETTER DA + // U+0CA7: "ಧ" KANNADA LETTER DHA + // U+0CEF: "೯" KANNADA DIGIT NINE + key("\u0CA6", joinMoreKeys("\u0CA7", "\u0CEF", "9")), + // U+0C9C: "ಜ" KANNADA LETTER JA + // U+0C9D: "ಝ" KANNADA LETTER JHA + // U+0CE6: "೦" KANNADA DIGIT ZERO + key("\u0C9C", joinMoreKeys("\u0C9D", "\u0CE6", "0")), + // U+0CA1: "ಡ" KANNADA LETTER DDA + // U+0CA2: "ಢ" KANNADA LETTER DDHA + key("\u0CA1", moreKey("\u0CA2"))) + .setKeysOfRow(2, + // U+0CCB: "ೋ" KANNADA VOWEL SIGN OO + // U+0C93: "ಓ" KANNADA LETTER OO + key("\u0CCB", moreKey("\u0C93")), + // U+0CC7: "ೇ" KANNADA VOWEL SIGN EE + // U+0C8F: "ಏ" KANNADA LETTER EE + key("\u0CC7", moreKey("\u0C8F")), + // U+0CCD: "್" KANNADA SIGN VIRAMA + // U+0C85: "ಅ" KANNADA LETTER A + key("\u0CCD", moreKey("\u0C85")), + // U+0CBF: "ಿ" KANNADA VOWEL SIGN I + // U+0C87: "ಇ" KANNADA LETTER I + key("\u0CBF", moreKey("\u0C87")), + // U+0CC1: "ು" KANNADA VOWEL SIGN U + // U+0C89: "ಉ" KANNADA LETTER U + key("\u0CC1", moreKey("\u0C89")), + // U+0CAA: "ಪ" KANNADA LETTER PA + // U+0CAB: "ಫ" KANNADA LETTER PHA + key("\u0CAA", moreKey("\u0CAB")), + // U+0CB0: "ರ" KANNADA LETTER RA + // U+0CB1: "ಱ" KANNADA LETTER RRA + // U+0CC3: "ೃ" KANNADA VOWEL SIGN VOCALIC R + key("\u0CB0", joinMoreKeys("\u0CB1", "\u0CC3")), + // U+0C95: "ಕ" KANNADA LETTER KA + // U+0C96: "ಖ" KANNADA LETTER KHA + key("\u0C95", moreKey("\u0C96")), + // U+0CA4: "ತ" KANNADA LETTER TA + // U+0CA5: "ಥ" KANNADA LETTER THA + key("\u0CA4", moreKey("\u0CA5")), + // U+0C9A: "ಚ" KANNADA LETTER CA + // U+0C9B: "ಛ" KANNADA LETTER CHA + key("\u0C9A", moreKey("\u0C9B")), + // U+0C9F: "ಟ" KANNADA LETTER TTA + // U+0CA0: "ಠ" KANNADA LETTER TTHA + key("\u0C9F", moreKey("\u0CA0"))) + .setKeysOfRow(3, + // U+0CC6: "ೆ" KANNADA VOWEL SIGN E + // U+0C92: "ಒ" KANNADA LETTER O + key("\u0CC6", moreKey("\u0C92")), + // U+0C82: "ಂ" KANNADA SIGN ANUSVARA + // U+0C8E: "ಎ" KANNADA LETTER E + key("\u0C82", moreKey("\u0C8E")), + // U+0CAE: "ಮ" KANNADA LETTER MA + "\u0CAE", + // U+0CA8: "ನ" KANNADA LETTER NA + // U+0CA3: "ಣ" KANNADA LETTER NNA + key("\u0CA8", moreKey("\u0CA3")), + // U+0CB5: "ವ" KANNADA LETTER VA + "\u0CB5", + // U+0CB2: "ಲ" KANNADA LETTER LA + // U+0CB3: "ಳ" KANNADA LETTER LLA + key("\u0CB2", moreKey("\u0CB3")), + // U+0CB8: "ಸ" KANNADA LETTER SA + // U+0CB6: "ಶ" KANNADA LETTER SHA + key("\u0CB8", moreKey("\u0CB6")), + // U+0C8B: "ಋ" KANNADA LETTER VOCALIC R + // U+0CCD/U+0CB0: "್ರ" KANNADA SIGN VIRAMA/KANNADA LETTER RA + key("\u0C8B", moreKey("\u0CCD\u0CB0")), + // U+0CB7: "ಷ" KANNADA LETTER SSA + // U+0C95/U+0CCD/U+0CB7: + // "ಕ್ಷ" KANNADA LETTER RA/KANNADA SIGN VIRAMA/KANNADA LETTER SSA + key("\u0CB7", moreKey("\u0C95\u0CCD\u0CB7")), + // U+0CAF: "ಯ" KANNADA LETTER YA + // U+0C9C/U+0CCD/U+0C9E: + // "ಜ್ಞ" KANNADA LETTER JA/KANNADA SIGN VIRAMA/KANNADA LETTER NYA + key("\u0CAF", moreKey("\u0C9C\u0CCD\u0C9E"))) + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Khmer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Khmer.java new file mode 100644 index 000000000..aff10226c --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Khmer.java @@ -0,0 +1,262 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Locale; + +/** + * The Khmer alphabet keyboard. + */ +public final class Khmer extends LayoutBase { + private static final String LAYOUT_NAME = "khmer"; + + public Khmer(final Locale locale) { + super(new KhmerCustomizer(locale), Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class KhmerCustomizer extends LayoutCustomizer { + KhmerCustomizer(final Locale locale) { super(locale); } + + @Override + public int getNumberOfRows() { return 5; } + + @Override + public ExpectedKey getAlphabetKey() { return KHMER_ALPHABET_KEY; } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_DOLLAR_WITH_RIEL; } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { return EMPTY_KEYS; } + + // U+1780: "ក" KHMER LETTER KA + // U+1781: "ខ" KHMER LETTER KHA + // U+1782: "គ" KHMER LETTER KO + private static final ExpectedKey KHMER_ALPHABET_KEY = key( + "\u1780\u1781\u1782", Constants.CODE_SWITCH_ALPHA_SYMBOL); + + // U+17DB: "៛" KHMER CURRENCY SYMBOL RIEL + private static final ExpectedKey CURRENCY_DOLLAR_WITH_RIEL = key(Symbols.DOLLAR_SIGN, + moreKey("\u17DB"), Symbols.CENT_SIGN, Symbols.POUND_SIGN, Symbols.EURO_SIGN, + Symbols.YEN_SIGN, Symbols.PESO_SIGN); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { + if (isPhone) { + return ALPHABET_COMMON; + } + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + builder.addKeysOnTheRightOfRow(4, (Object[])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); + } + return ALPHABET_SHIFTED_COMMON; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+17E1: "១" KHMER DIGIT ONE + // U+17F1: "៱" KHMER SYMBOL LEK ATTAK MUOY + key("\u17E1", joinMoreKeys("1", "\u17F1")), + // U+17E2: "២" KHMER DIGIT TWO + // U+17F2: "៲" KHMER SYMBOL LEK ATTAK PII + key("\u17E2", joinMoreKeys("2", "\u17F2")), + // U+17E3: "៣" KHMER DIGIT THREE + // U+17F3: "៳" KHMER SYMBOL LEK ATTAK BEI + key("\u17E3", joinMoreKeys("3", "\u17F3")), + // U+17E4: "៤" KHMER DIGIT FOUR + // U+17F4: "៴" KHMER SYMBOL LEK ATTAK BUON + key("\u17E4", joinMoreKeys("4", "\u17F4")), + // U+17E5: "៥" KHMER DIGIT FIVE + // U+17F5: "៵" KHMER SYMBOL LEK ATTAK PRAM + key("\u17E5", joinMoreKeys("5", "\u17F5")), + // U+17E6: "៦" KHMER DIGIT SIX + // U+17F6: "៶" KHMER SYMBOL LEK ATTAK PRAM-MUOY + key("\u17E6", joinMoreKeys("6", "\u17F6")), + // U+17E7: "៧" KHMER DIGIT SEVEN + // U+17F7: "៷" KHMER SYMBOL LEK ATTAK PRAM-PII + key("\u17E7", joinMoreKeys("7", "\u17F7")), + // U+17E8: "៨" KHMER DIGIT EIGHT + // U+17F8: "៸" KHMER SYMBOL LEK ATTAK PRAM-BEI + key("\u17E8", joinMoreKeys("8", "\u17F8")), + // U+17E9: "៩" KHMER DIGIT NINE + // U+17F9: "៹" KHMER SYMBOL LEK ATTAK PRAM-BUON + key("\u17E9", joinMoreKeys("9", "\u17F9")), + // U+17E0: "០" KHMER DIGIT ZERO + // U+17F0: "៰" KHMER SYMBOL LEK ATTAK SON + key("\u17E0", joinMoreKeys("0", "\u17F0")), + // U+17A5: "ឥ" KHMER INDEPENDENT VOWEL QI + // U+17A6: "ឦ" KHMER INDEPENDENT VOWEL QII + key("\u17A5", moreKey("\u17A6")), + // U+17B2: "ឲ" KHMER INDEPENDENT VOWEL QOO TYPE TWO + // U+17B1: "ឱ" KHMER INDEPENDENT VOWEL QOO TYPE ONE + key("\u17B2", moreKey("\u17B1"))) + .setKeysOfRow(2, + // U+1786: "ឆ" KHMER LETTER CHA + // U+17B9: "ឹ" KHMER VOWEL SIGN Y + // U+17C1: "េ" KHMER VOWEL SIGN E + // U+179A: "រ" KHMER LETTER RO + // U+178F: "ត" KHMER LETTER TA + // U+1799: "យ" KHMER LETTER YO + // U+17BB: "ុ" KHMER VOWEL SIGN U + // U+17B7: "ិ" KHMER VOWEL SIGN I + // U+17C4: "ោ" KHMER VOWEL SIGN OO + // U+1795: "ផ" KHMER LETTER PHA + // U+17C0: "ៀ" KHMER VOWEL SIGN IE + "\u1786", "\u17B9", "\u17C1", "\u179A", "\u178F", "\u1799", "\u17BB", "\u17B7", + "\u17C4", "\u1795", "\u17C0", + // U+17AA: "ឪ" KHMER INDEPENDENT VOWEL QUUV + // U+17A7: "ឧ" KHMER INDEPENDENT VOWEL QU + // U+17B1: "ឱ" KHMER INDEPENDENT VOWEL QOO TYPE ONE + // U+17B3: "ឳ" KHMER INDEPENDENT VOWEL QAU + // U+17A9: "ឩ" KHMER INDEPENDENT VOWEL QUU + // U+17A8: "ឨ" KHMER INDEPENDENT VOWEL QUK + key("\u17AA", joinMoreKeys("\u17A7", "\u17B1", "\u17B3", "\u17A9", "\u17A8"))) + .setKeysOfRow(3, + // U+17B6: "ា" KHMER VOWEL SIGN AA + // U+179F: "ស" KHMER LETTER SA + // U+178A: "ដ" KHMER LETTER DA + // U+1790: "ថ" KHMER LETTER THA + // U+1784: "ង" KHMER LETTER NGO + // U+17A0: "ហ" KHMER LETTER HA + // U+17D2: "្" KHMER SIGN COENG + // U+1780: "ក" KHMER LETTER KA + // U+179B: "ល" KHMER LETTER LO + // U+17BE: "ើ" KHMER VOWEL SIGN OE + // U+17CB: "់" KHMER SIGN BANTOC + "\u17B6", "\u179F", "\u178A", "\u1790", "\u1784", "\u17A0", "\u17D2", "\u1780", + "\u179B", "\u17BE", "\u17CB", + // U+17AE: "ឮ" KHMER INDEPENDENT VOWEL LYY + // U+17AD: "ឭ" KHMER INDEPENDENT VOWEL LY + // U+17B0: "ឰ" KHMER INDEPENDENT VOWEL QAI + key("\u17AE", joinMoreKeys("\u17AD", "\u17B0"))) + .setKeysOfRow(4, + // U+178B: "ឋ" KHMER LETTER TTHA + // U+1781: "ខ" KHMER LETTER KHA + // U+1785: "ច" KHMER LETTER CA + // U+179C: "វ" KHMER LETTER VO + // U+1794: "ប" KHMER LETTER BA + // U+1793: "ន" KHMER LETTER NO + // U+1798: "ម" KHMER LETTER MO + // U+17BB/U+17C6: "ុំ" KHMER VOWEL SIGN U/KHMER SIGN NIKAHIT + // U+17D4: "។" KHMER SIGN KHAN + // U+17CA: "៊" KHMER SIGN TRIISAP + "\u178B", "\u1781", "\u1785", "\u179C", "\u1794", "\u1793", "\u1798", + "\u17BB\u17C6", "\u17D4", "\u17CA") + .build(); + + private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + key("!", ZWJ_KEY), + // U+17D7: "ៗ" KHMER SIGN LEK TOO + key("\u17D7", ZWNJ_KEY), + // U+17D1: "៑" KHMER SIGN VIRIAM + key("\"", moreKey("\u17D1")), + // U+17DB: "៛" KHMER CURRENCY SYMBOL RIEL + key("\u17DB", joinMoreKeys(Symbols.DOLLAR_SIGN, Symbols.EURO_SIGN)), + // U+17D6: "៖" KHMER SIGN CAMNUC PII KUUH + key("%", moreKey("\u17D6")), + // U+17CD: "៍" KHMER SIGN TOANDAKHIAT + // U+17D9: "៙" KHMER SIGN PHNAEK MUAN + key("\u17CD", moreKey("\u17D9")), + // U+17D0: "័" KHMER SIGN SAMYOK SANNYA + // U+17DA: "៚" KHMER SIGN KOOMUUT + key("\u17D0", moreKey("\u17DA")), + // U+17CF: "៏" KHMER SIGN AHSDA + key("\u17CF", moreKey("*")), + // U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK + key("(", joinMoreKeys("{", "\u00AB")), + // U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK + key(")", joinMoreKeys("}", "\u00BB")), + // U+17CC: "៌" KHMER SIGN ROBAT + // U+00D7: "×" MULTIPLICATION SIGN + key("\u17CC", moreKey("\u00D7")), + // U+17CE: "៎" KHMER SIGN KAKABAT + "\u17CE") + .setKeysOfRow(2, + // U+1788: "ឈ" KHMER LETTER CHO + // U+17DC: "ៜ" KHMER SIGN AVAKRAHASANYA + key("\u1788", moreKey("\u17DC")), + // U+17BA: "ឺ" KHMER VOWEL SIGN YY + // U+17DD: "៝" KHMER SIGN ATTHACAN + key("\u17BA", moreKey("\u17DD")), + // U+17C2: "ែ" KHMER VOWEL SIGN AE + "\u17C2", + // U+17AC: "ឬ" KHMER INDEPENDENT VOWEL RYY + // U+17AB: "ឫ" KHMER INDEPENDENT VOWEL RY + key("\u17AC", moreKey("\u17AB")), + // U+1791: "ទ" KHMER LETTER TO + // U+17BD: "ួ" KHMER VOWEL SIGN UA + // U+17BC: "ូ" KHMER VOWEL SIGN UU + // U+17B8: "ី" KHMER VOWEL SIGN II + // U+17C5: "ៅ" KHMER VOWEL SIGN AU + // U+1797: "ភ" KHMER LETTER PHO + // U+17BF: "ឿ" KHMER VOWEL SIGN YA + // U+17B0: "ឰ" KHMER INDEPENDENT VOWEL QAI + "\u1791", "\u17BD", "\u17BC", "\u17B8", "\u17C5", "\u1797", "\u17BF", "\u17B0") + .setKeysOfRow(3, + // U+17B6/U+17C6: "ាំ" KHMER VOWEL SIGN AA/KHMER SIGN NIKAHIT + // U+17C3: "ៃ" KHMER VOWEL SIGN AI + // U+178C: "ឌ" KHMER LETTER DO + // U+1792: "ធ" KHMER LETTER THO + // U+17A2: "អ" KHMER LETTER QAE + "\u17B6\u17C6", "\u17C3", "\u178C", "\u1792", "\u17A2", + // U+17C7: "ះ" KHMER SIGN REAHMUK + // U+17C8: "ៈ" KHMER SIGN YUUKALEAPINTU + key("\u17C7", moreKey("\u17C8")), + // U+1789: "ញ" KHMER LETTER NYO + "\u1789", + // U+1782: "គ" KHMER LETTER KO + // U+179D: "ឝ" KHMER LETTER SHA + key("\u1782", moreKey("\u179D")), + // U+17A1: "ឡ" KHMER LETTER LA + // U+17C4/U+17C7: "ោះ" KHMER VOWEL SIGN OO/KHMER SIGN REAHMUK + // U+17C9: "៉" KHMER SIGN MUUSIKATOAN + // U+17AF: "ឯ" KHMER INDEPENDENT VOWEL QE + "\u17A1", "\u17C4\u17C7", "\u17C9", "\u17AF") + .setKeysOfRow(4, + // U+178D: "ឍ" KHMER LETTER TTHO + // U+1783: "ឃ" KHMER LETTER KHO + // U+1787: "ជ" KHMER LETTER CO + // U+17C1/U+17C7: "េះ" KHMER VOWEL SIGN E/KHMER SIGN REAHMUK + "\u178D", "\u1783", "\u1787", "\u17C1\u17C7", + // U+1796: "ព" KHMER LETTER PO + // U+179E: "ឞ" KHMER LETTER SSO + key("\u1796", moreKey("\u179E")), + // U+178E: "ណ" KHMER LETTER NNO + // U+17C6: "ំ" KHMER SIGN NIKAHIT + // U+17BB/U+17C7: "ុះ" KHMER VOWEL SIGN U/KHMER SIGN REAHMUK + // U+17D5: "៕" KHMER SIGN BARIYOOSAN + "\u178E", "\u17C6", "\u17BB\u17C7", "\u17D5", "?") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Lao.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Lao.java new file mode 100644 index 000000000..d3c3d0ccc --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Lao.java @@ -0,0 +1,218 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Locale; + +/** + * The Khmer alphabet keyboard. + */ +public final class Lao extends LayoutBase { + private static final String LAYOUT_NAME = "lao"; + + public Lao(final Locale locale) { + super(new LaoCustomizer(locale), Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class LaoCustomizer extends LayoutCustomizer { + LaoCustomizer(final Locale locale) { super(locale); } + + @Override + public int getNumberOfRows() { return 5; } + + @Override + public ExpectedKey getAlphabetKey() { return LAO_ALPHABET_KEY; } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_KIP; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { return EMPTY_KEYS; } + + // U+0E81: "ກ" LAO LETTER KO + // U+0E82: "ຂ" LAO LETTER KHO SUNG + // U+0E84: "ຄ" LAO LETTER KHO TAM + private static final ExpectedKey LAO_ALPHABET_KEY = key( + "\u0E81\u0E82\u0E84", Constants.CODE_SWITCH_ALPHA_SYMBOL); + + // U+20AD: "₭" KIP SIGN + private static final ExpectedKey CURRENCY_KIP = key("\u20AD", + Symbols.CURRENCY_GENERIC_MORE_KEYS); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { + if (isPhone) { + return ALPHABET_COMMON; + } + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + builder.addKeysOnTheRightOfRow(4, (Object[])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); + } + return ALPHABET_SHIFTED_COMMON; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0EA2: "ຢ" LAO LETTER YO + // U+0ED1: "໑" LAO DIGIT ONE + key("\u0EA2", joinMoreKeys("1", "\u0ED1")), + // U+0E9F: "ຟ" LAO LETTER FO SUNG + // U+0ED2: "໒" LAO DIGIT TWO + key("\u0E9F", joinMoreKeys("2", "\u0ED2")), + // U+0EC2: "ໂ" LAO VOWEL SIGN O + // U+0ED3: "໓" LAO DIGIT THREE + key("\u0EC2", joinMoreKeys("3", "\u0ED3")), + // U+0E96: "ຖ" LAO LETTER THO SUNG + // U+0ED4: "໔" LAO DIGIT FOUR + key("\u0E96", joinMoreKeys("4", "\u0ED4")), + // U+0EB8: "ຸ" LAO VOWEL SIGN U + // U+0EB9: "ູ" LAO VOWEL SIGN UU + "\u0EB8", "\u0EB9", + // U+0E84: "ຄ" LAO LETTER KHO TAM + // U+0ED5: "໕" LAO DIGIT FIVE + key("\u0E84", joinMoreKeys("5", "\u0ED5")), + // U+0E95: "ຕ" LAO LETTER TO + // U+0ED6: "໖" LAO DIGIT SIX + key("\u0E95", joinMoreKeys("6", "\u0ED6")), + // U+0E88: "ຈ" LAO LETTER CO + // U+0ED7: "໗" LAO DIGIT SEVEN + key("\u0E88", joinMoreKeys("7", "\u0ED7")), + // U+0E82: "ຂ" LAO LETTER KHO SUNG + // U+0ED8: "໘" LAO DIGIT EIGHT + key("\u0E82", joinMoreKeys("8", "\u0ED8")), + // U+0E8A: "ຊ" LAO LETTER SO TAM + // U+0ED9: "໙" LAO DIGIT NINE + key("\u0E8A", joinMoreKeys("9", "\u0ED9")), + // U+0ECD: "ໍ" LAO NIGGAHITA + "\u0ECD") + .setKeysOfRow(2, + // U+0EBB: "ົ" LAO VOWEL SIGN MAI KON + "\u0EBB", + // U+0EC4: "ໄ" LAO VOWEL SIGN AI + // U+0ED0: "໐" LAO DIGIT ZERO + key("\u0EC4", joinMoreKeys("0", "\u0ED0")), + // U+0EB3: "ຳ" LAO VOWEL SIGN AM + // U+0E9E: "ພ" LAO LETTER PHO TAM + // U+0EB0: "ະ" LAO VOWEL SIGN A + // U+0EB4: "ິ" LAO VOWEL SIGN I + // U+0EB5: "ີ" LAO VOWEL SIGN II + // U+0EAE: "ຮ" LAO LETTER HO TAM + // U+0E99: "ນ" LAO LETTER NO + // U+0E8D: "ຍ" LAO LETTER NYO + // U+0E9A: "ບ" LAO LETTER BO + // U+0EA5: "ລ" LAO LETTER LO LOOT + "\u0EB3", "\u0E9E", "\u0EB0", "\u0EB4", "\u0EB5", "\u0EAE", "\u0E99", "\u0E8D", + "\u0E9A", "\u0EA5") + .setKeysOfRow(3, + // U+0EB1: "ັ" LAO VOWEL SIGN MAI KAN + // U+0EAB: "ຫ" LAO LETTER HO SUNG + // U+0E81: "ກ" LAO LETTER KO + // U+0E94: "ດ" LAO LETTER DO + // U+0EC0: "ເ" LAO VOWEL SIGN E + // U+0EC9: "້" LAO TONE MAI THO + // U+0EC8: "່" LAO TONE MAI EK + // U+0EB2: "າ" LAO VOWEL SIGN AA + // U+0EAA: "ສ" LAO LETTER SO SUNG + // U+0EA7: "ວ" LAO LETTER WO + // U+0E87: "ງ" LAO LETTER NGO + // U+201C: "“" LEFT DOUBLE QUOTATION MARK + "\u0EB1", "\u0EAB", "\u0E81", "\u0E94", "\u0EC0", "\u0EC9", "\u0EC8", "\u0EB2", + "\u0EAA", "\u0EA7", "\u0E87", "\u201C") + .setKeysOfRow(4, + // U+0E9C: "ຜ" LAO LETTER PHO SUNG + // U+0E9B: "ປ" LAO LETTER PO + // U+0EC1: "ແ" LAO VOWEL SIGN EI + // U+0EAD: "ອ" LAO LETTER O + // U+0EB6: "ຶ" LAO VOWEL SIGN Y + // U+0EB7: "ື" LAO VOWEL SIGN YY + // U+0E97: "ທ" LAO LETTER THO TAM + // U+0EA1: "ມ" LAO LETTER MO + // U+0EC3: "ໃ" LAO VOWEL SIGN AY + // U+0E9D: "ຝ" LAO LETTER FO TAM + "\u0E9C", "\u0E9B", "\u0EC1", "\u0EAD", "\u0EB6", "\u0EB7", "\u0E97", "\u0EA1", + "\u0EC3", "\u0E9D") + .build(); + + private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0ED1: "໑" LAO DIGIT ONE + // U+0ED2: "໒" LAO DIGIT TWO + // U+0ED3: "໓" LAO DIGIT THREE + // U+0ED4: "໔" LAO DIGIT FOUR + // U+0ECC: "໌" LAO CANCELLATION MARK + // U+0EBC: "ຼ" LAO SEMIVOWEL SIGN LO + // U+0ED5: "໕" LAO DIGIT FIVE + // U+0ED6: "໖" LAO DIGIT SIX + // U+0ED7: "໗" LAO DIGIT SEVEN + // U+0ED8: "໘" LAO DIGIT EIGHT + // U+0ED9: "໙" LAO DIGIT NINE + // U+0ECD/U+0EC8: "ໍ່" LAO NIGGAHITA/LAO TONE MAI EK + "\u0ED1", "\u0ED2", "\u0ED3", "\u0ED4", "\u0ECC", "\u0EBC", "\u0ED5", "\u0ED6", + "\u0ED7", "\u0ED8", "\u0ED9", "\u0ECD\u0EC8") + .setKeysOfRow(2, + // U+0EBB/U+0EC9: "" LAO VOWEL SIGN MAI KON/LAO TONE MAI THO + // U+0ED0: "໐" LAO DIGIT ZERO + // U+0EB3/U+0EC9: "ຳ້" LAO VOWEL SIGN AM/LAO TONE MAI THO + // U+0EB4/U+0EC9: "ິ້" LAO VOWEL SIGN I/LAO TONE MAI THO + // U+0EB5/U+0EC9: "ີ້" LAO VOWEL SIGN II/LAO TONE MAI THO + // U+0EA3: "ຣ" LAO LETTER LO LING + // U+0EDC: "ໜ" LAO HO NO + // U+0EBD: "ຽ" LAO SEMIVOWEL SIGN NYO + // U+0EAB/U+0EBC: "" LAO LETTER HO SUNG/LAO SEMIVOWEL SIGN LO + // U+201D: "”" RIGHT DOUBLE QUOTATION MARK + "\u0EBB\u0EC9", "\u0ED0", "\u0EB3\u0EC9", "_", "+", "\u0EB4\u0EC9", + "\u0EB5\u0EC9", "\u0EA3", "\u0EDC", "\u0EBD", "\u0EAB\u0EBC", "\u201D") + .setKeysOfRow(3, + // U+0EB1/U+0EC9: "ັ້" LAO VOWEL SIGN MAI KAN/LAO TONE MAI THO + // U+0ECA: "໊" LAO TONE MAI TI + // U+0ECB: "໋" LAO TONE MAI CATAWA + // U+201C: "“" LEFT DOUBLE QUOTATION MARK + "\u0EB1\u0EC9", ";", ".", ",", ":", "\u0ECA", "\u0ECB", "!", "?", "%", "=", + "\u201C") + .setKeysOfRow(4, + // U+20AD: "₭" KIP SIGN + // U+0EAF: "ຯ" LAO ELLIPSIS + // U+0EB6/U+0EC9: "ຶ້" LAO VOWEL SIGN Y/LAO TONE MAI THO + // U+0EB7/U+0EC9: "ື້" LAO VOWEL SIGN YY/LAO TONE MAI THO + // U+0EC6: "ໆ" LAO KO LA + // U+0EDD: "ໝ" LAO HO MO + "\u20AD", "(", "\u0EAF", "@", "\u0EB6\u0EC9", "\u0EB7\u0EC9", "\u0EC6", + "\u0EDD", "$", ")") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/LayoutBase.java b/tests/src/org/kelar/inputmethod/keyboard/layout/LayoutBase.java new file mode 100644 index 000000000..620e0a442 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/LayoutBase.java @@ -0,0 +1,162 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.AbstractLayoutBase; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * The base class of keyboard layout. + */ +public abstract class LayoutBase extends AbstractLayoutBase { + 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; } + + /** + * 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 int numberOfRows = customizer.getNumberOfRows(); + builder.setKeysOfRow(numberOfRows, (Object[])customizer.getSpaceKeys(isPhone)); + builder.addKeysOnTheLeftOfRow( + numberOfRows, (Object[])customizer.getKeysLeftToSpacebar(isPhone)); + builder.addKeysOnTheRightOfRow( + numberOfRows, (Object[])customizer.getKeysRightToSpacebar(isPhone)); + if (isPhone) { + builder.addKeysOnTheRightOfRow(numberOfRows - 1, DELETE_KEY) + .addKeysOnTheLeftOfRow(numberOfRows, customizer.getSymbolsKey()) + .addKeysOnTheRightOfRow(numberOfRows, customizer.getEnterKey(isPhone)); + } else { + builder.addKeysOnTheRightOfRow(1, DELETE_KEY) + .addKeysOnTheRightOfRow(numberOfRows - 2, customizer.getEnterKey(isPhone)) + .addKeysOnTheLeftOfRow(numberOfRows, customizer.getSymbolsKey()) + .addKeysOnTheRightOfRow(numberOfRows, customizer.getEmojiKey(isPhone)); + } + builder.addKeysOnTheLeftOfRow( + numberOfRows - 1, (Object[])customizer.getLeftShiftKeys(isPhone)); + builder.addKeysOnTheRightOfRow( + numberOfRows - 1, (Object[])customizer.getRightShiftKeys(isPhone)); + return builder; + } + + /** + * Get common alphabet layout. This layout doesn't contain any special keys. + * + * A keyboard layout is an array of rows, and a row consists of an array of + * {@link ExpectedKey}s. Each row may have different number of {@link ExpectedKey}s. + * + * @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. + * + * A keyboard layout is an array of rows, and a row consists of an array of + * {@link ExpectedKey}s. Each row may have different number of {@link ExpectedKey}s. + * + * @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, elementId); + builder.toUpperCase(getLocale()); + return builder.build(); + } + + /** + * Get the complete expected keyboard layout. + * + * A keyboard layout is an array of rows, and a row consists of an array of + * {@link ExpectedKey}s. Each row may have different number of {@link ExpectedKey}s. + * + * @param isPhone true if requesting phone's layout. + * @param elementId the element id of the requesting keyboard mode. + * @return the keyboard layout of the <code>elementId</code>. + */ + 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, elementId); + } 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/org/kelar/inputmethod/keyboard/layout/Malayalam.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Malayalam.java new file mode 100644 index 000000000..714955f30 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Malayalam.java @@ -0,0 +1,189 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Locale; + +/** + * The Malayalam keyboard. + */ +public final class Malayalam extends LayoutBase { + private static final String LAYOUT_NAME = "malayalam"; + + public Malayalam(final Locale locale) { + super(new MalayalamCustomizer(locale), Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class MalayalamCustomizer extends LayoutCustomizer { + MalayalamCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getAlphabetKey() { return MALAYALAM_ALPHABET_KEY; } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + @Override + public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) { + return EMPTY_KEYS; + } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS; + } + + // U+0D05: "അ" MALAYALAM LETTER A + private static final ExpectedKey MALAYALAM_ALPHABET_KEY = key( + "\u0D05", Constants.CODE_SWITCH_ALPHA_SYMBOL); + + // U+20B9: "₹" INDIAN RUPEE SIGN + private static final ExpectedKey CURRENCY_RUPEE = key("\u20B9", + Symbols.CURRENCY_GENERIC_MORE_KEYS); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) { + return null; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0D4D: "്" MALAYALAM SIGN VIRAMA + // U+0D05: "അ" MALAYALAM LETTER A + key("\u0D4D", joinMoreKeys("\u0D05", "1")), + // U+0D3E: "ാ" MALAYALAM VOWEL SIGN AA + // U+0D06: "ആ" MALAYALAM LETTER AA + key("\u0D3E", joinMoreKeys("\u0D06", "2")), + // U+0D3F: "ി" MALAYALAM VOWEL SIGN I + // U+0D07: "ഇ" MALAYALAM LETTER I + key("\u0D3F", joinMoreKeys("\u0D07", "3")), + // U+0D40: "ീ" MALAYALAM VOWEL SIGN II + // U+0D08: "ഈ" MALAYALAM LETTER II + key("\u0D40", joinMoreKeys("\u0D08", "4")), + // U+0D41: "ു" MALAYALAM VOWEL SIGN U + // U+0D09: "ഉ" MALAYALAM LETTER U + key("\u0D41", joinMoreKeys("\u0D09", "5")), + // U+0D42: "ൂ" MALAYALAM VOWEL SIGN UU + // U+0D0A: "ഊ" MALAYALAM LETTER UU + key("\u0D42", joinMoreKeys("\u0D0A", "6")), + // U+0D43: "ൃ" MALAYALAM VOWEL SIGN VOCALIC R + // U+0D0B: "ഋ" MALAYALAM LETTER VOCALIC R + key("\u0D43", joinMoreKeys("\u0D0B", "7")), + // U+0D46: "െ" MALAYALAM VOWEL SIGN E + // U+0D0E: "എ" MALAYALAM LETTER E + // U+0D10: "ഐ" MALAYALAM LETTER AI + // U+0D48: "ൈ" MALAYALAM VOWEL SIGN AI + key("\u0D46", joinMoreKeys("\u0D0E", "\u0D10", "\u0D48", "8")), + // U+0D47: "േ" MALAYALAM VOWEL SIGN EE + // U+0D0F: "ഏ" MALAYALAM LETTER EE + key("\u0D47", joinMoreKeys("\u0D0F", "9")), + // U+0D4A: "ൊ" MALAYALAM VOWEL SIGN O + // U+0D12: "ഒ" MALAYALAM LETTER O + key("\u0D4A", joinMoreKeys("\u0D12", "0")), + // U+0D4B: "ോ" MALAYALAM VOWEL SIGN OO + // U+0D13: "ഓ" MALAYALAM LETTER OO + // U+0D14: "ഔ" MALAYALAM LETTER AU + // U+0D57: "ൗ" MALAYALAM AU LENGTH MARK + key("\u0D4B", joinMoreKeys("\u0D13", "\u0D14", "\u0D57"))) + .setKeysOfRow(2, + // U+0D15: "ക" MALAYALAM LETTER KA + // U+0D16: "ഖ" MALAYALAM LETTER KHA + key("\u0D15", moreKey("\u0D16")), + // U+0D17: "ഗ" MALAYALAM LETTER GA + // U+0D18: "ഘ" MALAYALAM LETTER GHA + key("\u0D17", moreKey("\u0D18")), + // U+0D19: "ങ" MALAYALAM LETTER NGA + // U+0D1E: "ഞ" MALAYALAM LETTER NYA + key("\u0D19", moreKey("\u0D1E")), + // U+0D1A: "ച" MALAYALAM LETTER CA + // U+0D1B: "ഛ" MALAYALAM LETTER CHA + key("\u0D1A", moreKey("\u0D1B")), + // U+0D1C: "ജ" MALAYALAM LETTER JA + // U+0D1D: "ഝ" MALAYALAM LETTER JHA + key("\u0D1C", moreKey("\u0D1D")), + // U+0D1F: "ട" MALAYALAM LETTER TTA + // U+0D20: "ഠ" MALAYALAM LETTER TTHA + key("\u0D1F", moreKey("\u0D20")), + // U+0D21: "ഡ" MALAYALAM LETTER DDA + // U+0D22: "ഢ" MALAYALAM LETTER DDHA + key("\u0D21", moreKey("\u0D22")), + // U+0D23: "ണ" MALAYALAM LETTER NNA + // U+0D7A: "ൺ" MALAYALAM LETTER CHILLU NN + key("\u0D23", moreKey("\u0D7A")), + // U+0D24: "ത" MALAYALAM LETTER TA + // U+0D25: "ഥ" MALAYALAM LETTER THA + key("\u0D24", moreKey("\u0D25")), + // U+0D26: "ദ" MALAYALAM LETTER DA + // U+0D27: "ധ" MALAYALAM LETTER DHA + key("\u0D26", moreKey("\u0D27")), + // U+0D28: "ഗന" MALAYALAM LETTER NA + // U+0D7B: "ൻ" MALAYALAM LETTER CHILLU N + key("\u0D28", moreKey("\u0D7B"))) + .setKeysOfRow(3, + // U+0D2A: "പ" MALAYALAM LETTER PA + // U+0D2B: "ഫ" MALAYALAM LETTER PHA + key("\u0D2A", moreKey("\u0D2B")), + // U+0D2C: "ബ" MALAYALAM LETTER BA + // U+0D2D: "ഭ" MALAYALAM LETTER BHA + key("\u0D2C", moreKey("\u0D2D")), + // U+0D2E: "മ" MALAYALAM LETTER MA + // U+0D02: "ം" MALAYALAM SIGN ANUSVARA + key("\u0D2E", moreKey("\u0D02")), + // U+0D2F: "യ" MALAYALAM LETTER YA + // U+0D4D/U+0D2F: "്യ" MALAYALAM SIGN VIRAMA/MALAYALAM LETTER YA + key("\u0D2F", moreKey("\u0D4D\u0D2F")), + // U+0D30: "ര" MALAYALAM LETTER RA + // U+0D4D/U+0D30: "്ര" MALAYALAM SIGN VIRAMA/MALAYALAM LETTER RA + // U+0D7C: "ർ" MALAYALAM LETTER CHILLU RR + // U+0D31: "റ" MALAYALAM LETTER RRA + key("\u0D30", joinMoreKeys("\u0D4D\u0D30", "\u0D7C", "\u0D31")), + // U+0D32: "ല" MALAYALAM LETTER LA + // U+0D7D: "ൽ" MALAYALAM LETTER CHILLU L + key("\u0D32", moreKey("\u0D7D")), + // U+0D35: "വ" MALAYALAM LETTER VA + // U+0D4D/U+0D35: "്വ" MALAYALAM SIGN VIRAMA/MALAYALAM LETTER VA + key("\u0D35", moreKey("\u0D4D\u0D35")), + // U+0D36: "ശ" MALAYALAM LETTER SHA + // U+0D37: "ഷ" MALAYALAM LETTER SSA + // U+0D38: "സ" MALAYALAM LETTER SA + key("\u0D36", joinMoreKeys("\u0D37", "\u0D38")), + // U+0D39: "ഹ" MALAYALAM LETTER HA + // U+0D03: "ഃ" MALAYALAM SIGN VISARGA + key("\u0D39", moreKey("\u0D03")), + // U+0D33: "ള" MALAYALAM LETTER LLA + // U+0D7E: "ൾ" MALAYALAM LETTER CHILLU LL + // U+0D34: "ഴ" MALAYALAM LETTER LLLA + key("\u0D33", joinMoreKeys("\u0D7E", "\u0D34"))) + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Marathi.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Marathi.java new file mode 100644 index 000000000..85b2c2501 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Marathi.java @@ -0,0 +1,196 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import static org.kelar.inputmethod.keyboard.layout.DevanagariLetterConstants.*; + +import org.kelar.inputmethod.keyboard.layout.Hindi.HindiSymbols; +import org.kelar.inputmethod.keyboard.layout.customizer.DevanagariCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * The Marathi keyboard. + */ +public final class Marathi extends LayoutBase { + private static final String LAYOUT_NAME = "marathi"; + + public Marathi(final Locale locale) { + super(new MarathiCustomizer(locale), HindiSymbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class MarathiCustomizer extends DevanagariCustomizer { + MarathiCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + @Override + public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) { + return EMPTY_KEYS; + } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS; + } + + // U+20B9: "₹" INDIAN RUPEE SIGN + private static final ExpectedKey CURRENCY_RUPEE = key("\u20B9", + Symbols.CURRENCY_GENERIC_MORE_KEYS); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(final boolean isPhone, final int elementId) { + return null; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+094C: "ौ" DEVANAGARI VOWEL SIGN AU + // U+0914: "औ" DEVANAGARI LETTER AU + // U+0967: "१" DEVANAGARI DIGIT ONE + key(VOWEL_SIGN_AU, "\u094C", joinMoreKeys("\u0914", "\u0967", "1")), + // U+0948: "ै" DEVANAGARI VOWEL SIGN AI + // U+0910: "ऐ" DEVANAGARI LETTER AI + // U+0968: "२" DEVANAGARI DIGIT TWO + key(VOWEL_SIGN_AI, "\u0948", joinMoreKeys("\u0910", "\u0968", "2")), + // U+093E: "ा" DEVANAGARI VOWEL SIGN AA + // U+0906: "आ" DEVANAGARI LETTER AA + // U+0969: "३" DEVANAGARI DIGIT THREE + key(VOWEL_SIGN_AA, "\u093E", joinMoreKeys("\u0906", "\u0969", "3")), + // U+0940: "ी" DEVANAGARI VOWEL SIGN II + // U+0908: "ई" DEVANAGARI LETTER II + // U+096A: "४" DEVANAGARI DIGIT FOUR + key(VOWEL_SIGN_II, "\u0940", joinMoreKeys("\u0908", "\u096A", "4")), + // U+0942: "ू" DEVANAGARI VOWEL SIGN UU + // U+090A: "ऊ" DEVANAGARI LETTER UU + // U+096B: "५" DEVANAGARI DIGIT FIVE + key(VOWEL_SIGN_UU, "\u0942", joinMoreKeys("\u090A", "\u096B", "5")), + // U+092C: "ब" DEVANAGARI LETTER BA + // U+092D: "भ" DEVANAGARI LETTER BHA + // U+096C: "६" DEVANAGARI DIGIT SIX + key("\u092C", joinMoreKeys("\u092D", "\u096C", "6")), + // U+0939: "ह" DEVANAGARI LETTER HA + // U+096D: "७" DEVANAGARI DIGIT SEVEN + key("\u0939", joinMoreKeys("\u096D", "7")), + // U+0917: "ग" DEVANAGARI LETTER GA + // U+0918: "घ" DEVANAGARI LETTER GHA + // U+096E: "८" DEVANAGARI DIGIT EIGHT + key("\u0917", joinMoreKeys("\u0918", "\u096E", "8")), + // U+0926: "द" DEVANAGARI LETTER DA + // U+0927: "ध" DEVANAGARI LETTER DHA + // U+096F: "९" DEVANAGARI DIGIT NINE + key("\u0926", joinMoreKeys("\u0927", "\u096F", "9")), + // U+091C: "ज" DEVANAGARI LETTER JA + // U+091D: "झ" DEVANAGARI LETTER JHA + // U+091C/U+094D/U+091E: + // "ज्ञ" DEVANAGARI LETTER JA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER NYA + // U+0966: "०" DEVANAGARI DIGIT ZERO + key("\u091C", joinMoreKeys("\u091D", "\u091C\u094D\u091E", "\u0966", "0")), + // U+0921: "ड" DEVANAGARI LETTER DDA + // U+0922: "ढ" DEVANAGARI LETTER DDHA + key("\u0921", moreKey("\u0922"))) + .setKeysOfRow(2, + // U+094B: "ो" DEVANAGARI VOWEL SIGN O + // U+0913: "ओ" DEVANAGARI LETTER O + key(VOWEL_SIGN_O, "\u094B", moreKey("\u0913")), + // U+0947: "े" DEVANAGARI VOWEL SIGN E + // U+090F: "ए" DEVANAGARI LETTER SHORT E + key(VOWEL_SIGN_E, "\u0947", moreKey("\u090F")), + // U+094D: "्" DEVANAGARI SIGN VIRAMA + // U+0905: "अ" DEVANAGARI LETTER A + key(SIGN_VIRAMA, "\u094D", moreKey("\u0905")), + // U+093F: "ि" DEVANAGARI VOWEL SIGN I + // U+0907: "इ" DEVANAGARI LETTER I + key(VOWEL_SIGN_I, "\u093F", moreKey("\u0907")), + // U+0941: "ु" DEVANAGARI VOWEL SIGN U + // U+0909: "उ" DEVANAGARI LETTER U + key(VOWEL_SIGN_U, "\u0941", moreKey("\u0909")), + // U+092A: "प" DEVANAGARI LETTER PA + // U+092B: "फ" DEVANAGARI LETTER PHA + key("\u092A", moreKey("\u092B")), + // U+0930: "र" DEVANAGARI LETTER RA + // U+0931: "ऱ" DEVANAGARI LETTER RRA + // U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R + // U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R + key("\u0930", joinMoreKeys( + "\u0931", "\u090B", moreKey(VOWEL_SIGN_VOCALIC_R, "\u0943"))), + // U+0915: "क" DEVANAGARI LETTER KA + // U+0916: "ख" DEVANAGARI LETTER KHA + key("\u0915", moreKey("\u0916")), + // U+0924: "त" DEVANAGARI LETTER TA + // U+0925: "थ" DEVANAGARI LETTER THA + // U+0924/U+094D/U+0930: + // "त्र" DEVANAGARI LETTER TA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA + key("\u0924", joinMoreKeys("\u0925", "\u0924\u094D\u0930")), + // U+091A: "च" DEVANAGARI LETTER CA + // U+091B: "छ" DEVANAGARI LETTER CHA + key("\u091A", moreKey("\u091B")), + // U+091F: "ट" DEVANAGARI LETTER TTA + // U+0920: "ठ" DEVANAGARI LETTER TTHA + key("\u091F", moreKey("\u0920"))) + .setKeysOfRow(3, + // U+0949: "ॉ" DEVANAGARI VOWEL SIGN CANDRA O + // U+0911: "ऑ" DEVANAGARI LETTER CANDRA O + key(VOWEL_SIGN_CANDRA_O, "\u0949", moreKey("\u0911")), + // U+0945: "ॅ" DEVANAGARI VOWEL SIGN CANDRA E + // U+090D: "ऍ" DEVANAGARI LETTER CANDRA E + key(VOWEL_SIGN_CANDRA_E, "\u0945", moreKey("\u090D")), + // U+0902: "ं" DEVANAGARI SIGN ANUSVARA + // U+0903: "ः" DEVANAGARI SIGN VISARGA + // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU + key(SIGN_ANUSVARA, "\u0902", joinMoreKeys( + moreKey(SIGN_VISARGA, "\u0903"), moreKey(SIGN_CANDRABINDU, "\u0901"))), + // U+092E: "म" DEVANAGARI LETTER MA + "\u092E", + // U+0928: "न" DEVANAGARI LETTER NA + // U+0923: "ण" DEVANAGARI LETTER NNA + // U+091E: "ञ" DEVANAGARI LETTER NYA + // U+0919: "ङ" DEVANAGARI LETTER NGA + key("\u0928", joinMoreKeys("\u0923", "\u091E", "\u0919")), + // U+0935: "व" DEVANAGARI LETTER VA + "\u0935", + // U+0932: "ल" DEVANAGARI LETTER LA + // U+0933: "ळ" DEVANAGARI LETTER LLA + key("\u0932", moreKey("\u0933")), + // U+0938: "स" DEVANAGARI LETTER SA + // U+0936: "श" DEVANAGARI LETTER SHA + // U+0937: "ष" DEVANAGARI LETTER SSA + // U+0936/U+094D/U+0930: + // "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA + key("\u0938", joinMoreKeys("\u0936", "\u0937", "\u0936\u094D\u0930")), + // U+092F: "य" DEVANAGARI LETTER YA + "\u092F", + // U+0915/U+094D/U+0937: + // "क्ष" DEVANAGARI LETTER KA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER SSA + "\u0915\u094D\u0937") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Mongolian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Mongolian.java new file mode 100644 index 000000000..e616cc931 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Mongolian.java @@ -0,0 +1,112 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.EastSlavicCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public final class Mongolian extends LayoutBase { + private static final String LAYOUT_NAME = "mongolian"; + + public Mongolian(final Locale locale) { + super(new MongolianCustomizer(locale), Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class MongolianCustomizer extends EastSlavicCustomizer { + MongolianCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_TUGRIK; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + // U+20AE: "₮" TUGRIK SIGN + private static final ExpectedKey CURRENCY_TUGRIK = key("\u20AE", + Symbols.CURRENCY_GENERIC_MORE_KEYS); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0444: "ф" CYRILLIC SMALL LETTER EF + key("\u0444", moreKey("1")), + // U+0446: "ц" CYRILLIC SMALL LETTER TSE + key("\u0446", moreKey("2")), + // U+0443: "у" CYRILLIC SMALL LETTER U + key("\u0443", moreKey("3")), + // U+0436: "ж" CYRILLIC SMALL LETTER ZHE + key("\u0436", moreKey("4")), + // U+044D: "э" CYRILLIC SMALL LETTER E + key("\u044D", 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 + // U+0449: "щ" CYRILLIC SMALL LETTER SHCHA + key("\u0448", joinMoreKeys("8", "\u0449")), + // U+04AF: "ү" CYRILLIC SMALL LETTER STRAIGHT U + key("\u04AF", moreKey("9")), + // U+0437: "з" CYRILLIC SMALL LETTER ZE + key("\u0437", moreKey("0")), + // U+043A: "к" CYRILLIC SMALL LETTER KA + "\u043A") + .setKeysOfRow(2, + // U+0439: "й" CYRILLIC SMALL LETTER SHORT I + // U+044B: "ы" CYRILLIC SMALL LETTER YERU + // U+0431: "б" CYRILLIC SMALL LETTER BE + // U+04E9: "ө" CYRILLIC SMALL LETTER BARRED O + // U+0430: "а" CYRILLIC SMALL LETTER A + // U+0445: "х" CYRILLIC SMALL LETTER HA + // 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+043F: "п" CYRILLIC SMALL LETTER PE + "\u0439", "\u044B", "\u0431", "\u04E9", "\u0430", "\u0445", "\u0440", "\u043E", + "\u043B", "\u0434", "\u043F") + .setKeysOfRow(3, + // U+044F: "я" CYRILLIC SMALL LETTER YA + // U+0447: "ч" CYRILLIC SMALL LETTER CHE + "\u044F", "\u0447", + // U+0451: "ё" CYRILLIC SMALL LETTER IO + // U+0435: "е" CYRILLIC SMALL LETTER IE + key("\u0451", moreKey("\u0435")), + // U+0441: "с" CYRILLIC SMALL LETTER ES + // U+043C: "м" CYRILLIC SMALL LETTER EM + // U+0438: "и" CYRILLIC SMALL LETTER I + // U+0442: "т" CYRILLIC SMALL LETTER TE + "\u0441", "\u043C", "\u0438", "\u0442", + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN + key("\u044C", moreKey("\u044A")), + // U+0432: "в" CYRILLIC SMALL LETTER VE + // U+044E: "ю" CYRILLIC SMALL LETTER YU + key("\u0432", moreKey("\u044E"))) + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/NepaliRomanized.java b/tests/src/org/kelar/inputmethod/keyboard/layout/NepaliRomanized.java new file mode 100644 index 000000000..ed4719a24 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/NepaliRomanized.java @@ -0,0 +1,166 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import static org.kelar.inputmethod.keyboard.layout.DevanagariLetterConstants.*; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.layout.Hindi.HindiSymbols; +import org.kelar.inputmethod.keyboard.layout.customizer.NepaliCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 Locale locale) { + super(new NepaliCustomizer(locale), HindiSymbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(final 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", key(SIGN_NUKTA, "\u093C"))), + // U+094C: "ौ" DEVANAGARI VOWEL SIGN AU + // U+0968: "२" DEVANAGARI DIGIT TWO + key(VOWEL_SIGN_AU, "\u094C", joinMoreKeys("\u0968", "2")), + // U+0947: "े" DEVANAGARI VOWEL SIGN E + // U+0969: "३" DEVANAGARI DIGIT THREE + key(VOWEL_SIGN_E, "\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(VOWEL_SIGN_U, "\u0941", joinMoreKeys("\u096D", "7")), + // U+093F: "ि" DEVANAGARI VOWEL SIGN I + // U+096E: "८" DEVANAGARI DIGIT EIGHT + key(VOWEL_SIGN_I, "\u093F", joinMoreKeys("\u096E", "8")), + // U+094B: "ो" DEVANAGARI VOWEL SIGN O + // U+096F: "९" DEVANAGARI DIGIT NINE + key(VOWEL_SIGN_O, "\u094B", joinMoreKeys("\u096F", "9")), + // U+092A: "प" DEVANAGARI LETTER PA + // U+0966: "०" DEVANAGARI DIGIT ZERO + key("\u092A", joinMoreKeys("\u0966", "0")), + // U+0907: "इ" DEVANAGARI LETTER I + "\u0907") + .setKeysOfRow(2, + // U+093E: "ा" DEVANAGARI VOWEL SIGN AA + key(VOWEL_SIGN_AA, "\u093E"), + // 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 + "\u0938", "\u0926", "\u0909", "\u0917", "\u0939", "\u091C", "\u0915", "\u0932", + "\u090F", "\u0950") + .setKeysOfRow(3, + // 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 + "\u0937", "\u0921", "\u091A", "\u0935", "\u092C", "\u0928", "\u092E", + // U+094D: "्" DEVANAGARI SIGN VIRAMA + // U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA + key(SIGN_VIRAMA, "\u094D", moreKey("\u093D"))) + .build(); + + private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0920: "ठ" DEVANAGARI LETTER TTHA + // U+0914: "औ" DEVANAGARI LETTER AU + "\u0920", "\u0914", + // U+0948: "ै" DEVANAGARI VOWEL SIGN AI + key(VOWEL_SIGN_AI, "\u0948"), + // U+0943: "ृ" DEVANAGARI VOWEL SIGN VOCALIC R + key(VOWEL_SIGN_VOCALIC_R, "\u0943"), + // U+0925: "थ" DEVANAGARI LETTER THA + // U+091E: "ञ" DEVANAGARI LETTER NYA + "\u0925", "\u091E", + // U+0942: "ू" DEVANAGARI VOWEL SIGN UU + key(VOWEL_SIGN_UU, "\u0942"), + // U+0940: "ी" DEVANAGARI VOWEL SIGN II + key(VOWEL_SIGN_II, "\u0940"), + // U+0913: "ओ" DEVANAGARI LETTER O + // U+092B: "फ" DEVANAGARI LETTER PHA + // U+0908: "ई" DEVANAGARI LETTER II + "\u0913", "\u092B", "\u0908") + .setKeysOfRow(2, + // 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 + "\u0906", "\u0936", "\u0927", "\u090A", "\u0918", "\u0905", "\u091D", "\u0916", + "\u0965", "\u0910", key(SIGN_VISARGA, "\u0903")) + .setKeysOfRow(3, + // U+090B: "ऋ" DEVANAGARI LETTER VOCALIC R + // U+0922: "ढ" DEVANAGARI LETTER DDHA + // U+091B: "छ" DEVANAGARI LETTER CHA + "\u090B", "\u0922", "\u091B", + // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU + key(SIGN_CANDRABINDU, "\u0901"), + // U+092D: "भ" DEVANAGARI LETTER BHA + // U+0923: "ण" DEVANAGARI LETTER NNA + "\u092D", "\u0923", + // U+0902: "ं" DEVANAGARI SIGN ANUSVARA + key(SIGN_ANUSVARA, "\u0902"), + // U+0919: "ङ" DEVANAGARI LETTER NGA + "\u0919") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/NepaliTraditional.java b/tests/src/org/kelar/inputmethod/keyboard/layout/NepaliTraditional.java new file mode 100644 index 000000000..c6282460e --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/NepaliTraditional.java @@ -0,0 +1,225 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import static org.kelar.inputmethod.keyboard.layout.DevanagariLetterConstants.*; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.layout.Hindi.HindiSymbols; +import org.kelar.inputmethod.keyboard.layout.customizer.NepaliCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 Locale locale) { + super(new NepaliTraditionalCustomizer(locale), HindiSymbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class NepaliTraditionalCustomizer extends NepaliCustomizer { + NepaliTraditionalCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS; + } + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { return ALPHABET_COMMON; } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(final 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 + 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"))) + .setKeysOfRow(2, + // U+092C: "ब" DEVANAGARI LETTER BA + // U+0915: "क" DEVANAGARI LETTER KA + // U+092E: "म" DEVANAGARI LETTER MA + "\u092C", "\u0915", "\u092E", + // U+093E: "ा" DEVANAGARI VOWEL SIGN AA + key(VOWEL_SIGN_AA, "\u093E"), + // U+0928: "न" DEVANAGARI LETTER NA + // U+091C: "ज" DEVANAGARI LETTER JA + // U+0935: "व" DEVANAGARI LETTER VA + // U+092A: "प" DEVANAGARI LETTER PA + "\u0928", "\u091C", "\u0935", "\u092A", + // U+093F: "ि" DEVANAGARI VOWEL SIGN I + key(VOWEL_SIGN_I, "\u093F"), + // U+0938: "स" DEVANAGARI LETTER SA + "\u0938", + // U+0941: "ु" DEVANAGARI VOWEL SIGN U + key(VOWEL_SIGN_U, "\u0941")) + .setKeysOfRow(3, + // 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 + "\u0936", "\u0939", "\u0905", "\u0916", "\u0926", "\u0932", + // U+0947: "े" DEVANAGARI VOWEL SIGN E + // U+0903: "ः" DEVANAGARI SIGN VISARGA + // U+093D: "ऽ" DEVANAGARI SIGN AVAGRAHA + key(VOWEL_SIGN_E, "\u0947", joinMoreKeys( + moreKey(SIGN_VISARGA, "\u0903"), "\u093D")), + // U+094D: "्" DEVANAGARI SIGN VIRAMA + key(SIGN_VIRAMA, "\u094D"), + // U+0930: "र" DEVANAGARI LETTER RA + // U+0930/U+0941: "रु" DEVANAGARI LETTER RA/DEVANAGARI VOWEL SIGN U + key("\u0930", moreKey("\u0930\u0941"))) + .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(VOWEL_SIGN_VOCALIC_R, "\u0943", moreKey("\u0913"))) + .setKeysOfRow(2, + // 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 + "\u0906", "\u0919\u094D", "\u0921\u094D\u0921", + // U+0901: "ँ" DEVANAGARI SIGN CANDRABINDU + key(SIGN_CANDRABINDU, "\u0901"), + // U+0926/U+094D/U+0926: + // "द्द" DEVANAGARI LETTER DA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER DA + // U+091D: "झ" DEVANAGARI LETTER JHA + "\u0926\u094D\u0926", "\u091D", + // U+094B: "ो" DEVANAGARI VOWEL SIGN O + key(VOWEL_SIGN_O, "\u094B"), + // U+092B: "फ" DEVANAGARI LETTER PHA + "\u092B", + // U+0940: "ी" DEVANAGARI VOWEL SIGN II + key(VOWEL_SIGN_II, "\u0940"), + // U+091F/U+094D/U+0920: + // "ट्ठ" DEVANAGARI LETTER TTA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER TTHA + "\u091F\u094D\u0920", + // U+0942: "ू" DEVANAGARI VOWEL SIGN UU + key(VOWEL_SIGN_UU, "\u0942")) + .setKeysOfRow(3, + // 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 + "\u0915\u094D", "\u0939\u094D\u092E", "\u090B", "\u0950", + // U+094C: "ौ" DEVANAGARI VOWEL SIGN AU + key(VOWEL_SIGN_AU, "\u094C"), + // U+0926/U+094D/U+092F: + // "द्य" DEVANAGARI LETTER DA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER YA + "\u0926\u094D\u092F", + // U+0902: "ं" DEVANAGARI SIGN ANUSVARA + key(SIGN_ANUSVARA, "\u0902"), + // U+0919: "ङ" DEVANAGARI LETTER NGA + "\u0919", + // U+0948: "ै" DEVANAGARI VOWEL SIGN AI + // U+0936/U+094D/U+0930: + // "श्र" DEVANAGARI LETTER SHA/DEVANAGARI SIGN VIRAMA/DEVANAGARI LETTER RA + key(VOWEL_SIGN_AI, "\u0948", moreKey("\u0936\u094D\u0930"))) + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Nordic.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Nordic.java new file mode 100644 index 000000000..303c55bee --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Nordic.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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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", additionalMoreKey("1")), + key("w", additionalMoreKey("2")), + key("e", additionalMoreKey("3")), + key("r", additionalMoreKey("4")), + key("t", additionalMoreKey("5")), + key("y", additionalMoreKey("6")), + key("u", additionalMoreKey("7")), + key("i", additionalMoreKey("8")), + key("o", additionalMoreKey("9")), + key("p", additionalMoreKey("0")), + ROW1_11) + .setKeysOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l", ROW2_10, ROW2_11) + .setKeysOfRow(3, "z", "x", "c", "v", "b", "n", "m") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/PcQwerty.java b/tests/src/org/kelar/inputmethod/keyboard/layout/PcQwerty.java new file mode 100644 index 000000000..1fdd28e16 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/PcQwerty.java @@ -0,0 +1,202 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +/** + * The PC QWERTY alphabet keyboard. + */ +public final class PcQwerty extends LayoutBase { + private static final String LAYOUT_NAME = "pcqwerty"; + + public PcQwerty(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { + final LayoutCustomizer customizer = getCustomizer(); + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + customizer.setAccentedLetters(builder); + builder.replaceKeyOfLabel(ROW1_1, key("`", moreKey("~"))) + .replaceKeyOfLabel(ROW2_11, key("[", moreKey("{"))) + .replaceKeyOfLabel(ROW2_12, key("]", moreKey("}"))) + .replaceKeyOfLabel(ROW2_13, key("\\", moreKey("|"))) + .replaceKeyOfLabel(ROW3_10, key(";", moreKey(":"))) + .replaceKeyOfLabel(ROW3_11, key("'", joinMoreKeys(additionalMoreKey("\""), + customizer.getDoubleQuoteMoreKeys(), + customizer.getSingleQuoteMoreKeys()))) + .setAdditionalMoreKeysPositionOf("'", 4) + .replaceKeyOfLabel(ROW4_8, key(",", moreKey("<"))) + .replaceKeyOfLabel(ROW4_9, key(".", moreKey(">"))) + // U+00BF: "¿" INVERTED QUESTION MARK + .replaceKeyOfLabel(ROW4_10, key("/", joinMoreKeys("?", "\u00BF"))); + if (isPhone) { + // U+221E: "∞" INFINITY + // U+2260: "≠" NOT EQUAL TO + // U+2248: "≈" ALMOST EQUAL TO + builder.replaceKeyOfLabel(ROW1_13, key("=", + joinMoreKeys("\u221E", "\u2260", "\u2248", "+"))); + } else { + // U+221E: "∞" INFINITY + // U+2260: "≠" NOT EQUAL TO + // U+2248: "≈" ALMOST EQUAL TO + builder.replaceKeyOfLabel(ROW1_13, key("=", + joinMoreKeys("+", "\u221E", "\u2260", "\u2248"))); + } + return builder.build(); + } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(final boolean isPhone, final int elementId) { + final ExpectedKeyboardBuilder builder; + if (elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED + || elementId == KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED) { + builder = new ExpectedKeyboardBuilder(getCommonAlphabetLayout(isPhone)); + } else { + builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + final LayoutCustomizer customizer = getCustomizer(); + customizer.setAccentedLetters(builder); + builder.setKeysOfRow(1, + "~", + // U+00A1: "¡" INVERTED EXCLAMATION MARK + key("!", moreKey("\u00A1")), + "@", "#", + customizer.getCurrencyKey(), + // U+2030: "‰" PER MILLE SIGN + key("%", moreKey("\u2030")), + "^", "&", + // U+2020: "†" DAGGER + // U+2021: "‡" DOUBLE DAGGER + // U+2605: "★" BLACK STAR + key("*", joinMoreKeys("\u2020", "\u2021", "\u2605")), + "(", ")", "_", + // U+00B1: "±" PLUS-MINUS SIGN + // U+00D7: "×" MULTIPLICATION SIGN + // U+00F7: "÷" DIVISION SIGN + // U+221A: "√" SQUARE ROOT + key("+", joinMoreKeys("\u00B1", "\u00D7", "\u00F7", "\u221A"))) + .replaceKeyOfLabel(ROW2_11, key("{")) + .replaceKeyOfLabel(ROW2_12, key("}")) + .replaceKeyOfLabel(ROW2_13, key("|")) + .replaceKeyOfLabel(ROW3_10, key(":")) + .replaceKeyOfLabel(ROW3_11, key("\"", joinMoreKeys( + customizer.getDoubleQuoteMoreKeys(), + customizer.getSingleQuoteMoreKeys()))) + // U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK + // U+2264: "≤" LESS-THAN OR EQUAL TO + // U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK + .replaceKeyOfLabel(ROW4_8, key("<", joinMoreKeys("\u2039", "\u2264", "\u00AB"))) + // U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK + // U+2265: "≥" GREATER-THAN EQUAL TO + // U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK + .replaceKeyOfLabel(ROW4_9, key(">", joinMoreKeys("\u203A", "\u2265", "\u00BB"))) + // U+00BF: "¿" INVERTED QUESTION MARK + .replaceKeyOfLabel(ROW4_10, key("?", moreKey("\u00BF"))); + } + builder.toUpperCase(getLocale()); + return builder.build(); + } + + // Helper method to create alphabet layout by adding special function keys. + @Override + ExpectedKeyboardBuilder convertCommonLayoutToKeyboard(final ExpectedKeyboardBuilder builder, + final boolean isPhone) { + final LayoutCustomizer customizer = getCustomizer(); + builder.setKeysOfRow(5, (Object[])customizer.getSpaceKeys(isPhone)); + builder.addKeysOnTheLeftOfRow(5, (Object[])customizer.getKeysLeftToSpacebar(isPhone)); + builder.addKeysOnTheRightOfRow(5, (Object[])customizer.getKeysRightToSpacebar(isPhone)); + if (isPhone) { + builder.addKeysOnTheRightOfRow(3, DELETE_KEY); + } else { + builder.addKeysOnTheRightOfRow(1, DELETE_KEY) + .addKeysOnTheLeftOfRow(2, TAB_KEY) + .addKeysOnTheRightOfRow(3, ENTER_KEY); + } + builder.addKeysOnTheLeftOfRow(4, (Object[])customizer.getLeftShiftKeys(isPhone)) + .addKeysOnTheRightOfRow(4, (Object[])customizer.getRightShiftKeys(isPhone)); + return builder; + } + + @Override + public ExpectedKey[][] getLayout(final boolean isPhone, final int elementId) { + if (elementId == KeyboardId.ELEMENT_SYMBOLS + || elementId == KeyboardId.ELEMENT_SYMBOLS_SHIFTED) { + return null; + } + return super.getLayout(isPhone, elementId); + } + + private static final String ROW1_1 = "ROW1_1"; + private static final String ROW1_13 = "ROW1_13"; + private static final String ROW2_11 = "ROW2_11"; + private static final String ROW2_12 = "ROW2_12"; + private static final String ROW2_13 = "ROW2_13"; + private static final String ROW3_10 = "ROW3_10"; + private static final String ROW3_11 = "ROW3_11"; + private static final String ROW4_8 = "ROW4_8"; + private static final String ROW4_9 = "ROW4_9"; + private static final String ROW4_10 = "ROW4_10"; + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + ROW1_1, + // U+00A1: "¡" INVERTED EXCLAMATION MARK + // U+00B9: "¹" SUPERSCRIPT ONE + // U+00BD: "½" VULGAR FRACTION ONE HALF + // U+2153: "⅓" VULGAR FRACTION ONE THIRD + // U+00BC: "¼" VULGAR FRACTION ONE QUARTER + // U+215B: "⅛" VULGAR FRACTION ONE EIGHTH + key("1", joinMoreKeys( + "!", "\u00A1", "\u00B9", "\u00BD", "\u2153", "\u00BC", "\u215B")), + // U+00B2: "²" SUPERSCRIPT TWO + // U+2154: "⅔" VULGAR FRACTION TWO THIRDS + key("2", joinMoreKeys("@", "\u00B2", "\u2154")), + // U+00B3: "³" SUPERSCRIPT THREE + // U+00BE: "¾" VULGAR FRACTION THREE QUARTERS + // U+215C: "⅜" VULGAR FRACTION THREE EIGHTHS + key("3", joinMoreKeys("#", "\u00B3", "\u00BE", "\u215C")), + // U+2074: "⁴" SUPERSCRIPT FOUR + key("4", joinMoreKeys("$", "\u2074")), + // U+215D: "⅝" VULGAR FRACTION FIVE EIGHTHS + key("5", joinMoreKeys("%", "\u215D")), + key("6", moreKey("^")), + // U+215E: "⅞" VULGAR FRACTION SEVEN EIGHTHS + key("7", joinMoreKeys("&", "\u215E")), + key("8", moreKey("*")), + key("9", moreKey("(")), + // U+207F: "ⁿ" SUPERSCRIPT LATIN SMALL LETTER N + // U+2205: "∅" EMPTY SET + key("0", joinMoreKeys(")", "\u207F", "\u2205")), + // U+2013: "–" EN DASH + // U+2014: "—" EM DASH + // U+00B7: "·" MIDDLE DOT + key("-", joinMoreKeys("_", "\u2013", "\u2014", "\u00B7")), + ROW1_13) + .setKeysOfRow(2, "q", "w", "e", "r", "t", "y", "u", "i", "o", "p", + ROW2_11, ROW2_12, ROW2_13) + .setKeysOfRow(3, "a", "s", "d", "f", "g", "h", "j", "k", "l", ROW3_10, ROW3_11) + .setKeysOfRow(4, "z", "x", "c", "v", "b", "n", "m", ROW4_8, ROW4_9, ROW4_10) + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Qwerty.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Qwerty.java new file mode 100644 index 000000000..fc535e032 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Qwerty.java @@ -0,0 +1,54 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +/** + * The QWERTY alphabet keyboard. + */ +public final class Qwerty extends LayoutBase { + private static final String LAYOUT_NAME = "qwerty"; + + public Qwerty(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", additionalMoreKey("1")), + key("w", additionalMoreKey("2")), + key("e", additionalMoreKey("3")), + key("r", additionalMoreKey("4")), + key("t", additionalMoreKey("5")), + key("y", additionalMoreKey("6")), + key("u", additionalMoreKey("7")), + key("i", additionalMoreKey("8")), + key("o", additionalMoreKey("9")), + key("p", additionalMoreKey("0"))) + .setKeysOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l") + .setKeysOfRow(3, "z", "x", "c", "v", "b", "n", "m") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Qwertz.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Qwertz.java new file mode 100644 index 000000000..74f3d0c77 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Qwertz.java @@ -0,0 +1,51 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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", additionalMoreKey("1")), + key("w", additionalMoreKey("2")), + key("e", additionalMoreKey("3")), + key("r", additionalMoreKey("4")), + key("t", additionalMoreKey("5")), + key("z", additionalMoreKey("6")), + key("u", additionalMoreKey("7")), + key("i", additionalMoreKey("8")), + key("o", additionalMoreKey("9")), + key("p", additionalMoreKey("0"))) + .setKeysOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l") + .setKeysOfRow(3, "y", "x", "c", "v", "b", "n", "m") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/SerbianQwertz.java b/tests/src/org/kelar/inputmethod/keyboard/layout/SerbianQwertz.java new file mode 100644 index 000000000..f2a00fc81 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/SerbianQwertz.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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +public final class SerbianQwertz extends LayoutBase { + private static final String LAYOUT_NAME = "serbian_qwertz"; + + public SerbianQwertz(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"; + public static final String ROW3_8 = "ROW3_8"; + public static final String ROW3_9 = "ROW3_9"; + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + key("q", additionalMoreKey("1")), + key("w", additionalMoreKey("2")), + key("e", additionalMoreKey("3")), + key("r", additionalMoreKey("4")), + key("t", additionalMoreKey("5")), + key("z", additionalMoreKey("6")), + key("u", additionalMoreKey("7")), + key("i", additionalMoreKey("8")), + key("o", additionalMoreKey("9")), + key("p", additionalMoreKey("0")), + ROW1_11) + .setKeysOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l", ROW2_10, ROW2_11) + .setKeysOfRow(3, "y", "x", "c", "v", "b", "n", "m", ROW3_8, ROW3_9) + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Sinhala.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Sinhala.java new file mode 100644 index 000000000..433c0ea93 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Sinhala.java @@ -0,0 +1,190 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Locale; + +/** + * The Sinhala keyboard. + */ +public final class Sinhala extends LayoutBase { + private static final String LAYOUT_NAME = "sinhala"; + + public Sinhala(final Locale locale) { + super(new SinhalaCustomizer(locale), Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class SinhalaCustomizer extends LayoutCustomizer { + SinhalaCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getAlphabetKey() { return SINHALA_ALPHABET_KEY; } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; } + + @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+0D85: "අ" SINHALA LETTER AYANNA + // U+0D86: "ආ" SINHALA LETTER AAYANNA + private static final ExpectedKey SINHALA_ALPHABET_KEY = key( + "\u0D85,\u0D86", Constants.CODE_SWITCH_ALPHA_SYMBOL); + + // U+0DBB/U+0DD4: "රු" SINHALA LETTER RAYANNA/SINHALA VOWEL SIGN KETTI PAA-PILLA + private static final ExpectedKey CURRENCY_RUPEE = key("\u0DBB\u0DD4", + Symbols.CURRENCY_GENERIC_MORE_KEYS); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) { + if (elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED) { + return ALPHABET_COMMON; + } + return ALPHABET_SHIFTED_COMMON; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0DD4: "ු" SINHALA VOWEL SIGN KETTI PAA-PILLA + key("\u0DD4", moreKey("1")), + // U+0D85: "අ" SINHALA LETTER AYANNA + key("\u0D85", moreKey("2")), + // U+0DD0: "ැ" SINHALA VOWEL SIGN KETTI AEDA-PILLA + key("\u0DD0", moreKey("3")), + // U+0DBB: "ර" SINHALA LETTER RAYANNA + key("\u0DBB", moreKey("4")), + // U+0D91: "එ" SINHALA LETTER EYANNA + key("\u0D91", moreKey("5")), + // U+0DC4: "හ" SINHALA LETTER HAYANNA + key("\u0DC4", moreKey("6")), + // U+0DB8: "ම" SINHALA LETTER MAYANNA + key("\u0DB8", moreKey("7")), + // U+0DC3: "ස" SINHALA LETTER DANTAJA SAYANNA + key("\u0DC3", moreKey("8")), + // U+0DAF: "ද" SINHALA LETTER ALPAPRAANA DAYANNA + // U+0DB3: "ඳ" SINHALA LETTER SANYAKA DAYANNA + key("\u0DAF", joinMoreKeys("9", "\u0DB3")), + // U+0DA0: "ච" SINHALA LETTER ALPAPRAANA CAYANNA + key("\u0DA0", moreKey("0")), + // U+0DA4: "ඤ" SINHALA LETTER TAALUJA NAASIKYAYA + // U+0DF4: "෴" SINHALA PUNCTUATION KUNDDALIYA + key("\u0DA4", moreKey("\u0DF4"))) + .setKeysOfRow(2, + // U+0DCA: "්" SINHALA SIGN AL-LAKUNA + // U+0DD2: "ි" SINHALA VOWEL SIGN KETTI IS-PILLA + // U+0DCF: "ා" SINHALA VOWEL SIGN AELA-PILLA + // U+0DD9: "ෙ" SINHALA VOWEL SIGN KOMBUVA + // U+0DA7: "ට" SINHALA LETTER ALPAPRAANA TTAYANNA + // U+0DBA: "ය" SINHALA LETTER YAYANNA + // U+0DC0: "ව" SINHALA LETTER VAYANNA + // U+0DB1: "න" SINHALA LETTER DANTAJA NAYANNA + // U+0D9A: "ක" SINHALA LETTER ALPAPRAANA KAYANNA + // U+0DAD: "ත" SINHALA LETTER ALPAPRAANA TAYANNA + // U+0D8F: "ඏ" SINHALA LETTER ILUYANNA + "\u0DCA", "\u0DD2", "\u0DCF", "\u0DD9", "\u0DA7", "\u0DBA", "\u0DC0", "\u0DB1", + "\u0D9A", "\u0DAD", "\u0D8F") + .setKeysOfRow(3, + // U+0D82: "ං" SINHALA SIGN ANUSVARAYA + // U+0D83: "ඃ" SINHALA SIGN VISARGAYA + key("\u0D82", moreKey("\u0D83")), + // U+0DA2: "ජ" SINHALA LETTER ALPAPRAANA JAYANNA + // U+0DA6: "ඦ" SINHALA LETTER SANYAKA JAYANNA + key("\u0DA2", moreKey("\u0DA6")), + // U+0DA9: "ඩ" SINHALA LETTER ALPAPRAANA DDAYANNA + // U+0DAC: "ඬ" SINHALA LETTER SANYAKA DDAYANNA + key("\u0DA9", moreKey("\u0DAC")), + // U+0D89: "ඉ" SINHALA LETTER IYANNA + // U+0DB6: "බ" SINHALA LETTER ALPAPRAANA BAYANNA + // U+0DB4: "ප" SINHALA LETTER ALPAPRAANA PAYANNA + // U+0DBD: "ල" SINHALA LETTER DANTAJA LAYANNA + "\u0D89", "\u0DB6", "\u0DB4", "\u0DBD", + // U+0D9C: "ග" SINHALA LETTER ALPAPRAANA GAYANNA + // U+0D9F: "ඟ" SINHALA LETTER SANYAKA GAYANNA + key("\u0D9C", moreKey("\u0D9F")), + // U+0DF3: "ෳ" SINHALA VOWEL SIGN DIGA GAYANUKITTA + "\u0DF3") + .build(); + + private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0DD6: "ූ" SINHALA VOWEL SIGN DIGA PAA-PILLA + // U+0D8B: "උ" SINHALA LETTER UYANNA + // U+0DD1: "ෑ" SINHALA VOWEL SIGN DIGA AEDA-PILLA + // U+0D8D: "ඍ" SINHALA LETTER IRUYANNA + // U+0D94: "ඔ" SINHALA LETTER OYANNA + // U+0DC1: "ශ" SINHALA LETTER TAALUJA SAYANNA + // U+0DB9: "ඹ" SINHALA LETTER AMBA BAYANNA + // U+0DC2: "ෂ" SINHALA LETTER MUURDHAJA SAYANNA + // U+0DB0: "ධ" SINHALA LETTER MAHAAPRAANA DAYANNA + // U+0DA1: "ඡ" SINHALA LETTER MAHAAPRAANA CAYANNA + "\u0DD6", "\u0D8B", "\u0DD1", "\u0D8D", "\u0D94", "\u0DC1", "\u0DB9", "\u0DC2", + "\u0DB0", "\u0DA1", + // U+0DA5: "ඥ" SINHALA LETTER TAALUJA SANYOOGA NAAKSIKYAYA + // U+0DF4: "෴" SINHALA PUNCTUATION KUNDDALIYA + key("\u0DA5", moreKey("\u0DF4"))) + .setKeysOfRow(2, + // U+0DDF: "ෟ" SINHALA VOWEL SIGN GAYANUKITTA + // U+0DD3: "ී" SINHALA VOWEL SIGN DIGA IS-PILLA + // U+0DD8: "ෘ" SINHALA VOWEL SIGN GAETTA-PILLA + // U+0DC6: "ෆ" SINHALA LETTER FAYANNA + // U+0DA8: "ඨ" SINHALA LETTER MAHAAPRAANA TTAYANNA + // U+0DCA/U+200D/U+0DBA: + // "්ය" SINHALA SIGN AL-LAKUNA/ZERO WIDTH JOINER/SINHALA LETTER YAYANNA + // U+0DC5/U+0DD4: + // "ළු" SINHALA LETTER MUURDHAJA LAYANNA/SINHALA VOWEL SIGN KETTI PAA-PILLA + // U+0DAB: "ණ" SINHALA LETTER MUURDHAJA NAYANNA + // U+0D9B: "ඛ" SINHALA LETTER MAHAAPRAANA KAYANNA + // U+0DAE: "ථ" SINHALA LETTER MAHAAPRAANA TAYANNA + // U+0DCA/U+200D/U+0DBB: + // "්ර" SINHALA SIGN AL-LAKUNA/ZERO WIDTH JOINER/SINHALA LETTER RAYANNA + "\u0DDF", "\u0DD3", "\u0DD8", "\u0DC6", "\u0DA8", "\u0DCA\u200D\u0DBA", + "\u0DC5\u0DD4", "\u0DAB", "\u0D9B", "\u0DAE", "\u0DCA\u200D\u0DBB") + .setKeysOfRow(3, + // U+0D9E: "ඞ" SINHALA LETTER KANTAJA NAASIKYAYA + // U+0DA3: "ඣ" SINHALA LETTER MAHAAPRAANA JAYANNA + // U+0DAA: "ඪ" SINHALA LETTER MAHAAPRAANA DDAYANNA + // U+0D8A: "ඊ" SINHALA LETTER IIYANNA + // U+0DB7: "භ" SINHALA LETTER MAHAAPRAANA BAYANNA + // U+0DB5: "ඵ" SINHALA LETTER MAHAAPRAANA PAYANNA + // U+0DC5: "ළ" SINHALA LETTER MUURDHAJA LAYANNA + // U+0D9D: "ඝ" SINHALA LETTER MAHAAPRAANA GAYANNA + // U+0DBB/U+0DCA/U+200D: + // "ර්" SINHALA LETTER RAYANNA/SINHALA SIGN AL-LAKUNA/ZERO WIDTH JOINER + "\u0d9E", "\u0DA3", "\u0DAA", "\u0D8A", "\u0DB7", "\u0DB5", "\u0DC5", "\u0D9D", + "\u0DBB\u0DCA\u200D") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/SouthSlavic.java b/tests/src/org/kelar/inputmethod/keyboard/layout/SouthSlavic.java new file mode 100644 index 000000000..503af359c --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/SouthSlavic.java @@ -0,0 +1,88 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +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; } + + @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", additionalMoreKey("1")), + // U+045A: "њ" CYRILLIC SMALL LETTER NJE + key("\u045A", additionalMoreKey("2")), + // U+0435: "е" CYRILLIC SMALL LETTER IE + key("\u0435", additionalMoreKey("3")), + // U+0440: "р" CYRILLIC SMALL LETTER ER + key("\u0440", additionalMoreKey("4")), + // U+0442: "т" CYRILLIC SMALL LETTER TE + key("\u0442", additionalMoreKey("5")), + key(ROW1_6, additionalMoreKey("6")), + // U+0443: "у" CYRILLIC SMALL LETTER U + key("\u0443", additionalMoreKey("7")), + // U+0438: "и" CYRILLIC SMALL LETTER I + key("\u0438", additionalMoreKey("8")), + // U+043E: "о" CYRILLIC SMALL LETTER O + key("\u043E", additionalMoreKey("9")), + // U+043F: "п" CYRILLIC SMALL LETTER PE + key("\u043F", additionalMoreKey("0")), + // U+0448: "ш" CYRILLIC SMALL LETTER SHA + "\u0448") + .setKeysOfRow(2, + // U+0430: "а" CYRILLIC SMALL LETTER A + // U+0441: "с" CYRILLIC SMALL LETTER ES + // U+0434: "д" CYRILLIC SMALL LETTER DE + // U+0444: "ф" CYRILLIC SMALL LETTER EF + // U+0433: "г" CYRILLIC SMALL LETTER GHE + // U+0445: "х" CYRILLIC SMALL LETTER HA + // U+0458: "ј" CYRILLIC SMALL LETTER JE + // U+043A: "к" CYRILLIC SMALL LETTER KA + // U+043B: "л" CYRILLIC SMALL LETTER EL + // U+0447: "ч" CYRILLIC SMALL LETTER CHE + "\u0430", "\u0441", "\u0434", "\u0444", "\u0433", "\u0445", "\u0458", "\u043A", + "\u043B", "\u0447", ROW2_11) + .setKeysOfRow(3, + // 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 + ROW3_1, "\u045F", "\u0446", "\u0432", "\u0431", "\u043D", "\u043C", ROW3_8, + "\u0436") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Spanish.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Spanish.java new file mode 100644 index 000000000..a5ac6bd71 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Spanish.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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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", additionalMoreKey("1")), + key("w", additionalMoreKey("2")), + key("e", additionalMoreKey("3")), + key("r", additionalMoreKey("4")), + key("t", additionalMoreKey("5")), + key("y", additionalMoreKey("6")), + key("u", additionalMoreKey("7")), + key("i", additionalMoreKey("8")), + key("o", additionalMoreKey("9")), + key("p", additionalMoreKey("0"))) + .setKeysOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l", ROW2_10) + .setKeysOfRow(3, "z", "x", "c", "v", "b", "n", "m") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Swiss.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Swiss.java new file mode 100644 index 000000000..6ab08d0b3 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Swiss.java @@ -0,0 +1,56 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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", additionalMoreKey("1")), + key("w", additionalMoreKey("2")), + key("e", additionalMoreKey("3")), + key("r", additionalMoreKey("4")), + key("t", additionalMoreKey("5")), + key("z", additionalMoreKey("6")), + key("u", additionalMoreKey("7")), + key("i", additionalMoreKey("8")), + key("o", additionalMoreKey("9")), + key("p", additionalMoreKey("0")), + ROW1_11) + .setKeysOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l", ROW2_10, ROW2_11) + .setKeysOfRow(3, "y", "x", "c", "v", "b", "n", "m") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Symbols.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Symbols.java new file mode 100644 index 000000000..e9d934283 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Symbols.java @@ -0,0 +1,205 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.AbstractLayoutBase; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +/** + * The symbols keyboard layout. + */ +public class Symbols extends AbstractLayoutBase { + private final LayoutCustomizer mCustomizer; + + public Symbols(final LayoutCustomizer customizer) { + mCustomizer = customizer; + } + + 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, customizer.getEnterKey(isPhone)); + } else { + // Tablet symbols keyboard has extra two keys at the left edge of the 3rd row. + builder.addKeysOnTheLeftOfRow(3, (Object[])joinKeys("\\", "=")); + builder.addKeysOnTheRightOfRow(1, DELETE_KEY) + .addKeysOnTheRightOfRow(2, customizer.getEnterKey(isPhone)) + .addKeysOnTheLeftOfRow(3, customizer.getSymbolsShiftKey(isPhone)) + .addKeysOnTheRightOfRow(3, customizer.getSymbolsShiftKey(isPhone)) + .addKeysOnTheLeftOfRow(4, customizer.getAlphabetKey()) + .addKeysOnTheRightOfRow(4, customizer.getEmojiKey(isPhone)); + } + return builder.build(); + } + + // Variations of the "currency" key on the 2nd row. + public static final String CURRENCY = "CURRENCY"; + // U+00A2: "¢" CENT SIGN + // U+00A3: "£" POUND SIGN + // U+00A5: "¥" YEN SIGN + // U+20AC: "€" EURO SIGN + // U+20B1: "₱" PESO SIGN + public static final ExpectedKey DOLLAR_SIGN = key("$"); + public static final ExpectedKey CENT_SIGN = key("\u00A2"); + public static final ExpectedKey POUND_SIGN = key("\u00A3"); + public static final ExpectedKey YEN_SIGN = key("\u00A5"); + public static final ExpectedKey EURO_SIGN = key("\u20AC"); + public static final ExpectedKey PESO_SIGN = key("\u20B1"); + public static final ExpectedKey CURRENCY_DOLLAR = key("$", + CENT_SIGN, POUND_SIGN, EURO_SIGN, YEN_SIGN, PESO_SIGN); + public static final ExpectedKey CURRENCY_EURO = key("\u20AC", + CENT_SIGN, POUND_SIGN, DOLLAR_SIGN, YEN_SIGN, PESO_SIGN); + public static final ExpectedKey[] CURRENCY_GENERIC_MORE_KEYS = joinMoreKeys( + Symbols.DOLLAR_SIGN, Symbols.CENT_SIGN, Symbols.EURO_SIGN, Symbols.POUND_SIGN, + Symbols.YEN_SIGN, Symbols.PESO_SIGN); + + // Variations of the "double quote" key's "more keys" on the 3rd row. + 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 + 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 }; + public static ExpectedKey[] DOUBLE_QUOTES_LR9 = { DQUOTE_LEFT, DQUOTE_RIGHT, DQUOTE_LOW9 }; + // U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK + // U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK + private static final ExpectedKey DAQUOTE_LEFT = key("\u00AB"); + private static final ExpectedKey DAQUOTE_RIGHT = key("\u00BB"); + public static ExpectedKey[] DOUBLE_ANGLE_QUOTES_LR = { DAQUOTE_LEFT, DAQUOTE_RIGHT }; + public static ExpectedKey[] DOUBLE_ANGLE_QUOTES_RL = { DAQUOTE_RIGHT, DAQUOTE_LEFT }; + + // Variations of the "single quote" key's "more keys" on the 3rd row. + 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 + 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 }; + public static ExpectedKey[] SINGLE_QUOTES_LR9 = { SQUOTE_LEFT, SQUOTE_RIGHT, SQUOTE_LOW9 }; + // U+2039: "‹" SINGLE LEFT-POINTING ANGLE QUOTATION MARK + // U+203A: "›" SINGLE RIGHT-POINTING ANGLE QUOTATION MARK + private static final ExpectedKey SAQUOTE_LEFT = key("\u2039"); + private static final ExpectedKey SAQUOTE_RIGHT = key("\u203A"); + public static ExpectedKey[] SINGLE_ANGLE_QUOTES_LR = { SAQUOTE_LEFT, SAQUOTE_RIGHT }; + public static ExpectedKey[] SINGLE_ANGLE_QUOTES_RL = { SAQUOTE_RIGHT, SAQUOTE_LEFT }; + + // Common symbols keyboard layout. + 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")), + "6", + // U+215E: "⅞" VULGAR FRACTION SEVEN EIGHTHS + key("7", moreKey("\u215E")), + "8", "9", + // U+207F: "ⁿ" SUPERSCRIPT LATIN SMALL LETTER N + // U+2205: "∅" EMPTY SET + key("0", joinMoreKeys("\u207F", "\u2205"))) + .setKeysOfRow(2, + key("@"), key("#"), key(CURRENCY), + // U+2030: "‰" PER MILLE SIGN + key("%", moreKey("\u2030")), + "&", + // 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(); + + 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 + }; + + @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/org/kelar/inputmethod/keyboard/layout/SymbolsShifted.java b/tests/src/org/kelar/inputmethod/keyboard/layout/SymbolsShifted.java new file mode 100644 index 000000000..f106ffb7f --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/SymbolsShifted.java @@ -0,0 +1,161 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import org.kelar.inputmethod.keyboard.layout.expected.AbstractLayoutBase; + +/** + * The symbols shifted keyboard layout. + */ +public class SymbolsShifted extends AbstractLayoutBase { + private final LayoutCustomizer mCustomizer; + + public SymbolsShifted(final LayoutCustomizer customizer) { + mCustomizer = customizer; + } + + public ExpectedKey[][] getLayout(final boolean isPhone) { + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(SYMBOLS_SHIFTED_COMMON); + final LayoutCustomizer customizer = mCustomizer; + builder.replaceKeyOfLabel(OTHER_CURRENCIES, (Object[])customizer.getOtherCurrencyKeys()); + if (isPhone) { + builder.addKeysOnTheLeftOfRow(3, customizer.getBackToSymbolsKey()) + .addKeysOnTheRightOfRow(3, DELETE_KEY) + .addKeysOnTheLeftOfRow(4, customizer.getAlphabetKey()) + .addKeysOnTheRightOfRow(4, customizer.getEnterKey(isPhone)); + } 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, (Object[])joinKeys("\u00A1", "\u00BF")); + builder.addKeysOnTheRightOfRow(1, DELETE_KEY) + .addKeysOnTheRightOfRow(2, customizer.getEnterKey(isPhone)) + .addKeysOnTheLeftOfRow(3, customizer.getBackToSymbolsKey()) + .addKeysOnTheRightOfRow(3, customizer.getBackToSymbolsKey()) + .addKeysOnTheLeftOfRow(4, customizer.getAlphabetKey()) + .addKeysOnTheRightOfRow(4, customizer.getEmojiKey(isPhone)); + } + return builder.build(); + } + + // Variations of the "other currencies" keys on the 2rd row. + 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 + }; + public static final ExpectedKey[] CURRENCIES_OTHER_THAN_EURO = { + 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. + private static final ExpectedKey[][] SYMBOLS_SHIFTED_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0060: "`" GRAVE ACCENT + "~", "\u0060", "|", + // 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 + "\u221A", + // U+03C0: "π" GREEK SMALL LETTER PI + // U+03A0: "Π" GREEK CAPITAL LETTER PI + key("\u03C0", moreKey("\u03A0")), + // U+00F7: "÷" DIVISION SIGN + // U+00D7: "×" MULTIPLICATION SIGN + "\u00F7", "\u00D7", + // U+00B6: "¶" PILCROW SIGN + // U+00A7: "§" SECTION SIGN + key("\u00B6", moreKey("\u00A7")), + // U+2206: "∆" INCREMENT + "\u2206") + .setKeysOfRow(2, + 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")), + "{", "}") + .setKeysOfRow(3, + // 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")), + SPACE_KEY, + // 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")), + // U+2026: "…" HORIZONTAL ELLIPSIS + key(".", moreKey("\u2026"))) + .build(); + + public static class RtlSymbolsShifted extends SymbolsShifted { + public RtlSymbolsShifted(final LayoutCustomizer customizer) { + super(customizer); + } + + @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/org/kelar/inputmethod/keyboard/layout/Tamil.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Tamil.java new file mode 100644 index 000000000..db6bbde1a --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Tamil.java @@ -0,0 +1,127 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +/** + * The Tamil keyboard. + */ +public final class Tamil extends LayoutBase { + private static final String LAYOUT_NAME = "tamil"; + + public Tamil(final LayoutCustomizer customizer) { + super(customizer, Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) { + return null; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0B94: "ஔ" TAMIL LETTER AU + // U+0BCC: "ௌ" TAMIL VOWEL SIGN AU + key("\u0B94", joinMoreKeys("\u0BCC", "1")), + // U+0B90: "ஐ" TAMIL LETTER AI + // U+0BC8: "ை" TAMIL VOWEL SIGN AI + key("\u0B90", joinMoreKeys("\u0BC8", "2")), + // U+0B86: "ஆ" TAMIL LETTER AA + // U+0BBE: "ா" TAMIL VOWEL SIGN AA + key("\u0B86", joinMoreKeys("\u0BBE", "3")), + // U+0B88: "ஈ" TAMIL LETTER II + // U+0BC0: "ீ" TAMIL VOWEL SIGN II + key("\u0B88", joinMoreKeys("\u0BC0", "4")), + // U+0B8A: "ஊ" TAMIL LETTER UU + // U+0BC2: "ூ" TAMIL VOWEL SIGN UU + key("\u0B8A", joinMoreKeys("\u0BC2","5")), + // U+0BAE: "ம" TAMIL LETTER MA + key("\u0BAE", moreKey("6")), + // U+0BA9: "ன" TAMIL LETTER NNNA + key("\u0BA9", moreKey("7")), + // U+0BA8: "ந" TAMIL LETTER NA + key("\u0BA8", moreKey("8")), + // U+0B99: "ங" TAMIL LETTER NGA + key("\u0B99", moreKey("9")), + // U+0BA3: "ண" TAMIL LETTER NNA + key("\u0BA3", moreKey("0")), + // U+0B9E: "ஞ" TAMIL LETTER NYA + "\u0B9E") + .setKeysOfRow(2, + // U+0B93: "ஓ" TAMIL LETTER OO + // U+0BCB: "ோ" TAMIL VOWEL SIGN OO + // U+0BD0: "ௐ" TAMIL OM + key("\u0B93", joinMoreKeys("\u0BCB", "\u0BD0")), + // U+0B8F: "ஏ" TAMIL LETTER EE + // U+0BC7: "ே" TAMIL VOWEL SIGN EE + key("\u0B8F", moreKey("\u0BC7")), + // U+0B85: "அ" TAMIL LETTER A + // U+0B83: "ஃ" TAMIL SIGN VISARGA + key("\u0B85", moreKey("\u0B83")), + // U+0B87: "இ" TAMIL LETTER I + // U+0BBF: "ி" TAMIL VOWEL SIGN I + key("\u0B87", moreKey("\u0BBF")), + // U+0B89: "உ" TAMIL LETTER U + // U+0BC1: "ு" TAMIL VOWEL SIGN U + key("\u0B89", moreKey("\u0BC1")), + // U+0BB1: "ற" TAMIL LETTER RRA + // U+0BAA: "ப" TAMIL LETTER PA + "\u0BB1", "\u0BAA", + // U+0B95: "க" TAMIL LETTER KA + // U+0BB9: "ஹ" TAMIL LETTER HA + // U+0B95/U+0BCD/U+0BB7: + // "க்ஷ" TAMIL LETTER KA/TAMIL SIGN VIRAMA/TAMIL LETTER SSA + key("\u0B95", joinMoreKeys("\u0BB9", "\u0B95\u0BCD\u0BB7")), + // U+0BA4: "த" TAMIL LETTER TA + "\u0BA4", + // U+0B9A: "ச" TAMIL LETTER CA + // U+0BB8: "ஸ" TAMIL LETTER SA + // U+0BB6/U+0BCD/U+0BB0/U+0BC0: + // "ஶ்ரீ" TAMIL LETTER SHA/TAMIL SIGN VIRAMA/TAMIL LETTER RA + // /TAMIL VOWEL SIGN II + key("\u0B9A", joinMoreKeys("\u0BB8", "\u0BB6\u0BCD\u0BB0\u0BC0")), + // U+0B9F: "ட" TAMIL LETTER TTA + "\u0B9F") + .setKeysOfRow(3, + // U+0B92: "ஒ" TAMIL LETTER O + // U+0BCA: "ொ" TAMIL VOWEL SIGN O + key("\u0B92", moreKey("\u0BCA")), + // U+0B8E: "எ" TAMIL LETTER E + // U+0BC6: "ெ" TAMIL VOWEL SIGN E + key("\u0B8E", moreKey("\u0BC6")), + // U+0BCD: "்" TAMIL SIGN VIRAMA + // U+0BB0: "ர" TAMIL LETTER RA + // U+0BB5: "வ" TAMIL LETTER VA + // U+0BB4: "ழ TAMIL LETTER LLLA + // U+0BB2: "ல" TAMIL LETTER LA + // U+0BB3: "ள" TAMIL LETTER LLA + // U+0BAF: "ய" TAMIL LETTER YA + "\u0BCD", "\u0BB0", "\u0BB5", "\u0BB4", "\u0BB2", "\u0BB3", "\u0BAF", + // U+0BB7: "ஷ" TAMIL LETTER SSA + // U+0B9C: "ஜ" TAMIL LETTER JA + key("\u0BB7", moreKey("\u0B9C"))) + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Telugu.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Telugu.java new file mode 100644 index 000000000..370f21eb3 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Telugu.java @@ -0,0 +1,193 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Locale; + +/** + * The Telugu keyboard. + */ +public final class Telugu extends LayoutBase { + private static final String LAYOUT_NAME = "telugu"; + + public Telugu(final Locale locale) { + super(new TeluguCustomizer(locale), Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class TeluguCustomizer extends LayoutCustomizer { + TeluguCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getAlphabetKey() { return TELUGU_ALPHABET_KEY; } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + @Override + public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) { + return EMPTY_KEYS; + } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS; + } + + @Override + public ExpectedKey[] getSpaceKeys(final boolean isPhone) { + return joinKeys(LANGUAGE_SWITCH_KEY, SPACE_KEY, key(ZWNJ_KEY, ZWJ_KEY)); + } + + // U+0C05: "అ" TELUGU LETTER A + // U+0C06: "ఆ" TELUGU LETTER AA + // U+0C07: "ఇ" TELUGU LETTER I + private static final ExpectedKey TELUGU_ALPHABET_KEY = key( + "\u0C05\u0C06\u0C07", Constants.CODE_SWITCH_ALPHA_SYMBOL); + + // U+20B9: "₹" INDIAN RUPEE SIGN + private static final ExpectedKey CURRENCY_RUPEE = key("\u20B9", + Symbols.CURRENCY_GENERIC_MORE_KEYS); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(boolean isPhone) { return ALPHABET_COMMON; } + + @Override + ExpectedKey[][] getCommonAlphabetShiftLayout(boolean isPhone, final int elementId) { + return null; + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0C4C: "ౌ" TELUGU VOWEL SIGN AU + // U+0C14: "ఔ" TELUGU LETTER AU + key("\u0C4C", joinMoreKeys("\u0C14", "1")), + // U+0C48: "ై" TELUGU VOWEL SIGN AI + // U+0C10: "ఐ" TELUGU LETTER AI + key("\u0C48", joinMoreKeys("\u0C10", "2")), + // U+0C3E: "ా" TELUGU VOWEL SIGN AA + // U+0C06: "ఆ" TELUGU LETTER AA + key("\u0C3E", joinMoreKeys("\u0C06", "3")), + // U+0C40: "ీ" TELUGU VOWEL SIGN II + // U+0C08: "ఈ" TELUGU LETTER II + key("\u0C40", joinMoreKeys("\u0C08", "4")), + // U+0C42: "ూ" TELUGU VOWEL SIGN UU + // U+0C0A: "ఊ" TELUGU LETTER UU + key("\u0C42", joinMoreKeys("\u0C0A", "5")), + // U+0C2C: "బ" TELUGU LETTER BA + // U+0C2D: "భ" TELUGU LETTER BHA + key("\u0C2C", joinMoreKeys("\u0C2D", "6")), + // U+0C39: "హ" TELUGU LETTER HA + // U+0C03: "ః" TELUGU SIGN VISARGA + key("\u0C39", joinMoreKeys("\u0C03", "7")), + // U+0C17: "గ" TELUGU LETTER GA + // U+0C18: "ఘ" TELUGU LETTER GHA + key("\u0C17", joinMoreKeys("\u0C18", "8")), + // U+0C26: "ద" TELUGU LETTER DA + // U+0C27: "ధ" TELUGU LETTER DHA + key("\u0C26", joinMoreKeys("\u0C27", "9")), + // U+0C1C: "జ" TELUGU LETTER JA + // U+0C1D: "ఝ" TELUGU LETTER JHA + key("\u0C1C", joinMoreKeys("\u0C1D", "0")), + // U+0C21: "డ" TELUGU LETTER DDA + // U+0C22: "ఢ" TELUGU LETTER DDHA + key("\u0C21", moreKey("\u0C22"))) + .setKeysOfRow(2, + // U+0C4B: "ో" TELUGU VOWEL SIGN OO + // U+0C13: "ఓ" TELUGU LETTER OO + key("\u0C4B", moreKey("\u0C13")), + // U+0C47: "ే" TELUGU VOWEL SIGN EE + // U+0C0F: "ఏ" TELUGU LETTER EE + key("\u0C47", moreKey("\u0C0F")), + // U+0C4D: "్" TELUGU SIGN VIRAMA + // U+0C05: "అ" TELUGU LETTER A + key("\u0C4D", moreKey("\u0C05")), + // U+0C3F: "ి" TELUGU VOWEL SIGN I + // U+0C07: "ఇ" TELUGU LETTER I + key("\u0C3F", moreKey("\u0C07")), + // U+0C41: "ు" TELUGU VOWEL SIGN U + // U+0C09: "ఉ" TELUGU LETTER U + key("\u0C41", moreKey("\u0C09")), + // U+0C2A: "ప" TELUGU LETTER PA + // U+0C2B: "ఫ" TELUGU LETTER PHA + key("\u0C2A", moreKey("\u0C2B")), + // U+0C30: "ర" TELUGU LETTER RA + // U+0C31: "ఱ" TELUGU LETTER RRA + // U+0C4D/U+0C30: "్ర" TELUGU SIGN VIRAMA/TELUGU LETTER RA + key("\u0C30", joinMoreKeys("\u0C31", "\u0C4D\u0C30")), + // U+0C15: "క" TELUGU LETTER KA + // U+0C16: "ఖ" TELUGU LETTER KHA + key("\u0C15", moreKey("\u0C16")), + // U+0C24: "త" TELUGU LETTER TA + // U+0C25: "థ" TELUGU LETTER THA + key("\u0C24", moreKey("\u0C25")), + // U+0C1A: "చ" TELUGU LETTER CA + // U+0C1B: "ఛ" TELUGU LETTER CHA + key("\u0C1A", moreKey("\u0C1B")), + // U+0C1F: "ట" TELUGU LETTER TTA + // U+0C20: "ఠ" TELUGU LETTER TTHA + key("\u0C1F", moreKey("\u0C20"))) + .setKeysOfRow(3, + // U+0C4A: "ొ" TELUGU VOWEL SIGN O + // U+0C12: "ఒ" TELUGU LETTER O + key("\u0C4A", moreKey("\u0C12")), + // U+0C46: "ె" TELUGU VOWEL SIGN E + // U+0C0E: "ఎ" TELUGU LETTER E + key("\u0C46", moreKey("\u0C0E")), + // U+0C2E: "మ" TELUGU LETTER MA + // U+0C02: "ం" TELUGU SIGN ANUSVARA + // U+0C01: "ఁ" TELUGU SIGN CANDRABINDU + key("\u0C2E", joinMoreKeys("\u0C02", "\u0C01")), + // U+0C28: "న" TELUGU LETTER NA + // U+0C23: "ణ" TELUGU LETTER NNA + // U+0C19: "ఙ" TELUGU LETTER NGA + // U+0C1E: "ఞ" TELUGU LETTER NYA + key("\u0C28", joinMoreKeys("\u0C23", "\u0C19", "\u0C1E")), + // U+0C35: "వ" TELUGU LETTER VA + "\u0C35", + // U+0C32: "ల" TELUGU LETTER LA + // U+0C33: "ళ" TELUGU LETTER LLA + key("\u0C32", moreKey("\u0C33")), + // U+0C38: "స" TELUGU LETTER SA + // U+0C36: "శ" TELUGU LETTER SHA + key("\u0C38", moreKey("\u0C36")), + // U+0C0B: "ఋ" TELUGU LETTER VOCALIC R + // U+0C43: "ృ" TELUGU VOWEL SIGN VOCALIC R + key("\u0C0B", moreKey("\u0C43")), + // U+0C37: "ష" TELUGU LETTER SSA + // U+0C15/U+0C4D/U+0C37: + // "క్ష" TELUGU LETTER KA/TELUGU SIGN VIRAMA/TELUGU LETTER SSA + key("\u0C37", moreKey("\u0C15\u0C4D\u0C37")), + // U+0C2F: "య" TELUGU LETTER YA + // U+0C1C/U+0C4D/U+0C1E: + // "జ్ఞ" TELUGU LETTER JA/TELUGU SIGN VIRAMA/TELUGU LETTER NYA + key("\u0C2F", moreKey("\u0C1C\u0C4D\u0C1E"))) + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Thai.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Thai.java new file mode 100644 index 000000000..f19d44f8f --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Thai.java @@ -0,0 +1,247 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import org.kelar.inputmethod.latin.common.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 Locale locale) { + super(new ThaiCustomizer(locale), Symbols.class, SymbolsShifted.class); + } + + @Override + public String getName() { return LAYOUT_NAME; } + + private static class ThaiCustomizer extends LayoutCustomizer { + ThaiCustomizer(final Locale locale) { super(locale); } + + @Override + public int getNumberOfRows() { return 5; } + + @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.CURRENCY_GENERIC_MORE_KEYS); + } + + @Override + ExpectedKey[][] getCommonAlphabetLayout(final boolean isPhone) { + final ExpectedKeyboardBuilder builder = new ExpectedKeyboardBuilder(ALPHABET_COMMON); + if (isPhone) { + // U+0E03: "ฃ" THAI CHARACTER KHO KHUAT + builder.addKeysOnTheRightOfRow(3, "\u0E03"); + } else { + // U+0E03: "ฃ" THAI CHARACTER KHO KHUAT + builder.addKeysOnTheRightOfRow(2, "\u0E03") + .addKeysOnTheRightOfRow(4, (Object[])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, "\u0E05"); + } else { + // U+0E05: "ฅ" THAI CHARACTER KHO KHON + builder.addKeysOnTheRightOfRow(2, "\u0E05"); + } + return builder.build(); + } + + private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0E45: "ๅ" THAI CHARACTER LAKKHANGYAO + "\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 + // U+0E33: "ำ" THAI CHARACTER SARA AM + // U+0E1E: "พ" THAI CHARACTER PHO PHAN + // U+0E30: "ะ" THAI CHARACTER SARA A + "\u0E44", "\u0E33", "\u0E1E", "\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 + // U+0E19: "น" THAI CHARACTER NO NU + // U+0E22: "ย" THAI CHARACTER YO YAK + // U+0E1A: "บ" THAI CHARACTER BO BAIMAI + // U+0E25: "ล" THAI CHARACTER LO LING + "\u0E23", "\u0E19", "\u0E22", "\u0E1A", "\u0E25") + .setKeysOfRow(3, + // U+0E1F: "ฟ" THAI CHARACTER FO FAN + // U+0E2B: "ห" THAI CHARACTER HO HIP + // U+0E01: "ก" THAI CHARACTER KO KAI + // U+0E14: "ด" THAI CHARACTER DO DEK + // U+0E40: "เ" THAI CHARACTER SARA E + "\u0E1F", "\u0E2B", "\u0E01", "\u0E14", "\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 + // U+0E2A: "ส" THAI CHARACTER SO SUA + // U+0E27: "ว" THAI CHARACTER WO WAEN + // U+0E07: "ง" THAI CHARACTER NGO NGU + "\u0E32", "\u0E2A", "\u0E27", "\u0E07") + .setKeysOfRow(4, + // U+0E1C: "ผ" THAI CHARACTER PHO PHUNG + // U+0E1B: "ป" THAI CHARACTER PO PLA + // U+0E41: "แ" THAI CHARACTER SARA AE + // U+0E2D: "อ" THAI CHARACTER O ANG + "\u0E1C", "\u0E1B", "\u0E41", "\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 + // U+0E21: "ม" THAI CHARACTER MO MA + // U+0E43: "ใ" THAI CHARACTER SARA AI MAIMUAN + // U+0E1D: "ฝ" THAI CHARACTER FO FA + "\u0E17", "\u0E21", "\u0E43", "\u0E1D") + .build(); + + private static final ExpectedKey[][] ALPHABET_SHIFTED_COMMON = new ExpectedKeyboardBuilder() + .setKeysOfRow(1, + // U+0E51: "๑" THAI DIGIT ONE + // U+0E52: "๒" THAI DIGIT TWO + // U+0E53: "๓" THAI DIGIT THREE + // U+0E54: "๔" THAI DIGIT FOUR + // U+0E39: " ู" THAI CHARACTER SARA UU + "+", "\u0E51", "\u0E52", "\u0E53", "\u0E54", + key(" \u0E39", "\u0E39"), + // U+0E3F: "฿" THAI CURRENCY SYMBOL BAHT + // U+0E55: "๕" THAI DIGIT FIVE + // U+0E56: "๖" THAI DIGIT SIX + // U+0E57: "๗" THAI DIGIT SEVEN + // U+0E58: "๘" THAI DIGIT EIGHT + // U+0E59: "๙" THAI DIGIT NINE + "\u0E3F", "\u0E55", "\u0E56", "\u0E57", "\u0E58", "\u0E59") + .setKeysOfRow(2, + // U+0E50: "๐" THAI DIGIT ZERO + // U+0E0E: "ฎ" THAI CHARACTER DO CHADA + // U+0E11: "ฑ" THAI CHARACTER THO NANGMONTHO + // U+0E18: "ธ" THAI CHARACTER THO THONG + "\u0E50", "\"", "\u0E0E", "\u0E11", "\u0E18", + // U+0E4D: " ํ" THAI CHARACTER THANTHAKHAT + key(" \u0E4D", "\u0E4D"), + // U+0E4A: " ๊" THAI CHARACTER MAI TRI + key(" \u0E4A", "\u0E4A"), + // U+0E13: "ณ" THAI CHARACTER NO NEN + // U+0E2F: "ฯ" THAI CHARACTER PAIYANNOI + // U+0E0D: "ญ" THAI CHARACTER YO YING + // U+0E10: "ฐ" THAI CHARACTER THO THAN + "\u0E13", "\u0E2F", "\u0E0D", "\u0E10", ",") + .setKeysOfRow(3, + // U+0E24: "ฤ" THAI CHARACTER RU + // U+0E06: "ฆ" THAI CHARACTER KHO RAKHANG + // U+0E0F: "ฏ" THAI CHARACTER TO PATAK + // U+0E42: "โ" THAI CHARACTER SARA O + // U+0E0C: "ฌ" THAI CHARACTER CHO CHOE + "\u0E24", "\u0E06", "\u0E0F", "\u0E42", "\u0E0C", + // U+0E47: " ็" THAI CHARACTER MAITAIKHU + key(" \u0E47", "\u0E47"), + // U+0E4B: " ๋" THAI CHARACTER MAI CHATTAWA + key(" \u0E4B", "\u0E4B"), + // U+0E29: "ษ" THAI CHARACTER SO RUSI + // U+0E28: "ศ" THAI CHARACTER SO SALA + // U+0E0B: "ซ" THAI CHARACTER SO SO + "\u0E29", "\u0E28", "\u0E0B", ".") + .setKeysOfRow(4, + // U+0E09: "ฉ" THAI CHARACTER CHO CHING + // U+0E2E: "ฮ" THAI CHARACTER HO NOKHUK + "(", ")", "\u0E09", "\u0E2E", + // U+0E3A: " ฺ" THAI CHARACTER PHINTHU + key(" \u0E3A", "\u0E3A"), + // U+0E4C: " ์" THAI CHARACTER THANTHAKHAT + key(" \u0E4C", "\u0E4C"), + // U+0E12: "ฒ" THAI CHARACTER THO PHUTHAO + // U+0E2C: "ฬ" THAI CHARACTER LO CHULA + // U+0E26: "ฦ" THAI CHARACTER LU + "?", "\u0E12", "\u0E2C", "\u0E26") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/Uzbek.java b/tests/src/org/kelar/inputmethod/keyboard/layout/Uzbek.java new file mode 100644 index 000000000..dcee48857 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/Uzbek.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 org.kelar.inputmethod.keyboard.layout; + +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +/** + * The Uzbek alphabet keyboard. + */ +public final class Uzbek extends LayoutBase { + private static final String LAYOUT_NAME = "uzbek"; + + public Uzbek(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", additionalMoreKey("1")), + key("w", additionalMoreKey("2")), + key("e", additionalMoreKey("3")), + key("r", additionalMoreKey("4")), + key("t", additionalMoreKey("5")), + key("y", additionalMoreKey("6")), + key("u", additionalMoreKey("7")), + key("i", additionalMoreKey("8")), + key("o", additionalMoreKey("9")), + key("p", additionalMoreKey("0")), + ROW1_11) + .setKeysOfRow(2, "a", "s", "d", "f", "g", "h", "j", "k", "l", ROW2_10, ROW2_11) + .setKeysOfRow(3, "z", "x", "c", "v", "b", "n", "m") + .build(); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/BengaliCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/BengaliCustomizer.java new file mode 100644 index 000000000..b9faf5ea6 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/BengaliCustomizer.java @@ -0,0 +1,46 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.SymbolsShifted; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Locale; + +public class BengaliCustomizer extends LayoutCustomizer { + public BengaliCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getAlphabetKey() { return BENGALI_ALPHABET_KEY; } + + @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+0995: "क" BENGALI LETTER KA + // U+0996: "ख" BENGALI LETTER KHA + // U+0997: "ग" BENGALI LETTER GA + private static final ExpectedKey BENGALI_ALPHABET_KEY = key( + "\u0995\u0996\u0997", Constants.CODE_SWITCH_ALPHA_SYMBOL); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/DanishCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/DanishCustomizer.java new file mode 100644 index 000000000..c7ec65fb3 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/DanishCustomizer.java @@ -0,0 +1,112 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.Nordic; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public class DanishCustomizer extends EuroCustomizer { + 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; } + + protected void setNordicKeys(final ExpectedKeyboardBuilder builder) { + builder + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + .replaceKeyOfLabel(Nordic.ROW1_11, "\u00E5") + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + .replaceKeyOfLabel(Nordic.ROW2_10, "\u00E6") + .setMoreKeysOf("\u00E6", "\u00E4") + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + .replaceKeyOfLabel(Nordic.ROW2_11, "\u00F8") + .setMoreKeysOf("\u00F8", "\u00F6"); + } + + protected void setMoreKeysOfA(final ExpectedKeyboardBuilder builder) { + builder + // 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"); + } + + protected void setMoreKeysOfO(final ExpectedKeyboardBuilder builder) { + builder + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // 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", "\u00F6", "\u00F3", "\u00F4", "\u00F2", "\u00F5", "\u0153", + "\u014D"); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + setNordicKeys(builder); + setMoreKeysOfA(builder); + setMoreKeysOfO(builder); + return builder + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + // U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS + .setMoreKeysOf("e", "\u00E9", "\u00EB") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "\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", "\u00FA", "\u00FC", "\u00FB", "\u00F9", "\u016B") + // U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE + // U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS + .setMoreKeysOf("i", "\u00ED", "\u00EF") + // 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/org/kelar/inputmethod/keyboard/layout/customizer/DevanagariCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/DevanagariCustomizer.java new file mode 100644 index 000000000..4308fac31 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/DevanagariCustomizer.java @@ -0,0 +1,49 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Locale; + +public class DevanagariCustomizer extends LayoutCustomizer { + public DevanagariCustomizer(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; } + + // 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); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/DutchCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/DutchCustomizer.java new file mode 100644 index 000000000..fc7729562 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/DutchCustomizer.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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public class DutchCustomizer extends EuroCustomizer { + 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+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+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", + "\u00E9", "\u00EB", "\u00EA", "\u00E8", "\u0119", "\u0117", "\u0113") + // U+0133: "ij" LATIN SMALL LIGATURE IJ + .setMoreKeysOf("y", "\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", "\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", + "\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", + "\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/org/kelar/inputmethod/keyboard/layout/customizer/DvorakCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/DvorakCustomizer.java new file mode 100644 index 000000000..815e19680 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/DvorakCustomizer.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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey.ExpectedAdditionalMoreKey; + +import java.util.Locale; + +public class DvorakCustomizer extends LayoutCustomizer { + public DvorakCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) { + return isPhone ? joinKeys(SHIFT_KEY): joinKeys(SHIFT_KEY, key("q")); + } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return isPhone ? EMPTY_KEYS : joinKeys(key("z"), SHIFT_KEY); + } + + @Override + public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) { + // U+00A1: "¡" INVERTED EXCLAMATION MARK + return isPhone ? joinKeys(key("q", SETTINGS_KEY)) + : joinKeys(key("!", joinMoreKeys("\u00A1", SETTINGS_KEY))); + } + + @Override + public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) { + final ExpectedAdditionalMoreKey[] punctuationMoreKeys = + convertToAdditionalMoreKeys(getPunctuationMoreKeys(isPhone)); + // U+00BF: "¿" INVERTED QUESTION MARK + return isPhone + ? joinKeys(key("z", punctuationMoreKeys)) + : joinKeys(key("?", joinMoreKeys(punctuationMoreKeys, "\u00BF"))); + } + + private static ExpectedAdditionalMoreKey[] convertToAdditionalMoreKeys( + final ExpectedKey ... moreKeys) { + final ExpectedAdditionalMoreKey[] additionalMoreKeys = + new ExpectedAdditionalMoreKey[moreKeys.length]; + for (int index = 0; index < moreKeys.length; index++) { + additionalMoreKeys[index] = ExpectedAdditionalMoreKey.newInstance(moreKeys[index]); + } + return additionalMoreKeys; + } + + public static class EnglishDvorakCustomizer extends DvorakCustomizer { + private final EnglishCustomizer mEnglishCustomizer; + + public EnglishDvorakCustomizer(final Locale locale) { + super(locale); + mEnglishCustomizer = new EnglishCustomizer(locale); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return mEnglishCustomizer.setAccentedLetters(builder); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/EastSlavicCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/EastSlavicCustomizer.java new file mode 100644 index 000000000..1cf087a09 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/EastSlavicCustomizer.java @@ -0,0 +1,40 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Locale; + +public 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); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/EnglishCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/EnglishCustomizer.java new file mode 100644 index 000000000..75454f2b7 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/EnglishCustomizer.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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public class EnglishCustomizer extends LayoutCustomizer { + public EnglishCustomizer(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+0113: "ē" LATIN SMALL LETTER E WITH MACRON + .setMoreKeysOf("e", "\u00E9", "\u00E8", "\u00EA", "\u00EB", "\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", "\u00FA", "\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+012B: "ī" LATIN SMALL LETTER I WITH MACRON + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + .setMoreKeysOf("i", "\u00ED", "\u00EE", "\u00EF", "\u012B", "\u00EC") + // 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+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", + "\u00F3", "\u00F4", "\u00F6", "\u00F2", "\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/org/kelar/inputmethod/keyboard/layout/customizer/EstonianEECustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/EstonianEECustomizer.java new file mode 100644 index 000000000..91c10405a --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/EstonianEECustomizer.java @@ -0,0 +1,167 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.layout.Nordic; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public class EstonianEECustomizer extends EuroCustomizer { + 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; } + + protected void setNordicKeys(final ExpectedKeyboardBuilder builder) { + builder + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + .replaceKeyOfLabel(Nordic.ROW1_11, "\u00FC") + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE + .replaceKeyOfLabel(Nordic.ROW2_10, "\u00F6") + .setMoreKeysOf("\u00F6", "\u00F5") + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + .replaceKeyOfLabel(Nordic.ROW2_11, "\u00E4"); + } + + protected void setMoreKeysOfA(final ExpectedKeyboardBuilder builder) { + builder + // 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", "\u0101", "\u00E0", "\u00E1", "\u00E2", "\u00E3", "\u00E5", + "\u00E6", "\u0105"); + } + + protected void setMoreKeysOfI(final ExpectedKeyboardBuilder builder, final int elementId) { + // 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 + if (elementId == KeyboardId.ELEMENT_ALPHABET) { + builder.setMoreKeysOf("i", + "\u012B", "\u00EC", "\u012F", "\u00ED", "\u00EE", "\u00EF", "\u0131"); + } else { + // The upper-case letter of "ı" in Estonian locale is "I". It should be omitted + // from the more keys of "I". + builder.setMoreKeysOf("i", + "\u012B", "\u00EC", "\u012F", "\u00ED", "\u00EE", "\u00EF"); + } + } + + protected void setMoreKeysOfO(final ExpectedKeyboardBuilder builder) { + builder + // 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", "\u00F5", "\u00F2", "\u00F3", "\u00F4", "\u0153", "\u0151", + "\u00F8"); + } + + protected void setMoreKeysOfU(final ExpectedKeyboardBuilder builder) { + builder + // 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", "\u016B", "\u0173", "\u00F9", "\u00FA", "\u00FB", "\u016F", + "\u0171"); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder, + final int elementId) { + setNordicKeys(builder); + setMoreKeysOfA(builder); + setMoreKeysOfI(builder, elementId); + setMoreKeysOfO(builder); + setMoreKeysOfU(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", + "\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", "\u0157", "\u0159", "\u0155") + // U+0163: "ţ" LATIN SMALL LETTER T WITH CEDILLA + // U+0165: "ť" LATIN SMALL LETTER T WITH CARON + .setMoreKeysOf("t", "\u0163", "\u0165") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "\u00FD", "\u00FF") + // 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/org/kelar/inputmethod/keyboard/layout/customizer/EuroCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/EuroCustomizer.java new file mode 100644 index 000000000..162843a7e --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/EuroCustomizer.java @@ -0,0 +1,40 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.SymbolsShifted; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +import java.util.Locale; + +/** + * The layout customize class for countries that use Euro. + */ +public class EuroCustomizer extends LayoutCustomizer { + public EuroCustomizer(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; + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/FinnishCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/FinnishCustomizer.java new file mode 100644 index 000000000..e70251df7 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/FinnishCustomizer.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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.Nordic; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public class FinnishCustomizer extends EuroCustomizer { + public FinnishCustomizer(final Locale locale) { super(locale); } + + protected void setNordicKeys(final ExpectedKeyboardBuilder builder) { + builder + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + .replaceKeyOfLabel(Nordic.ROW1_11, "\u00E5") + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + .replaceKeyOfLabel(Nordic.ROW2_10, "\u00F6") + .setMoreKeysOf("\u00F6","\u00F8") + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E6: "æ" LATIN SMALL LETTER AE + .replaceKeyOfLabel(Nordic.ROW2_11, "\u00E4") + .setMoreKeysOf("\u00E4", "\u00E6"); + } + + protected void setMoreKeysOfA(final ExpectedKeyboardBuilder builder) { + builder + // 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"); + } + + protected void setMoreKeysOfO(final ExpectedKeyboardBuilder builder) { + builder + // 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", "\u00F8", "\u00F4", "\u00F2", "\u00F3", "\u00F5", "\u0153", + "\u014D"); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + setNordicKeys(builder); + setMoreKeysOfA(builder); + setMoreKeysOfO(builder); + return builder + // U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS + .setMoreKeysOf("u", "\u00FC") + // 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/org/kelar/inputmethod/keyboard/layout/customizer/FrenchCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/FrenchCustomizer.java new file mode 100644 index 000000000..b78ce4fb1 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/FrenchCustomizer.java @@ -0,0 +1,106 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public class FrenchCustomizer extends LayoutCustomizer { + 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 + .setAdditionalMoreKeysPositionOf("a", 3) + .setMoreKeysOf("a", + "\u00E0", "\u00E2", "\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 + .setAdditionalMoreKeysPositionOf("e", 5) + .setMoreKeysOf("e", + "\u00E9", "\u00E8", "\u00EA", "\u00EB", "\u0119", "\u0117", "\u0113") + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "\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 + .setAdditionalMoreKeysPositionOf("u", 3) + .setMoreKeysOf("u", "\u00F9", "\u00FB", "\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 + .setAdditionalMoreKeysPositionOf("i", 2) + .setMoreKeysOf("i", "\u00EE", "\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 + .setAdditionalMoreKeysPositionOf("o", 3) + .setMoreKeysOf("o", + "\u00F4", "\u0153", "\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") + .setAdditionalMoreKeysPositionOf("c", 2); + } + + public static final class FrenchEuroCustomizer extends FrenchCustomizer { + private final EuroCustomizer mEuroCustomizer; + + public FrenchEuroCustomizer(final Locale locale) { + super(locale); + mEuroCustomizer = new EuroCustomizer(locale); + } + + @Override + public final ExpectedKey getCurrencyKey() { return mEuroCustomizer.getCurrencyKey(); } + + @Override + public final ExpectedKey[] getOtherCurrencyKeys() { + return mEuroCustomizer.getOtherCurrencyKeys(); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/GermanCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/GermanCustomizer.java new file mode 100644 index 000000000..3cc165b39 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/GermanCustomizer.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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public class GermanCustomizer extends LayoutCustomizer { + 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", "\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", "\u00FC", "\u00FB", "\u00F9", "\u00FA", "\u016B") + .setAdditionalMoreKeysPositionOf("u", 2) + // 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", + "\u00F6", "\u00F4", "\u00F2", "\u00F3", "\u00F5", "\u0153", "\u00F8", + "\u014D") + .setAdditionalMoreKeysPositionOf("o", 2) + // 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") + .setAdditionalMoreKeysPositionOf("a", 2) + // 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"); + } + + public static class GermanEuroCustomizer extends GermanCustomizer { + private final EuroCustomizer mEuroCustomizer; + + public GermanEuroCustomizer(final Locale locale) { + super(locale); + mEuroCustomizer = new EuroCustomizer(locale); + } + + @Override + public ExpectedKey getCurrencyKey() { return mEuroCustomizer.getCurrencyKey(); } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return mEuroCustomizer.getOtherCurrencyKeys(); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/HindiCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/HindiCustomizer.java new file mode 100644 index 000000000..6023fe709 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/HindiCustomizer.java @@ -0,0 +1,65 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.SymbolsShifted; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +import java.util.Locale; + +public class HindiCustomizer extends DevanagariCustomizer { + public HindiCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS; + } + + @Override + public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) { + // U+0964: "।" DEVANAGARI DANDA + final ExpectedKey periodKey = key("\u0964", getPunctuationMoreKeys(isPhone)); + return joinKeys(periodKey); + } + + @Override + public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { + return isPhone ? HINDI_PHONE_PUNCTUATION_MORE_KEYS : HINDI_TABLET_PUNCTUATION_MORE_KEYS; + } + + // U+20B9: "₹" INDIAN RUPEE SIGN + private static final ExpectedKey CURRENCY_RUPEE = key("\u20B9", + Symbols.CURRENCY_GENERIC_MORE_KEYS); + + // Punctuation more keys for phone form factor. + private static final ExpectedKey[] HINDI_PHONE_PUNCTUATION_MORE_KEYS = joinKeys( + ",", ".", "?", "!", "#", ")", "(", "/", ";", + "'", "@", ":", "-", "\"", "+", "%", "&"); + // Punctuation more keys for tablet form factor. + private static final ExpectedKey[] HINDI_TABLET_PUNCTUATION_MORE_KEYS = joinKeys( + ",", ".", "'", "#", ")", "(", "/", ";", + "@", ":", "-", "\"", "+", "%", "&"); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/ItalianCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/ItalianCustomizer.java new file mode 100644 index 000000000..6b04af939 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/ItalianCustomizer.java @@ -0,0 +1,76 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public class ItalianCustomizer extends LayoutCustomizer { + 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", + "\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", "\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", "\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", + "\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/org/kelar/inputmethod/keyboard/layout/customizer/LayoutCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/LayoutCustomizer.java new file mode 100644 index 000000000..ffac507d1 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/LayoutCustomizer.java @@ -0,0 +1,214 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.SymbolsShifted; +import org.kelar.inputmethod.keyboard.layout.expected.AbstractLayoutBase; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * This class is used to customize common keyboard layout to language specific layout. + */ +public class LayoutCustomizer extends AbstractLayoutBase { + 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; } + + public int getNumberOfRows() { return 4; } + + /** + * Set accented letters to a specific keyboard element. + * @param builder the {@link ExpectedKeyboardBuilder} object that contains common keyboard + * layout. + * @param elementId the element id of keyboard + * @return the {@link ExpectedKeyboardBuilder} object that contains accented letters as + * "more keys". + */ + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder, + final int elementId) { + // This method can be overridden by an extended class to provide customized expected + // accented letters depending on the shift state of keyboard. + // This is a default behavior to call a shift-state-independent + // {@link #setAccentedLetters(ExpectedKeyboardBuilder)} implementation, so that + // <code>elementId</code> is ignored here. + return setAccentedLetters(builder); + } + + /** + * 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 enter key. + * @param isPhone true if requesting phone's key. + * @return the array of {@link ExpectedKey} that should be placed as an enter key. + */ + public ExpectedKey getEnterKey(final boolean isPhone) { + return isPhone ? key(ENTER_KEY, EMOJI_ACTION_KEY) : ENTER_KEY; + } + + /** + * Get the emoji key. + * @param isPhone true if requesting phone's key. + * @return the array of {@link ExpectedKey} that should be placed as an emoji key. + */ + public ExpectedKey getEmojiKey(final boolean isPhone) { + return EMOJI_NORMAL_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(LANGUAGE_SWITCH_KEY, 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) { + // U+002C: "," COMMA + return joinKeys(key("\u002C", SETTINGS_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 joinKeys(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; + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/NepaliCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/NepaliCustomizer.java new file mode 100644 index 000000000..aa557ba5b --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/NepaliCustomizer.java @@ -0,0 +1,67 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.SymbolsShifted; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +import java.util.Locale; + +public class NepaliCustomizer extends DevanagariCustomizer { + public NepaliCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_NEPALI; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + @Override + public ExpectedKey[] getSpaceKeys(final boolean isPhone) { + return joinKeys(LANGUAGE_SWITCH_KEY, SPACE_KEY, key(ZWNJ_KEY, ZWJ_KEY)); + } + + @Override + public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) { + // U+0964: "।" DEVANAGARI DANDA + final ExpectedKey periodKey = key("\u0964", getPunctuationMoreKeys(isPhone)); + return joinKeys(periodKey); + } + + @Override + public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { + return isPhone ? NEPALI_PHONE_PUNCTUATION_MORE_KEYS + : NEPALI_TABLET_PUNCTUATION_MORE_KEYS; + } + + // 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); + + // Punctuation more keys for phone form factor. + private static final ExpectedKey[] NEPALI_PHONE_PUNCTUATION_MORE_KEYS = joinKeys( + ".", ",", "?", "!", "#", ")", "(", "/", ";", + "'", "@", ":", "-", "\"", "+", "%", "&"); + // Punctuation more keys for tablet form factor. + private static final ExpectedKey[] NEPALI_TABLET_PUNCTUATION_MORE_KEYS = joinKeys( + ".", ",", "'", "#", ")", "(", "/", ";", + "@", ":", "-", "\"", "+", "%", "&"); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/NoLanguageCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/NoLanguageCustomizer.java new file mode 100644 index 000000000..2581b67bb --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/NoLanguageCustomizer.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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public 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", "\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", + "\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", "\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", "\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", "\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", + "\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", + "\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", + "\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/org/kelar/inputmethod/keyboard/layout/customizer/NorwegianCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/NorwegianCustomizer.java new file mode 100644 index 000000000..02dd48dc0 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/NorwegianCustomizer.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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.Nordic; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public 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; } + + protected void setNordicKeys(final ExpectedKeyboardBuilder builder) { + builder + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + .replaceKeyOfLabel(Nordic.ROW1_11, "\u00E5") + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + .replaceKeyOfLabel(Nordic.ROW2_10, "\u00F8") + .setMoreKeysOf("\u00F8", "\u00F6") + // U+00E6: "æ" LATIN SMALL LETTER AE + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + .replaceKeyOfLabel(Nordic.ROW2_11, "\u00E6") + .setMoreKeysOf("\u00E6", "\u00E4"); + } + + protected void setMoreKeysOfA(final ExpectedKeyboardBuilder builder) { + builder + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // 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", "\u00E4", "\u00E0", "\u00E1", "\u00E2", "\u00E3", "\u0101"); + } + + protected void setMoreKeysOfO(final ExpectedKeyboardBuilder builder) { + builder + // 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+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", "\u00F6", "\u00F4", "\u00F2", "\u00F3", "\u00F5", "\u0153", + "\u014D"); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + setNordicKeys(builder); + setMoreKeysOfA(builder); + setMoreKeysOfO(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", "\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", "\u00FC", "\u00FB", "\u00F9", "\u00FA", "\u016B"); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/PcQwertyCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/PcQwertyCustomizer.java new file mode 100644 index 000000000..03d72a485 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/PcQwertyCustomizer.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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +import java.util.Locale; + +public class PcQwertyCustomizer extends LayoutCustomizer { + public PcQwertyCustomizer(final Locale locale) { super(locale); } + + @Override + public int getNumberOfRows() { return 5; } + + @Override + public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) { + return joinKeys(SHIFT_KEY); + } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return joinKeys(SHIFT_KEY); + } + + @Override + public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) { + return joinKeys(SETTINGS_KEY); + } + + @Override + public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) { + return isPhone + ? joinKeys(key(ENTER_KEY, EMOJI_ACTION_KEY)) + : joinKeys(EMOJI_NORMAL_KEY); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/PortugueseCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/PortugueseCustomizer.java new file mode 100644 index 000000000..253b63e2f --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/PortugueseCustomizer.java @@ -0,0 +1,79 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public class PortugueseCustomizer extends LayoutCustomizer { + public PortugueseCustomizer(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", + "\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", "\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", "\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", + "\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/org/kelar/inputmethod/keyboard/layout/customizer/SerbianLatinCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/SerbianLatinCustomizer.java new file mode 100644 index 000000000..ef075c264 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/SerbianLatinCustomizer.java @@ -0,0 +1,80 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.SerbianQwertz; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public class SerbianLatinCustomizer extends LayoutCustomizer { + public SerbianLatinCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS; + } + + protected void setSerbianKeys(final ExpectedKeyboardBuilder builder) { + builder + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + .replaceKeyOfLabel(SerbianQwertz.ROW1_11, "\u0161") + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + .replaceKeyOfLabel(SerbianQwertz.ROW2_10, "\u010D") + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + .replaceKeyOfLabel(SerbianQwertz.ROW2_11, "\u0107") + // U+0111: "đ" LATIN SMALL LETTER D WITH STROKE + .replaceKeyOfLabel(SerbianQwertz.ROW3_8, "\u0111") + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + .replaceKeyOfLabel(SerbianQwertz.ROW3_9, "\u017E"); + } + + @SuppressWarnings("unused") + protected void setMoreKeysOfS(final ExpectedKeyboardBuilder builder) { + // Serbian QWERTZ has a dedicated "š" key. + } + + @SuppressWarnings("unused") + protected void setMoreKeysOfC(final ExpectedKeyboardBuilder builder) { + // Serbian QWERTZ has a dedicated "č" and "ć" keys. + } + + @SuppressWarnings("unused") + protected void setMoreKeysOfD(final ExpectedKeyboardBuilder builder) { + // Serbian QWERTZ has a dedicated "đ" key. + } + + @SuppressWarnings("unused") + protected void setMoreKeysOfZ(final ExpectedKeyboardBuilder builder) { + // Serbian QWERTZ has a dedicated "ž" key. + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + setSerbianKeys(builder); + setMoreKeysOfS(builder); + setMoreKeysOfC(builder); + setMoreKeysOfD(builder); + setMoreKeysOfZ(builder); + return builder + // U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE + .setMoreKeysOf("e", "\u00E8") + // U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE + .setMoreKeysOf("i", "\u00EC"); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/SouthSlavicLayoutCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/SouthSlavicLayoutCustomizer.java new file mode 100644 index 000000000..bfe5913f6 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/SouthSlavicLayoutCustomizer.java @@ -0,0 +1,43 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Locale; + +public 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); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/SpanishCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/SpanishCustomizer.java new file mode 100644 index 000000000..400481c14 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/SpanishCustomizer.java @@ -0,0 +1,100 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.Spanish; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public class SpanishCustomizer extends LayoutCustomizer { + public SpanishCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { + return isPhone ? SPANISH_PHONE_PUNCTUATION_MORE_KEYS : TABLET_PUNCTUATION_MORE_KEYS; + } + + // Punctuation more keys for phone form factor. + private static final ExpectedKey[] SPANISH_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", + "\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", "\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", "\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", + "\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, "\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/org/kelar/inputmethod/keyboard/layout/customizer/SwedishCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/SwedishCustomizer.java new file mode 100644 index 000000000..325f94f97 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/SwedishCustomizer.java @@ -0,0 +1,143 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.Nordic; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public class SwedishCustomizer extends LayoutCustomizer { + private final LayoutCustomizer mEuroCustomizer; + + public SwedishCustomizer(final Locale locale) { + super(locale); + mEuroCustomizer = new EuroCustomizer(locale); + } + + @Override + public ExpectedKey getCurrencyKey() { + return mEuroCustomizer.getCurrencyKey(); + } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return mEuroCustomizer.getOtherCurrencyKeys(); + } + + @Override + public ExpectedKey[] getDoubleAngleQuoteKeys() { return Symbols.DOUBLE_ANGLE_QUOTES_RL; } + + @Override + public ExpectedKey[] getSingleAngleQuoteKeys() { return Symbols.SINGLE_ANGLE_QUOTES_RL; } + + protected void setNordicKeys(final ExpectedKeyboardBuilder builder) { + builder + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + .replaceKeyOfLabel(Nordic.ROW1_11, "\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, "\u00F6") + .setMoreKeysOf("\u00F6", "\u00F8", "\u0153") + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E6: "æ" LATIN SMALL LETTER AE + .replaceKeyOfLabel(Nordic.ROW2_11, "\u00E4") + .setMoreKeysOf("\u00E4", "\u00E6"); + } + + protected void setMoreKeysOfA(final ExpectedKeyboardBuilder builder) { + builder + // U+00E6: "æ" LATIN SMALL LETTER AE + // 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", "\u00E6", "\u00E1", "\u00E0", "\u00E2", "\u0105", "\u00E3"); + } + + protected void setMoreKeysOfO(final ExpectedKeyboardBuilder builder) { + builder + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // 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", "\u00F8", "\u0153", "\u00F3", "\u00F2", "\u00F4", "\u00F5", + "\u014D"); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + setNordicKeys(builder); + setMoreKeysOfA(builder); + setMoreKeysOfO(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", "\u00E9", "\u00E8", "\u00EA", "\u00EB", "\u0119") + // U+0159: "ř" LATIN SMALL LETTER R WITH CARON + .setMoreKeysOf("r", "\u0159") + // U+0165: "ť" LATIN SMALL LETTER T WITH CARON + // U+00FE: "þ" LATIN SMALL LETTER THORN + .setMoreKeysOf("t", "\u0165", "\u00FE") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "\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", "\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", "\u00ED", "\u00EC", "\u00EE", "\u00EF") + // 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/org/kelar/inputmethod/keyboard/layout/customizer/TamilCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/TamilCustomizer.java new file mode 100644 index 000000000..13da88037 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/TamilCustomizer.java @@ -0,0 +1,45 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.latin.common.Constants; + +import java.util.Locale; + +public class TamilCustomizer extends LayoutCustomizer { + public TamilCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getAlphabetKey() { return TAMIL_ALPHABET_KEY; } + + @Override + public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) { + return EMPTY_KEYS; + } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS; + } + + // U+0BA4: "த" TAMIL LETTER TA + // U+0BAE/U+0BBF: "மி" TAMIL LETTER MA/TAMIL VOWEL SIGN I + // U+0BB4/U+0BCD: "ழ்" TAMIL LETTER LLLA/TAMIL SIGN VIRAMA + private static final ExpectedKey TAMIL_ALPHABET_KEY = key( + "\u0BA4\u0BAE\u0BBF\u0BB4\u0BCD", Constants.CODE_SWITCH_ALPHA_SYMBOL); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/TurkicCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/TurkicCustomizer.java new file mode 100644 index 000000000..6789a6e95 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/TurkicCustomizer.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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * Turkic languages layout customizer. + */ +public class TurkicCustomizer extends LayoutCustomizer { + public TurkicCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder + // U+0259: "ə" LATIN SMALL LETTER SCHWA + // U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE + .setMoreKeysOf("e", "\u0259", "\u00E9") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + .setMoreKeysOf("y", "\u00FD") + // 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", "\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", + "\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", + "\u00F6", "\u00F4", "\u0153", "\u00F2", "\u00F3", "\u00F5", "\u00F8", + "\u014D") + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE + .setMoreKeysOf("a", "\u00E2", "\u00E4", "\u00E1") + // 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+017E: "ž" LATIN SMALL LETTER Z WITH CARON + .setMoreKeysOf("z", "\u017E") + // 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+0148: "ň" LATIN SMALL LETTER N WITH CARON + // U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE + .setMoreKeysOf("n", "\u0148", "\u00F1"); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/UzbekCustomizer.java b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/UzbekCustomizer.java new file mode 100644 index 000000000..08dd3fd25 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/customizer/UzbekCustomizer.java @@ -0,0 +1,42 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.customizer; + +import org.kelar.inputmethod.keyboard.layout.Nordic; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +public class UzbekCustomizer extends TurkicCustomizer { + public UzbekCustomizer(final Locale locale) { super(locale); } + + protected void setUzbekKeys(final ExpectedKeyboardBuilder builder) { + builder + // U+006F/U+02BB: "oʻ" LATIN SMALL LETTER O/MODIFIER LETTER TURNED COMMA + .replaceKeyOfLabel(Nordic.ROW1_11, "o\u02BB") + // U+0067/U+02BB: "gʻ" LATIN SMALL LETTER G/MODIFIER LETTER TURNED COMMA + .replaceKeyOfLabel(Nordic.ROW2_10, "g\u02BB") + // U+02BC: "ʼ" MODIFIER LETTER APOSTROPHE + .replaceKeyOfLabel(Nordic.ROW2_11, "\u02BC"); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + setUzbekKeys(builder); + return super.setAccentedLetters(builder); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/expected/AbstractKeyboardBuilder.java b/tests/src/org/kelar/inputmethod/keyboard/layout/expected/AbstractKeyboardBuilder.java new file mode 100644 index 000000000..0ed74eb25 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/expected/AbstractKeyboardBuilder.java @@ -0,0 +1,143 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.expected; + +import java.util.Arrays; + +/** + * This class builds a keyboard that is a two dimensional array of elements <code>E</code>. + * + * A keyboard consists of an array of rows, and a row consists of an array of elements. Each row + * may have different number of elements. A element of a keyboard can be specified by a row number + * and a column number, both numbers starts from 1. + * + * @param <E> the type of a keyboard element. A keyboard element must be an immutable object. + */ +abstract class AbstractKeyboardBuilder<E> { + // A building array of rows. + private E[][] mRows; + + // Returns an instance of default element. + abstract E defaultElement(); + // Returns an <code>E</code> array instance of the <code>size</code>. + abstract E[] newArray(final int size); + // Returns an <code>E[]</code> array instance of the <code>size</code>. + abstract E[][] newArrayOfArray(final int size); + + /** + * Construct an empty builder. + */ + AbstractKeyboardBuilder() { + mRows = newArrayOfArray(0); + } + + /** + * Construct a builder from template keyboard. This builder has the same dimensions and + * elements of <code>rows</rows>. + * @param rows the template keyboard rows. The elements of the <code>rows</code> will be + * shared with this builder. Therefore a element must be an immutable object. + */ + AbstractKeyboardBuilder(final E[][] rows) { + mRows = newArrayOfArray(rows.length); + for (int rowIndex = 0; rowIndex < rows.length; rowIndex++) { + final E[] row = rows[rowIndex]; + mRows[rowIndex] = Arrays.copyOf(row, row.length); + } + } + + /** + * Return current constructing keyboard. + * @return the array of the array of the element being constructed. + */ + E[][] build() { + return mRows; + } + + /** + * Return the number of rows. + * @return the number of rows being constructed. + */ + int getRowCount() { + return mRows.length; + } + + /** + * Get the current contents of the specified row. + * @param row the row number to get the contents. + * @return the array of elements at row number <code>row</code>. + * @throws RuntimeException if <code>row</code> is illegal. + */ + E[] getRowAt(final int row) { + final int rowIndex = row - 1; + if (rowIndex < 0 || rowIndex >= mRows.length) { + throw new RuntimeException("Illegal row number: " + row); + } + return mRows[rowIndex]; + } + + /** + * Set an array of elements to the specified row. + * @param row the row number to set <code>elements</code>. + * @param elements the array of elements to set at row number <code>row</code>. + * @throws RuntimeException if <code>row</code> is illegal. + */ + void setRowAt(final int row, final E[] elements) { + final int rowIndex = row - 1; + if (rowIndex < 0) { + throw new RuntimeException("Illegal row number: " + row); + } + final E[][] newRows = (rowIndex < mRows.length) ? mRows + : Arrays.copyOf(mRows, rowIndex + 1); + newRows[rowIndex] = elements; + mRows = newRows; + } + + /** + * Set or insert an element at specified position. + * @param row the row number to set or insert the <code>element</code>. + * @param column the column number to set or insert the <code>element</code>. + * @param element the element to set or insert at <code>row,column</code>. + * @param insert if true, the <code>element</code> is inserted at <code>row,column</code>. + * Otherwise the <code>element</code> replace the element at <code>row,column</code>. + * @throws RuntimeException if <code>row</code> or <code>column</code> is illegal. + */ + 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 >= elements.length + 1) { + throw new RuntimeException("Illegal column number: " + column); + } + final E[] newElements = Arrays.copyOf(elements, elements.length + 1); + // Shift the remaining elements. + System.arraycopy(newElements, columnIndex, newElements, columnIndex + 1, + elements.length - columnIndex); + // Insert the element at <code>row,column</code>. + newElements[columnIndex] = element; + // Replace the current row with one. + setRowAt(row, newElements); + return; + } + final E[] newElements = (columnIndex < elements.length) ? elements + : Arrays.copyOf(elements, columnIndex + 1); + newElements[columnIndex] = element; + setRowAt(row, newElements); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java b/tests/src/org/kelar/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java new file mode 100644 index 000000000..dba595ab5 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/expected/AbstractLayoutBase.java @@ -0,0 +1,178 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.expected; + +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey.ExpectedAdditionalMoreKey; +import org.kelar.inputmethod.latin.common.Constants; + +/** + * 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 ExpectedAdditionalMoreKey} object for an + // "additional more key" that has the label. + // The additional more keys can be defined independently from other more keys. The position of + // the additional more keys in the long press popup keyboard can be controlled by specifying + // special marker "%" in the usual more keys definitions. + public static ExpectedAdditionalMoreKey additionalMoreKey(final String label) { + return ExpectedAdditionalMoreKey.newInstance(label); + } + + // Helper method to create an {@link ExpectedKey} object for a "more key" that has the label. + public static ExpectedKey moreKey(final String label) { + return ExpectedKey.newInstance(label); + } + + // 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) { + return ExpectedKeyboardBuilder.joinKeys(keys); + } + + // Icon ids. + private static final int ICON_DELETE = KeyboardIconsSet.getIconId( + KeyboardIconsSet.NAME_DELETE_KEY); + private static final int ICON_SPACE = KeyboardIconsSet.getIconId( + KeyboardIconsSet.NAME_SPACE_KEY); + private static final int ICON_TAB = KeyboardIconsSet.getIconId( + KeyboardIconsSet.NAME_TAB_KEY); + private static final int ICON_SHORTCUT = KeyboardIconsSet.getIconId( + KeyboardIconsSet.NAME_SHORTCUT_KEY); + private static final int ICON_SETTINGS = KeyboardIconsSet.getIconId( + KeyboardIconsSet.NAME_SETTINGS_KEY); + private static final int ICON_LANGUAGE_SWITCH = KeyboardIconsSet.getIconId( + KeyboardIconsSet.NAME_LANGUAGE_SWITCH_KEY); + private static final int ICON_ENTER = KeyboardIconsSet.getIconId( + KeyboardIconsSet.NAME_ENTER_KEY); + private static final int ICON_EMOJI_ACTION = KeyboardIconsSet.getIconId( + KeyboardIconsSet.NAME_EMOJI_ACTION_KEY); + private static final int ICON_EMOJI_NORMAL = KeyboardIconsSet.getIconId( + KeyboardIconsSet.NAME_EMOJI_NORMAL_KEY); + 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 keys. + protected static final ExpectedKey DELETE_KEY = key(ICON_DELETE, Constants.CODE_DELETE); + protected static final ExpectedKey TAB_KEY = key(ICON_TAB, Constants.CODE_TAB); + protected static final ExpectedKey SHORTCUT_KEY = key(ICON_SHORTCUT, Constants.CODE_SHORTCUT); + protected static final ExpectedKey SETTINGS_KEY = key(ICON_SETTINGS, Constants.CODE_SETTINGS); + protected static final ExpectedKey LANGUAGE_SWITCH_KEY = key( + ICON_LANGUAGE_SWITCH, Constants.CODE_LANGUAGE_SWITCH); + protected static final ExpectedKey ENTER_KEY = key(ICON_ENTER, Constants.CODE_ENTER); + protected static final ExpectedKey EMOJI_ACTION_KEY = key(ICON_EMOJI_ACTION, Constants.CODE_EMOJI); + protected static final ExpectedKey EMOJI_NORMAL_KEY = key(ICON_EMOJI_NORMAL, Constants.CODE_EMOJI); + protected static final ExpectedKey SPACE_KEY = key(ICON_SPACE, Constants.CODE_SPACE); + protected static final ExpectedKey CAPSLOCK_MORE_KEY = key(" ", Constants.CODE_CAPSLOCK); + protected static final ExpectedKey SHIFT_KEY = key(ICON_SHIFT, + Constants.CODE_SHIFT, CAPSLOCK_MORE_KEY); + protected static final ExpectedKey SHIFTED_SHIFT_KEY = key(ICON_SHIFTED_SHIFT, + Constants.CODE_SHIFT, CAPSLOCK_MORE_KEY); + protected static final ExpectedKey ALPHABET_KEY = key("ABC", Constants.CODE_SWITCH_ALPHA_SYMBOL); + protected static final ExpectedKey SYMBOLS_KEY = key("?123", Constants.CODE_SWITCH_ALPHA_SYMBOL); + protected static final ExpectedKey BACK_TO_SYMBOLS_KEY = key("?123", Constants.CODE_SHIFT); + protected static final ExpectedKey SYMBOLS_SHIFT_KEY = key("= \\ <", Constants.CODE_SHIFT); + protected static final ExpectedKey TABLET_SYMBOLS_SHIFT_KEY = key("~ [ <", Constants.CODE_SHIFT); + + // U+00A1: "¡" INVERTED EXCLAMATION MARK + // U+00BF: "¿" INVERTED QUESTION MARK + protected 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 + protected static final ExpectedKey ZWNJ_KEY = key(ICON_ZWNJ, "\u200C"); + protected static final ExpectedKey ZWJ_KEY = key(ICON_ZWJ, "\u200D"); + // Domain key + protected static final ExpectedKey DOMAIN_KEY = + key(".com", joinMoreKeys(".net", ".org", ".gov", ".edu")).preserveCase(); + + // Punctuation more keys for phone form factor. + protected static final ExpectedKey[] PHONE_PUNCTUATION_MORE_KEYS = joinKeys( + ",", "?", "!", "#", ")", "(", "/", ";", + "'", "@", ":", "-", "\"", "+", "%", "&"); + // Punctuation more keys for tablet form factor. + protected static final ExpectedKey[] TABLET_PUNCTUATION_MORE_KEYS = joinKeys( + ",", "'", "#", ")", "(", "/", ";", + "@", ":", "-", "\"", "+", "%", "&"); +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java b/tests/src/org/kelar/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java new file mode 100644 index 000000000..779cc0b6c --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/expected/ActualKeyboardBuilder.java @@ -0,0 +1,194 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.expected; + +import org.kelar.inputmethod.keyboard.Key; +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.keyboard.internal.MoreKeySpec; +import org.kelar.inputmethod.latin.common.Constants; +import org.kelar.inputmethod.latin.common.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * This class builds an actual keyboard for unit test. + * + * An actual keyboard is an array of rows, and a row consists of an array of {@link Key}s. + * Each row may have different number of {@link Key}s. + */ +public final class ActualKeyboardBuilder extends AbstractKeyboardBuilder<Key> { + private static ArrayList<Key> filterOutSpacer(final List<Key> keys) { + final ArrayList<Key> filteredKeys = new ArrayList<>(); + for (final Key key : keys) { + if (key.isSpacer()) { + continue; + } + filteredKeys.add(key); + } + return filteredKeys; + } + + /** + * Create the keyboard that consists of the array of rows of the actual keyboard's keys. + * @param sortedKeys keys list of the actual keyboard that is sorted from top-left to + * bottom-right. + * @return the actual keyboard grouped with rows. + */ + public static Key[][] buildKeyboard(final List<Key> sortedKeys) { + // Filter out spacer to prepare to create rows. + final ArrayList<Key> filteredSortedKeys = filterOutSpacer(sortedKeys); + + // Grouping keys into rows. + final ArrayList<ArrayList<Key>> rows = new ArrayList<>(); + ArrayList<Key> elements = new ArrayList<>(); + int lastY = filteredSortedKeys.get(0).getY(); + for (final Key key : filteredSortedKeys) { + if (lastY != key.getY()) { + // A new row is starting. + lastY = key.getY(); + rows.add(elements); + elements = new ArrayList<>(); + } + elements.add(key); + } + rows.add(elements); // Add the last row. + + // Calculate each dimension of rows and create a builder. + final int[] dimensions = new int[rows.size()]; + for (int rowIndex = 0; rowIndex < dimensions.length; rowIndex++) { + dimensions[rowIndex] = rows.get(rowIndex).size(); + } + final ActualKeyboardBuilder builder = new ActualKeyboardBuilder(); + + for (int rowIndex = 0; rowIndex < rows.size(); rowIndex++) { + final int row = rowIndex + 1; + final ArrayList<Key> rowKeys = rows.get(rowIndex); + builder.setRowAt(row, rowKeys.toArray(new Key[rowKeys.size()])); + } + return builder.build(); + } + + @Override + Key defaultElement() { return null; } + + @Override + Key[] newArray(final int size) { return new Key[size]; } + + @Override + Key[][] newArrayOfArray(final int size) { return new Key[size][]; } + + // Helper class to create concise representation from the key specification. + static class MoreKeySpecStringizer extends StringUtils.Stringizer<MoreKeySpec> { + static final MoreKeySpecStringizer STRINGIZER = new MoreKeySpecStringizer(); + + @Override + public String stringize(final MoreKeySpec spec) { + if (spec == null) { + return "null"; + } + return toString(spec.mLabel, spec.mIconId, spec.mOutputText, spec.mCode); + } + + @Nonnull + static String toString(final String label, final int iconId, final String outputText, + final int code) { + final String visual = (iconId != KeyboardIconsSet.ICON_UNDEFINED) + ? KeyboardIconsSet.getIconName(iconId) : label; + final String output; + if (code == Constants.CODE_OUTPUT_TEXT) { + output = outputText; + } else if (code < Constants.CODE_SPACE) { + output = Constants.printableCode(code); + } else { + output = StringUtils.newSingleCodePointString(code); + } + if (visual.equals(output)) { + return visual; + } + return visual + "|" + output; + } + } + + // Helper class to create concise representation from the key. + static class KeyStringizer extends StringUtils.Stringizer<Key> { + static final KeyStringizer STRINGIZER = new KeyStringizer(); + + @Override + public String stringize(@Nullable final Key key) { + if (key == null) { + return "NULL"; + } + if (key.isSpacer()) { + return "SPACER"; + } + final StringBuilder sb = new StringBuilder(); + sb.append(MoreKeySpecStringizer.toString( + key.getLabel(), key.getIconId(), key.getOutputText(), key.getCode())); + final MoreKeySpec[] moreKeys = key.getMoreKeys(); + if (moreKeys == null) { + return sb.toString(); + } + sb.append("^"); + sb.append(MoreKeySpecStringizer.STRINGIZER.join(moreKeys)); + return sb.toString(); + } + } + + /** + * Convert the key to human readable string. + * @param key the key to be converted to string. + * @return the human readable representation of <code>key</code>. + */ + @Nonnull + public static String toString(@Nullable final Key key) { + return KeyStringizer.STRINGIZER.stringize(key); + } + + /** + * Convert the keyboard row to human readable string. + * @param keys the keyboard row to be converted to string. + * @return the human readable representation of <code>keys</code>. + */ + @Nonnull + public static String toString(@Nullable final Key[] keys) { + return KeyStringizer.STRINGIZER.join(keys); + } + + // Helper class to create concise representation from the array of the key. + static class KeyArrayStringizer extends StringUtils.Stringizer<Key[]> { + static final KeyArrayStringizer STRINGIZER = new KeyArrayStringizer(); + + @Override + public String stringize(@Nullable final Key[] keyArray) { + return KeyStringizer.STRINGIZER.join(keyArray); + } + } + + /** + * Convert the keyboard to human readable string. + * @param rows the keyboard to be converted to string. + * @return the human readable representation of <code>rows</code>. + */ + @Nonnull + public static String toString(@Nullable final Key[][] rows) { + return KeyArrayStringizer.STRINGIZER.join(rows, "\n" /* delimiter */); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/expected/ExpectedKey.java b/tests/src/org/kelar/inputmethod/keyboard/layout/expected/ExpectedKey.java new file mode 100644 index 000000000..aeec19dde --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/expected/ExpectedKey.java @@ -0,0 +1,376 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.expected; + +import org.kelar.inputmethod.keyboard.Key; +import org.kelar.inputmethod.keyboard.internal.MoreKeySpec; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Locale; + +/** + * This class represents an expected key. + */ +public class ExpectedKey { + static ExpectedKey EMPTY_KEY = newInstance(""); + + // A key that has a string label and may have "more keys". + static ExpectedKey newInstance(final String label, final ExpectedKey... moreKeys) { + return newInstance(label, label, moreKeys); + } + + // A key that has a string label and a different output text and may have "more keys". + static ExpectedKey newInstance(final String label, final String outputText, + final ExpectedKey... moreKeys) { + return newInstance(ExpectedKeyVisual.newInstance(label), + ExpectedKeyOutput.newInstance(outputText), moreKeys); + } + + // A key that has a string label and a code point output and may have "more keys". + static ExpectedKey newInstance(final String label, final int code, + final ExpectedKey... moreKeys) { + return newInstance(ExpectedKeyVisual.newInstance(label), + ExpectedKeyOutput.newInstance(code), moreKeys); + } + + // A key that has an icon and an output text and may have "more keys". + static ExpectedKey newInstance(final int iconId, final String outputText, + final ExpectedKey... moreKeys) { + 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) { + return newInstance(ExpectedKeyVisual.newInstance(iconId), + ExpectedKeyOutput.newInstance(code), moreKeys); + } + + static ExpectedKey newInstance(final ExpectedKeyVisual visual, final ExpectedKeyOutput output, + final ExpectedKey... moreKeys) { + if (moreKeys.length == 0) { + return new ExpectedKey(visual, output); + } + // The more keys are the extra keys that the main keyboard key may have in its long press + // popup keyboard. + // The additional more keys can be defined independently from other more keys. + // The position of the additional more keys in the long press popup keyboard can be + // controlled by specifying special marker "%" in the usual more keys definitions. + final ArrayList<ExpectedKey> moreKeysList = new ArrayList<>(); + final ArrayList<ExpectedAdditionalMoreKey> additionalMoreKeys = new ArrayList<>(); + int firstAdditionalMoreKeyIndex = -1; + for (int index = 0; index < moreKeys.length; index++) { + final ExpectedKey moreKey = moreKeys[index]; + if (moreKey instanceof ExpectedAdditionalMoreKey) { + additionalMoreKeys.add((ExpectedAdditionalMoreKey) moreKey); + if (firstAdditionalMoreKeyIndex < 0) { + firstAdditionalMoreKeyIndex = index; + } + } else { + moreKeysList.add(moreKey); + } + } + if (additionalMoreKeys.isEmpty()) { + return new ExpectedKeyWithMoreKeys(visual, output, moreKeys); + } + final ExpectedKey[] moreKeysArray = moreKeysList.toArray( + new ExpectedKey[moreKeysList.size()]); + final ExpectedAdditionalMoreKey[] additionalMoreKeysArray = additionalMoreKeys.toArray( + new ExpectedAdditionalMoreKey[additionalMoreKeys.size()]); + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + visual, output, moreKeysArray, firstAdditionalMoreKeyIndex, + additionalMoreKeysArray); + } + + private static final ExpectedKey[] EMPTY_KEYS = new ExpectedKey[0]; + + // The expected visual outlook of this key. + private final ExpectedKeyVisual mVisual; + // The expected output of this key. + private final ExpectedKeyOutput mOutput; + + protected final ExpectedKeyVisual getVisual() { + return mVisual; + } + + protected final ExpectedKeyOutput getOutput() { + return mOutput; + } + + public ExpectedKey[] getMoreKeys() { + // This key has no "more keys". + return EMPTY_KEYS; + } + + public ExpectedKey setMoreKeys(final ExpectedKey... moreKeys) { + return newInstance(mVisual, mOutput, moreKeys); + } + + public ExpectedKey setAdditionalMoreKeys( + final ExpectedAdditionalMoreKey... additionalMoreKeys) { + if (additionalMoreKeys.length == 0) { + return this; + } + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + mVisual, mOutput, EMPTY_KEYS, 0 /* additionalMoreKeysIndex */, additionalMoreKeys); + } + + public ExpectedKey setAdditionalMoreKeysIndex(final int additionalMoreKeysIndex) { + if (additionalMoreKeysIndex == 0) { + return this; + } + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + mVisual, mOutput, EMPTY_KEYS, additionalMoreKeysIndex); + } + + protected ExpectedKey(final ExpectedKeyVisual visual, final ExpectedKeyOutput output) { + mVisual = visual; + mOutput = output; + } + + public ExpectedKey toUpperCase(Locale locale) { + return newInstance(mVisual.toUpperCase(locale), mOutput.toUpperCase(locale)); + } + + public ExpectedKey preserveCase() { + final ExpectedKey[] moreKeys = getMoreKeys(); + final ExpectedKey[] casePreservedMoreKeys = new ExpectedKey[moreKeys.length]; + for (int index = 0; index < moreKeys.length; index++) { + final ExpectedKey moreKey = moreKeys[index]; + casePreservedMoreKeys[index] = newInstance( + moreKey.getVisual().preserveCase(), moreKey.getOutput().preserveCase()); + } + return newInstance( + getVisual().preserveCase(), getOutput().preserveCase(), casePreservedMoreKeys); + } + + public boolean equalsTo(final Key key) { + // This key has no "more keys". + return mVisual.hasSameKeyVisual(key) && mOutput.hasSameKeyOutput(key) + && key.getMoreKeys() == null; + } + + public boolean equalsTo(final MoreKeySpec moreKeySpec) { + return mVisual.hasSameKeyVisual(moreKeySpec) && mOutput.hasSameKeyOutput(moreKeySpec); + } + + @Override + public boolean equals(final Object object) { + if (object instanceof ExpectedKey) { + final ExpectedKey key = (ExpectedKey) object; + return mVisual.hasSameKeyVisual(key.mVisual) && mOutput.hasSameKeyOutput(key.mOutput) + && Arrays.equals(getMoreKeys(), key.getMoreKeys()); + } + return false; + } + + private static int hashCode(final Object... objects) { + return Arrays.hashCode(objects); + } + + @Override + public int hashCode() { + return hashCode(mVisual, mOutput, getMoreKeys()); + } + + @Override + public String toString() { + if (mVisual.hasSameKeyVisual(mOutput)) { + return mVisual.toString(); + } + return mVisual + "|" + mOutput; + } + + /** + * This class represents an expected "additional more key". + * + * The additional more keys can be defined independently from other more keys. The position of + * the additional more keys in the long press popup keyboard can be controlled by specifying + * special marker "%" in the usual more keys definitions. + */ + public static class ExpectedAdditionalMoreKey extends ExpectedKey { + public static ExpectedAdditionalMoreKey newInstance(final String label) { + return new ExpectedAdditionalMoreKey(ExpectedKeyVisual.newInstance(label), + ExpectedKeyOutput.newInstance(label)); + } + + public static ExpectedAdditionalMoreKey newInstance(final ExpectedKey key) { + return new ExpectedAdditionalMoreKey(key.getVisual(), key.getOutput()); + } + + ExpectedAdditionalMoreKey(final ExpectedKeyVisual visual, final ExpectedKeyOutput output) { + super(visual, output); + } + + @Override + public ExpectedAdditionalMoreKey toUpperCase(final Locale locale) { + final ExpectedKey upperCaseKey = super.toUpperCase(locale); + return new ExpectedAdditionalMoreKey( + upperCaseKey.getVisual(), upperCaseKey.getOutput()); + } + } + + /** + * This class represents an expected key that has "more keys". + */ + private static class ExpectedKeyWithMoreKeys extends ExpectedKey { + private final ExpectedKey[] mMoreKeys; + + ExpectedKeyWithMoreKeys(final ExpectedKeyVisual visual, final ExpectedKeyOutput output, + final ExpectedKey... moreKeys) { + super(visual, output); + mMoreKeys = moreKeys; + } + + @Override + public ExpectedKey toUpperCase(final Locale locale) { + final ExpectedKey[] upperCaseMoreKeys = new ExpectedKey[mMoreKeys.length]; + for (int i = 0; i < mMoreKeys.length; i++) { + upperCaseMoreKeys[i] = mMoreKeys[i].toUpperCase(locale); + } + return newInstance(getVisual().toUpperCase(locale), getOutput().toUpperCase(locale), + upperCaseMoreKeys); + } + + @Override + public ExpectedKey[] getMoreKeys() { + return mMoreKeys; + } + + @Override + public ExpectedKey setAdditionalMoreKeys( + final ExpectedAdditionalMoreKey... additionalMoreKeys) { + if (additionalMoreKeys.length == 0) { + return this; + } + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + getVisual(), getOutput(), mMoreKeys, 0 /* additionalMoreKeysIndex */, + additionalMoreKeys); + } + + @Override + public ExpectedKey setAdditionalMoreKeysIndex(final int additionalMoreKeysIndex) { + if (additionalMoreKeysIndex == 0) { + return this; + } + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + getVisual(), getOutput(), mMoreKeys, additionalMoreKeysIndex); + } + + @Override + public boolean equalsTo(final Key key) { + if (getVisual().hasSameKeyVisual(key) && getOutput().hasSameKeyOutput(key)) { + final MoreKeySpec[] moreKeySpecs = key.getMoreKeys(); + final ExpectedKey[] moreKeys = getMoreKeys(); + // This key should have at least one "more key". + if (moreKeySpecs == null || moreKeySpecs.length != moreKeys.length) { + return false; + } + for (int index = 0; index < moreKeySpecs.length; index++) { + if (!moreKeys[index].equalsTo(moreKeySpecs[index])) { + return false; + } + } + return true; + } + return false; + } + + @Override + public boolean equalsTo(final MoreKeySpec moreKeySpec) { + // MoreKeySpec has no "more keys". + return false; + } + + @Override + public String toString() { + return super.toString() + "^" + Arrays.toString(getMoreKeys()); + } + } + + /** + * This class represents an expected key that has "more keys" and "additional more keys". + */ + private static final class ExpectedKeyWithMoreKeysAndAdditionalMoreKeys + extends ExpectedKeyWithMoreKeys { + private final ExpectedAdditionalMoreKey[] mAdditionalMoreKeys; + private final int mAdditionalMoreKeysIndex; + + ExpectedKeyWithMoreKeysAndAdditionalMoreKeys(final ExpectedKeyVisual visual, + final ExpectedKeyOutput output, final ExpectedKey[] moreKeys, + final int additionalMoreKeysIndex, + final ExpectedAdditionalMoreKey... additionalMoreKeys) { + super(visual, output, moreKeys); + mAdditionalMoreKeysIndex = additionalMoreKeysIndex; + mAdditionalMoreKeys = additionalMoreKeys; + } + + @Override + public ExpectedKey setMoreKeys(final ExpectedKey... moreKeys) { + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + getVisual(), getOutput(), moreKeys, mAdditionalMoreKeysIndex, + mAdditionalMoreKeys); + } + + @Override + public ExpectedKey setAdditionalMoreKeys( + final ExpectedAdditionalMoreKey... additionalMoreKeys) { + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + getVisual(), getOutput(), super.getMoreKeys(), mAdditionalMoreKeysIndex, + additionalMoreKeys); + } + + @Override + public ExpectedKey setAdditionalMoreKeysIndex(final int additionalMoreKeysIndex) { + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + getVisual(), getOutput(), super.getMoreKeys(), additionalMoreKeysIndex, + mAdditionalMoreKeys); + } + + @Override + public ExpectedKey toUpperCase(final Locale locale) { + final ExpectedKey[] moreKeys = super.getMoreKeys(); + final ExpectedKey[] upperCaseMoreKeys = new ExpectedKey[moreKeys.length]; + for (int i = 0; i < moreKeys.length; i++) { + upperCaseMoreKeys[i] = moreKeys[i].toUpperCase(locale); + } + final ExpectedAdditionalMoreKey[] upperCaseAdditionalMoreKeys = + new ExpectedAdditionalMoreKey[mAdditionalMoreKeys.length]; + for (int i = 0; i < mAdditionalMoreKeys.length; i++) { + upperCaseAdditionalMoreKeys[i] = mAdditionalMoreKeys[i].toUpperCase(locale); + } + return new ExpectedKeyWithMoreKeysAndAdditionalMoreKeys( + getVisual().toUpperCase(locale), getOutput().toUpperCase(locale), + upperCaseMoreKeys, mAdditionalMoreKeysIndex, upperCaseAdditionalMoreKeys); + } + + @Override + public ExpectedKey[] getMoreKeys() { + final ExpectedKey[] moreKeys = super.getMoreKeys(); + final ExpectedKey[] edittedMoreKeys = Arrays.copyOf( + moreKeys, moreKeys.length + mAdditionalMoreKeys.length); + System.arraycopy(edittedMoreKeys, mAdditionalMoreKeysIndex, + edittedMoreKeys, mAdditionalMoreKeysIndex + mAdditionalMoreKeys.length, + moreKeys.length - mAdditionalMoreKeysIndex); + System.arraycopy(mAdditionalMoreKeys, 0, edittedMoreKeys, mAdditionalMoreKeysIndex, + mAdditionalMoreKeys.length); + return edittedMoreKeys; + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/expected/ExpectedKeyOutput.java b/tests/src/org/kelar/inputmethod/keyboard/layout/expected/ExpectedKeyOutput.java new file mode 100644 index 000000000..fbfdc7403 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/expected/ExpectedKeyOutput.java @@ -0,0 +1,169 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.expected; + +import org.kelar.inputmethod.keyboard.Key; +import org.kelar.inputmethod.keyboard.internal.MoreKeySpec; +import org.kelar.inputmethod.latin.common.Constants; +import org.kelar.inputmethod.latin.common.StringUtils; + +import java.util.Locale; + +/** + * This class represents an expected output of a key. + * + * There are two types of expected output, an integer code point and a string output text. + */ +abstract class ExpectedKeyOutput { + static ExpectedKeyOutput newInstance(final int code) { + return new Code(code); + } + + static ExpectedKeyOutput newInstance(final String outputText) { + // If the <code>outputText</code> is one code point string, use {@link CodePoint} object. + if (StringUtils.codePointCount(outputText) == 1) { + return new Code(outputText.codePointAt(0)); + } + return new Text(outputText); + } + + abstract ExpectedKeyOutput toUpperCase(final Locale locale); + abstract ExpectedKeyOutput preserveCase(); + abstract boolean hasSameKeyOutput(final String text); + abstract boolean hasSameKeyOutput(final Key key); + abstract boolean hasSameKeyOutput(final MoreKeySpec moreKeySpec); + abstract boolean hasSameKeyOutput(final ExpectedKeyOutput output); + + /** + * This class represents an integer code point. + */ + private static class Code extends ExpectedKeyOutput { + // UNICODE code point or a special negative value defined in {@link Constants}. + private final int mCode; + + Code(final int code) { mCode = code; } + + @Override + ExpectedKeyOutput toUpperCase(final Locale locale) { + if (Constants.isLetterCode(mCode)) { + final String codeString = StringUtils.newSingleCodePointString(mCode); + // A letter may have an upper case counterpart that consists of multiple code + // points, for instance the upper case of "ß" is "SS". + return newInstance(StringUtils.toTitleCaseOfKeyLabel(codeString, locale)); + } + // A special negative value has no upper case. + return this; + } + + @Override + ExpectedKeyOutput preserveCase() { + return new CasePreservedCode(mCode); + } + + @Override + boolean hasSameKeyOutput(final String text) { + return StringUtils.codePointCount(text) == 1 && text.codePointAt(0) == mCode; + } + + @Override + boolean hasSameKeyOutput(final Key key) { + return mCode == key.getCode(); + } + + @Override + boolean hasSameKeyOutput(final MoreKeySpec moreKeySpec) { + return mCode == moreKeySpec.mCode; + } + + @Override + boolean hasSameKeyOutput(final ExpectedKeyOutput output) { + return (output instanceof Code) && mCode == ((Code)output).mCode; + } + + @Override + public String toString() { + return Constants.isLetterCode(mCode) ? StringUtils.newSingleCodePointString(mCode) + : Constants.printableCode(mCode); + } + + private static class CasePreservedCode extends Code { + CasePreservedCode(final int code) { super(code); } + + @Override + ExpectedKeyOutput toUpperCase(final Locale locale) { return this; } + + @Override + ExpectedKeyOutput preserveCase() { return this; } + } + } + + /** + * This class represents a string output text. + */ + private static class Text extends ExpectedKeyOutput { + private final String mText; + + Text(final String text) { mText = text; } + + @Override + ExpectedKeyOutput toUpperCase(final Locale locale) { + return newInstance(mText.toUpperCase(locale)); + } + + @Override + ExpectedKeyOutput preserveCase() { + return new CasePreservedText(mText); + } + + @Override + boolean hasSameKeyOutput(final String text) { + return mText.equals(text); + } + + @Override + boolean hasSameKeyOutput(final Key key) { + return key.getCode() == Constants.CODE_OUTPUT_TEXT + && mText.equals(key.getOutputText()); + } + + @Override + boolean hasSameKeyOutput(final MoreKeySpec moreKeySpec) { + return moreKeySpec.mCode == Constants.CODE_OUTPUT_TEXT + && mText.equals(moreKeySpec.mOutputText); + } + + @Override + boolean hasSameKeyOutput(final ExpectedKeyOutput output) { + return (output instanceof Text) && mText == ((Text)output).mText; + } + + @Override + public String toString() { + return mText; + } + + private static class CasePreservedText extends Text { + CasePreservedText(final String text) { super(text); } + + @Override + ExpectedKeyOutput toUpperCase(final Locale locale) { return this; } + + @Override + ExpectedKeyOutput preserveCase() { return this; } + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/expected/ExpectedKeyVisual.java b/tests/src/org/kelar/inputmethod/keyboard/layout/expected/ExpectedKeyVisual.java new file mode 100644 index 000000000..bdd939b1e --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/expected/ExpectedKeyVisual.java @@ -0,0 +1,193 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.expected; + +import org.kelar.inputmethod.keyboard.Key; +import org.kelar.inputmethod.keyboard.internal.KeyboardIconsSet; +import org.kelar.inputmethod.keyboard.internal.MoreKeySpec; +import org.kelar.inputmethod.latin.common.StringUtils; + +import java.util.Locale; + +/** + * This class represents an expected visual outlook of a key. + * + * There are two types of expected visual, an integer icon id and a string label. + */ +public abstract class ExpectedKeyVisual { + public static ExpectedKeyVisual newInstance(final String label) { + return new Label(label); + } + + public static ExpectedKeyVisual newInstance(final int iconId) { + return new Icon(iconId); + } + + public abstract int getIconId(); + public abstract String getLabel(); + abstract ExpectedKeyVisual toUpperCase(final Locale locale); + abstract ExpectedKeyVisual preserveCase(); + abstract boolean hasSameKeyVisual(final String text); + abstract boolean hasSameKeyVisual(final Key key); + abstract boolean hasSameKeyVisual(final MoreKeySpec moreKeySpec); + abstract boolean hasSameKeyVisual(final ExpectedKeyOutput output); + abstract boolean hasSameKeyVisual(final ExpectedKeyVisual visual); + + /** + * This class represents an integer icon id. + */ + private static class Icon extends ExpectedKeyVisual { + private final int mIconId; + + Icon(final int iconId) { + mIconId = iconId; + } + + @Override + public int getIconId() { + return mIconId; + } + + @Override + public String getLabel() { + return null; + } + + @Override + ExpectedKeyVisual toUpperCase(final Locale locale) { + return this; + } + + @Override + ExpectedKeyVisual preserveCase() { + return this; + } + + @Override + boolean hasSameKeyVisual(final String text) { + return false; + } + + @Override + boolean hasSameKeyVisual(final Key key) { + // If the actual key has an icon as its visual, a label has to be null. + // See {@link KeyboardView#onDrawKeyTopVisuals(Key,Canvas,Paint,KeyDrawParams). + return mIconId == key.getIconId() && key.getLabel() == null; + } + + @Override + boolean hasSameKeyVisual(final MoreKeySpec moreKeySpec) { + // If the actual more key has an icon as its visual, a label has to be null. + // See {@link KeySpecParser#getIconId(String)} and + // {@link KeySpecParser#getLabel(String)}. + return mIconId == moreKeySpec.mIconId && moreKeySpec.mLabel == null; + } + + @Override + boolean hasSameKeyVisual(final ExpectedKeyOutput output) { + return false; + } + + @Override + boolean hasSameKeyVisual(final ExpectedKeyVisual visual) { + return (visual instanceof Icon) && mIconId == ((Icon)visual).mIconId; + } + + @Override + public String toString() { + return KeyboardIconsSet.getIconName(mIconId); + } + } + + /** + * This class represents a string label. + */ + private static class Label extends ExpectedKeyVisual { + private final String mLabel; + + Label(final String label) { + mLabel = label; + } + + @Override + public int getIconId() { + return KeyboardIconsSet.ICON_UNDEFINED; + } + + @Override + public String getLabel() { + return mLabel; + } + + @Override + ExpectedKeyVisual toUpperCase(final Locale locale) { + return new Label(StringUtils.toTitleCaseOfKeyLabel(mLabel, locale)); + } + + @Override + ExpectedKeyVisual preserveCase() { + return new CasePreservedLabel(mLabel); + } + + @Override + boolean hasSameKeyVisual(final String text) { + return mLabel.equals(text); + } + + @Override + boolean hasSameKeyVisual(final Key key) { + // If the actual key has a label as its visual, an icon has to be undefined. + // See {@link KeyboardView#onDrawKeyTopVisuals(Key,Canvas,Paint,KeyDrawParams). + return mLabel.equals(key.getLabel()) + && key.getIconId() == KeyboardIconsSet.ICON_UNDEFINED; + } + + @Override + boolean hasSameKeyVisual(final MoreKeySpec moreKeySpec) { + // If the actual more key has a label as its visual, an icon has to be undefined. + // See {@link KeySpecParser#getIconId(String)} and + // {@link KeySpecParser#getLabel(String)}. + return mLabel.equals(moreKeySpec.mLabel) + && moreKeySpec.mIconId == KeyboardIconsSet.ICON_UNDEFINED; + } + + @Override + boolean hasSameKeyVisual(final ExpectedKeyOutput output) { + return output.hasSameKeyOutput(mLabel); + } + + @Override + boolean hasSameKeyVisual(final ExpectedKeyVisual visual) { + return (visual instanceof Label) && mLabel.equals(((Label)visual).mLabel); + } + + @Override + public String toString() { + return mLabel; + } + + private static class CasePreservedLabel extends Label { + CasePreservedLabel(final String label) { super(label); } + + @Override + ExpectedKeyVisual toUpperCase(final Locale locale) { return this; } + + @Override + ExpectedKeyVisual preserveCase() { return this; } + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java b/tests/src/org/kelar/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java new file mode 100644 index 000000000..9da1ac4df --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/expected/ExpectedKeyboardBuilder.java @@ -0,0 +1,345 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.expected; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Locale; + +/** + * This class builds an expected keyboard for unit test. + * + * An expected keyboard is an array of rows, and a row consists of an array of {@link ExpectedKey}s. + * Each row may have different number of {@link ExpectedKey}s. While building an expected keyboard, + * an {@link ExpectedKey} can be specified by a row number and a column number, both numbers starts + * from 1. + */ +public final class ExpectedKeyboardBuilder extends AbstractKeyboardBuilder<ExpectedKey> { + public ExpectedKeyboardBuilder() { + super(); + } + + public ExpectedKeyboardBuilder(final ExpectedKey[][] rows) { + super(rows); + } + + @Override + protected ExpectedKey defaultElement() { + return ExpectedKey.EMPTY_KEY; + } + + @Override + ExpectedKey[] newArray(final int size) { + return new ExpectedKey[size]; + } + + @Override + ExpectedKey[][] newArrayOfArray(final int size) { + return new ExpectedKey[size][]; + } + + @Override + public ExpectedKey[][] build() { + return super.build(); + } + + // A replacement job to be performed. + private interface ReplaceJob { + // Returns a {@link ExpectedKey} objects to replace. + ExpectedKey[] replacingKeys(final ExpectedKey oldKey); + // Return true if replacing should be stopped at first occurrence. + boolean stopAtFirstOccurrence(); + } + + private static ExpectedKey[] replaceKeyAt(final ExpectedKey[] keys, final int columnIndex, + final ExpectedKey[] replacingKeys) { + // Optimization for replacing a key with another key. + if (replacingKeys.length == 1) { + keys[columnIndex] = replacingKeys[0]; + return keys; + } + final int newLength = keys.length - 1 + replacingKeys.length; + // Remove the key at columnIndex. + final ExpectedKey[] newKeys = Arrays.copyOf(keys, newLength); + System.arraycopy(keys, columnIndex + 1, newKeys, columnIndex + replacingKeys.length, + keys.length - 1 - columnIndex); + // Insert replacing keys at columnIndex. + System.arraycopy(replacingKeys, 0, newKeys, columnIndex, replacingKeys.length); + return newKeys; + + } + + // Replace key(s) that has the specified visual. + private void replaceKeyOf(final ExpectedKeyVisual visual, final ReplaceJob job) { + int replacedCount = 0; + final int rowCount = getRowCount(); + for (int row = 1; row <= rowCount; row++) { + ExpectedKey[] keys = getRowAt(row); + for (int columnIndex = 0; columnIndex < keys.length; /* nothing */) { + final ExpectedKey currentKey = keys[columnIndex]; + if (!currentKey.getVisual().hasSameKeyVisual(visual)) { + columnIndex++; + continue; + } + final ExpectedKey[] replacingKeys = job.replacingKeys(currentKey); + keys = replaceKeyAt(keys, columnIndex, replacingKeys); + columnIndex += replacingKeys.length; + setRowAt(row, keys); + replacedCount++; + if (job.stopAtFirstOccurrence()) { + return; + } + } + } + if (replacedCount == 0) { + throw new RuntimeException( + "Can't find key that has visual: " + visual + " in\n" + this); + } + } + + // Helper method to create {@link ExpectedKey} array by joining {@link ExpectedKey}, + // {@link ExpectedKey} array, and {@link String}. + static ExpectedKey[] joinKeys(final Object ... keys) { + final ArrayList<ExpectedKey> list = new ArrayList<>(); + 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(ExpectedKey.newInstance((String)key)); + } else { + throw new RuntimeException("Unknown expected key type: " + key); + } + } + return list.toArray(new ExpectedKey[list.size()]); + } + + /** + * 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>. Each key can be {@link ExpectedKey}, + * {@link ExpectedKey} array, and {@link String}. + * @return this builder. + */ + public ExpectedKeyboardBuilder setKeysOfRow(final int row, final Object ... keys) { + setRowAt(row, joinKeys(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 "more key" to be set. Each "more key" can be + * {@link ExpectedKey}, {@link ExpectedKey} array, and {@link String}. + * @return this builder. + */ + public ExpectedKeyboardBuilder setMoreKeysOf(final String label, final Object ... moreKeys) { + setMoreKeysOf(ExpectedKeyVisual.newInstance(label), joinKeys(moreKeys)); + return this; + } + + /** + * Set the "more keys" of the key that has the specified icon. + * @param iconId the icon id of the key to set the "more keys". + * @param moreKeys the array of "more key" to be set. Each "more key" can be + * {@link ExpectedKey}, {@link ExpectedKey} array, and {@link String}. + * @return this builder. + */ + public ExpectedKeyboardBuilder setMoreKeysOf(final int iconId, final Object ... moreKeys) { + setMoreKeysOf(ExpectedKeyVisual.newInstance(iconId), joinKeys(moreKeys)); + return this; + } + + private void setMoreKeysOf(final ExpectedKeyVisual visual, final ExpectedKey[] moreKeys) { + replaceKeyOf(visual, new ReplaceJob() { + @Override + public ExpectedKey[] replacingKeys(final ExpectedKey oldKey) { + return new ExpectedKey[] { oldKey.setMoreKeys(moreKeys) }; + } + @Override + public boolean stopAtFirstOccurrence() { + return true; + } + }); + } + + /** + * Set the "additional more keys position" of the key that has the specified label. + * @param label the label of the key to set the "additional more keys". + * @param additionalMoreKeysPosition the position in the "more keys" where + * "additional more keys" will be merged. The position starts from 1. + * @return this builder. + */ + public ExpectedKeyboardBuilder setAdditionalMoreKeysPositionOf(final String label, + final int additionalMoreKeysPosition) { + final int additionalMoreKeysIndex = additionalMoreKeysPosition - 1; + if (additionalMoreKeysIndex < 0) { + throw new RuntimeException("Illegal additional more keys position: " + + additionalMoreKeysPosition); + } + final ExpectedKeyVisual visual = ExpectedKeyVisual.newInstance(label); + replaceKeyOf(visual, new ReplaceJob() { + @Override + public ExpectedKey[] replacingKeys(final ExpectedKey oldKey) { + return new ExpectedKey[] { + oldKey.setAdditionalMoreKeysIndex(additionalMoreKeysIndex) + }; + } + @Override + public boolean stopAtFirstOccurrence() { + return true; + } + }); + return this; + } + + /** + * Insert the keys at specified position. + * @param row the row number to insert the <code>keys</code>. + * @param column the column number to insert the <code>keys</code>. + * @param keys the array of keys to insert at <code>row,column</code>. Each key can be + * {@link ExpectedKey}, {@link ExpectedKey} array, and {@link String}. + * @return this builder. + * @throws RuntimeException if <code>row</code> or <code>column</code> is illegal. + */ + public ExpectedKeyboardBuilder insertKeysAtRow(final int row, final int column, + final Object ... keys) { + final ExpectedKey[] expectedKeys = joinKeys(keys); + for (int index = 0; index < keys.length; index++) { + setElementAt(row, column + index, expectedKeys[index], true /* insert */); + } + return this; + } + + /** + * Add the keys on the left most of the row. + * @param row the row number to add the <code>keys</code>. + * @param keys the array of keys to add on the left most of the row. Each key can be + * {@link ExpectedKey}, {@link ExpectedKey} array, and {@link String}. + * @return this builder. + * @throws RuntimeException if <code>row</code> is illegal. + */ + public ExpectedKeyboardBuilder addKeysOnTheLeftOfRow(final int row, + final Object ... keys) { + final ExpectedKey[] expectedKeys = joinKeys(keys); + // Keys should be inserted from the last to preserve the order. + for (int index = keys.length - 1; index >= 0; index--) { + setElementAt(row, 1, expectedKeys[index], true /* insert */); + } + return this; + } + + /** + * Add the keys on the right most of the row. + * @param row the row number to add the <code>keys</code>. + * @param keys the array of keys to add on the right most of the row. Each key can be + * {@link ExpectedKey}, {@link ExpectedKey} array, and {@link String}. + * @return this builder. + * @throws RuntimeException if <code>row</code> is illegal. + */ + public ExpectedKeyboardBuilder addKeysOnTheRightOfRow(final int row, + final Object ... keys) { + final int rightEnd = getRowAt(row).length + 1; + insertKeysAtRow(row, rightEnd, keys); + return this; + } + + /** + * Replace the most top-left key that has the specified label with the new keys. + * @param label the label of the key to set <code>newKeys</code>. + * @param newKeys the keys to be set. Each key can be {@link ExpectedKey}, {@link ExpectedKey} + * array, and {@link String}. + * @return this builder. + */ + public ExpectedKeyboardBuilder replaceKeyOfLabel(final String label, + final Object ... newKeys) { + final ExpectedKeyVisual visual = ExpectedKeyVisual.newInstance(label); + replaceKeyOf(visual, new ReplaceJob() { + @Override + public ExpectedKey[] replacingKeys(final ExpectedKey oldKey) { + return joinKeys(newKeys); + } + @Override + public boolean stopAtFirstOccurrence() { + return true; + } + }); + return this; + } + + /** + * Replace the all specified keys with the new keys. + * @param key the key to be replaced by <code>newKeys</code>. + * @param newKeys the keys to be set. Each key can be {@link ExpectedKey}, {@link ExpectedKey} + * array, and {@link String}. + * @return this builder. + */ + public ExpectedKeyboardBuilder replaceKeysOfAll(final ExpectedKey key, + final Object ... newKeys) { + replaceKeyOf(key.getVisual(), new ReplaceJob() { + @Override + public ExpectedKey[] replacingKeys(final ExpectedKey oldKey) { + return joinKeys(newKeys); + } + @Override + public boolean stopAtFirstOccurrence() { + return false; + } + }); + return this; + } + + /** + * Convert all keys of this keyboard builder to upper case keys. + * @param locale the locale used to convert cases. + * @return this builder + */ + public ExpectedKeyboardBuilder toUpperCase(final Locale locale) { + final int rowCount = getRowCount(); + for (int row = 1; row <= rowCount; row++) { + final ExpectedKey[] lowerCaseKeys = getRowAt(row); + final ExpectedKey[] upperCaseKeys = new ExpectedKey[lowerCaseKeys.length]; + for (int columnIndex = 0; columnIndex < lowerCaseKeys.length; columnIndex++) { + upperCaseKeys[columnIndex] = lowerCaseKeys[columnIndex].toUpperCase(locale); + } + setRowAt(row, upperCaseKeys); + } + return this; + } + + @Override + public String toString() { + return toString(build()); + } + + /** + * Convert the keyboard to human readable string. + * @param rows the keyboard to be converted to string. + * @return the human readable representation of <code>rows</code>. + */ + public static String toString(final ExpectedKey[][] rows) { + final StringBuilder sb = new StringBuilder(); + for (int rowIndex = 0; rowIndex < rows.length; rowIndex++) { + if (rowIndex > 0) { + sb.append("\n"); + } + sb.append(Arrays.toString(rows[rowIndex])); + } + return sb.toString(); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/KeyboardLayoutSetSubtypesCountTests.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/KeyboardLayoutSetSubtypesCountTests.java new file mode 100644 index 000000000..c2fc8dff2 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/KeyboardLayoutSetSubtypesCountTests.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 org.kelar.inputmethod.keyboard.layout.tests; + +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.KeyboardLayoutSetTestsBase; +import org.kelar.inputmethod.keyboard.KeyboardTheme; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +import java.util.ArrayList; + +@SmallTest +public class KeyboardLayoutSetSubtypesCountTests extends KeyboardLayoutSetTestsBase { + private static final int NUMBER_OF_SUBTYPES = 81; + private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 49; + private static final int NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES = 2; + + @Override + protected int getKeyboardThemeForTests() { + return KeyboardTheme.THEME_ID_KLP; + } + + private static String toString(final ArrayList<InputMethodSubtype> subtypeList) { + final StringBuilder sb = new StringBuilder(); + for (int index = 0; index < subtypeList.size(); index++) { + final InputMethodSubtype subtype = subtypeList.get(index); + sb.append(index + ": "); + sb.append(SubtypeLocaleUtils.getSubtypeNameForLogging(subtype)); + sb.append("\n"); + } + return sb.toString(); + } + + public final void testAllSubtypesCount() { + final ArrayList<InputMethodSubtype> allSubtypesList = getAllSubtypesList(); + assertEquals(toString(allSubtypesList), NUMBER_OF_SUBTYPES, allSubtypesList.size()); + } + + public final void testAsciiCapableSubtypesCount() { + final ArrayList<InputMethodSubtype> asciiCapableSubtypesList = + getSubtypesFilteredBy(FILTER_IS_ASCII_CAPABLE); + assertEquals(toString(asciiCapableSubtypesList), + NUMBER_OF_ASCII_CAPABLE_SUBTYPES, asciiCapableSubtypesList.size()); + } + + public final void testAdditionalSubtypesCount() { + final ArrayList<InputMethodSubtype> additionalSubtypesList = + getSubtypesFilteredBy(FILTER_IS_ADDITIONAL_SUBTYPE); + assertEquals(toString(additionalSubtypesList), + NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES, additionalSubtypesList.size()); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/LayoutTestsBase.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/LayoutTestsBase.java new file mode 100644 index 000000000..2e8f4d3e8 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/LayoutTestsBase.java @@ -0,0 +1,174 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import android.util.Log; +import android.view.inputmethod.InputMethodSubtype; + +import org.kelar.inputmethod.keyboard.Key; +import org.kelar.inputmethod.keyboard.Keyboard; +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.KeyboardLayoutSet; +import org.kelar.inputmethod.keyboard.KeyboardLayoutSetTestsBase; +import org.kelar.inputmethod.keyboard.KeyboardTheme; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.expected.AbstractLayoutBase; +import org.kelar.inputmethod.keyboard.layout.expected.ActualKeyboardBuilder; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey.ExpectedAdditionalMoreKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; +import org.kelar.inputmethod.latin.utils.SubtypeLocaleUtils; + +import java.util.Arrays; + +/** + * Base class for keyboard layout unit test. + */ +abstract class LayoutTestsBase extends KeyboardLayoutSetTestsBase { + private LayoutBase mLayout; + private InputMethodSubtype mSubtype; + private String mLogTag; + private KeyboardLayoutSet mKeyboardLayoutSet; + + @Override + protected void setUp() throws Exception { + super.setUp(); + + mLayout = getLayout(); + mSubtype = getSubtype(mLayout.getLocale(), mLayout.getName()); + mLogTag = SubtypeLocaleUtils.getSubtypeNameForLogging(mSubtype) + "/" + + (isPhone() ? "phone" : "tablet"); + // TODO: Test with language switch key enabled and disabled. + mKeyboardLayoutSet = createKeyboardLayoutSet(mSubtype, null /* editorInfo */, + true /* voiceInputKeyEnabled */, true /* languageSwitchKeyEnabled */, + false /* splitLayoutEnabled */); + } + + @Override + protected int getKeyboardThemeForTests() { + return KeyboardTheme.THEME_ID_KLP; + } + + // 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. + static ExpectedKey key(final String label, final ExpectedKey ... moreKeys) { + return AbstractLayoutBase.key(label, moreKeys); + } + + // Helper method to create an {@link ExpectedKey} object that has the label and the output text. + static ExpectedKey key(final String label, final String outputText, + final ExpectedKey ... moreKeys) { + return AbstractLayoutBase.key(label, outputText, moreKeys); + } + + // Helper method to create an {@link ExpectedKey} object that has new "more keys". + static ExpectedKey key(final ExpectedKey key, final ExpectedKey ... moreKeys) { + return AbstractLayoutBase.key(key, moreKeys); + } + + // Helper method to create an {@link ExpectedAdditionalMoreKey} object for an + // "additional more key" that has the label. + public static ExpectedAdditionalMoreKey additionalMoreKey(final String label) { + return AbstractLayoutBase.additionalMoreKey(label); + } + + // Helper method to create an {@link ExpectedKey} object for a "more key" that has the label. + static ExpectedKey moreKey(final String label) { + return AbstractLayoutBase.moreKey(label); + } + + // Helper method to create an {@link ExpectedKey} object for a "more key" that has the label + // and the output text. + static ExpectedKey moreKey(final String label, final String outputText) { + return AbstractLayoutBase.moreKey(label, outputText); + } + + // Helper method to create {@link ExpectedKey} array by joining {@link ExpectedKey}, + // {@link ExpectedKey} array, and {@link String}. + static ExpectedKey[] joinMoreKeys(final Object ... moreKeys) { + return AbstractLayoutBase.joinKeys(moreKeys); + } + + // 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); + } + + // Keyboard layout for testing subtype. + abstract LayoutBase getLayout(); + + ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return builder; + } + + // TODO: Add phone, phone symbols, number, number password layout tests. + + public final void testLayouts() { + doKeyboardTests(KeyboardId.ELEMENT_ALPHABET); + doKeyboardTests(KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED); + doKeyboardTests(KeyboardId.ELEMENT_ALPHABET_MANUAL_SHIFTED); + doKeyboardTests(KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCKED); + doKeyboardTests(KeyboardId.ELEMENT_ALPHABET_SHIFT_LOCK_SHIFTED); + doKeyboardTests(KeyboardId.ELEMENT_SYMBOLS); + doKeyboardTests(KeyboardId.ELEMENT_SYMBOLS_SHIFTED); + } + + // Comparing expected keyboard and actual keyboard. + private void doKeyboardTests(final int elementId) { + final ExpectedKey[][] expectedKeyboard = mLayout.getLayout(isPhone(), elementId); + // Skip test if no keyboard is defined. + if (expectedKeyboard == null) { + return; + } + final String tag = mLogTag + "/" + KeyboardId.elementIdToName(elementId); + // Create actual keyboard object. + final Keyboard keyboard = mKeyboardLayoutSet.getKeyboard(elementId); + // Create actual keyboard to be compared with the expected keyboard. + final Key[][] actualKeyboard = ActualKeyboardBuilder.buildKeyboard( + keyboard.getSortedKeys()); + + // Dump human readable definition of expected/actual keyboards. + Log.d(tag, "expected=\n" + ExpectedKeyboardBuilder.toString(expectedKeyboard)); + Log.d(tag, "actual =\n" + ActualKeyboardBuilder.toString(actualKeyboard)); + // Test both keyboards have the same number of rows. + assertEquals(tag + " labels" + + "\nexpected=" + ExpectedKeyboardBuilder.toString(expectedKeyboard) + + "\nactual =" + ActualKeyboardBuilder.toString(actualKeyboard), + expectedKeyboard.length, actualKeyboard.length); + for (int r = 0; r < actualKeyboard.length; r++) { + final int row = r + 1; + // Test both keyboards' rows have the same number of columns. + assertEquals(tag + " labels row=" + row + + "\nexpected=" + Arrays.toString(expectedKeyboard[r]) + + "\nactual =" + ActualKeyboardBuilder.toString(actualKeyboard[r]), + expectedKeyboard[r].length, actualKeyboard[r].length); + for (int c = 0; c < actualKeyboard[r].length; c++) { + final int column = c + 1; + final Key actualKey = actualKeyboard[r][c]; + final ExpectedKey expectedKey = expectedKeyboard[r][c]; + // Test both keyboards' keys have the same visual outlook and key output. + assertTrue(tag + " labels row,column=" + row + "," + column + + "\nexpected=" + expectedKey + + "\nactual =" + ActualKeyboardBuilder.toString(actualKey), + expectedKey.equalsTo(actualKey)); + } + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsAfrikaans.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsAfrikaans.java new file mode 100644 index 000000000..8bc2b3dcc --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsAfrikaans.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.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", + "\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", "\u00FA", "\u00FB", "\u00FC", "\u00F9", "\u016B") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+0133: "ij" LATIN SMALL LIGATURE IJ + .setMoreKeysOf("y", "\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", + "\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", + "\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/org/kelar/inputmethod/keyboard/layout/tests/TestsArabic.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsArabic.java new file mode 100644 index 000000000..ae489eca3 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsArabic.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Arabic; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; + +import java.util.Locale; + +/** + * ar: Arabic/arabic + */ +@SmallTest +public class TestsArabic extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("ar"); + private static final LayoutBase LAYOUT = new Arabic(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsArmenianAMPhonetic.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsArmenianAMPhonetic.java new file mode 100644 index 000000000..bc5b6bfa1 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsArmenianAMPhonetic.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.ArmenianPhonetic; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; + +import java.util.Locale; + +/** + * hy_AM: Armenian (Armenia) Phonetic/armenian_phonetic + */ +@SmallTest +public final class TestsArmenianAMPhonetic extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("hy", "AM"); + private static final LayoutBase LAYOUT = new ArmenianPhonetic(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsAzerbaijaniAZ.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsAzerbaijaniAZ.java new file mode 100644 index 000000000..dabf419bb --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsAzerbaijaniAZ.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.TurkicCustomizer; + +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 TurkicCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBasqueES.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBasqueES.java new file mode 100644 index 000000000..8ca34122e --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBasqueES.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Spanish; +import org.kelar.inputmethod.keyboard.layout.customizer.EuroCustomizer; +import org.kelar.inputmethod.keyboard.layout.customizer.SpanishCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * eu_ES: Basque (Spain)/spanish + */ +@SmallTest +public class TestsBasqueES extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("eu", "ES"); + private static final LayoutBase LAYOUT = new Spanish(new BasqueESCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class BasqueESCustomizer extends EuroCustomizer { + private final SpanishCustomizer mSpanishCustomizer; + + BasqueESCustomizer(final Locale locale) { + super(locale); + mSpanishCustomizer = new SpanishCustomizer(locale); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return mSpanishCustomizer.setAccentedLetters(builder); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBelarusianBY.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBelarusianBY.java new file mode 100644 index 000000000..cc7f31994 --- /dev/null +++ b/tests/src/org/kelar/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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.EastSlavic; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.EastSlavicCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 { + 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", "\u0451") + // U+045E: "ў" CYRILLIC SMALL LETTER SHORT U + .replaceKeyOfLabel(EastSlavic.ROW1_9, key("\u045E", additionalMoreKey("9"))) + // U+044B: "ы" CYRILLIC SMALL LETTER YERU + .replaceKeyOfLabel(EastSlavic.ROW2_2, "\u044B") + // U+044D: "э" CYRILLIC SMALL LETTER E + .replaceKeyOfLabel(EastSlavic.ROW2_11, "\u044D") + // U+0456: "і" CYRILLIC SMALL LETTER BYELORUSSIAN-UKRAINIAN I + .replaceKeyOfLabel(EastSlavic.ROW3_5, "\u0456") + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN + .setMoreKeysOf("\u044C", "\u044A"); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBengaliBD.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBengaliBD.java new file mode 100644 index 000000000..af63d113a --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBengaliBD.java @@ -0,0 +1,60 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.BengaliAkkhor; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.BengaliCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +import java.util.Locale; + +/** + * bn_BD: Bengali (Bangladesh)/bengali_akkhor + */ +@SmallTest +public final class TestsBengaliBD extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("bn", "BD"); + private static final LayoutBase LAYOUT = new BengaliAkkhor(new BengaliBDCustomzier(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class BengaliBDCustomzier extends BengaliCustomizer { + BengaliBDCustomzier(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return isPhone ? EMPTY_KEYS : EXCLAMATION_AND_QUESTION_MARKS; + } + + @Override + public ExpectedKey[] getSpaceKeys(final boolean isPhone) { + return joinKeys(LANGUAGE_SWITCH_KEY, SPACE_KEY, key(ZWNJ_KEY, ZWJ_KEY)); + } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; } + + // U+09F3: "৳" BENGALI RUPEE SIGN + private static final ExpectedKey CURRENCY_RUPEE = key("\u09F3", + Symbols.CURRENCY_GENERIC_MORE_KEYS); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBengaliIN.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBengaliIN.java new file mode 100644 index 000000000..8a4570e01 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBengaliIN.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Bengali; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.BengaliCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +import java.util.Locale; + +/** + * bn_IN: Bengali (India)/bengali + */ +@SmallTest +public final class TestsBengaliIN extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("bn", "IN"); + private static final LayoutBase LAYOUT = new Bengali(new BengaliINCustomzier(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class BengaliINCustomzier extends BengaliCustomizer { + BengaliINCustomzier(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) { return EMPTY_KEYS; } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; } + + // U+20B9: "₹" INDIAN RUPEE SIGN + private static final ExpectedKey CURRENCY_RUPEE = key("\u20B9", + Symbols.CURRENCY_GENERIC_MORE_KEYS); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBulgarian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBulgarian.java new file mode 100644 index 000000000..9ce1906d1 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBulgarian.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Bulgarian; +import org.kelar.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(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBulgarianBds.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBulgarianBds.java new file mode 100644 index 000000000..651b5414c --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsBulgarianBds.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.BulgarianBds; +import org.kelar.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(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsCatalan.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsCatalan.java new file mode 100644 index 000000000..57515cb74 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsCatalan.java @@ -0,0 +1,122 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Spanish; +import org.kelar.inputmethod.keyboard.layout.customizer.EuroCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 EuroCustomizer { + CatalanCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { + return isPhone ? CATALAN_PHONE_PUNCTUATION_MORE_KEYS + : CATALAN_TABLET_PUNCTUATION_MORE_KEYS; + } + + // U+00B7: "·" MIDDLE DOT + private static final ExpectedKey[] CATALAN_PHONE_PUNCTUATION_MORE_KEYS = joinKeys( + ",", "?", "!", "\u00B7", "#", ")", "(", "/", ";", + "'", "@", ":", "-", "\"", "+", "%", "&"); + + private static final ExpectedKey[] CATALAN_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", + "\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", "\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", "\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", + "\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, "\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/org/kelar/inputmethod/keyboard/layout/tests/TestsCroatian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsCroatian.java new file mode 100644 index 000000000..ca96dc892 --- /dev/null +++ b/tests/src/org/kelar/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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwertz; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 { + 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", "\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/org/kelar/inputmethod/keyboard/layout/tests/TestsCzech.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsCzech.java new file mode 100644 index 000000000..2b7a5253a --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsCzech.java @@ -0,0 +1,133 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwertz; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 { + 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", + "\u00E9", "\u011B", "\u00E8", "\u00EA", "\u00EB", "\u0119", "\u0117", + "\u0113") + // U+0159: "ř" LATIN SMALL LETTER R WITH CARON + .setMoreKeysOf("r", "\u0159") + // U+0165: "ť" LATIN SMALL LETTER T WITH CARON + .setMoreKeysOf("t", "\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", "\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", "\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", "\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", + "\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/org/kelar/inputmethod/keyboard/layout/tests/TestsDanish.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDanish.java new file mode 100644 index 000000000..ca18e31f4 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDanish.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Nordic; +import org.kelar.inputmethod.keyboard.layout.customizer.DanishCustomizer; + +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; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDanishQwertz.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDanishQwertz.java new file mode 100644 index 000000000..019f5dc89 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDanishQwertz.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwertz; +import org.kelar.inputmethod.keyboard.layout.customizer.DanishCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * da: Danish/qwertz + */ +@SmallTest +public final class TestsDanishQwertz extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("da"); + private static final LayoutBase LAYOUT = new Qwertz(new DanishQwertyCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class DanishQwertyCustomizer extends DanishCustomizer { + DanishQwertyCustomizer(final Locale locale) { super(locale); } + + @Override + protected void setNordicKeys(final ExpectedKeyboardBuilder builder) { + // QWERTZ layout doesn't have Nordic keys. + } + + @Override + protected void setMoreKeysOfA(final ExpectedKeyboardBuilder builder) { + builder + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+00E6: "æ" LATIN SMALL LETTER AE + // 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", "\u00E5", "\u00E6", "\u00E1", "\u00E4", "\u00E0", "\u00E2", + "\u00E3", "\u0101"); + } + + @Override + protected void setMoreKeysOfO(final ExpectedKeyboardBuilder builder) { + builder + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // 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", "\u00F8", "\u00F6", "\u00F3", "\u00F4", "\u00F2", "\u00F5", + "\u0153", "\u014D"); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDutch.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDutch.java new file mode 100644 index 000000000..281cb1858 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDutch.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.DutchCustomizer; + +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; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDutchBE.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDutchBE.java new file mode 100644 index 000000000..9e66d6884 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDutchBE.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Azerty; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.customizer.DutchCustomizer; + +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 DutchCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDvorakEmail.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDvorakEmail.java new file mode 100644 index 000000000..72a093fb0 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDvorakEmail.java @@ -0,0 +1,94 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import android.text.InputType; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.KeyboardLayoutSet; +import org.kelar.inputmethod.keyboard.layout.Dvorak; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.customizer.DvorakCustomizer.EnglishDvorakCustomizer; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +import java.util.Locale; + +/** + * en_US: English (United States)/dvorak, email input field. + */ +@SmallTest +public class TestsDvorakEmail extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("en", "US"); + private static final LayoutBase LAYOUT = new DvorakEmail(new DvorakEmailCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + @Override + protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype, + final EditorInfo editorInfo, final boolean voiceInputKeyEnabled, + final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) { + final EditorInfo emailField = new EditorInfo(); + emailField.inputType = + InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; + return super.createKeyboardLayoutSet( + subtype, emailField, voiceInputKeyEnabled, languageSwitchKeyEnabled, + splitLayoutEnabled); + } + + private static class DvorakEmailCustomizer extends EnglishDvorakCustomizer { + DvorakEmailCustomizer(final Locale locale) { + super(locale); + } + + @Override + public ExpectedKey getEnterKey(final boolean isPhone) { + return isPhone ? ENTER_KEY : super.getEnterKey(isPhone); + } + + @Override + public ExpectedKey getEmojiKey(final boolean isPhone) { + return DOMAIN_KEY; + } + + @Override + public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) { + return isPhone ? super.getKeysLeftToSpacebar(isPhone) + : joinKeys(key("@", SETTINGS_KEY)); + } + } + + private static class DvorakEmail extends Dvorak { + DvorakEmail(final LayoutCustomizer customizer) { + super(customizer); + } + + @Override + protected ExpectedKey getRow1_1Key(final boolean isPhone, final int elementId) { + if (isPhone && (elementId == KeyboardId.ELEMENT_ALPHABET + || elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED)) { + return key("@", joinMoreKeys(additionalMoreKey("1"))); + } + return super.getRow1_1Key(isPhone, elementId); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDvorakUrl.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDvorakUrl.java new file mode 100644 index 000000000..e0d8989cf --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsDvorakUrl.java @@ -0,0 +1,90 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import android.text.InputType; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.KeyboardId; +import org.kelar.inputmethod.keyboard.KeyboardLayoutSet; +import org.kelar.inputmethod.keyboard.layout.Dvorak; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.customizer.DvorakCustomizer.EnglishDvorakCustomizer; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +import java.util.Locale; + +/** + * en_US: English (United States)/dvorak, URL input field. + */ +@SmallTest +public class TestsDvorakUrl extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("en", "US"); + private static final LayoutBase LAYOUT = new DvorakEmail(new DvorakUrlCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + @Override + protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype, + final EditorInfo editorInfo, final boolean voiceInputKeyEnabled, + final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) { + final EditorInfo emailField = new EditorInfo(); + emailField.inputType = + InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI; + return super.createKeyboardLayoutSet( + subtype, emailField, voiceInputKeyEnabled, languageSwitchKeyEnabled, + splitLayoutEnabled); + } + + private static class DvorakUrlCustomizer extends EnglishDvorakCustomizer { + DvorakUrlCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getEnterKey(final boolean isPhone) { + return isPhone ? ENTER_KEY : super.getEnterKey(isPhone); + } + + @Override + public ExpectedKey getEmojiKey(final boolean isPhone) { + return DOMAIN_KEY; + } + + @Override + public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) { + return isPhone ? super.getKeysLeftToSpacebar(isPhone) + : joinKeys(key("/", SETTINGS_KEY)); + } + } + + private static class DvorakEmail extends Dvorak { + DvorakEmail(final LayoutCustomizer customizer) { super(customizer); } + + @Override + protected ExpectedKey getRow1_1Key(final boolean isPhone, final int elementId) { + if (isPhone && (elementId == KeyboardId.ELEMENT_ALPHABET + || elementId == KeyboardId.ELEMENT_ALPHABET_AUTOMATIC_SHIFTED)) { + return key("/", joinMoreKeys(additionalMoreKey("1"))); + } + return super.getRow1_1Key(isPhone, elementId); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEnglishDvorak.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEnglishDvorak.java new file mode 100644 index 000000000..4ce4a4ecc --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEnglishDvorak.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Dvorak; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.customizer.DvorakCustomizer.EnglishDvorakCustomizer; + +import java.util.Locale; + +/** + * en_US: English (United States)/dvorak + */ +@SmallTest +public class TestsEnglishDvorak extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("en", "US"); + private static final LayoutBase LAYOUT = new Dvorak(new EnglishDvorakCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEnglishIN.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEnglishIN.java new file mode 100644 index 000000000..85c54b693 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEnglishIN.java @@ -0,0 +1,56 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.SymbolsShifted; +import org.kelar.inputmethod.keyboard.layout.customizer.EnglishCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +import java.util.Locale; + +/* + * en_IN: English (India)/qwerty + */ +@SmallTest +public final class TestsEnglishIN extends TestsEnglishUS { + private static final Locale LOCALE = new Locale("en", "IN"); + private static final LayoutBase LAYOUT = new Qwerty(new EnglishINCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class EnglishINCustomizer extends EnglishCustomizer { + EnglishINCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + // U+20B9: "₹" INDIAN RUPEE SIGN + private static final ExpectedKey CURRENCY_RUPEE = key("\u20B9", + Symbols.CURRENCY_GENERIC_MORE_KEYS); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEnglishUK.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEnglishUK.java new file mode 100644 index 000000000..648ca3879 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEnglishUK.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.EnglishCustomizer; +import org.kelar.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 EnglishCustomizer { + 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/org/kelar/inputmethod/keyboard/layout/tests/TestsEnglishUS.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEnglishUS.java new file mode 100644 index 000000000..72f57db8f --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEnglishUS.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.EnglishCustomizer; + +import java.util.Locale; + +/** + * en_US: English (United States)/qwerty + */ +@SmallTest +public class TestsEnglishUS extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("en", "US"); + private static final LayoutBase LAYOUT = new Qwerty(new EnglishCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEsperanto.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEsperanto.java new file mode 100644 index 000000000..de34b7a38 --- /dev/null +++ b/tests/src/org/kelar/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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Spanish; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.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 { + 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", joinMoreKeys( + additionalMoreKey("1"), "q"))) + // U+011D: "ĝ" LATIN SMALL LETTER G WITH CIRCUMFLEX + // U+0175: "ŵ" LATIN SMALL LETTER W WITH CIRCUMFLEX + .replaceKeyOfLabel("w", key("\u011D", joinMoreKeys( + additionalMoreKey("2"), "w", "\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", + "\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", "\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", "\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", joinMoreKeys( + additionalMoreKey("6"), "y", "\u00FD", "\u0177", "\u00FF", "\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", + "\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", + "\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", + "\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, "\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/org/kelar/inputmethod/keyboard/layout/tests/TestsEstonianEE.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEstonianEE.java new file mode 100644 index 000000000..2a0f636de --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEstonianEE.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Nordic; +import org.kelar.inputmethod.keyboard.layout.customizer.EstonianEECustomizer; + +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; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEstonianEEQwerty.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEstonianEEQwerty.java new file mode 100644 index 000000000..1727523da --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsEstonianEEQwerty.java @@ -0,0 +1,109 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.EstonianEECustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * et_EE: Estonian (Estonia)/qwerty + */ +@SmallTest +public final class TestsEstonianEEQwerty extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("et", "EE"); + private static final LayoutBase LAYOUT = new Qwerty(new EstonianEEQwertyCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class EstonianEEQwertyCustomizer extends EstonianEECustomizer { + EstonianEEQwertyCustomizer(final Locale locale) { super(locale); } + + @Override + protected void setNordicKeys(final ExpectedKeyboardBuilder builder) { + // QWERTY layout doesn't have Nordic keys. + } + + @Override + protected void setMoreKeysOfA(final ExpectedKeyboardBuilder builder) { + builder + // 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"); + } + + @Override + protected void setMoreKeysOfI(final ExpectedKeyboardBuilder builder, final int elementId) { + // TODO: The upper-case letter of "ı" in Estonian locale is "I". It should be omitted + // from the more keys of "I". + builder + // 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", + "\u012B", "\u00EC", "\u012F", "\u00ED", "\u00EE", "\u00EF", "\u0131"); + } + + @Override + protected void setMoreKeysOfO(final ExpectedKeyboardBuilder builder) { + builder + // 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", "\u00F6", "\u00F5", "\u00F2", "\u00F3", "\u00F4", "\u0153", + "\u0151", "\u00F8"); + } + + @Override + protected void setMoreKeysOfU(final ExpectedKeyboardBuilder builder) { + builder + // 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", "\u00FC", "\u016B", "\u0173", "\u00F9", "\u00FA", "\u00FB", + "\u016F", "\u0171"); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFinnish.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFinnish.java new file mode 100644 index 000000000..329c22ac8 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFinnish.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Nordic; +import org.kelar.inputmethod.keyboard.layout.customizer.FinnishCustomizer; + +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; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFinnishQwerty.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFinnishQwerty.java new file mode 100644 index 000000000..5aeade2dd --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFinnishQwerty.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.FinnishCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * fi: Finnish/qwerty + */ +@SmallTest +public final class TestsFinnishQwerty extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("fi"); + private static final LayoutBase LAYOUT = new Qwerty(new FinnishQwertyCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class FinnishQwertyCustomizer extends FinnishCustomizer { + FinnishQwertyCustomizer(final Locale locale) { super(locale); } + + @Override + protected void setNordicKeys(final ExpectedKeyboardBuilder builder) { + // QWERTY layout doesn't have Nordic keys. + } + + @Override + protected void setMoreKeysOfA(final ExpectedKeyboardBuilder builder) { + builder + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // 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", "\u00E4", "\u00E5", "\u00E6", "\u00E0", "\u00E1", "\u00E2", + "\u00E3", "\u0101"); + } + + @Override + protected void setMoreKeysOfO(final ExpectedKeyboardBuilder builder) { + builder + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // 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", "\u00F6", "\u00F8", "\u00F4", "\u00F2", "\u00F3", "\u00F5", + "\u0153", "\u014D"); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFrench.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFrench.java new file mode 100644 index 000000000..b8f5331b7 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFrench.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Azerty; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.customizer.FrenchCustomizer.FrenchEuroCustomizer; + +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 FrenchEuroCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFrenchCA.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFrenchCA.java new file mode 100644 index 000000000..59092d344 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFrenchCA.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.FrenchCustomizer; + +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 FrenchCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFrenchCH.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFrenchCH.java new file mode 100644 index 000000000..1bd896cae --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFrenchCH.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Swiss; +import org.kelar.inputmethod.keyboard.layout.customizer.FrenchCustomizer; +import org.kelar.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 FrenchCustomizer { + FrenchCHCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + super.setAccentedLetters(builder); + return builder + // 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+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"))); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFrenchDvorak.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFrenchDvorak.java new file mode 100644 index 000000000..2d04239b3 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFrenchDvorak.java @@ -0,0 +1,62 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Dvorak; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.customizer.DvorakCustomizer; +import org.kelar.inputmethod.keyboard.layout.customizer.FrenchCustomizer.FrenchEuroCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * fr: French/dvorak + */ +@SmallTest +public final class TestsFrenchDvorak extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("fr"); + private static final LayoutBase LAYOUT = new Dvorak(new FrenchDvorakCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class FrenchDvorakCustomizer extends DvorakCustomizer { + private final FrenchEuroCustomizer mFrenchEuroCustomizer; + + FrenchDvorakCustomizer(final Locale locale) { + super(locale); + mFrenchEuroCustomizer = new FrenchEuroCustomizer(locale); + } + + @Override + public ExpectedKey getCurrencyKey() { return mFrenchEuroCustomizer.getCurrencyKey(); } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return mFrenchEuroCustomizer.getOtherCurrencyKeys(); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return mFrenchEuroCustomizer.setAccentedLetters(builder); + } + } +}
\ No newline at end of file diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFrenchQwertz.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFrenchQwertz.java new file mode 100644 index 000000000..a6ab73174 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsFrenchQwertz.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwertz; +import org.kelar.inputmethod.keyboard.layout.customizer.FrenchCustomizer.FrenchEuroCustomizer; + +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 FrenchEuroCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGalicianES.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGalicianES.java new file mode 100644 index 000000000..6c7a0e1e4 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGalicianES.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Spanish; +import org.kelar.inputmethod.keyboard.layout.customizer.EuroCustomizer; +import org.kelar.inputmethod.keyboard.layout.customizer.SpanishCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * gl_ES: Galician (Spain)/spanish + */ +@SmallTest +public class TestsGalicianES extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("gl", "ES"); + private static final LayoutBase LAYOUT = new Spanish(new GalicianESCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class GalicianESCustomizer extends EuroCustomizer { + private final SpanishCustomizer mSpanishCustomizer; + + GalicianESCustomizer(final Locale locale) { + super(locale); + mSpanishCustomizer = new SpanishCustomizer(locale); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return mSpanishCustomizer.setAccentedLetters(builder); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGeorgianGE.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGeorgianGE.java new file mode 100644 index 000000000..db278e91e --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGeorgianGE.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Georgian; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; + +import java.util.Locale; + +/** + * ka_GE: Georgian (Georgia)/georgian + */ +@SmallTest +public final class TestsGeorgianGE extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("ka", "GE"); + private static final LayoutBase LAYOUT = new Georgian(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGerman.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGerman.java new file mode 100644 index 000000000..dc4c65e2c --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGerman.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwertz; +import org.kelar.inputmethod.keyboard.layout.customizer.GermanCustomizer.GermanEuroCustomizer; + +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 GermanEuroCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGermanCH.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGermanCH.java new file mode 100644 index 000000000..756c7a77c --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGermanCH.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Swiss; +import org.kelar.inputmethod.keyboard.layout.customizer.GermanCustomizer; +import org.kelar.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 GermanCustomizer { + GermanCHCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + super.setAccentedLetters(builder); + return builder + // 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+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"))); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGermanDvorak.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGermanDvorak.java new file mode 100644 index 000000000..0da8eb4ef --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGermanDvorak.java @@ -0,0 +1,76 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Dvorak; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.SymbolsShifted; +import org.kelar.inputmethod.keyboard.layout.customizer.DvorakCustomizer; +import org.kelar.inputmethod.keyboard.layout.customizer.GermanCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * de: German/dvorak + */ +@SmallTest +public final class TestsGermanDvorak extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("de"); + private static final LayoutBase LAYOUT = new Dvorak(new GermanDvorakCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class GermanDvorakCustomizer extends DvorakCustomizer { + private final GermanCustomizer mGermanCustomizer; + + GermanDvorakCustomizer(final Locale locale) { + super(locale); + mGermanCustomizer = new GermanCustomizer(locale); + } + + @Override + public ExpectedKey getCurrencyKey() { return Symbols.CURRENCY_EURO; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_THAN_EURO; + } + + @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 mGermanCustomizer.setAccentedLetters(builder); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGermanQwerty.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGermanQwerty.java new file mode 100644 index 000000000..33bf2df25 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGermanQwerty.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.GermanCustomizer.GermanEuroCustomizer; + +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 GermanEuroCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGreek.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGreek.java new file mode 100644 index 000000000..5c8e8e6d1 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsGreek.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Greek; +import org.kelar.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(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsHebrew.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsHebrew.java new file mode 100644 index 000000000..eb31e4e12 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsHebrew.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Hebrew; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; + +import java.util.Locale; + +/** + * iw: Hebrew/hebrew + */ +@SmallTest +public class TestsHebrew extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("iw"); + private static final LayoutBase LAYOUT = new Hebrew(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsHindi.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsHindi.java new file mode 100644 index 000000000..b67cf0f1c --- /dev/null +++ b/tests/src/org/kelar/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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Hindi; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.customizer.HindiCustomizer; + +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/org/kelar/inputmethod/keyboard/layout/tests/TestsHindiCompact.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsHindiCompact.java new file mode 100644 index 000000000..a70cf7c6f --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsHindiCompact.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.HindiCompact; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; + +import java.util.Locale; + +/** + * hi: Hindi/hindi_compact + */ +@SmallTest +public final class TestsHindiCompact extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("hi"); + private static final LayoutBase LAYOUT = new HindiCompact(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsHinglish.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsHinglish.java new file mode 100644 index 000000000..7b6563001 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsHinglish.java @@ -0,0 +1,56 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.Suppress; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.SymbolsShifted; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +import java.util.Locale; + +/* + * hi_ZZ: Hinglish/qwerty + */ +@Suppress +public final class TestsHinglish extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("hi", "ZZ"); + private static final LayoutBase LAYOUT = new Qwerty(new HinglishCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class HinglishCustomizer extends LayoutCustomizer { + HinglishCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + // U+20B9: "₹" INDIAN RUPEE SIGN + private static final ExpectedKey CURRENCY_RUPEE = key("\u20B9", + Symbols.CURRENCY_GENERIC_MORE_KEYS); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsHungarian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsHungarian.java new file mode 100644 index 000000000..f3536e122 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsHungarian.java @@ -0,0 +1,107 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwertz; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 { + 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", + "\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", "\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", "\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", + "\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/org/kelar/inputmethod/keyboard/layout/tests/TestsIcelandic.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsIcelandic.java new file mode 100644 index 000000000..76a039f87 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsIcelandic.java @@ -0,0 +1,106 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 { + 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", + "\u00E9", "\u00EB", "\u00E8", "\u00EA", "\u0119", "\u0117", "\u0113") + // U+00FE: "þ" LATIN SMALL LETTER THORN + .setMoreKeysOf("t", "\u00FE") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "\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", "\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", "\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", + "\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/org/kelar/inputmethod/keyboard/layout/tests/TestsIndonesian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsIndonesian.java new file mode 100644 index 000000000..0c122fddd --- /dev/null +++ b/tests/src/org/kelar/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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; + +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/org/kelar/inputmethod/keyboard/layout/tests/TestsItalian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsItalian.java new file mode 100644 index 000000000..4f727f140 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsItalian.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.EuroCustomizer; +import org.kelar.inputmethod.keyboard.layout.customizer.ItalianCustomizer; +import org.kelar.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 ItalianITCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class ItalianITCustomizer extends EuroCustomizer { + private final ItalianCustomizer mItalianCustomizer; + + ItalianITCustomizer(final Locale locale) { + super(locale); + mItalianCustomizer = new ItalianCustomizer(locale); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return mItalianCustomizer.setAccentedLetters(builder); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsItalianCH.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsItalianCH.java new file mode 100644 index 000000000..ff7c04620 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsItalianCH.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Swiss; +import org.kelar.inputmethod.keyboard.layout.customizer.ItalianCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * it_CH: Italian (Switzerland)/swiss + */ +@SmallTest +public final class TestsItalianCH extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("it", "CH"); + private static final LayoutBase LAYOUT = new Swiss(new ItalianCHCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class ItalianCHCustomizer extends ItalianCustomizer { + ItalianCHCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + super.setAccentedLetters(builder); + return builder + // 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+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"))); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsKannadaIN.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsKannadaIN.java new file mode 100644 index 000000000..3f5169444 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsKannadaIN.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Kannada; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; + +import java.util.Locale; + +/** + * kn_IN: Kannada (India)/kannada + */ +@SmallTest +public final class TestsKannadaIN extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("kn", "IN"); + private static final LayoutBase LAYOUT = new Kannada(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsKazakh.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsKazakh.java new file mode 100644 index 000000000..92797d005 --- /dev/null +++ b/tests/src/org/kelar/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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.EastSlavic; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.customizer.EastSlavicCustomizer; +import org.kelar.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 { + 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", "\u04AF", "\u04B1") + // U+043A: "к" CYRILLIC SMALL LETTER KA + // U+049B: "қ" CYRILLIC SMALL LETTER KA WITH DESCENDER + .setMoreKeysOf("\u043A", "\u049B") + // U+0435: "е" CYRILLIC SMALL LETTER IE + // U+0451: "ё" CYRILLIC SMALL LETTER IO + .setMoreKeysOf("\u0435", "\u0451") + // U+043D: "н" CYRILLIC SMALL LETTER EN + // U+04A3: "ң" CYRILLIC SMALL LETTER EN WITH DESCENDER + .setMoreKeysOf("\u043D", "\u04A3") + // U+0433: "г" CYRILLIC SMALL LETTER GHE + // U+0493: "ғ" CYRILLIC SMALL LETTER GHE WITH STROKE + .setMoreKeysOf("\u0433", "\u0493") + // U+0449: "щ" CYRILLIC SMALL LETTER SHCHA + .replaceKeyOfLabel(EastSlavic.ROW1_9, key("\u0449", additionalMoreKey("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, "\u0438") + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN + .setMoreKeysOf("\u044C", "\u044A"); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsKhmerKH.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsKhmerKH.java new file mode 100644 index 000000000..9e28a1bf2 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsKhmerKH.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Khmer; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; + +import java.util.Locale; + +/** + * km_KH: Khmer (Cambodia)/khmer + */ +@SmallTest +public final class TestsKhmerKH extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("km", "KH"); + private static final LayoutBase LAYOUT = new Khmer(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsKyrgyz.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsKyrgyz.java new file mode 100644 index 000000000..a60801cb5 --- /dev/null +++ b/tests/src/org/kelar/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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.EastSlavic; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.customizer.EastSlavicCustomizer; +import org.kelar.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 { + 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", "\u04AF") + // U+0435: "е" CYRILLIC SMALL LETTER IE + // U+0451: "ё" CYRILLIC SMALL LETTER IO + .setMoreKeysOf("\u0435", "\u0451") + // U+043D: "н" CYRILLIC SMALL LETTER EN + // U+04A3: "ң" CYRILLIC SMALL LETTER EN WITH DESCENDER + .setMoreKeysOf("\u043D", "\u04A3") + // U+0449: "щ" CYRILLIC SMALL LETTER SHCHA + .replaceKeyOfLabel(EastSlavic.ROW1_9, key("\u0449", additionalMoreKey("9"))) + // U+044B: "ы" CYRILLIC SMALL LETTER YERU + .replaceKeyOfLabel(EastSlavic.ROW2_2, "\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, "\u044D") + // U+0438: "и" CYRILLIC SMALL LETTER I + .replaceKeyOfLabel(EastSlavic.ROW3_5, "\u0438") + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN + .setMoreKeysOf("\u044C", "\u044A"); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsLaoLA.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsLaoLA.java new file mode 100644 index 000000000..b6d06baf3 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsLaoLA.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Lao; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; + +import java.util.Locale; + +/** + * lo_LA: Lao (Laos)/lao + */ +@SmallTest +public final class TestsLaoLA extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("lo", "LA"); + private static final LayoutBase LAYOUT = new Lao(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsLatvian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsLatvian.java new file mode 100644 index 000000000..873a42ec5 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsLatvian.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 { + 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", + "\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", "\u0157", "\u0159", "\u0155") + // U+0163: "ţ" LATIN SMALL LETTER T WITH CEDILLA + // U+0165: "ť" LATIN SMALL LETTER T WITH CARON + .setMoreKeysOf("t", "\u0163", "\u0165") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "\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", + "\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", + "\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", + "\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/org/kelar/inputmethod/keyboard/layout/tests/TestsLithuanian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsLithuanian.java new file mode 100644 index 000000000..6c9797ccb --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsLithuanian.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 { + 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", + "\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", "\u0157", "\u0159", "\u0155") + // U+0163: "ţ" LATIN SMALL LETTER T WITH CEDILLA + // U+0165: "ť" LATIN SMALL LETTER T WITH CARON + .setMoreKeysOf("t", "\u0163", "\u0165") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "\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", + "\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", + "\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", + "\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/org/kelar/inputmethod/keyboard/layout/tests/TestsMacedonian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsMacedonian.java new file mode 100644 index 000000000..5970c15e5 --- /dev/null +++ b/tests/src/org/kelar/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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.SouthSlavic; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.SouthSlavicLayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 { + 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", "\u0450") + // U+0455: "ѕ" CYRILLIC SMALL LETTER DZE + .replaceKeyOfLabel(SouthSlavic.ROW1_6, key("\u0455", additionalMoreKey("6"))) + // U+0438: "и" CYRILLIC SMALL LETTER I + // U+045D: "ѝ" CYRILLIC SMALL LETTER I WITH GRAVE + .setMoreKeysOf("\u0438", "\u045D") + // U+045C: "ќ" CYRILLIC SMALL LETTER KJE + .replaceKeyOfLabel(SouthSlavic.ROW2_11, "\u045C") + // U+0437: "з" CYRILLIC SMALL LETTER ZE + .replaceKeyOfLabel(SouthSlavic.ROW3_1, "\u0437") + // U+0453: "ѓ" CYRILLIC SMALL LETTER GJE + .replaceKeyOfLabel(SouthSlavic.ROW3_8, "\u0453"); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsMalayMY.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsMalayMY.java new file mode 100644 index 000000000..6aa2a13ea --- /dev/null +++ b/tests/src/org/kelar/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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; + +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/org/kelar/inputmethod/keyboard/layout/tests/TestsMalayalamIN.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsMalayalamIN.java new file mode 100644 index 000000000..4ab784650 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsMalayalamIN.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Malayalam; + +import java.util.Locale; + +/** + * ml_IN: Malayalam (India)/malayalam + */ +@SmallTest +public final class TestsMalayalamIN extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("ml", "IN"); + private static final LayoutBase LAYOUT = new Malayalam(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsMarathiIN.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsMarathiIN.java new file mode 100644 index 000000000..e0ff90742 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsMarathiIN.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Marathi; + +import java.util.Locale; + +/** + * mr_IN: Marathi (India)/marathi + */ +@SmallTest +public final class TestsMarathiIN extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("mr", "IN"); + private static final LayoutBase LAYOUT = new Marathi(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsMongolianMN.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsMongolianMN.java new file mode 100644 index 000000000..0c94f6ec9 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsMongolianMN.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Mongolian; + +import java.util.Locale; + +/** + * mn_MN: Mongolian (Mongolia)/mongolian + */ +@SmallTest +public final class TestsMongolianMN extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("mn", "MN"); + private static final LayoutBase LAYOUT = new Mongolian(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNepaliRomanized.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNepaliRomanized.java new file mode 100644 index 000000000..ae57bec7a --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNepaliRomanized.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.NepaliRomanized; + +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(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNepaliTraditional.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNepaliTraditional.java new file mode 100644 index 000000000..17dee2b61 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNepaliTraditional.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.NepaliTraditional; + +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(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNoLanguage.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNoLanguage.java new file mode 100644 index 000000000..09953ceed --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNoLanguage.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.NoLanguageCustomizer; + +import java.util.Locale; + +/** + * zz: Alphabet/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; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNoLanguageColemak.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNoLanguageColemak.java new file mode 100644 index 000000000..25577eb92 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNoLanguageColemak.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Colemak; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.customizer.NoLanguageCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * zz: Alphabet/colemak + */ +@SmallTest +public final class TestsNoLanguageColemak extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("zz"); + private static final LayoutBase LAYOUT = new Colemak(new NoLanguageColemakCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class NoLanguageColemakCustomizer extends LayoutCustomizer { + private final NoLanguageCustomizer mNoLanguageCustomizer; + + NoLanguageColemakCustomizer(final Locale locale) { + super(locale); + mNoLanguageCustomizer = new NoLanguageCustomizer(locale); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return mNoLanguageCustomizer.setAccentedLetters(builder); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNoLanguageDvorak.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNoLanguageDvorak.java new file mode 100644 index 000000000..078f2a231 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNoLanguageDvorak.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Dvorak; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.customizer.DvorakCustomizer; +import org.kelar.inputmethod.keyboard.layout.customizer.NoLanguageCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * zz: Alphabet/dvorak + */ +@SmallTest +public final class TestsNoLanguageDvorak extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("zz"); + private static final LayoutBase LAYOUT = new Dvorak(new NoLanguageDvorakCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class NoLanguageDvorakCustomizer extends DvorakCustomizer { + private final NoLanguageCustomizer mNoLanguageCustomizer; + + NoLanguageDvorakCustomizer(final Locale locale) { + super(locale); + mNoLanguageCustomizer = new NoLanguageCustomizer(locale); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return mNoLanguageCustomizer.setAccentedLetters(builder); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNoLanguagePcQwerty.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNoLanguagePcQwerty.java new file mode 100644 index 000000000..ac5b5b571 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNoLanguagePcQwerty.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.PcQwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.NoLanguageCustomizer; +import org.kelar.inputmethod.keyboard.layout.customizer.PcQwertyCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * zz: Alphabet/pcqwerty + */ +@SmallTest +public final class TestsNoLanguagePcQwerty extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("zz"); + private static final LayoutBase LAYOUT = new PcQwerty(new NoLanguagePcQwertyCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class NoLanguagePcQwertyCustomizer extends PcQwertyCustomizer { + private final NoLanguageCustomizer mNoLanguageCustomizer; + + NoLanguagePcQwertyCustomizer(final Locale locale) { + super(locale); + mNoLanguageCustomizer = new NoLanguageCustomizer(locale); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return mNoLanguageCustomizer.setAccentedLetters(builder); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNorwegian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNorwegian.java new file mode 100644 index 000000000..077af6daa --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNorwegian.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Nordic; +import org.kelar.inputmethod.keyboard.layout.customizer.NorwegianCustomizer; + +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; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNorwegianColemak.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNorwegianColemak.java new file mode 100644 index 000000000..10214573a --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsNorwegianColemak.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Colemak; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.customizer.NorwegianCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * nb: Norwegian Bokmål/colemak + */ +@SmallTest +public final class TestsNorwegianColemak extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("nb"); + private static final LayoutBase LAYOUT = new Colemak(new NorwegianColemakCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class NorwegianColemakCustomizer extends NorwegianCustomizer { + NorwegianColemakCustomizer(final Locale locale) { super(locale); } + + @Override + protected void setNordicKeys(final ExpectedKeyboardBuilder builder) { + // Colemak layout doesn't have Nordic keys. + } + + @Override + protected void setMoreKeysOfA(final ExpectedKeyboardBuilder builder) { + builder + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // 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", "\u00E5", "\u00E6", "\u00E4", "\u00E0", "\u00E1", "\u00E2", + "\u00E3", "\u0101"); + } + + @Override + protected void setMoreKeysOfO(final ExpectedKeyboardBuilder builder) { + builder + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // 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+014D: "ō" LATIN SMALL LETTER O WITH MACRON + .setMoreKeysOf("o", "\u00F8", "\u00F6", "\u00F4", "\u00F2", "\u00F3", "\u00F5", + "\u0153", "\u014D"); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsPersian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsPersian.java new file mode 100644 index 000000000..fb45a264e --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsPersian.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.Farsi; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; + +import java.util.Locale; + +/** + * fa: Persian/farsi + */ +@SmallTest +public class TestsPersian extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("fa"); + private static final LayoutBase LAYOUT = new Farsi(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsPolish.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsPolish.java new file mode 100644 index 000000000..e9fb37354 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsPolish.java @@ -0,0 +1,104 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 { + 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", + "\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", + "\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/org/kelar/inputmethod/keyboard/layout/tests/TestsPortugueseBR.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsPortugueseBR.java new file mode 100644 index 000000000..9dc5f2cf6 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsPortugueseBR.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.PortugueseCustomizer; + +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 PortugueseCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsPortuguesePT.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsPortuguesePT.java new file mode 100644 index 000000000..44c0afa30 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsPortuguesePT.java @@ -0,0 +1,56 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.EuroCustomizer; +import org.kelar.inputmethod.keyboard.layout.customizer.PortugueseCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +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 PortugueseCustomizer { + private final EuroCustomizer mEuroCustomizer; + + PortuguesePTCustomizer(final Locale locale) { + super(locale); + mEuroCustomizer = new EuroCustomizer(locale); + } + + @Override + public ExpectedKey getCurrencyKey() { return mEuroCustomizer.getCurrencyKey(); } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return mEuroCustomizer.getOtherCurrencyKeys(); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsQwertyEmail.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsQwertyEmail.java new file mode 100644 index 000000000..a30dccaed --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsQwertyEmail.java @@ -0,0 +1,74 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import android.text.InputType; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.KeyboardLayoutSet; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.EnglishCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +import java.util.Locale; + +/** + * en_US: English (United States)/qwerty, email input field. + */ +@SmallTest +public class TestsQwertyEmail extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("en", "US"); + private static final LayoutBase LAYOUT = new Qwerty(new EnglishEmailCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + @Override + protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype, + final EditorInfo editorInfo, final boolean voiceInputKeyEnabled, + final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) { + final EditorInfo emailField = new EditorInfo(); + emailField.inputType = + InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS; + return super.createKeyboardLayoutSet( + subtype, emailField, voiceInputKeyEnabled, languageSwitchKeyEnabled, + splitLayoutEnabled); + } + + private static class EnglishEmailCustomizer extends EnglishCustomizer { + EnglishEmailCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getEnterKey(final boolean isPhone) { + return isPhone ? ENTER_KEY : super.getEnterKey(isPhone); + } + + @Override + public ExpectedKey getEmojiKey(final boolean isPhone) { + return DOMAIN_KEY; + } + + @Override + public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) { + return joinKeys(key("@", SETTINGS_KEY)); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsQwertyUrl.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsQwertyUrl.java new file mode 100644 index 000000000..8e9897df0 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsQwertyUrl.java @@ -0,0 +1,74 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import android.text.InputType; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.KeyboardLayoutSet; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.EnglishCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +import java.util.Locale; + +/** + * en_US: English (United States)/qwerty, URL input field. + */ +@SmallTest +public class TestsQwertyUrl extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("en", "US"); + private static final LayoutBase LAYOUT = new Qwerty(new EnglishUrlCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + @Override + protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype, + final EditorInfo editorInfo, final boolean voiceInputKeyEnabled, + final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) { + final EditorInfo emailField = new EditorInfo(); + emailField.inputType = + InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI; + return super.createKeyboardLayoutSet( + subtype, emailField, voiceInputKeyEnabled, languageSwitchKeyEnabled, + splitLayoutEnabled); + } + + private static class EnglishUrlCustomizer extends EnglishCustomizer { + EnglishUrlCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getEnterKey(final boolean isPhone) { + return isPhone ? ENTER_KEY : super.getEnterKey(isPhone); + } + + @Override + public ExpectedKey getEmojiKey(final boolean isPhone) { + return DOMAIN_KEY; + } + + @Override + public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) { + return joinKeys(key("/", SETTINGS_KEY)); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsRomanian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsRomanian.java new file mode 100644 index 000000000..fed99b1d9 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsRomanian.java @@ -0,0 +1,81 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 { + 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", "\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", "\u00EE", "\u00EF", "\u00EC", "\u00ED", "\u012F", "\u012B") + // U+0103: "ă" LATIN SMALL LETTER A WITH BREVE + // U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX + // U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE + // 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", + "\u0103", "\u00E2", "\u00E3", "\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/org/kelar/inputmethod/keyboard/layout/tests/TestsRussian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsRussian.java new file mode 100644 index 000000000..57f2d7bd0 --- /dev/null +++ b/tests/src/org/kelar/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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.EastSlavic; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.EastSlavicCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 { + 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", "\u0451") + // U+0449: "щ" CYRILLIC SMALL LETTER SHCHA + .replaceKeyOfLabel(EastSlavic.ROW1_9, key("\u0449", additionalMoreKey("9"))) + // U+044B: "ы" CYRILLIC SMALL LETTER YERU + .replaceKeyOfLabel(EastSlavic.ROW2_2, "\u044B") + // U+044D: "э" CYRILLIC SMALL LETTER E + .replaceKeyOfLabel(EastSlavic.ROW2_11, "\u044D") + // U+0438: "и" CYRILLIC SMALL LETTER I + .replaceKeyOfLabel(EastSlavic.ROW3_5, "\u0438") + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN + .setMoreKeysOf("\u044C", "\u044A"); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSerbian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSerbian.java new file mode 100644 index 000000000..cfbbcd9e1 --- /dev/null +++ b/tests/src/org/kelar/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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.SouthSlavic; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.SouthSlavicLayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 { + 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", "\u0450") + // U+0437: "з" CYRILLIC SMALL LETTER ZE + .replaceKeyOfLabel(SouthSlavic.ROW1_6, key("\u0437", additionalMoreKey("6"))) + // U+0438: "и" CYRILLIC SMALL LETTER I + // U+045D: "ѝ" CYRILLIC SMALL LETTER I WITH GRAVE + .setMoreKeysOf("\u0438", "\u045D") + // U+045B: "ћ" CYRILLIC SMALL LETTER TSHE + .replaceKeyOfLabel(SouthSlavic.ROW2_11, "\u045B") + // U+0455: "ѕ" CYRILLIC SMALL LETTER DZE + .replaceKeyOfLabel(SouthSlavic.ROW3_1, "\u0455") + // U+0452: "ђ" CYRILLIC SMALL LETTER DJE + .replaceKeyOfLabel(SouthSlavic.ROW3_8, "\u0452"); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSerbianLatin.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSerbianLatin.java new file mode 100644 index 000000000..facef7aa8 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSerbianLatin.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.SerbianQwertz; +import org.kelar.inputmethod.keyboard.layout.customizer.SerbianLatinCustomizer; + +import java.util.Locale; + +/** + * sr_ZZ: Serbian (Latin)/serbian_qwertz + */ +@SmallTest +public final class TestsSerbianLatin extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("sr", "ZZ"); + private static final LayoutBase LAYOUT = new SerbianQwertz(new SerbianLatinCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSerbianLatinQwerty.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSerbianLatinQwerty.java new file mode 100644 index 000000000..c4b9f5595 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSerbianLatinQwerty.java @@ -0,0 +1,87 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.SerbianLatinCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * sr_ZZ: Serbian (Latin)/qwerty + */ +@SmallTest +public final class TestsSerbianLatinQwerty extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("sr", "ZZ"); + private static final LayoutBase LAYOUT = new Qwerty(new SerbianLatinQwertyCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class SerbianLatinQwertyCustomizer extends SerbianLatinCustomizer { + SerbianLatinQwertyCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return isPhone ? EMPTY_KEYS + : joinKeys(EXCLAMATION_AND_QUESTION_MARKS, SHIFT_KEY); + } + + @Override + protected void setSerbianKeys(final ExpectedKeyboardBuilder builder) { + // QWERTY layout doesn't have Serbian Latin Keys. + } + + @Override + protected void setMoreKeysOfS(final ExpectedKeyboardBuilder builder) { + builder + // U+0161: "š" LATIN SMALL LETTER S WITH CARON + .setMoreKeysOf("s", "\u0161") + .setAdditionalMoreKeysPositionOf("s", 2); + } + + @Override + protected void setMoreKeysOfC(final ExpectedKeyboardBuilder builder) { + builder + // U+010D: "č" LATIN SMALL LETTER C WITH CARON + // U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE + .setMoreKeysOf("c", "\u010D", "\u0107") + .setAdditionalMoreKeysPositionOf("c", 3); + } + + @Override + protected void setMoreKeysOfD(final ExpectedKeyboardBuilder builder) { + builder + // U+0111: "đ" LATIN SMALL LETTER D WITH STROKE + .setMoreKeysOf("d", "\u0111") + .setAdditionalMoreKeysPositionOf("d", 2); + } + + @Override + protected void setMoreKeysOfZ(final ExpectedKeyboardBuilder builder) { + builder + // U+017E: "ž" LATIN SMALL LETTER Z WITH CARON + .setMoreKeysOf("z", "\u017E") + .setAdditionalMoreKeysPositionOf("z", 2); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSinhalaLK.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSinhalaLK.java new file mode 100644 index 000000000..c615f3bde --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSinhalaLK.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.Suppress; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Sinhala; + +import java.util.Locale; + +/** + * si_LK: Sinhala (Sri Lanka)/sinhala + */ +@Suppress +public final class TestsSinhalaLK extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("si", "LK"); + private static final LayoutBase LAYOUT = new Sinhala(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSlovak.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSlovak.java new file mode 100644 index 000000000..83ce1874d --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSlovak.java @@ -0,0 +1,155 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.EuroCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 EuroCustomizer { + 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", + "\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", "\u0155", "\u0159", "\u0157") + // U+0165: "ť" LATIN SMALL LETTER T WITH CARON + // U+0163: "ţ" LATIN SMALL LETTER T WITH CEDILLA + .setMoreKeysOf("t", "\u0165", "\u0163") + // U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE + // U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS + .setMoreKeysOf("y", "\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", + "\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", + "\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", + "\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/org/kelar/inputmethod/keyboard/layout/tests/TestsSlovenian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSlovenian.java new file mode 100644 index 000000000..6c7a4e7f2 --- /dev/null +++ b/tests/src/org/kelar/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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.customizer.EuroCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 EuroCustomizer { + 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/org/kelar/inputmethod/keyboard/layout/tests/TestsSpanish.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSpanish.java new file mode 100644 index 000000000..6ce6f22c0 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSpanish.java @@ -0,0 +1,56 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Spanish; +import org.kelar.inputmethod.keyboard.layout.customizer.EuroCustomizer; +import org.kelar.inputmethod.keyboard.layout.customizer.SpanishCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +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 SpanishCustomizer { + private final EuroCustomizer mEuroCustomizer; + + SpanishESCustomizer(final Locale locale) { + super(locale); + mEuroCustomizer = new EuroCustomizer(locale); + } + + @Override + public ExpectedKey getCurrencyKey() { return mEuroCustomizer.getCurrencyKey(); } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return mEuroCustomizer.getOtherCurrencyKeys(); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSpanish419.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSpanish419.java new file mode 100644 index 000000000..f37ad0052 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSpanish419.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Spanish; +import org.kelar.inputmethod.keyboard.layout.customizer.SpanishCustomizer; + +import java.util.Locale; + +/** + * es_419: Spanish (Latin America)/spanish + */ +@SmallTest +public class TestsSpanish419 extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("es", "419"); + private static final LayoutBase LAYOUT = new Spanish(new SpanishCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSpanishUS.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSpanishUS.java new file mode 100644 index 000000000..eb9d80bdf --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSpanishUS.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Spanish; +import org.kelar.inputmethod.keyboard.layout.customizer.SpanishCustomizer; + +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 SpanishCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSplitLayoutQwertyEnglishUS.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSplitLayoutQwertyEnglishUS.java new file mode 100644 index 000000000..75385f643 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSplitLayoutQwertyEnglishUS.java @@ -0,0 +1,62 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.KeyboardLayoutSet; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.EnglishCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +import java.util.Locale; + +/** + * en_US: English (United States)/qwerty - split layout + */ +@SmallTest +public class TestsSplitLayoutQwertyEnglishUS extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("en", "US"); + private static final LayoutBase LAYOUT = new Qwerty(new EnglishSplitCustomizer(LOCALE)); + + @Override + protected KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype, + final EditorInfo editorInfo, final boolean voiceInputKeyEnabled, + final boolean languageSwitchKeyEnabled, final boolean splitLayoutEnabled) { + return super.createKeyboardLayoutSet(subtype, editorInfo, voiceInputKeyEnabled, + languageSwitchKeyEnabled, true /* splitLayoutEnabled */); + } + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class EnglishSplitCustomizer extends EnglishCustomizer { + EnglishSplitCustomizer(Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getSpaceKeys(final boolean isPhone) { + if (isPhone) { + return super.getSpaceKeys(isPhone); + } + return joinKeys(LANGUAGE_SWITCH_KEY, SPACE_KEY, SPACE_KEY); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSwahili.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSwahili.java new file mode 100644 index 000000000..1ef382572 --- /dev/null +++ b/tests/src/org/kelar/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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.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 { + 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", "\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", "\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", "\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", + "\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/org/kelar/inputmethod/keyboard/layout/tests/TestsSwedish.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSwedish.java new file mode 100644 index 000000000..faf9be6dc --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSwedish.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Nordic; +import org.kelar.inputmethod.keyboard.layout.customizer.SwedishCustomizer; + +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; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSwedishPcQwerty.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSwedishPcQwerty.java new file mode 100644 index 000000000..b1cb06d60 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsSwedishPcQwerty.java @@ -0,0 +1,121 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.PcQwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.customizer.PcQwertyCustomizer; +import org.kelar.inputmethod.keyboard.layout.customizer.SwedishCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * sv: Swedish/pcqwerty + */ +@SmallTest +public final class TestsSwedishPcQwerty extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("sv"); + private static final LayoutBase LAYOUT = new PcQwerty(new SwedishPcQwertyCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class SwedishPcQwertyCustomizer extends SwedishCustomizer { + private final LayoutCustomizer mPcQwertyCustomizer; + + SwedishPcQwertyCustomizer(final Locale locale) { + super(locale); + mPcQwertyCustomizer = new PcQwertyCustomizer(locale); + } + + @Override + public ExpectedKey getCurrencyKey() { + return mPcQwertyCustomizer.getCurrencyKey(); + } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return mPcQwertyCustomizer.getOtherCurrencyKeys(); + } + + @Override + public int getNumberOfRows() { + return mPcQwertyCustomizer.getNumberOfRows(); + } + + @Override + public ExpectedKey[] getLeftShiftKeys(final boolean isPhone) { + return mPcQwertyCustomizer.getLeftShiftKeys(isPhone); + } + + @Override + public ExpectedKey[] getRightShiftKeys(final boolean isPhone) { + return mPcQwertyCustomizer.getRightShiftKeys(isPhone); + } + + @Override + public ExpectedKey[] getKeysLeftToSpacebar(final boolean isPhone) { + return mPcQwertyCustomizer.getKeysLeftToSpacebar(isPhone); + } + + @Override + public ExpectedKey[] getKeysRightToSpacebar(final boolean isPhone) { + return mPcQwertyCustomizer.getKeysRightToSpacebar(isPhone); + } + + @Override + protected void setNordicKeys(final ExpectedKeyboardBuilder builder) { + // PC QWERTY layout doesn't have Nordic keys. + } + + @Override + protected void setMoreKeysOfA(final ExpectedKeyboardBuilder builder) { + builder + // U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS + // U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE + // U+00E6: "æ" LATIN SMALL LETTER AE + // 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", "\u00E4", "\u00E5", "\u00E6", "\u00E1", "\u00E0", "\u00E2", + "\u0105", "\u00E3"); + } + + @Override + protected void setMoreKeysOfO(final ExpectedKeyboardBuilder builder) { + builder + // U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS + // U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE + // U+0153: "œ" LATIN SMALL LIGATURE OE + // 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", "\u00F6", "\u00F8", "\u0153", "\u00F3", "\u00F2", "\u00F4", + "\u00F5", "\u014D"); + } + + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTagalog.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTagalog.java new file mode 100644 index 000000000..bd4956b8f --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTagalog.java @@ -0,0 +1,47 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Spanish; +import org.kelar.inputmethod.keyboard.layout.customizer.SpanishCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +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 SpanishCustomizer { + TagalogCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey[] getPunctuationMoreKeys(final boolean isPhone) { + return isPhone ? PHONE_PUNCTUATION_MORE_KEYS : TABLET_PUNCTUATION_MORE_KEYS; + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTamilIN.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTamilIN.java new file mode 100644 index 000000000..02656aea2 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTamilIN.java @@ -0,0 +1,56 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.SymbolsShifted; +import org.kelar.inputmethod.keyboard.layout.Tamil; +import org.kelar.inputmethod.keyboard.layout.customizer.TamilCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +import java.util.Locale; + +/** + * ta_IN: Tamil (India)/tamil + */ +@SmallTest +public final class TestsTamilIN extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("ta", "IN"); + private static final LayoutBase LAYOUT = new Tamil(new TamilINCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class TamilINCustomizer extends TamilCustomizer { + TamilINCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + // U+20B9: "₹" INDIAN RUPEE SIGN + private static final ExpectedKey CURRENCY_RUPEE = key("\u20B9", + Symbols.CURRENCY_GENERIC_MORE_KEYS); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTamilLK.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTamilLK.java new file mode 100644 index 000000000..dc3c16cee --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTamilLK.java @@ -0,0 +1,56 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.Suppress; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.SymbolsShifted; +import org.kelar.inputmethod.keyboard.layout.Tamil; +import org.kelar.inputmethod.keyboard.layout.customizer.TamilCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; + +import java.util.Locale; + +/** + * ta_LK: Tamil (Sri Lanka)/tamil + */ +@Suppress +public final class TestsTamilLK extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("ta", "LK"); + private static final LayoutBase LAYOUT = new Tamil(new TamilLKCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class TamilLKCustomizer extends TamilCustomizer { + TamilLKCustomizer(final Locale locale) { super(locale); } + + @Override + public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; } + + @Override + public ExpectedKey[] getOtherCurrencyKeys() { + return SymbolsShifted.CURRENCIES_OTHER_GENERIC; + } + + // U+0DBB/U+0DD4: "රු" SINHALA LETTER RAYANNA/SINHALA VOWEL SIGN KETTI PAA-PILLA + private static final ExpectedKey CURRENCY_RUPEE = key("\u0DBB\u0DD4", + Symbols.CURRENCY_GENERIC_MORE_KEYS); + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTamilSG.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTamilSG.java new file mode 100644 index 000000000..8bd34fbfd --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTamilSG.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Tamil; +import org.kelar.inputmethod.keyboard.layout.customizer.TamilCustomizer; + +import java.util.Locale; + +/** + * ta_SG: Tamil (Singapore)/tamil + */ +@SmallTest +public final class TestsTamilSG extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("ta", "SG"); + private static final LayoutBase LAYOUT = new Tamil(new TamilCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTeluguIN.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTeluguIN.java new file mode 100644 index 000000000..eda1895f6 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTeluguIN.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Telugu; + +import java.util.Locale; + +/** + * te_IN: Telugu (India)/telugu + */ +@SmallTest +public final class TestsTeluguIN extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("te", "IN"); + private static final LayoutBase LAYOUT = new Telugu(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsThai.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsThai.java new file mode 100644 index 000000000..95475956a --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsThai.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Thai; + +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(LOCALE); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTurkish.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTurkish.java new file mode 100644 index 000000000..511dca380 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsTurkish.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.EuroCustomizer; +import org.kelar.inputmethod.keyboard.layout.customizer.TurkicCustomizer; +import org.kelar.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 EuroCustomizer { + private final TurkicCustomizer mTurkicCustomizer; + + TurkishCustomizer(final Locale locale) { + super(locale); + mTurkicCustomizer = new TurkicCustomizer(locale); + } + + @Override + public ExpectedKeyboardBuilder setAccentedLetters(final ExpectedKeyboardBuilder builder) { + return mTurkicCustomizer.setAccentedLetters(builder); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsUkrainian.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsUkrainian.java new file mode 100644 index 000000000..60fc97f29 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsUkrainian.java @@ -0,0 +1,83 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.EastSlavic; +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.SymbolsShifted; +import org.kelar.inputmethod.keyboard.layout.customizer.EastSlavicCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 { + 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.CURRENCY_GENERIC_MORE_KEYS); + + @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", "\u0491") + // U+0449: "щ" CYRILLIC SMALL LETTER SHCHA + .replaceKeyOfLabel(EastSlavic.ROW1_9, key("\u0449", additionalMoreKey("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, "\u0454") + // U+0438: "и" CYRILLIC SMALL LETTER I + .replaceKeyOfLabel(EastSlavic.ROW3_5, "\u0438") + // U+044C: "ь" CYRILLIC SMALL LETTER SOFT SIGN + // U+044A: "ъ" CYRILLIC SMALL LETTER HARD SIGN + .setMoreKeysOf("\u044C", "\u044A"); + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsUzbek.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsUzbek.java new file mode 100644 index 000000000..ad9ab8762 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsUzbek.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Uzbek; +import org.kelar.inputmethod.keyboard.layout.customizer.UzbekCustomizer; + +import java.util.Locale; + +/** + * uz_UZ: Uzbek (Uzbekistan)/uzbek + */ +@SmallTest +public final class TestsUzbek extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("uz", "UZ"); + private static final LayoutBase LAYOUT = new Uzbek(new UzbekCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsUzbekQwerty.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsUzbekQwerty.java new file mode 100644 index 000000000..e795a5ed6 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsUzbekQwerty.java @@ -0,0 +1,47 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.UzbekCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder; + +import java.util.Locale; + +/** + * uz_UZ: Uzbek (Uzbekistan)/qwerty + */ +@SmallTest +public final class TestsUzbekQwerty extends LayoutTestsBase { + private static final Locale LOCALE = new Locale("uz", "UZ"); + private static final LayoutBase LAYOUT = new Qwerty(new UzbekQwertyCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } + + private static class UzbekQwertyCustomizer extends UzbekCustomizer { + UzbekQwertyCustomizer(final Locale locale) { super(locale); } + + @Override + protected void setUzbekKeys(final ExpectedKeyboardBuilder builder) { + // QWERTY layout doesn't have Uzebk keys. + } + } +} diff --git a/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsVietnamese.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsVietnamese.java new file mode 100644 index 000000000..91e50dfd5 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsVietnamese.java @@ -0,0 +1,146 @@ +/* + * 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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.Symbols; +import org.kelar.inputmethod.keyboard.layout.SymbolsShifted; +import org.kelar.inputmethod.keyboard.layout.customizer.LayoutCustomizer; +import org.kelar.inputmethod.keyboard.layout.expected.ExpectedKey; +import org.kelar.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 { + 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.CURRENCY_GENERIC_MORE_KEYS); + + @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", + "\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", "\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", + "\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", "\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", + "\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/org/kelar/inputmethod/keyboard/layout/tests/TestsZulu.java b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsZulu.java new file mode 100644 index 000000000..d745d9956 --- /dev/null +++ b/tests/src/org/kelar/inputmethod/keyboard/layout/tests/TestsZulu.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 org.kelar.inputmethod.keyboard.layout.tests; + +import androidx.test.filters.SmallTest; + +import org.kelar.inputmethod.keyboard.layout.LayoutBase; +import org.kelar.inputmethod.keyboard.layout.Qwerty; +import org.kelar.inputmethod.keyboard.layout.customizer.EnglishCustomizer; + +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 EnglishCustomizer(LOCALE)); + + @Override + LayoutBase getLayout() { return LAYOUT; } +} |