Loading java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java +17 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,10 @@ public final class KeySpecParser { } public static String getLabel(final String keySpec) { if (keySpec == null) { // TODO: Throw {@link KeySpecParserError} once Key.keyLabel attribute becomes mandatory. return null; } if (hasIcon(keySpec)) { return null; } Loading @@ -140,6 +144,10 @@ public final class KeySpecParser { } public static String getOutputText(final String keySpec) { if (keySpec == null) { // TODO: Throw {@link KeySpecParserError} once Key.keyLabel attribute becomes mandatory. return null; } final int labelEnd = indexOfLabelEnd(keySpec); if (hasCode(keySpec, labelEnd)) { return null; Loading @@ -165,6 +173,10 @@ public final class KeySpecParser { } public static int getCode(final String keySpec, final KeyboardCodesSet codesSet) { if (keySpec == null) { // TODO: Throw {@link KeySpecParserError} once Key.keyLabel attribute becomes mandatory. return CODE_UNSPECIFIED; } final int labelEnd = indexOfLabelEnd(keySpec); if (hasCode(keySpec, labelEnd)) { checkDoubleLabelEnd(keySpec, labelEnd); Loading @@ -187,6 +199,7 @@ public final class KeySpecParser { return (StringUtils.codePointCount(label) == 1) ? label.codePointAt(0) : CODE_OUTPUT_TEXT; } // TODO: Make this method private once Key.code attribute is removed. public static int parseCode(final String text, final KeyboardCodesSet codesSet, final int defCode) { if (text == null) { Loading @@ -202,6 +215,10 @@ public final class KeySpecParser { } public static int getIconId(final String keySpec) { if (keySpec == null) { // TODO: Throw {@link KeySpecParserError} once Key.keyLabel attribute becomes mandatory. return KeyboardIconsSet.ICON_UNDEFINED; } if (!hasIcon(keySpec)) { return KeyboardIconsSet.ICON_UNDEFINED; } Loading java/src/com/android/inputmethod/keyboard/internal/MoreKeySpec.java +3 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,9 @@ public final class MoreKeySpec { public MoreKeySpec(final String moreKeySpec, boolean needsToUpperCase, final Locale locale, final KeyboardCodesSet codesSet) { if (TextUtils.isEmpty(moreKeySpec)) { throw new KeySpecParser.KeySpecParserError("Empty more key spec"); } mLabel = StringUtils.toUpperCaseOfStringForLocale( KeySpecParser.getLabel(moreKeySpec), needsToUpperCase, locale); final int code = StringUtils.toUpperCaseOfCodeForLocale( Loading tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserTests.java +12 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.inputmethod.keyboard.internal; import static com.android.inputmethod.keyboard.internal.KeyboardIconsSet.ICON_UNDEFINED; import static com.android.inputmethod.latin.Constants.CODE_UNSPECIFIED; import android.test.suitebuilder.annotation.SmallTest; import com.android.inputmethod.latin.Constants; Loading @@ -40,4 +43,13 @@ public final class KeySpecParserTests extends KeySpecParserTestsBase { 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); } } tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserTestsBase.java +0 −4 Original line number Diff line number Diff line Loading @@ -251,10 +251,6 @@ abstract class KeySpecParserTestsBase extends AndroidTestCase { } public void testFormatError() { assertParserError("Null spec", null, null, null, ICON_UNDEFINED, CODE_UNSPECIFIED); assertParserError("Empty spec", "", null, null, ICON_UNDEFINED, CODE_UNSPECIFIED); assertParserError("Single bar", "|", "|", null, ICON_UNDEFINED, '|'); assertParserError("Empty label with outputText", "|a", Loading tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecTests.java +11 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.inputmethod.keyboard.internal; import static com.android.inputmethod.keyboard.internal.KeyboardIconsSet.ICON_UNDEFINED; import static com.android.inputmethod.latin.Constants.CODE_UNSPECIFIED; import android.test.suitebuilder.annotation.SmallTest; import com.android.inputmethod.latin.Constants; Loading @@ -42,6 +45,14 @@ public final class MoreKeySpecTests extends KeySpecParserTestsBase { 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) { Loading Loading
java/src/com/android/inputmethod/keyboard/internal/KeySpecParser.java +17 −0 Original line number Diff line number Diff line Loading @@ -120,6 +120,10 @@ public final class KeySpecParser { } public static String getLabel(final String keySpec) { if (keySpec == null) { // TODO: Throw {@link KeySpecParserError} once Key.keyLabel attribute becomes mandatory. return null; } if (hasIcon(keySpec)) { return null; } Loading @@ -140,6 +144,10 @@ public final class KeySpecParser { } public static String getOutputText(final String keySpec) { if (keySpec == null) { // TODO: Throw {@link KeySpecParserError} once Key.keyLabel attribute becomes mandatory. return null; } final int labelEnd = indexOfLabelEnd(keySpec); if (hasCode(keySpec, labelEnd)) { return null; Loading @@ -165,6 +173,10 @@ public final class KeySpecParser { } public static int getCode(final String keySpec, final KeyboardCodesSet codesSet) { if (keySpec == null) { // TODO: Throw {@link KeySpecParserError} once Key.keyLabel attribute becomes mandatory. return CODE_UNSPECIFIED; } final int labelEnd = indexOfLabelEnd(keySpec); if (hasCode(keySpec, labelEnd)) { checkDoubleLabelEnd(keySpec, labelEnd); Loading @@ -187,6 +199,7 @@ public final class KeySpecParser { return (StringUtils.codePointCount(label) == 1) ? label.codePointAt(0) : CODE_OUTPUT_TEXT; } // TODO: Make this method private once Key.code attribute is removed. public static int parseCode(final String text, final KeyboardCodesSet codesSet, final int defCode) { if (text == null) { Loading @@ -202,6 +215,10 @@ public final class KeySpecParser { } public static int getIconId(final String keySpec) { if (keySpec == null) { // TODO: Throw {@link KeySpecParserError} once Key.keyLabel attribute becomes mandatory. return KeyboardIconsSet.ICON_UNDEFINED; } if (!hasIcon(keySpec)) { return KeyboardIconsSet.ICON_UNDEFINED; } Loading
java/src/com/android/inputmethod/keyboard/internal/MoreKeySpec.java +3 −0 Original line number Diff line number Diff line Loading @@ -46,6 +46,9 @@ public final class MoreKeySpec { public MoreKeySpec(final String moreKeySpec, boolean needsToUpperCase, final Locale locale, final KeyboardCodesSet codesSet) { if (TextUtils.isEmpty(moreKeySpec)) { throw new KeySpecParser.KeySpecParserError("Empty more key spec"); } mLabel = StringUtils.toUpperCaseOfStringForLocale( KeySpecParser.getLabel(moreKeySpec), needsToUpperCase, locale); final int code = StringUtils.toUpperCaseOfCodeForLocale( Loading
tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserTests.java +12 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.inputmethod.keyboard.internal; import static com.android.inputmethod.keyboard.internal.KeyboardIconsSet.ICON_UNDEFINED; import static com.android.inputmethod.latin.Constants.CODE_UNSPECIFIED; import android.test.suitebuilder.annotation.SmallTest; import com.android.inputmethod.latin.Constants; Loading @@ -40,4 +43,13 @@ public final class KeySpecParserTests extends KeySpecParserTestsBase { 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); } }
tests/src/com/android/inputmethod/keyboard/internal/KeySpecParserTestsBase.java +0 −4 Original line number Diff line number Diff line Loading @@ -251,10 +251,6 @@ abstract class KeySpecParserTestsBase extends AndroidTestCase { } public void testFormatError() { assertParserError("Null spec", null, null, null, ICON_UNDEFINED, CODE_UNSPECIFIED); assertParserError("Empty spec", "", null, null, ICON_UNDEFINED, CODE_UNSPECIFIED); assertParserError("Single bar", "|", "|", null, ICON_UNDEFINED, '|'); assertParserError("Empty label with outputText", "|a", Loading
tests/src/com/android/inputmethod/keyboard/internal/MoreKeySpecTests.java +11 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,9 @@ package com.android.inputmethod.keyboard.internal; import static com.android.inputmethod.keyboard.internal.KeyboardIconsSet.ICON_UNDEFINED; import static com.android.inputmethod.latin.Constants.CODE_UNSPECIFIED; import android.test.suitebuilder.annotation.SmallTest; import com.android.inputmethod.latin.Constants; Loading @@ -42,6 +45,14 @@ public final class MoreKeySpecTests extends KeySpecParserTestsBase { 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) { Loading