aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src
diff options
context:
space:
mode:
Diffstat (limited to 'tests/src')
-rw-r--r--tests/src/com/android/inputmethod/latin/ArbitrarySubtype.java54
-rw-r--r--tests/src/com/android/inputmethod/latin/InputTestsBase.java32
2 files changed, 30 insertions, 56 deletions
diff --git a/tests/src/com/android/inputmethod/latin/ArbitrarySubtype.java b/tests/src/com/android/inputmethod/latin/ArbitrarySubtype.java
deleted file mode 100644
index 1e3482ca7..000000000
--- a/tests/src/com/android/inputmethod/latin/ArbitrarySubtype.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not
- * use this file except in compliance with the License. You may obtain a copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations under
- * the License.
- */
-
-package com.android.inputmethod.latin;
-
-import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper;
-
-public class ArbitrarySubtype extends InputMethodSubtypeCompatWrapper {
- final String mLocale;
- final String mExtraValue;
-
- public ArbitrarySubtype(final String locale, final String extraValue) {
- super(locale);
- mLocale = locale;
- mExtraValue = extraValue;
- }
-
- public String getLocale() {
- return mLocale;
- }
-
- public String getExtraValue() {
- return mExtraValue;
- }
-
- public String getMode() {
- return "keyboard";
- }
-
- public String getExtraValueOf(final String key) {
- if (LatinIME.SUBTYPE_EXTRA_VALUE_ASCII_CAPABLE.equals(key)) {
- return "";
- } else {
- return null;
- }
- }
-
- public boolean containsExtraValueKey(final String key) {
- return LatinIME.SUBTYPE_EXTRA_VALUE_ASCII_CAPABLE.equals(key);
- }
-}
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();
}