am d28ac520: Merge "Add lao keyboard test"

* commit 'd28ac52033be1291337065c60de1c32d1a3cce23':
  Add lao keyboard test
This commit is contained in:
Tadashi G. Takaoka 2014-03-17 05:58:58 -07:00 committed by Android Git Automerger
commit 599564554d
2 changed files with 285 additions and 0 deletions

View file

@ -0,0 +1,248 @@
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.inputmethod.keyboard.layout;
import com.android.inputmethod.keyboard.KeyboardId;
import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
import com.android.inputmethod.keyboard.layout.expected.ExpectedKeyboardBuilder;
import com.android.inputmethod.latin.Constants;
import java.util.Locale;
/**
* The Khmer alphabet keyboard.
*/
public final class Lao extends LayoutBase {
private static final String LAYOUT_NAME = "lao";
public Lao(final LayoutCustomizer customizer) {
super(customizer, Symbols.class, SymbolsShifted.class);
}
@Override
public String getName() { return LAYOUT_NAME; }
public static class LaoCustomizer extends LayoutCustomizer {
public LaoCustomizer(final Locale locale) { super(locale); }
@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, 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;
}
// Helper method to create alphabet layout by adding special function keys.
@Override
ExpectedKeyboardBuilder convertCommonLayoutToKeyboard(final ExpectedKeyboardBuilder builder,
final boolean isPhone) {
final LayoutCustomizer customizer = getCustomizer();
final ExpectedKey[] spacebar = joinKeys(
customizer.getKeysLeftToSpacebar(isPhone),
customizer.getSpaceKeys(isPhone),
customizer.getKeysRightToSpacebar(isPhone));
builder.setKeysOfRow(5, spacebar);
if (isPhone) {
builder.addKeysOnTheRightOfRow(4, DELETE_KEY)
.addKeysOnTheLeftOfRow(5, customizer.getSymbolsKey())
.addKeysOnTheRightOfRow(5, key(ENTER_KEY, EMOJI_KEY));
} else {
builder.addKeysOnTheRightOfRow(1, DELETE_KEY)
.addKeysOnTheRightOfRow(3, ENTER_KEY)
.addKeysOnTheLeftOfRow(5, customizer.getSymbolsKey(), SETTINGS_KEY)
.addKeysOnTheRightOfRow(5, EMOJI_KEY);
}
builder.addKeysOnTheLeftOfRow(4, customizer.getLeftShiftKeys(isPhone))
.addKeysOnTheRightOfRow(4, customizer.getRightShiftKeys(isPhone));
return builder;
}
private static final ExpectedKey[][] ALPHABET_COMMON = new ExpectedKeyboardBuilder()
.setKeysOfRow(1,
// U+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
key("\u0EB8"),
// U+0EB9: "" LAO VOWEL SIGN UU
key("\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
key("\u0ECD"))
.setKeysOfRow(2,
// U+0EBB: "" LAO VOWEL SIGN MAI KON
key("\u0EBB"),
// U+0EC4: "" LAO VOWEL SIGN AI
// U+0ED0: "" LAO DIGIT ZERO
key("\u0EC4", joinMoreKeys("0", "\u0ED0")),
// U+0EB3: "" LAO VOWEL SIGN AM
key("\u0EB3"),
// U+0E9E: "" LAO LETTER PHO TAM
key("\u0E9E"),
// U+0EB0: "" LAO VOWEL SIGN A
key("\u0EB0"),
// U+0EB4: "" LAO VOWEL SIGN I
key("\u0EB4"),
// U+0EB5: "" LAO VOWEL SIGN II
key("\u0EB5"),
// U+0EAE: "" LAO LETTER HO TAM
key("\u0EAE"),
// U+0E99: "" LAO LETTER NO
key("\u0E99"),
// U+0E8D: "" LAO LETTER NYO
key("\u0E8D"),
// U+0E9A: "" LAO LETTER BO
key("\u0E9A"),
// U+0EA5: "" LAO LETTER LO LOOT
key("\u0EA5"))
.setLabelsOfRow(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")
.setLabelsOfRow(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()
.setLabelsOfRow(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")
.setLabelsOfRow(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")
.setLabelsOfRow(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")
.setLabelsOfRow(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();
}

View file

@ -0,0 +1,37 @@
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.inputmethod.keyboard.layout.tests;
import android.test.suitebuilder.annotation.SmallTest;
import com.android.inputmethod.keyboard.layout.Lao;
import com.android.inputmethod.keyboard.layout.Lao.LaoCustomizer;
import com.android.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(new LaoCustomizer(LOCALE));
@Override
LayoutBase getLayout() { return LAYOUT; }
}