Add lao keyboard test

This CL adds Lao (Laos) keyboard test.

Bug: 13017434
Change-Id: I4ae63099d260b14df9663f1bc938cce7c384b9fd
main
Tadashi G. Takaoka 2014-03-15 15:56:48 +09:00
parent bef6a4e209
commit 4a00627fcc
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; }
}