diff options
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/InputTestsBase.java')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/InputTestsBase.java | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java index ea7823c64..0d9b36ac0 100644 --- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java +++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java @@ -58,7 +58,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { // Default value for auto-correction threshold. This is the string representation of the // index in the resources array of auto-correction threshold settings. - private static final String DEFAULT_AUTO_CORRECTION_THRESHOLD = "1"; + private static final boolean DEFAULT_AUTO_CORRECTION = true; // The message that sets the underline is posted with a 500 ms delay protected static final int DELAY_TO_WAIT_FOR_UNDERLINE_MILLIS = 500; @@ -77,7 +77,8 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { protected MyEditText mEditText; protected View mInputView; protected InputConnection mInputConnection; - private String mPreviousAutoCorrectSetting; + private boolean mPreviousAutoCorrectSetting; + private boolean mPreviousBigramPredictionSettings; // A helper class to ease span tests public static class SpanGetter { @@ -163,6 +164,11 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { return previousSetting; } + protected boolean getBooleanPreference(final String key, final boolean defaultValue) { + return PreferenceManager.getDefaultSharedPreferences(mLatinIME) + .getBoolean(key, defaultValue); + } + protected String setStringPreference(final String key, final String value, final String defaultValue) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mLatinIME); @@ -200,8 +206,10 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { setupService(); mLatinIME = getService(); setDebugMode(true); - mPreviousAutoCorrectSetting = setStringPreference(Settings.PREF_AUTO_CORRECTION_THRESHOLD, - DEFAULT_AUTO_CORRECTION_THRESHOLD, DEFAULT_AUTO_CORRECTION_THRESHOLD); + mPreviousBigramPredictionSettings = setBooleanPreference(Settings.PREF_BIGRAM_PREDICTIONS, + true, true /* defaultValue */); + mPreviousAutoCorrectSetting = setBooleanPreference(Settings.PREF_AUTO_CORRECTION, + DEFAULT_AUTO_CORRECTION, DEFAULT_AUTO_CORRECTION); mLatinIME.onCreate(); EditorInfo ei = new EditorInfo(); final InputConnection ic = mEditText.onCreateInputConnection(ei); @@ -230,8 +238,10 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { mLatinIME.onFinishInput(); runMessages(); mLatinIME.mHandler.removeAllMessages(); - setStringPreference(Settings.PREF_AUTO_CORRECTION_THRESHOLD, mPreviousAutoCorrectSetting, - DEFAULT_AUTO_CORRECTION_THRESHOLD); + setBooleanPreference(Settings.PREF_BIGRAM_PREDICTIONS, mPreviousBigramPredictionSettings, + true /* defaultValue */); + setBooleanPreference(Settings.PREF_AUTO_CORRECTION, mPreviousAutoCorrectSetting, + DEFAULT_AUTO_CORRECTION); setDebugMode(false); mLatinIME.recycle(); super.tearDown(); @@ -399,7 +409,8 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { } protected void pickSuggestionManually(final String suggestion) { - mLatinIME.pickSuggestionManually(new SuggestedWordInfo(suggestion, 1, + mLatinIME.pickSuggestionManually(new SuggestedWordInfo(suggestion, + "" /* prevWordsContext */, 1 /* score */, SuggestedWordInfo.KIND_CORRECTION, DICTIONARY_TEST, SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */, SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */)); |