diff options
author | 2010-12-20 20:30:26 +0900 | |
---|---|---|
committer | 2010-12-20 21:58:31 +0900 | |
commit | c4f71668d7b8203dc66f0f04c089a363189eb4ce (patch) | |
tree | 5901e47d308234b926cd5bb3215aa084221f6812 /tests/src | |
parent | 8aa3f5a3ad6095a3355841ce30bce4877319d0a0 (diff) | |
download | latinime-c4f71668d7b8203dc66f0f04c089a363189eb4ce.tar.gz latinime-c4f71668d7b8203dc66f0f04c089a363189eb4ce.tar.xz latinime-c4f71668d7b8203dc66f0f04c089a363189eb4ce.zip |
Remove multi-tap feature
Change-Id: Ife44b3f9d420d77d2cfb51044a8356f02ed63e8b
Diffstat (limited to 'tests/src')
-rw-r--r-- | tests/src/com/android/inputmethod/keyboard/KeyStylesTests.java | 30 | ||||
-rw-r--r-- | tests/src/com/android/inputmethod/keyboard/PopupCharactersParserTests.java | 158 |
2 files changed, 80 insertions, 108 deletions
diff --git a/tests/src/com/android/inputmethod/keyboard/KeyStylesTests.java b/tests/src/com/android/inputmethod/keyboard/KeyStylesTests.java index 3f2b7f4d5..5dff11471 100644 --- a/tests/src/com/android/inputmethod/keyboard/KeyStylesTests.java +++ b/tests/src/com/android/inputmethod/keyboard/KeyStylesTests.java @@ -22,23 +22,6 @@ import android.test.AndroidTestCase; import android.text.TextUtils; public class KeyStylesTests extends AndroidTestCase { - private static void assertNumberFormatException(String message, String value) { - try { - EmptyKeyStyle.parseCsvInt(value); - fail(message); - } catch (NumberFormatException nfe) { - // success. - } - } - - private static void assertIntArray(String message, String value, Integer ... expected) { - final int actual[] = EmptyKeyStyle.parseCsvInt(value); - assertSame(message + ": result length", expected.length, actual.length); - for (int i = 0; i < actual.length; i++) { - assertEquals(message + ": result at " + i + ":", (int)expected[i], actual[i]); - } - } - private static String format(String message, Object expected, Object actual) { return message + " expected:<" + expected + "> but was:<" + actual + ">"; } @@ -57,19 +40,6 @@ public class KeyStylesTests extends AndroidTestCase { } } - public void testParseCsvInt() { - assertIntArray("Empty string", ""); - assertNumberFormatException("Spaces", " "); - assertNumberFormatException("Non-decimal number", "abc"); - assertIntArray("Single number", "123", 123); - assertIntArray("Negative number", "-123", -123); - assertNumberFormatException("Hexadecimal number", "1b2b"); - assertIntArray("Multiple numbers", "123,456", 123, 456); - assertNumberFormatException("Non-decimal numbers", "123,abc"); - assertNumberFormatException("Escaped comma", "123\\,456"); - assertNumberFormatException("Escaped escape", "123\\\\,456"); - } - public void testParseCsvTextZero() { assertTextArray("Empty string", ""); } diff --git a/tests/src/com/android/inputmethod/keyboard/PopupCharactersParserTests.java b/tests/src/com/android/inputmethod/keyboard/PopupCharactersParserTests.java index 77b62ca5d..ae78866e6 100644 --- a/tests/src/com/android/inputmethod/keyboard/PopupCharactersParserTests.java +++ b/tests/src/com/android/inputmethod/keyboard/PopupCharactersParserTests.java @@ -32,8 +32,6 @@ public class PopupCharactersParserTests extends AndroidTestCase { private int mCodeSettings; private Drawable mIconSettings; - private static final Integer[] DUMMY_CODES = { 0 }; - @Override protected void setUp() { Resources res = getContext().getResources(); @@ -47,7 +45,7 @@ public class PopupCharactersParserTests extends AndroidTestCase { } private void assertParser(String message, String popupSpec, String expectedLabel, - String expectedOutputText, Drawable expectedIcon, Integer ... expectedCodes) { + String expectedOutputText, Drawable expectedIcon, int expectedCode) { String actualLabel = PopupCharactersParser.getLabel(popupSpec); assertEquals(message + ": label:", expectedLabel, actualLabel); @@ -62,28 +60,15 @@ public class PopupCharactersParserTests extends AndroidTestCase { assertNotNull(message + ": icon non-null:", actualIcon); } - int[] actualCodes = PopupCharactersParser.getCodes(mRes, popupSpec); - if (expectedCodes == null) { - assertNull(message + ": codes null:", actualCodes); - return; - } - assertSame(message + ": codes length:", expectedCodes.length, actualCodes.length); - for (int i = 0; i < actualCodes.length; i++) { - assertEquals(message + ": codes value at " + i + ":", (int)expectedCodes[i], - actualCodes[i]); - } + int actualCode = PopupCharactersParser.getCode(mRes, popupSpec); + assertEquals(message + ": codes value:", expectedCode, actualCode); } private void assertParserError(String message, String popupSpec, String expectedLabel, - String expectedOutputText, Drawable expectedIcon, Integer ... expectedCodes) { + String expectedOutputText, Drawable expectedIcon, int expectedCode) { try { - if (expectedCodes.length > 0) { - assertParser(message, popupSpec, expectedLabel, expectedOutputText, expectedIcon, - expectedCodes); - } else { - assertParser(message, popupSpec, expectedLabel, expectedOutputText, expectedIcon, - DUMMY_CODES); - } + assertParser(message, popupSpec, expectedLabel, expectedOutputText, expectedIcon, + expectedCode); fail(message); } catch (PopupCharactersParser.PopupCharactersParserError pcpe) { // success. @@ -91,71 +76,83 @@ public class PopupCharactersParserTests extends AndroidTestCase { } public void testSingleLetter() { - assertParser("Single letter", "a", "a", null, null, (int)'a'); - assertParser("Single escaped bar", "\\|", "|", null, null, (int)'|'); - assertParser("Single escaped escape", "\\\\", "\\", null, null, (int)'\\'); - assertParser("Single comma", ",", ",", null, null, (int)','); - assertParser("Single escaped comma", "\\,", ",", null, null, (int)','); - assertParser("Single escaped letter", "\\a", "a", null, null, (int)'a'); - assertParser("Single at", "@", "@", null, null, (int)'@'); - assertParser("Single escaped at", "\\@", "@", null, null, (int)'@'); - assertParser("Single letter with outputText", "a|abc", "a", "abc", null, DUMMY_CODES); + assertParser("Single letter", "a", "a", null, null, 'a'); + assertParser("Single escaped bar", "\\|", "|", null, null, '|'); + assertParser("Single escaped escape", "\\\\", "\\", null, null, '\\'); + assertParser("Single comma", ",", ",", null, null, ','); + assertParser("Single escaped comma", "\\,", ",", null, null, ','); + assertParser("Single escaped letter", "\\a", "a", null, null, 'a'); + assertParser("Single at", "@", "@", null, null, '@'); + assertParser("Single escaped at", "\\@", "@", null, null, '@'); + assertParser("Single letter with outputText", "a|abc", "a", "abc", null, + Keyboard.CODE_DUMMY); assertParser("Single letter with escaped outputText", "a|a\\|c", "a", "a|c", null, - DUMMY_CODES); - assertParser("Single letter with comma outputText", "a|a,b", "a", "a,b", null, DUMMY_CODES); + Keyboard.CODE_DUMMY); + assertParser("Single letter with comma outputText", "a|a,b", "a", "a,b", null, + Keyboard.CODE_DUMMY); assertParser("Single letter with escaped comma outputText", "a|a\\,b", "a", "a,b", null, - DUMMY_CODES); + Keyboard.CODE_DUMMY); assertParser("Single letter with outputText starts with at", "a|@bc", "a", "@bc", null, - DUMMY_CODES); + Keyboard.CODE_DUMMY); assertParser("Single letter with outputText contains at", "a|a@c", "a", "a@c", null, - DUMMY_CODES); + Keyboard.CODE_DUMMY); assertParser("Single letter with escaped at outputText", "a|\\@bc", "a", "@bc", null, - DUMMY_CODES); + Keyboard.CODE_DUMMY); assertParser("Single escaped escape with outputText", "\\\\|\\\\", "\\", "\\", null, - DUMMY_CODES); - assertParser("Single escaped bar with outputText", "\\||\\|", "|", "|", null, DUMMY_CODES); + Keyboard.CODE_DUMMY); + assertParser("Single escaped bar with outputText", "\\||\\|", "|", "|", null, + Keyboard.CODE_DUMMY); assertParser("Single letter with code", "a|" + CODE_SETTINGS, "a", null, null, mCodeSettings); } public void testLabel() { - assertParser("Simple label", "abc", "abc", "abc", null, DUMMY_CODES); - assertParser("Label with escaped bar", "a\\|c", "a|c", "a|c", null, DUMMY_CODES); - assertParser("Label with escaped escape", "a\\\\c", "a\\c", "a\\c", null, DUMMY_CODES); - assertParser("Label with comma", "a,c", "a,c", "a,c", null, DUMMY_CODES); - assertParser("Label with escaped comma", "a\\,c", "a,c", "a,c", null, DUMMY_CODES); - assertParser("Label starts with at", "@bc", "@bc", "@bc", null, DUMMY_CODES); - assertParser("Label contains at", "a@c", "a@c", "a@c", null, DUMMY_CODES); - assertParser("Label with escaped at", "\\@bc", "@bc", "@bc", null, DUMMY_CODES); - assertParser("Label with escaped letter", "\\abc", "abc", "abc", null, DUMMY_CODES); - assertParser("Label with outputText", "abc|def", "abc", "def", null, DUMMY_CODES); - assertParser("Label with comma and outputText", "a,c|def", "a,c", "def", null, DUMMY_CODES); + assertParser("Simple label", "abc", "abc", "abc", null, Keyboard.CODE_DUMMY); + assertParser("Label with escaped bar", "a\\|c", "a|c", "a|c", null, + Keyboard.CODE_DUMMY); + assertParser("Label with escaped escape", "a\\\\c", "a\\c", "a\\c", null, + Keyboard.CODE_DUMMY); + assertParser("Label with comma", "a,c", "a,c", "a,c", null, Keyboard.CODE_DUMMY); + assertParser("Label with escaped comma", "a\\,c", "a,c", "a,c", null, + Keyboard.CODE_DUMMY); + assertParser("Label starts with at", "@bc", "@bc", "@bc", null, Keyboard.CODE_DUMMY); + assertParser("Label contains at", "a@c", "a@c", "a@c", null, Keyboard.CODE_DUMMY); + assertParser("Label with escaped at", "\\@bc", "@bc", "@bc", null, + Keyboard.CODE_DUMMY); + assertParser("Label with escaped letter", "\\abc", "abc", "abc", null, + Keyboard.CODE_DUMMY); + assertParser("Label with outputText", "abc|def", "abc", "def", null, + Keyboard.CODE_DUMMY); + assertParser("Label with comma and outputText", "a,c|def", "a,c", "def", null, + Keyboard.CODE_DUMMY); assertParser("Escaped comma label with outputText", "a\\,c|def", "a,c", "def", null, - DUMMY_CODES); - assertParser("Escaped label with outputText", "a\\|c|def", "a|c", "def", null, DUMMY_CODES); + Keyboard.CODE_DUMMY); + assertParser("Escaped label with outputText", "a\\|c|def", "a|c", "def", null, + Keyboard.CODE_DUMMY); assertParser("Label with escaped bar outputText", "abc|d\\|f", "abc", "d|f", null, - DUMMY_CODES); + Keyboard.CODE_DUMMY); assertParser("Escaped escape label with outputText", "a\\\\|def", "a\\", "def", null, - DUMMY_CODES); + Keyboard.CODE_DUMMY); assertParser("Label starts with at and outputText", "@bc|def", "@bc", "def", null, - DUMMY_CODES); + Keyboard.CODE_DUMMY); assertParser("Label contains at label and outputText", "a@c|def", "a@c", "def", null, - DUMMY_CODES); + Keyboard.CODE_DUMMY); assertParser("Escaped at label with outputText", "\\@bc|def", "@bc", "def", null, - DUMMY_CODES); - assertParser("Label with comma outputText", "abc|a,b", "abc", "a,b", null, DUMMY_CODES); + Keyboard.CODE_DUMMY); + assertParser("Label with comma outputText", "abc|a,b", "abc", "a,b", null, + Keyboard.CODE_DUMMY); assertParser("Label with escaped comma outputText", "abc|a\\,b", "abc", "a,b", null, - DUMMY_CODES); + Keyboard.CODE_DUMMY); assertParser("Label with outputText starts with at", "abc|@bc", "abc", "@bc", null, - DUMMY_CODES); + Keyboard.CODE_DUMMY); assertParser("Label with outputText contains at", "abc|a@c", "abc", "a@c", null, - DUMMY_CODES); + Keyboard.CODE_DUMMY); assertParser("Label with escaped at outputText", "abc|\\@bc", "abc", "@bc", null, - DUMMY_CODES); + Keyboard.CODE_DUMMY); assertParser("Label with escaped bar outputText", "abc|d\\|f", "abc", "d|f", - null, DUMMY_CODES); + null, Keyboard.CODE_DUMMY); assertParser("Escaped bar label with escaped bar outputText", "a\\|c|d\\|f", "a|c", "d|f", - null, DUMMY_CODES); + null, Keyboard.CODE_DUMMY); assertParser("Label with code", "abc|" + CODE_SETTINGS, "abc", null, null, mCodeSettings); assertParser("Escaped label with code", "a\\|c|" + CODE_SETTINGS, "a|c", null, null, mCodeSettings); @@ -163,13 +160,13 @@ public class PopupCharactersParserTests extends AndroidTestCase { public void testIconAndCode() { assertParser("Icon with outputText", ICON_SETTINGS + "|abc", null, "abc", mIconSettings, - DUMMY_CODES); + Keyboard.CODE_DUMMY); assertParser("Icon with outputText starts with at", ICON_SETTINGS + "|@bc", null, "@bc", - mIconSettings, DUMMY_CODES); + mIconSettings, Keyboard.CODE_DUMMY); assertParser("Icon with outputText contains at", ICON_SETTINGS + "|a@c", null, "a@c", - mIconSettings, DUMMY_CODES); + mIconSettings, Keyboard.CODE_DUMMY); assertParser("Icon with escaped at outputText", ICON_SETTINGS + "|\\@bc", null, "@bc", - mIconSettings, DUMMY_CODES); + mIconSettings, Keyboard.CODE_DUMMY); assertParser("Label starts with at and code", "@bc|" + CODE_SETTINGS, "@bc", null, null, mCodeSettings); assertParser("Label contains at and code", "a@c|" + CODE_SETTINGS, "a@c", null, null, @@ -181,23 +178,28 @@ public class PopupCharactersParserTests extends AndroidTestCase { } public void testFormatError() { - assertParserError("Empty spec", "", null, null, null); - assertParserError("Empty label with outputText", "|a", null, "a", null); + assertParserError("Empty spec", "", null, null, null, Keyboard.CODE_UNSPECIFIED); + assertParserError("Empty label with outputText", "|a", null, "a", null, + Keyboard.CODE_DUMMY); assertParserError("Empty label with code", "|" + CODE_SETTINGS, null, null, null, mCodeSettings); - assertParserError("Empty outputText with label", "a|", "a", null, null); + assertParserError("Empty outputText with label", "a|", "a", null, null, + Keyboard.CODE_UNSPECIFIED); assertParserError("Empty outputText with icon", ICON_SETTINGS + "|", null, null, - mIconSettings); - assertParserError("Empty icon and code", "|", null, null, null); - assertParserError("Icon without code", ICON_SETTINGS, null, null, mIconSettings); - assertParserError("Non existing icon", ICON_NON_EXISTING + "|abc", null, "abc", null); - assertParserError("Non existing code", "abc|" + CODE_NON_EXISTING, "abc", null, null); - assertParserError("Third bar at end", "a|b|", "a", null, null); - assertParserError("Multiple bar", "a|b|c", "a", null, null); + mIconSettings, Keyboard.CODE_UNSPECIFIED); + assertParserError("Empty icon and code", "|", null, null, null, Keyboard.CODE_UNSPECIFIED); + assertParserError("Icon without code", ICON_SETTINGS, null, null, mIconSettings, + Keyboard.CODE_DUMMY); + assertParserError("Non existing icon", ICON_NON_EXISTING + "|abc", null, "abc", null, + Keyboard.CODE_DUMMY); + assertParserError("Non existing code", "abc|" + CODE_NON_EXISTING, "abc", null, null, + Keyboard.CODE_UNSPECIFIED); + assertParserError("Third bar at end", "a|b|", "a", null, null, Keyboard.CODE_UNSPECIFIED); + assertParserError("Multiple bar", "a|b|c", "a", null, null, Keyboard.CODE_UNSPECIFIED); assertParserError("Multiple bar with label and code", "a|" + CODE_SETTINGS + "|c", "a", null, null, mCodeSettings); assertParserError("Multiple bar with icon and outputText", ICON_SETTINGS + "|b|c", null, - null, mIconSettings); + null, mIconSettings, Keyboard.CODE_UNSPECIFIED); assertParserError("Multiple bar with icon and code", ICON_SETTINGS + "|" + CODE_SETTINGS + "|c", null, null, mIconSettings, mCodeSettings); |