diff options
author | 2013-12-13 04:15:33 +0000 | |
---|---|---|
committer | 2013-12-13 04:15:33 +0000 | |
commit | 18d033405c18a8dc28f60ca22d1d0df23a679384 (patch) | |
tree | 77ae6dc696eb7f2942e6d5bfebdccb95eebf8a6e /tests/src/com/android/inputmethod/latin/InputTestsBase.java | |
parent | 95050f54e92ff5465e713990315e8cf421836a64 (diff) | |
parent | c95efbbd575239b97db20b71fb347b543b5808f8 (diff) | |
download | latinime-18d033405c18a8dc28f60ca22d1d0df23a679384.tar.gz latinime-18d033405c18a8dc28f60ca22d1d0df23a679384.tar.xz latinime-18d033405c18a8dc28f60ca22d1d0df23a679384.zip |
Merge branch 'master' of https://googleplex-android.googlesource.com/_direct/platform/packages/inputmethods/LatinIME
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/InputTestsBase.java')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/InputTestsBase.java | 50 |
1 files changed, 6 insertions, 44 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java index aaad740e4..b9b52a6f3 100644 --- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java +++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java @@ -30,7 +30,6 @@ import android.view.View; import android.view.ViewGroup; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputConnection; -import android.view.inputmethod.InputMethodSubtype; import android.widget.EditText; import android.widget.FrameLayout; @@ -38,20 +37,15 @@ import com.android.inputmethod.keyboard.Key; import com.android.inputmethod.keyboard.Keyboard; import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo; import com.android.inputmethod.latin.utils.LocaleUtils; -import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import java.util.Locale; public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { private static final String PREF_DEBUG_MODE = "debug_mode"; - private static final String PREF_AUTO_CORRECTION_THRESHOLD = "auto_correction_threshold"; - // 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"; - // The message that sets the underline is posted with a 500 ms delay - protected static final int DELAY_TO_WAIT_FOR_UNDERLINE = 500; + // The message that sets the underline is posted with a 200 ms delay + protected static final int DELAY_TO_WAIT_FOR_UNDERLINE = 200; // The message that sets predictions is posted with a 200 ms delay protected static final int DELAY_TO_WAIT_FOR_PREDICTIONS = 200; @@ -60,8 +54,6 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { protected MyEditText mEditText; protected View mInputView; protected InputConnection mInputConnection; - private boolean mPreviousDebugSetting; - private String mPreviousAutoCorrectSetting; // A helper class to ease span tests public static class SpanGetter { @@ -143,17 +135,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { final boolean previousSetting = prefs.getBoolean(key, defaultValue); final SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean(key, value); - editor.apply(); - return previousSetting; - } - - protected String setStringPreference(final String key, final String value, - final String defaultValue) { - final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mLatinIME); - final String previousSetting = prefs.getString(key, defaultValue); - final SharedPreferences.Editor editor = prefs.edit(); - editor.putString(key, value); - editor.apply(); + editor.commit(); return previousSetting; } @@ -172,10 +154,9 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { mEditText.setEnabled(true); setupService(); mLatinIME = getService(); - mPreviousDebugSetting = setDebugMode(true); - mPreviousAutoCorrectSetting = setStringPreference(PREF_AUTO_CORRECTION_THRESHOLD, - DEFAULT_AUTO_CORRECTION_THRESHOLD, DEFAULT_AUTO_CORRECTION_THRESHOLD); + final boolean previousDebugSetting = setDebugMode(true); mLatinIME.onCreate(); + setDebugMode(previousDebugSetting); final EditorInfo ei = new EditorInfo(); final InputConnection ic = mEditText.onCreateInputConnection(ei); final LayoutInflater inflater = @@ -191,14 +172,6 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { changeLanguage("en_US"); } - @Override - protected void tearDown() { - mLatinIME.mHandler.removeAllMessages(); - setStringPreference(PREF_AUTO_CORRECTION_THRESHOLD, mPreviousAutoCorrectSetting, - DEFAULT_AUTO_CORRECTION_THRESHOLD); - setDebugMode(mPreviousDebugSetting); - } - // We need to run the messages added to the handler from LatinIME. The only way to do // that is to call Looper#loop() on the right looper, so we're going to get the looper // object and call #loop() here. The messages in the handler actually run on the UI @@ -271,18 +244,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIMEForTests> { protected void changeLanguageWithoutWait(final String locale) { mEditText.mCurrentLocale = LocaleUtils.constructLocaleFromString(locale); - final InputMethodSubtype subtype = new InputMethodSubtype( - R.string.subtype_no_language_qwerty, R.drawable.ic_ime_switcher_dark, - locale, "keyboard", "KeyboardLayoutSet=" - // TODO: this is forcing a QWERTY keyboard for all locales, which is wrong. - // It's still better than using whatever keyboard is the current one, but we - // should actually use the default keyboard for this locale. - + SubtypeLocaleUtils.QWERTY - + "," + Constants.Subtype.ExtraValue.ASCII_CAPABLE - + "," + Constants.Subtype.ExtraValue.ENABLED_WHEN_DEFAULT_IS_NOT_ASCII_CAPABLE - + "," + Constants.Subtype.ExtraValue.EMOJI_CAPABLE, - false /* isAuxiliary */, false /* overridesImplicitlyEnabledSubtype */); - SubtypeSwitcher.getInstance().forceSubtype(subtype); + SubtypeSwitcher.getInstance().forceLocale(mEditText.mCurrentLocale); mLatinIME.loadKeyboard(); runMessages(); mKeyboard = mLatinIME.mKeyboardSwitcher.getKeyboard(); |