am 9c75ad1a: Merge "Fix international tests"
* commit '9c75ad1adec6e7ce2f2b202795fc23e0a4ac5617': Fix international testsmain
commit
01b2510c7c
|
@ -31,6 +31,7 @@ import android.view.inputmethod.InputMethodInfo;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.view.inputmethod.InputMethodSubtype;
|
import android.view.inputmethod.InputMethodSubtype;
|
||||||
|
|
||||||
|
import com.android.inputmethod.annotations.UsedForTesting;
|
||||||
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -239,7 +240,14 @@ public final class SubtypeSwitcher {
|
||||||
return mNeedsToDisplayLanguage.getValue();
|
return mNeedsToDisplayLanguage.getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static Locale sForcedLocaleForTesting = null;
|
||||||
|
@UsedForTesting
|
||||||
|
void forceLocale(final Locale locale) {
|
||||||
|
sForcedLocaleForTesting = locale;
|
||||||
|
}
|
||||||
|
|
||||||
public Locale getCurrentSubtypeLocale() {
|
public Locale getCurrentSubtypeLocale() {
|
||||||
|
if (null != sForcedLocaleForTesting) return sForcedLocaleForTesting;
|
||||||
return SubtypeLocale.getSubtypeLocale(getCurrentSubtype());
|
return SubtypeLocale.getSubtypeLocale(getCurrentSubtype());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,5 @@ public class BlueUnderlineTests extends InputTestsBase {
|
||||||
// Now simulate the user moving the cursor.
|
// Now simulate the user moving the cursor.
|
||||||
SpanGetter span = new SpanGetter(mTextView.getText(), UnderlineSpan.class);
|
SpanGetter span = new SpanGetter(mTextView.getText(), UnderlineSpan.class);
|
||||||
assertNull("should not be composing, so should not have an underline span", span.mSpan);
|
assertNull("should not be composing, so should not have an underline span", span.mSpan);
|
||||||
span = new SpanGetter(mTextView.getText(), SuggestionSpan.class);
|
|
||||||
assertNull("should not be composing, so should not have an underline span", span.mSpan);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,6 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||||
protected MyTextView mTextView;
|
protected MyTextView mTextView;
|
||||||
protected View mInputView;
|
protected View mInputView;
|
||||||
protected InputConnection mInputConnection;
|
protected InputConnection mInputConnection;
|
||||||
private final HashMap<String, InputMethodSubtype> mSubtypeMap =
|
|
||||||
new HashMap<String, InputMethodSubtype>();
|
|
||||||
|
|
||||||
// A helper class to ease span tests
|
// A helper class to ease span tests
|
||||||
public static class SpanGetter {
|
public static class SpanGetter {
|
||||||
|
@ -143,7 +141,6 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||||
final boolean previousDebugSetting = setDebugMode(true);
|
final boolean previousDebugSetting = setDebugMode(true);
|
||||||
mLatinIME.onCreate();
|
mLatinIME.onCreate();
|
||||||
setDebugMode(previousDebugSetting);
|
setDebugMode(previousDebugSetting);
|
||||||
initSubtypeMap();
|
|
||||||
final EditorInfo ei = new EditorInfo();
|
final EditorInfo ei = new EditorInfo();
|
||||||
ei.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;
|
ei.inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_AUTO_CORRECT;
|
||||||
final InputConnection ic = mTextView.onCreateInputConnection(ei);
|
final InputConnection ic = mTextView.onCreateInputConnection(ei);
|
||||||
|
@ -161,26 +158,6 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||||
changeLanguage("en_US");
|
changeLanguage("en_US");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initSubtypeMap() {
|
|
||||||
final InputMethodManager imm = (InputMethodManager)mLatinIME.getSystemService(
|
|
||||||
Context.INPUT_METHOD_SERVICE);
|
|
||||||
final String packageName = mLatinIME.getPackageName();
|
|
||||||
// The IMEs and subtypes don't need to be enabled to run this test because IMF isn't
|
|
||||||
// involved here.
|
|
||||||
for (final InputMethodInfo imi : imm.getInputMethodList()) {
|
|
||||||
if (imi.getPackageName().equals(packageName)) {
|
|
||||||
final int subtypeCount = imi.getSubtypeCount();
|
|
||||||
for (int i = 0; i < subtypeCount; i++) {
|
|
||||||
final InputMethodSubtype ims = imi.getSubtypeAt(i);
|
|
||||||
final String locale = ims.getLocale();
|
|
||||||
mSubtypeMap.put(locale, ims);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fail("LatinIME is not found");
|
|
||||||
}
|
|
||||||
|
|
||||||
// We need to run the messages added to the handler from LatinIME. The only way to do
|
// 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
|
// 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
|
// object and call #loop() here. The messages in the handler actually run on the UI
|
||||||
|
@ -270,12 +247,8 @@ public class InputTestsBase extends ServiceTestCase<LatinIME> {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void changeLanguage(final String locale) {
|
protected void changeLanguage(final String locale) {
|
||||||
final InputMethodSubtype subtype = mSubtypeMap.get(locale);
|
|
||||||
mTextView.mCurrentLocale = LocaleUtils.constructLocaleFromString(locale);
|
mTextView.mCurrentLocale = LocaleUtils.constructLocaleFromString(locale);
|
||||||
if (subtype == null) {
|
SubtypeSwitcher.getInstance().forceLocale(mTextView.mCurrentLocale);
|
||||||
fail("InputMethodSubtype for locale " + locale + " is not enabled");
|
|
||||||
}
|
|
||||||
SubtypeSwitcher.getInstance().onSubtypeChanged(subtype);
|
|
||||||
mLatinIME.loadKeyboard();
|
mLatinIME.loadKeyboard();
|
||||||
mKeyboard = mLatinIME.mKeyboardSwitcher.getKeyboard();
|
mKeyboard = mLatinIME.mKeyboardSwitcher.getKeyboard();
|
||||||
waitForDictionaryToBeLoaded();
|
waitForDictionaryToBeLoaded();
|
||||||
|
|
Loading…
Reference in New Issue