diff options
Diffstat (limited to 'tests/src')
6 files changed, 105 insertions, 21 deletions
diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysBase.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysBase.java index 1fce362b5..8a55455d0 100644 --- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysBase.java +++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysBase.java @@ -35,12 +35,24 @@ abstract class KeyboardLayoutSetNavigateMoreKeysBase extends KeyboardLayoutSetTe 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 = new ExpectedMoreKey(R.string.label_next_key); - mExpectedNavigatePreviousMoreKey = new ExpectedMoreKey(R.string.label_previous_key); - mExpectedEmojiMoreKey = new ExpectedMoreKey(KeyboardIconsSet.NAME_EMOJI_ACTION_KEY); + mExpectedNavigateNextMoreKey = getExpectedNavigateNextMoreKey(); + mExpectedNavigatePreviousMoreKey = getExpectedNavigatePreviousMoreKey(); + mExpectedEmojiMoreKey = getExpectedEmojiMoreKey(); } /** @@ -90,6 +102,7 @@ abstract class KeyboardLayoutSetNavigateMoreKeysBase extends KeyboardLayoutSetTe 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; diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysLxxTests.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysLxxTests.java index 02593cb49..d2bb41e5d 100644 --- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysLxxTests.java +++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetNavigateMoreKeysLxxTests.java @@ -18,6 +18,8 @@ package com.android.inputmethod.keyboard; import android.test.suitebuilder.annotation.SmallTest; +import com.android.inputmethod.keyboard.internal.KeyboardIconsSet; + @SmallTest public class KeyboardLayoutSetNavigateMoreKeysLxxTests extends KeyboardLayoutSetNavigateMoreKeysBase { @@ -25,4 +27,14 @@ public class KeyboardLayoutSetNavigateMoreKeysLxxTests 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/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java index 29aa7580d..570865738 100644 --- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java +++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java @@ -53,6 +53,7 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase { final KeyboardTheme keyboardTheme = KeyboardTheme.searchKeyboardThemeById( getKeyboardThemeForTests()); setContext(new ContextThemeWrapper(getContext(), keyboardTheme.mStyleId)); + KeyboardLayoutSet.onKeyboardThemeChanged(); final Context context = getContext(); mScreenMetrics = context.getResources().getInteger(R.integer.config_screen_metrics); diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java b/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java index 866f8894c..715d449a0 100644 --- a/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java +++ b/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java @@ -18,6 +18,8 @@ package com.android.inputmethod.latin; import android.test.suitebuilder.annotation.LargeTest; +import com.android.inputmethod.latin.settings.Settings; + @LargeTest public class InputLogicTestsNonEnglish extends InputTestsBase { final String NEXT_WORD_PREDICTION_OPTION = "next_word_prediction"; @@ -121,4 +123,32 @@ public class InputLogicTestsNonEnglish extends InputTestsBase { assertEquals("auto-correct with umlaut for German", EXPECTED_RESULT, mEditText.getText().toString()); } + + // Corresponds to InputLogicTests#testDoubleSpace + public void testDoubleSpaceHindi() { + changeLanguage("hi"); + // Set default pref just in case + setBooleanPreference(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true, true); + // U+1F607 is an emoji + final String[] STRINGS_TO_TYPE = + new String[] { "this ", "a+ ", "\u1F607 ", "|| ", ") ", "( ", "% " }; + final String[] EXPECTED_RESULTS = + new String[] { "this| ", "a+| ", "\u1F607| ", "|| ", ")| ", "( ", "%| " }; + for (int i = 0; i < STRINGS_TO_TYPE.length; ++i) { + mEditText.setText(""); + type(STRINGS_TO_TYPE[i]); + assertEquals("double space processing", EXPECTED_RESULTS[i], + mEditText.getText().toString()); + } + } + + // Corresponds to InputLogicTests#testCancelDoubleSpace + public void testCancelDoubleSpaceHindi() { + changeLanguage("hi"); + final String STRING_TO_TYPE = "this "; + final String EXPECTED_RESULT = "this "; + type(STRING_TO_TYPE); + type(Constants.CODE_DELETE); + assertEquals("double space make a period", EXPECTED_RESULT, mEditText.getText().toString()); + } } diff --git a/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java b/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java index 199922491..f9d72269e 100644 --- a/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java +++ b/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java @@ -215,18 +215,23 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase { "abc 'def", mSpacingAndPunctuations, 2), PrevWordsInfo.EMPTY_PREV_WORDS_INFO); } - /** - * Test logic in getting the word range at the cursor. - */ - private static final int[] SPACE = { Constants.CODE_SPACE }; - static final int[] TAB = { Constants.CODE_TAB }; - private static final int[] SPACE_TAB = StringUtils.toSortedCodePointArray(" \t"); - // A character that needs surrogate pair to represent its code point (U+2008A). - private static final String SUPPLEMENTARY_CHAR = "\uD840\uDC8A"; - private static final String HIRAGANA_WORD = "\u3042\u3044\u3046\u3048\u304A"; // あいうえお - private static final String GREEK_WORD = "\u03BA\u03B1\u03B9"; // και - public void testGetWordRangeAtCursor() { + /** + * Test logic in getting the word range at the cursor. + */ + final SpacingAndPunctuations SPACE = new SpacingAndPunctuations( + mSpacingAndPunctuations, new int[] { Constants.CODE_SPACE }); + final SpacingAndPunctuations TAB = new SpacingAndPunctuations( + mSpacingAndPunctuations, new int[] { Constants.CODE_TAB }); + final int[] SPACE_TAB = StringUtils.toSortedCodePointArray(" \t"); + // A character that needs surrogate pair to represent its code point (U+2008A). + final String SUPPLEMENTARY_CHAR_STRING = "\uD840\uDC8A"; + final SpacingAndPunctuations SUPPLEMENTARY_CHAR = new SpacingAndPunctuations( + mSpacingAndPunctuations, StringUtils.toSortedCodePointArray( + SUPPLEMENTARY_CHAR_STRING)); + final String HIRAGANA_WORD = "\u3042\u3044\u3046\u3048\u304A"; // あいうえお + final String GREEK_WORD = "\u03BA\u03B1\u03B9"; // και + ExtractedText et = new ExtractedText(); final MockInputMethodService mockInputMethodService = new MockInputMethodService(); final RichInputConnection ic = new RichInputConnection(mockInputMethodService); @@ -249,10 +254,9 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase { // splitting on supplementary character mockInputMethodService.setInputConnection( - new MockConnection("one word" + SUPPLEMENTARY_CHAR + "wo", "rd", et)); + new MockConnection("one word" + SUPPLEMENTARY_CHAR_STRING + "wo", "rd", et)); ic.beginBatchEdit(); - r = ic.getWordRangeAtCursor(StringUtils.toSortedCodePointArray(SUPPLEMENTARY_CHAR), - ScriptUtils.SCRIPT_LATIN); + r = ic.getWordRangeAtCursor(SUPPLEMENTARY_CHAR, ScriptUtils.SCRIPT_LATIN); ic.endBatchEdit(); assertTrue(TextUtils.equals("word", r.mWord)); @@ -260,8 +264,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase { mockInputMethodService.setInputConnection( new MockConnection(HIRAGANA_WORD + "wo", "rd" + GREEK_WORD, et)); ic.beginBatchEdit(); - r = ic.getWordRangeAtCursor(StringUtils.toSortedCodePointArray(SUPPLEMENTARY_CHAR), - ScriptUtils.SCRIPT_LATIN); + r = ic.getWordRangeAtCursor(SUPPLEMENTARY_CHAR, ScriptUtils.SCRIPT_LATIN); ic.endBatchEdit(); assertTrue(TextUtils.equals("word", r.mWord)); @@ -269,8 +272,7 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase { mockInputMethodService.setInputConnection( new MockConnection("text" + GREEK_WORD, "text", et)); ic.beginBatchEdit(); - r = ic.getWordRangeAtCursor(StringUtils.toSortedCodePointArray(SUPPLEMENTARY_CHAR), - ScriptUtils.SCRIPT_GREEK); + r = ic.getWordRangeAtCursor(SUPPLEMENTARY_CHAR, ScriptUtils.SCRIPT_GREEK); ic.endBatchEdit(); assertTrue(TextUtils.equals(GREEK_WORD, r.mWord)); } @@ -286,6 +288,8 @@ public class RichInputConnectionAndTextRangeTests extends AndroidTestCase { } private void helpTestGetSuggestionSpansAtWord(final int cursorPos) { + final SpacingAndPunctuations SPACE = new SpacingAndPunctuations( + mSpacingAndPunctuations, new int[] { Constants.CODE_SPACE }); final MockInputMethodService mockInputMethodService = new MockInputMethodService(); final RichInputConnection ic = new RichInputConnection(mockInputMethodService); diff --git a/tests/src/com/android/inputmethod/latin/utils/CapsModeUtilsTests.java b/tests/src/com/android/inputmethod/latin/utils/CapsModeUtilsTests.java index c746c8345..4646a823d 100644 --- a/tests/src/com/android/inputmethod/latin/utils/CapsModeUtilsTests.java +++ b/tests/src/com/android/inputmethod/latin/utils/CapsModeUtilsTests.java @@ -124,5 +124,29 @@ public class CapsModeUtilsTests extends AndroidTestCase { allPathsForCaps("Word. ", c | w, sp, false); // Armenian period : capitalize if MODE_SENTENCES allPathsForCaps("Word\u0589 ", c | w | s, sp, false); + + // Test for sentence terminators + sp = job.runInLocale(res, Locale.ENGLISH); + allPathsForCaps("Word? ", c | w | s, sp, false); + allPathsForCaps("Word?", c | w | s, sp, true); + allPathsForCaps("Word?", c, sp, false); + allPathsForCaps("Word! ", c | w | s, sp, false); + allPathsForCaps("Word!", c | w | s, sp, true); + allPathsForCaps("Word!", c, sp, false); + allPathsForCaps("Word; ", c | w, sp, false); + allPathsForCaps("Word;", c | w, sp, true); + allPathsForCaps("Word;", c, sp, false); + // Test for sentence terminators in Greek + sp = job.runInLocale(res, LocaleUtils.constructLocaleFromString("el")); + allPathsForCaps("Word? ", c | w | s, sp, false); + allPathsForCaps("Word?", c | w | s, sp, true); + allPathsForCaps("Word?", c, sp, false); + allPathsForCaps("Word! ", c | w | s, sp, false); + allPathsForCaps("Word!", c | w | s, sp, true); + allPathsForCaps("Word!", c, sp, false); + // In Greek ";" is the question mark and it terminates the sentence + allPathsForCaps("Word; ", c | w | s, sp, false); + allPathsForCaps("Word;", c | w | s, sp, true); + allPathsForCaps("Word;", c, sp, false); } } |