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.java170
1 files changed, 49 insertions, 121 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
index eb94e2266..02cd21c8d 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
@@ -217,22 +217,45 @@ public class InputLogicTests extends InputTestsBase {
}
public void testDoubleSpace() {
- // 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) {
+ verifyDoubleSpace(STRINGS_TO_TYPE, EXPECTED_RESULTS);
+ }
+
+ public void testDoubleSpaceHindi() {
+ changeLanguage("hi");
+ // U+1F607 is an emoji
+ final String[] STRINGS_TO_TYPE =
+ new String[] { "this ", "a+ ", "\u1F607 ", "|| ", ") ", "( ", "% " };
+ final String[] EXPECTED_RESULTS =
+ new String[] { "this| ", "a+| ", "\u1F607| ", "|| ", ")| ", "( ", "%| " };
+ verifyDoubleSpace(STRINGS_TO_TYPE, EXPECTED_RESULTS);
+ }
+
+ private void verifyDoubleSpace(String[] stringsToType, String[] expectedResults) {
+ // Set default pref just in case
+ setBooleanPreference(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true, true);
+ for (int i = 0; i < stringsToType.length; ++i) {
mEditText.setText("");
- type(STRINGS_TO_TYPE[i]);
- assertEquals("double space processing", EXPECTED_RESULTS[i],
+ type(stringsToType[i]);
+ assertEquals("double space processing", expectedResults[i],
mEditText.getText().toString());
}
}
- public void testCancelDoubleSpace() {
+ public void testCancelDoubleSpaceEnglish() {
+ 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());
+ }
+
+ public void testCancelDoubleSpaceHindi() {
+ changeLanguage("hi");
final String STRING_TO_TYPE = "this ";
final String EXPECTED_RESULT = "this ";
type(STRING_TO_TYPE);
@@ -283,7 +306,7 @@ public class InputLogicTests extends InputTestsBase {
setBooleanPreference(Settings.PREF_SHOW_SUGGESTIONS, true, true);
setBooleanPreference(Settings.PREF_AUTO_CORRECTION, true, true);
setBooleanPreference(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true, true);
- testDoubleSpacePeriodWithSettings(true /* expectsPeriod */);
+ testDoubleSpacePeriodWithSettings(true);
// "Suggestion visibility" to off
testDoubleSpacePeriodWithSettings(true, Settings.PREF_SHOW_SUGGESTIONS, false);
// "Suggestion visibility" to on
@@ -463,38 +486,19 @@ public class InputLogicTests extends InputTestsBase {
type(" ");
helperTestComposing("a'", true);
}
+
// TODO: Add some tests for non-BMP characters
public void testAutoCorrectByUserHistory() {
- final String WORD_TO_BE_CORRECTED = "qpmx";
- final String NOT_CORRECTED_RESULT = "qpmx ";
- final String DESIRED_WORD = "qpmz";
- final String CORRECTED_RESULT = "qpmz ";
- final int typeCountNotToAutocorrect = 1;
- final int typeCountToAutoCorrect = 16;
- int startIndex = 0;
- int endIndex = 0;
-
- for (int i = 0; i < typeCountNotToAutocorrect; i++) {
- type(DESIRED_WORD);
- type(Constants.CODE_SPACE);
- }
- startIndex = mEditText.getText().length();
- type(WORD_TO_BE_CORRECTED);
+ type("qpmz");
type(Constants.CODE_SPACE);
- endIndex = mEditText.getText().length();
- assertEquals("not auto-corrected by user history", NOT_CORRECTED_RESULT,
- mEditText.getText().subSequence(startIndex, endIndex).toString());
- for (int i = typeCountNotToAutocorrect; i < typeCountToAutoCorrect; i++) {
- type(DESIRED_WORD);
- type(Constants.CODE_SPACE);
- }
- startIndex = mEditText.getText().length();
- type(WORD_TO_BE_CORRECTED);
+
+ int startIndex = mEditText.getText().length();
+ type("qpmx");
type(Constants.CODE_SPACE);
- endIndex = mEditText.getText().length();
+ int endIndex = mEditText.getText().length();
assertEquals("auto-corrected by user history",
- CORRECTED_RESULT, mEditText.getText().subSequence(startIndex, endIndex).toString());
+ "qpmz ", mEditText.getText().subSequence(startIndex, endIndex).toString());
}
public void testPredictionsAfterSpace() {
@@ -641,31 +645,15 @@ public class InputLogicTests extends InputTestsBase {
mEditText.getText().toString());
}
- public void testSwitchLanguages() {
- final String WORD_TO_TYPE_FIRST_PART = "com";
- final String WORD_TO_TYPE_SECOND_PART = "md";
- final String EXPECTED_RESULT = "comme";
- changeLanguage("en");
- type(WORD_TO_TYPE_FIRST_PART);
- changeLanguage("fr");
- runMessages();
- type(WORD_TO_TYPE_SECOND_PART);
- sleep(DELAY_TO_WAIT_FOR_UNDERLINE_MILLIS);
- runMessages();
- final SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest();
- assertEquals("Suggestions updated after switching languages",
- EXPECTED_RESULT, suggestedWords.size() > 0 ? suggestedWords.getWord(1) : null);
- }
-
public void testBasicGesture() {
gesture("this");
- assertEquals("gesture \"this\"", "this", mEditText.getText().toString());
+ assertEquals("this", mEditText.getText().toString());
}
public void testGestureGesture() {
- gesture("this");
- gesture("is");
- assertEquals("gesture \"this is\"", "this is", mEditText.getText().toString());
+ gesture("got");
+ gesture("milk");
+ assertEquals("got milk", mEditText.getText().toString());
}
public void testGestureBackspaceGestureAgain() {
@@ -694,8 +682,6 @@ public class InputLogicTests extends InputTestsBase {
sendUpdateForCursorMoveTo(NEW_CURSOR_POSITION);
sleep(DELAY_TO_WAIT_FOR_UNDERLINE_MILLIS);
runMessages();
- ensureComposingSpanPos("move cursor inside word leaves composing span in the right place",
- startPos, END_OF_WORD);
}
private void typeWordAndPutCursorInside(final String word, final int startPos) {
@@ -725,7 +711,7 @@ public class InputLogicTests extends InputTestsBase {
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);
+ ensureComposingSpanPos("delete while in the middle of a word cancels composition", -1, -1);
}
public void testTypeWithinGestureComposing() {
@@ -741,17 +727,8 @@ public class InputLogicTests extends InputTestsBase {
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);
- }
-
- // TODO: Verify this works when we return FIGS language models to the APK.
- public void testAutoCorrectForFrench() {
- final String STRING_TO_TYPE = "irq ";
- final String EXPECTED_RESULT = "ir a ";
- changeLanguage("es");
- type(STRING_TO_TYPE);
- assertEquals("simple auto-correct for Spanish", EXPECTED_RESULT,
- mEditText.getText().toString());
+ sleep(DELAY_TO_WAIT_FOR_UNDERLINE_MILLIS);
+ ensureComposingSpanPos("delete while in the middle of a word cancels composition", -1, -1);
}
public void testManualPickThenSeparatorForFrench() {
@@ -779,13 +756,12 @@ public class InputLogicTests extends InputTestsBase {
mEditText.getText().toString());
}
- public void testWordThenSpaceThenPunctuationFromStripTwiceForFrench() {
+ public void testWordThenSpaceThenPunctuationFromStripTwice() {
setBooleanPreference(Settings.PREF_BIGRAM_PREDICTIONS, false, true);
final String WORD_TO_TYPE = "test ";
final String PUNCTUATION_FROM_STRIP = "!";
- final String EXPECTED_RESULT = "test !!";
- changeLanguage("fr");
+ final String EXPECTED_RESULT = "test!! ";
type(WORD_TO_TYPE);
sleep(DELAY_TO_WAIT_FOR_UNDERLINE_MILLIS);
runMessages();
@@ -793,14 +769,12 @@ public class InputLogicTests extends InputTestsBase {
mLatinIME.getSuggestedWordsForTest().isPunctuationSuggestions());
pickSuggestionManually(PUNCTUATION_FROM_STRIP);
pickSuggestionManually(PUNCTUATION_FROM_STRIP);
- assertEquals("type word then type space then punctuation from strip twice for French",
- EXPECTED_RESULT, mEditText.getText().toString());
+ assertEquals(EXPECTED_RESULT, mEditText.getText().toString());
}
public void testWordThenSpaceDisplaysPredictions() {
- final String WORD_TO_TYPE = "beaujolais ";
- final String EXPECTED_RESULT = "nouveau";
- changeLanguage("fr");
+ final String WORD_TO_TYPE = "Barack ";
+ final String EXPECTED_RESULT = "Obama";
type(WORD_TO_TYPE);
sleep(DELAY_TO_WAIT_FOR_UNDERLINE_MILLIS);
runMessages();
@@ -808,50 +782,4 @@ public class InputLogicTests extends InputTestsBase {
assertEquals("type word then type space yields predictions for French",
EXPECTED_RESULT, suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
}
-
- public void testAutoCorrectForGerman() {
- final String STRING_TO_TYPE = "unf ";
- final String EXPECTED_RESULT = "und ";
- changeLanguage("de");
- type(STRING_TO_TYPE);
- assertEquals("simple auto-correct for German", EXPECTED_RESULT,
- mEditText.getText().toString());
- }
-
- public void testAutoCorrectWithUmlautForGerman() {
- final String STRING_TO_TYPE = "ueber ";
- final String EXPECTED_RESULT = "über ";
- changeLanguage("de");
- type(STRING_TO_TYPE);
- 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());
- }
}