aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/latin
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-10-28 06:22:17 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-10-28 06:22:18 +0000
commit450c8e8935c35b93ab7c8183931313cb9acfb3a6 (patch)
treef38345d68a324670866c0ec66e16bdb7cef17ee5 /tests/src/com/android/inputmethod/latin
parent395009c03eeda42b2b2114d005c3ed8d7e4bfd4b (diff)
parentd17e1d31b69e006af7302903686e3ddb3cb30d27 (diff)
downloadlatinime-450c8e8935c35b93ab7c8183931313cb9acfb3a6.tar.gz
latinime-450c8e8935c35b93ab7c8183931313cb9acfb3a6.tar.xz
latinime-450c8e8935c35b93ab7c8183931313cb9acfb3a6.zip
Merge "Add some gesture-move tests"
Diffstat (limited to 'tests/src/com/android/inputmethod/latin')
-rw-r--r--tests/src/com/android/inputmethod/latin/InputLogicTests.java34
1 files changed, 32 insertions, 2 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
index 7d356a4be..c76f6f446 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
@@ -674,10 +674,15 @@ public class InputLogicTests extends InputTestsBase {
mEditText.getText().toString());
}
- private void typeWordAndPutCursorInside(final String word, final int startPos) {
+ private void typeOrGestureWordAndPutCursorInside(final boolean gesture, final String word,
+ final int startPos) {
final int END_OF_WORD = startPos + word.length();
final int NEW_CURSOR_POSITION = startPos + word.length() / 2;
- type(word);
+ if (gesture) {
+ gesture(word);
+ } else {
+ type(word);
+ }
sendUpdateForCursorMoveTo(END_OF_WORD);
runMessages();
sendUpdateForCursorMoveTo(NEW_CURSOR_POSITION);
@@ -687,6 +692,14 @@ public class InputLogicTests extends InputTestsBase {
startPos, END_OF_WORD);
}
+ private void typeWordAndPutCursorInside(final String word, final int startPos) {
+ typeOrGestureWordAndPutCursorInside(false /* gesture */, word, startPos);
+ }
+
+ private void gestureWordAndPutCursorInside(final String word, final int startPos) {
+ typeOrGestureWordAndPutCursorInside(true /* gesture */, word, startPos);
+ }
+
private void ensureComposingSpanPos(final String message, final int from, final int to) {
assertEquals(message, from, BaseInputConnection.getComposingSpanStart(mEditText.getText()));
assertEquals(message, to, BaseInputConnection.getComposingSpanEnd(mEditText.getText()));
@@ -703,6 +716,23 @@ public class InputLogicTests extends InputTestsBase {
int cursorPos = sendUpdateForCursorMoveToEndOfLine();
runMessages();
type(" ");
+ assertEquals("mbo", "some thing ", mEditText.getText().toString());
+ typeWordAndPutCursorInside(WORD_TO_TYPE, cursorPos + 1 /* startPos */);
+ type(Constants.CODE_DELETE);
+ ensureComposingSpanPos("space while in the middle of a word cancels composition", -1, -1);
+ }
+
+ public void testTypeWithinGestureComposing() {
+ final String WORD_TO_TYPE = "something";
+ final String EXPECTED_RESULT = "some thing";
+ gestureWordAndPutCursorInside(WORD_TO_TYPE, 0 /* startPos */);
+ type(" ");
+ ensureComposingSpanPos("space while in the middle of a word cancels composition", -1, -1);
+ assertEquals("space in the middle of a composing word", EXPECTED_RESULT,
+ mEditText.getText().toString());
+ int cursorPos = sendUpdateForCursorMoveToEndOfLine();
+ runMessages();
+ type(" ");
typeWordAndPutCursorInside(WORD_TO_TYPE, cursorPos + 1 /* startPos */);
type(Constants.CODE_DELETE);
ensureComposingSpanPos("space while in the middle of a word cancels composition", -1, -1);