Loading tests/src/com/android/inputmethod/latin/InputTestsBase.java +12 −5 Original line number Diff line number Diff line Loading @@ -90,14 +90,21 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> { super(LatinIME.class); } // returns the previous setting value protected boolean setDebugMode(final boolean mode) { // TODO: Isn't there a way to make this generic somehow? We can take a <T> and return a <T> // but we'd have to dispatch types on editor.put...() functions protected boolean setBooleanPreference(final String key, final boolean value, final boolean defaultValue) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mLatinIME); final boolean previousDebugSetting = prefs.getBoolean(PREF_DEBUG_MODE, false); final boolean previousSetting = prefs.getBoolean(key, defaultValue); final SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(PREF_DEBUG_MODE, mode); editor.putBoolean(key, value); editor.commit(); return previousDebugSetting; return previousSetting; } // returns the previous setting value protected boolean setDebugMode(final boolean value) { return setBooleanPreference(PREF_DEBUG_MODE, value, false); } // overload this to configure preferences in a way specific to a subclass's tests Loading tests/src/com/android/inputmethod/latin/PunctuationTests.java +24 −9 Original line number Diff line number Diff line Loading @@ -16,12 +16,23 @@ package com.android.inputmethod.latin; import com.android.inputmethod.latin.R; 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_suggestions); final boolean previousNextWordPredictionOption = setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, false, defaultNextWordPredictionOption); try { mLatinIME.loadSettings(); type(WORD_TO_TYPE); sleep(DELAY_TO_WAIT_FOR_UNDERLINE); runMessages(); Loading @@ -29,8 +40,12 @@ public class PunctuationTests extends InputTestsBase { mLatinIME.isShowingPunctuationList()); mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); assertEquals("type word then type space then punctuation from strip twice", EXPECTED_RESULT, mTextView.getText().toString()); assertEquals("type word then type space then punctuation from strip twice", EXPECTED_RESULT, mTextView.getText().toString()); } finally { setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, previousNextWordPredictionOption, defaultNextWordPredictionOption); } } public void testWordThenSpaceThenPunctuationFromKeyboardTwice() { Loading Loading
tests/src/com/android/inputmethod/latin/InputTestsBase.java +12 −5 Original line number Diff line number Diff line Loading @@ -90,14 +90,21 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> { super(LatinIME.class); } // returns the previous setting value protected boolean setDebugMode(final boolean mode) { // TODO: Isn't there a way to make this generic somehow? We can take a <T> and return a <T> // but we'd have to dispatch types on editor.put...() functions protected boolean setBooleanPreference(final String key, final boolean value, final boolean defaultValue) { final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mLatinIME); final boolean previousDebugSetting = prefs.getBoolean(PREF_DEBUG_MODE, false); final boolean previousSetting = prefs.getBoolean(key, defaultValue); final SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(PREF_DEBUG_MODE, mode); editor.putBoolean(key, value); editor.commit(); return previousDebugSetting; return previousSetting; } // returns the previous setting value protected boolean setDebugMode(final boolean value) { return setBooleanPreference(PREF_DEBUG_MODE, value, false); } // overload this to configure preferences in a way specific to a subclass's tests Loading
tests/src/com/android/inputmethod/latin/PunctuationTests.java +24 −9 Original line number Diff line number Diff line Loading @@ -16,12 +16,23 @@ package com.android.inputmethod.latin; import com.android.inputmethod.latin.R; 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_suggestions); final boolean previousNextWordPredictionOption = setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, false, defaultNextWordPredictionOption); try { mLatinIME.loadSettings(); type(WORD_TO_TYPE); sleep(DELAY_TO_WAIT_FOR_UNDERLINE); runMessages(); Loading @@ -29,8 +40,12 @@ public class PunctuationTests extends InputTestsBase { mLatinIME.isShowingPunctuationList()); mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP); assertEquals("type word then type space then punctuation from strip twice", EXPECTED_RESULT, mTextView.getText().toString()); assertEquals("type word then type space then punctuation from strip twice", EXPECTED_RESULT, mTextView.getText().toString()); } finally { setBooleanPreference(NEXT_WORD_PREDICTION_OPTION, previousNextWordPredictionOption, defaultNextWordPredictionOption); } } public void testWordThenSpaceThenPunctuationFromKeyboardTwice() { Loading