aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-09-03 15:27:01 +0900
committerJean Chalard <jchalard@google.com>2014-09-08 21:47:01 +0900
commit914078fd9198aeb3d7ffa034562321d688d588f7 (patch)
treeb0a2f371d846b6e5c1b639e263b950382a4544e5 /tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java
parent42665f0ee26407fae984446b306309376aac2b36 (diff)
downloadlatinime-914078fd9198aeb3d7ffa034562321d688d588f7.tar.gz
latinime-914078fd9198aeb3d7ffa034562321d688d588f7.tar.xz
latinime-914078fd9198aeb3d7ffa034562321d688d588f7.zip
Fix a bug where recorrection would stop on connectors
Bug: 16733686 Change-Id: I7a9f79a81e33a1f5bf5f3daf0b78d0f1e4447e7a
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java')
-rw-r--r--tests/src/com/android/inputmethod/latin/RichInputConnectionAndTextRangeTests.java40
1 files changed, 22 insertions, 18 deletions
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);