aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java2
-rw-r--r--tests/src/com/android/inputmethod/latin/InputLogicTests.java23
-rw-r--r--tests/src/com/android/inputmethod/latin/InputTestsBase.java5
-rw-r--r--tests/src/com/android/inputmethod/latin/PunctuationTests.java34
4 files changed, 49 insertions, 15 deletions
diff --git a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
index 9da1e9470..752051775 100644
--- a/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
+++ b/tests/src/com/android/inputmethod/latin/BinaryDictionaryTests.java
@@ -170,7 +170,7 @@ public class BinaryDictionaryTests extends AndroidTestCase {
private void testAddTooLongWord(final int formatVersion) {
final BinaryDictionary binaryDictionary = getEmptyBinaryDictionary(formatVersion);
final StringBuffer stringBuilder = new StringBuffer();
- for (int i = 0; i < DecoderSpecificConstants.DICTIONARY_MAX_WORD_LENGTH; i++) {
+ for (int i = 0; i < BinaryDictionary.DICTIONARY_MAX_WORD_LENGTH; i++) {
stringBuilder.append('a');
}
final String validLongWord = stringBuilder.toString();
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
index e09b1e936..b1b48135f 100644
--- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java
+++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java
@@ -502,11 +502,9 @@ public class InputLogicTests extends InputTestsBase {
type(" ");
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS_MILLIS);
runMessages();
- // Corrections have been replaced with predictions.
+ // Test the predictions have been cleared
SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest();
- String word = suggestedWords == null ? null : suggestedWords.getWord(0);
- assertTrue("predictions after double-space-to-period is I or The",
- "I".equals(word) || "The".equals(word));
+ assertEquals("predictions cleared after double-space-to-period", suggestedWords.size(), 0);
type(Constants.CODE_DELETE);
sleep(DELAY_TO_WAIT_FOR_PREDICTIONS_MILLIS);
runMessages();
@@ -529,6 +527,23 @@ public class InputLogicTests extends InputTestsBase {
suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
}
+ public void testPredictionsAfterPeriod() {
+ mLatinIME.clearPersonalizedDictionariesForTest();
+ final String WORD_TO_TYPE = "Barack. ";
+ type(WORD_TO_TYPE);
+ sleep(DELAY_TO_WAIT_FOR_PREDICTIONS_MILLIS);
+ runMessages();
+ SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest();
+ assertEquals("No prediction after period after inputting once.", 0, suggestedWords.size());
+
+ type(WORD_TO_TYPE);
+ sleep(DELAY_TO_WAIT_FOR_PREDICTIONS_MILLIS);
+ runMessages();
+ suggestedWords = mLatinIME.getSuggestedWordsForTest();
+ assertEquals("Beginning-of-Sentence prediction after inputting 2 times.", "Barack",
+ suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null);
+ }
+
public void testPredictionsAfterRecorrection() {
final String PREFIX = "A ";
final String WORD_TO_TYPE = "Barack";
diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
index d5e93744a..6ae38c615 100644
--- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java
+++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
@@ -78,6 +78,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> {
protected View mInputView;
protected InputConnection mInputConnection;
private boolean mPreviousAutoCorrectSetting;
+ private boolean mPreviousBigramPredictionSettings;
// A helper class to ease span tests
public static class SpanGetter {
@@ -200,6 +201,8 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> {
setupService();
mLatinIME = getService();
setDebugMode(true);
+ mPreviousBigramPredictionSettings = setBooleanPreference(Settings.PREF_BIGRAM_PREDICTIONS,
+ true, true /* defaultValue */);
mPreviousAutoCorrectSetting = setBooleanPreference(Settings.PREF_AUTO_CORRECTION,
DEFAULT_AUTO_CORRECTION, DEFAULT_AUTO_CORRECTION);
mLatinIME.onCreate();
@@ -230,6 +233,8 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> {
mLatinIME.onFinishInput();
runMessages();
mLatinIME.mHandler.removeAllMessages();
+ setBooleanPreference(Settings.PREF_BIGRAM_PREDICTIONS, mPreviousBigramPredictionSettings,
+ true /* defaultValue */);
setBooleanPreference(Settings.PREF_AUTO_CORRECTION, mPreviousAutoCorrectSetting,
DEFAULT_AUTO_CORRECTION);
setDebugMode(false);
diff --git a/tests/src/com/android/inputmethod/latin/PunctuationTests.java b/tests/src/com/android/inputmethod/latin/PunctuationTests.java
index 9ac220407..3537918de 100644
--- a/tests/src/com/android/inputmethod/latin/PunctuationTests.java
+++ b/tests/src/com/android/inputmethod/latin/PunctuationTests.java
@@ -19,23 +19,37 @@ package com.android.inputmethod.latin;
import android.provider.Settings.Secure;
import android.test.suitebuilder.annotation.LargeTest;
+import com.android.inputmethod.latin.R;
+
@LargeTest
public class PunctuationTests extends InputTestsBase {
+ final String NEXT_WORD_PREDICTION_OPTION = "next_word_prediction";
+
public void testWordThenSpaceThenPunctuationFromStripTwice() {
final String WORD_TO_TYPE = "this ";
final String PUNCTUATION_FROM_STRIP = "!";
final String EXPECTED_RESULT = "this!! ";
- mLatinIME.loadSettings();
- type(WORD_TO_TYPE);
- sleep(DELAY_TO_WAIT_FOR_UNDERLINE_MILLIS);
- runMessages();
- assertTrue("type word then type space should display punctuation strip",
- mLatinIME.getSuggestedWordsForTest().isPunctuationSuggestions());
- pickSuggestionManually(PUNCTUATION_FROM_STRIP);
- pickSuggestionManually(PUNCTUATION_FROM_STRIP);
- assertEquals("type word then type space then punctuation from strip twice",
- EXPECTED_RESULT, mEditText.getText().toString());
+ final boolean defaultNextWordPredictionOption =
+ mLatinIME.getResources().getBoolean(R.bool.config_default_next_word_prediction);
+ final boolean previousNextWordPredictionOption =
+ setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, false,
+ defaultNextWordPredictionOption);
+ try {
+ mLatinIME.loadSettings();
+ type(WORD_TO_TYPE);
+ sleep(DELAY_TO_WAIT_FOR_UNDERLINE_MILLIS);
+ runMessages();
+ assertTrue("type word then type space should display punctuation strip",
+ mLatinIME.getSuggestedWordsForTest().isPunctuationSuggestions());
+ pickSuggestionManually(PUNCTUATION_FROM_STRIP);
+ pickSuggestionManually(PUNCTUATION_FROM_STRIP);
+ assertEquals("type word then type space then punctuation from strip twice",
+ EXPECTED_RESULT, mEditText.getText().toString());
+ } finally {
+ setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, previousNextWordPredictionOption,
+ defaultNextWordPredictionOption);
+ }
}
public void testWordThenSpaceThenPunctuationFromKeyboardTwice() {