aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/latin/InputLogicTests.java
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/InputLogicTests.java')
-rw-r--r--tests/src/com/android/inputmethod/latin/InputLogicTests.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
index d27a7a903..fe92be618 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
@@ -17,6 +17,7 @@
package com.android.inputmethod.latin;
import android.test.suitebuilder.annotation.LargeTest;
+import android.view.inputmethod.BaseInputConnection;
@LargeTest
public class InputLogicTests extends InputTestsBase {
@@ -290,5 +291,47 @@ public class InputLogicTests extends InputTestsBase {
}
assertEquals("delete whole composing word", "", mEditText.getText().toString());
}
+
+ public void testResumeSuggestionOnBackspace() {
+ final String WORD_TO_TYPE = "and this ";
+ type(WORD_TO_TYPE);
+ assertEquals("resume suggestion on backspace", -1,
+ BaseInputConnection.getComposingSpanStart(mEditText.getText()));
+ assertEquals("resume suggestion on backspace", -1,
+ BaseInputConnection.getComposingSpanEnd(mEditText.getText()));
+ type(Constants.CODE_DELETE);
+ assertEquals("resume suggestion on backspace", 4,
+ BaseInputConnection.getComposingSpanStart(mEditText.getText()));
+ assertEquals("resume suggestion on backspace", 8,
+ BaseInputConnection.getComposingSpanEnd(mEditText.getText()));
+ }
+
+ private void helperTestComposing(final String wordToType, final boolean shouldBeComposing) {
+ mEditText.setText("");
+ type(wordToType);
+ assertEquals("start composing inside text", shouldBeComposing ? 0 : -1,
+ BaseInputConnection.getComposingSpanStart(mEditText.getText()));
+ assertEquals("start composing inside text", shouldBeComposing ? wordToType.length() : -1,
+ BaseInputConnection.getComposingSpanEnd(mEditText.getText()));
+ }
+
+ public void testStartComposing() {
+ // Should start composing on a letter
+ helperTestComposing("a", true);
+ type(" "); // To reset the composing state
+ // Should not start composing on quote
+ helperTestComposing("'", false);
+ type(" ");
+ helperTestComposing("'-", false);
+ type(" ");
+ // Should not start composing on dash
+ helperTestComposing("-", false);
+ type(" ");
+ helperTestComposing("-'", false);
+ type(" ");
+ helperTestComposing("a-", true);
+ type(" ");
+ helperTestComposing("a'", true);
+ }
// TODO: Add some tests for non-BMP characters
}