aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/latin/InputTestsBase.java
diff options
context:
space:
mode:
authorTadashi G. Takaoka <takaoka@google.com>2012-04-02 21:31:52 +0900
committerTadashi G. Takaoka <takaoka@google.com>2012-04-03 15:31:26 +0900
commit9cc2c94c8b4bfd4e00e5d3478b9f6e520e791bc5 (patch)
tree056fdaabed52b2cb2c8ddcbf8128f1cabcbce5c8 /tests/src/com/android/inputmethod/latin/InputTestsBase.java
parent19457316c1da5e4ca52d2fe8039d76469fbf1e61 (diff)
downloadlatinime-9cc2c94c8b4bfd4e00e5d3478b9f6e520e791bc5.tar.gz
latinime-9cc2c94c8b4bfd4e00e5d3478b9f6e520e791bc5.tar.xz
latinime-9cc2c94c8b4bfd4e00e5d3478b9f6e520e791bc5.zip
Remove InputMethodSubtypeCompatWrapper
Bug: 6129704 Change-Id: I8f84f0f61a2205ac1fcd1cd40e3a586ee535282d
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/InputTestsBase.java')
-rw-r--r--tests/src/com/android/inputmethod/latin/InputTestsBase.java32
1 files changed, 30 insertions, 2 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
index 7d97eed9e..5f6b229dd 100644
--- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java
+++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
@@ -30,6 +30,9 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
+import android.view.inputmethod.InputMethodInfo;
+import android.view.inputmethod.InputMethodManager;
+import android.view.inputmethod.InputMethodSubtype;
import android.widget.FrameLayout;
import android.widget.TextView;
@@ -37,6 +40,8 @@ import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardActionListener;
+import java.util.HashMap;
+
public class InputTestsBase extends ServiceTestCase<LatinIME> {
private static final String PREF_DEBUG_MODE = "debug_mode";
@@ -48,6 +53,8 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
protected Keyboard mKeyboard;
protected TextView mTextView;
protected InputConnection mInputConnection;
+ private final HashMap<String, InputMethodSubtype> mSubtypeMap =
+ new HashMap<String, InputMethodSubtype>();
// A helper class to ease span tests
public static class Span {
@@ -108,6 +115,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
final boolean previousDebugSetting = setDebugMode(true);
mLatinIME.onCreate();
setDebugMode(previousDebugSetting);
+ initSubtypeMap();
final EditorInfo ei = new EditorInfo();
ei.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;
final InputConnection ic = mTextView.onCreateInputConnection(ei);
@@ -126,6 +134,23 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
changeLanguage("en_US");
}
+ private void initSubtypeMap() {
+ final InputMethodManager imm = (InputMethodManager)mLatinIME.getSystemService(
+ Context.INPUT_METHOD_SERVICE);
+ final String packageName = mLatinIME.getPackageName();
+ for (final InputMethodInfo imi : imm.getEnabledInputMethodList()) {
+ if (imi.getPackageName().equals(packageName)) {
+ for (final InputMethodSubtype ims :
+ imm.getEnabledInputMethodSubtypeList(imi, true)) {
+ final String locale = ims.getLocale();
+ mSubtypeMap.put(locale, ims);
+ }
+ return;
+ }
+ }
+ fail("LatinIME is disabled");
+ }
+
// 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
@@ -217,8 +242,11 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
}
protected void changeLanguage(final String locale) {
- SubtypeSwitcher.getInstance().updateSubtype(
- new ArbitrarySubtype(locale, LatinIME.SUBTYPE_EXTRA_VALUE_ASCII_CAPABLE));
+ final InputMethodSubtype subtype = mSubtypeMap.get(locale);
+ if (subtype == null) {
+ fail("InputMethodSubtype for locale " + locale + " is not enabled");
+ }
+ SubtypeSwitcher.getInstance().updateSubtype(subtype);
waitForDictionaryToBeLoaded();
}