diff options
author | 2015-03-04 10:54:50 -0800 | |
---|---|---|
committer | 2015-03-04 15:02:53 -0800 | |
commit | 1ae16dc3db170802d1b38273f477125a2a969d32 (patch) | |
tree | 1628004f1e78e57b8c84d50c359c29bed4d14dc7 /tests | |
parent | 83e95e601876a2f7938da8a3f773f9ef088a23ab (diff) | |
download | latinime-1ae16dc3db170802d1b38273f477125a2a969d32.tar.gz latinime-1ae16dc3db170802d1b38273f477125a2a969d32.tar.xz latinime-1ae16dc3db170802d1b38273f477125a2a969d32.zip |
Next-word suggestion bit in keyboard settings.
This feature works in supported languages.
We don't need a user setting.
Bug 19596067.
Change-Id: Icdded772745f9816da47f8a5e3b87b733083b121
Diffstat (limited to 'tests')
4 files changed, 31 insertions, 86 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputLogicTests.java b/tests/src/com/android/inputmethod/latin/InputLogicTests.java index c76f6f446..7647773e7 100644 --- a/tests/src/com/android/inputmethod/latin/InputLogicTests.java +++ b/tests/src/com/android/inputmethod/latin/InputLogicTests.java @@ -504,9 +504,11 @@ public class InputLogicTests extends InputTestsBase { type(" "); sleep(DELAY_TO_WAIT_FOR_PREDICTIONS_MILLIS); runMessages(); - // Test the predictions have been cleared + // Corrections have been replaced with predictions. SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest(); - assertEquals("predictions cleared after double-space-to-period", suggestedWords.size(), 0); + 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)); type(Constants.CODE_DELETE); sleep(DELAY_TO_WAIT_FOR_PREDICTIONS_MILLIS); runMessages(); @@ -529,23 +531,6 @@ 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/InputLogicTestsNonEnglish.java b/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java index 3cfd0e2a6..fa39f31d4 100644 --- a/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java +++ b/tests/src/com/android/inputmethod/latin/InputLogicTestsNonEnglish.java @@ -23,7 +23,6 @@ import com.android.inputmethod.latin.settings.Settings; @LargeTest public class InputLogicTestsNonEnglish extends InputTestsBase { - final String NEXT_WORD_PREDICTION_OPTION = "next_word_prediction"; public void testAutoCorrectForFrench() { final String STRING_TO_TYPE = "irq "; @@ -63,48 +62,28 @@ public class InputLogicTestsNonEnglish extends InputTestsBase { final String WORD_TO_TYPE = "test "; final String PUNCTUATION_FROM_STRIP = "!"; final String EXPECTED_RESULT = "test !!"; - final boolean defaultNextWordPredictionOption = - mLatinIME.getResources().getBoolean(R.bool.config_default_next_word_prediction); - final boolean previousNextWordPredictionOption = - setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, false, - defaultNextWordPredictionOption); - try { - changeLanguage("fr"); - 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 for French", - EXPECTED_RESULT, mEditText.getText().toString()); - } finally { - setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, previousNextWordPredictionOption, - defaultNextWordPredictionOption); - } + changeLanguage("fr"); + 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 for French", + EXPECTED_RESULT, mEditText.getText().toString()); } public void testWordThenSpaceDisplaysPredictions() { final String WORD_TO_TYPE = "beaujolais "; final String EXPECTED_RESULT = "nouveau"; - final boolean defaultNextWordPredictionOption = - mLatinIME.getResources().getBoolean(R.bool.config_default_next_word_prediction); - final boolean previousNextWordPredictionOption = - setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, true, - defaultNextWordPredictionOption); - try { - changeLanguage("fr"); - type(WORD_TO_TYPE); - sleep(DELAY_TO_WAIT_FOR_UNDERLINE_MILLIS); - runMessages(); - final SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest(); - assertEquals("type word then type space yields predictions for French", - EXPECTED_RESULT, suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null); - } finally { - setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, previousNextWordPredictionOption, - defaultNextWordPredictionOption); - } + changeLanguage("fr"); + type(WORD_TO_TYPE); + sleep(DELAY_TO_WAIT_FOR_UNDERLINE_MILLIS); + runMessages(); + final SuggestedWords suggestedWords = mLatinIME.getSuggestedWordsForTest(); + assertEquals("type word then type space yields predictions for French", + EXPECTED_RESULT, suggestedWords.size() > 0 ? suggestedWords.getWord(0) : null); } public void testAutoCorrectForGerman() { diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java index 00e0b52cb..ea7823c64 100644 --- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java +++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java @@ -77,7 +77,6 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { protected MyEditText mEditText; protected View mInputView; protected InputConnection mInputConnection; - private boolean mPreviousBigramPredictionSettings; private String mPreviousAutoCorrectSetting; // A helper class to ease span tests @@ -201,8 +200,6 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { setupService(); mLatinIME = getService(); setDebugMode(true); - mPreviousBigramPredictionSettings = setBooleanPreference(Settings.PREF_BIGRAM_PREDICTIONS, - true, true /* defaultValue */); mPreviousAutoCorrectSetting = setStringPreference(Settings.PREF_AUTO_CORRECTION_THRESHOLD, DEFAULT_AUTO_CORRECTION_THRESHOLD, DEFAULT_AUTO_CORRECTION_THRESHOLD); mLatinIME.onCreate(); @@ -233,8 +230,6 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { mLatinIME.onFinishInput(); runMessages(); mLatinIME.mHandler.removeAllMessages(); - setBooleanPreference(Settings.PREF_BIGRAM_PREDICTIONS, mPreviousBigramPredictionSettings, - true /* defaultValue */); setStringPreference(Settings.PREF_AUTO_CORRECTION_THRESHOLD, mPreviousAutoCorrectSetting, DEFAULT_AUTO_CORRECTION_THRESHOLD); setDebugMode(false); diff --git a/tests/src/com/android/inputmethod/latin/PunctuationTests.java b/tests/src/com/android/inputmethod/latin/PunctuationTests.java index 3537918de..9ac220407 100644 --- a/tests/src/com/android/inputmethod/latin/PunctuationTests.java +++ b/tests/src/com/android/inputmethod/latin/PunctuationTests.java @@ -19,37 +19,23 @@ 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!! "; - 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); - } + 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()); } public void testWordThenSpaceThenPunctuationFromKeyboardTwice() { |