aboutsummaryrefslogtreecommitdiffstats
path: root/tests/src/com/android/inputmethod/latin/InputTestsBase.java
diff options
context:
space:
mode:
authorSatoshi Kataoka <satok@google.com>2013-05-01 13:33:39 +0900
committerSatoshi Kataoka <satok@google.com>2013-05-01 18:21:56 +0900
commitd5781eef628c2cd4ac38029040746daa4679d637 (patch)
tree68c1ae758e67be2c46dce8daa40a085c0fcae05a /tests/src/com/android/inputmethod/latin/InputTestsBase.java
parentdf2eae6e69948e99618a28d087b847c70582efd8 (diff)
downloadlatinime-d5781eef628c2cd4ac38029040746daa4679d637.tar.gz
latinime-d5781eef628c2cd4ac38029040746daa4679d637.tar.xz
latinime-d5781eef628c2cd4ac38029040746daa4679d637.zip
Fix Google spell checker tests
Bug: 8613307 Change-Id: Ief04a4abb6dc1f79660a2e419c9c5e271802b5a1
Diffstat (limited to 'tests/src/com/android/inputmethod/latin/InputTestsBase.java')
-rw-r--r--tests/src/com/android/inputmethod/latin/InputTestsBase.java40
1 files changed, 24 insertions, 16 deletions
diff --git a/tests/src/com/android/inputmethod/latin/InputTestsBase.java b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
index 9e107a49c..28da74bf8 100644
--- a/tests/src/com/android/inputmethod/latin/InputTestsBase.java
+++ b/tests/src/com/android/inputmethod/latin/InputTestsBase.java
@@ -19,7 +19,6 @@ package com.android.inputmethod.latin;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Looper;
-import android.os.MessageQueue;
import android.preference.PreferenceManager;
import android.test.ServiceTestCase;
import android.text.InputType;
@@ -31,8 +30,8 @@ import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputConnection;
+import android.widget.EditText;
import android.widget.FrameLayout;
-import android.widget.TextView;
import com.android.inputmethod.keyboard.Key;
import com.android.inputmethod.keyboard.Keyboard;
@@ -49,7 +48,7 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
protected LatinIME mLatinIME;
protected Keyboard mKeyboard;
- protected MyTextView mTextView;
+ protected MyEditText mEditText;
protected View mInputView;
protected InputConnection mInputConnection;
@@ -88,22 +87,31 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
}
}
- // A helper class to increase control over the TextView
- public static class MyTextView extends TextView {
+ // A helper class to increase control over the EditText
+ public static class MyEditText extends EditText {
public Locale mCurrentLocale;
- public MyTextView(final Context c) {
+ public MyEditText(final Context c) {
super(c);
}
- public void onAttachedToWindow() {
- super.onAttachedToWindow();
- }
+
+ // overriding hidden API in EditText
public Locale getTextServicesLocale() {
- // This method is necessary because TextView is asking this method for the language
+ // This method is necessary because EditText is asking this method for the language
// to check the spell in. If we don't override this, the spell checker will run in
// whatever language the keyboard is currently set on the test device, ignoring any
// settings we do inside the tests.
return mCurrentLocale;
}
+
+ // overriding hidden API in EditText
+ public Locale getSpellCheckerLocale() {
+ // This method is necessary because EditText is asking this method for the language
+ // to check the spell in. If we don't override this, the spell checker will run in
+ // whatever language the keyboard is currently set on the test device, ignoring any
+ // settings we do inside the tests.
+ return mCurrentLocale;
+ }
+
}
public InputTestsBase() {
@@ -130,18 +138,18 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
@Override
protected void setUp() throws Exception {
super.setUp();
- mTextView = new MyTextView(getContext());
+ mEditText = new MyEditText(getContext());
final int inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT
| InputType.TYPE_TEXT_FLAG_MULTI_LINE;
- mTextView.setInputType(inputType);
- mTextView.setEnabled(true);
+ mEditText.setInputType(inputType);
+ mEditText.setEnabled(true);
setupService();
mLatinIME = getService();
final boolean previousDebugSetting = setDebugMode(true);
mLatinIME.onCreate();
setDebugMode(previousDebugSetting);
final EditorInfo ei = new EditorInfo();
- final InputConnection ic = mTextView.onCreateInputConnection(ei);
+ final InputConnection ic = mEditText.onCreateInputConnection(ei);
final LayoutInflater inflater =
(LayoutInflater)getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final ViewGroup vg = new FrameLayout(getContext());
@@ -225,8 +233,8 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
}
protected void changeLanguage(final String locale) {
- mTextView.mCurrentLocale = LocaleUtils.constructLocaleFromString(locale);
- SubtypeSwitcher.getInstance().forceLocale(mTextView.mCurrentLocale);
+ mEditText.mCurrentLocale = LocaleUtils.constructLocaleFromString(locale);
+ SubtypeSwitcher.getInstance().forceLocale(mEditText.mCurrentLocale);
mLatinIME.loadKeyboard();
mKeyboard = mLatinIME.mKeyboardSwitcher.getKeyboard();
waitForDictionaryToBeLoaded();