am ee8ebeec: Merge "Fix unit tests"
* commit 'ee8ebeecbf80b9cccc5569570112634b49c45b53': Fix unit testsmain
commit
781d75126b
|
@ -20,6 +20,7 @@ import android.os.Build;
|
|||
import android.view.inputmethod.InputMethodSubtype;
|
||||
|
||||
import com.android.inputmethod.annotations.UsedForTesting;
|
||||
import com.android.inputmethod.latin.Constants;
|
||||
import com.android.inputmethod.latin.RichInputMethodSubtype;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
|
@ -69,7 +70,8 @@ public final class InputMethodSubtypeCompatUtils {
|
|||
}
|
||||
|
||||
public static boolean isAsciiCapable(final InputMethodSubtype subtype) {
|
||||
return InputMethodSubtypeCompatUtils.isAsciiCapableWithAPI(subtype);
|
||||
return isAsciiCapableWithAPI(subtype)
|
||||
|| subtype.containsExtraValueKey(Constants.Subtype.ExtraValue.ASCII_CAPABLE);
|
||||
}
|
||||
|
||||
@UsedForTesting
|
||||
|
|
|
@ -315,9 +315,12 @@ public final class SubtypeSwitcher {
|
|||
|
||||
public RichInputMethodSubtype getEmojiSubtype() {
|
||||
if (mEmojiSubtype == null) {
|
||||
mEmojiSubtype = new RichInputMethodSubtype(
|
||||
final InputMethodSubtype rawEmojiSubtype =
|
||||
mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
|
||||
SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.EMOJI));
|
||||
SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.EMOJI);
|
||||
if (null != rawEmojiSubtype) {
|
||||
mEmojiSubtype = new RichInputMethodSubtype(rawEmojiSubtype);
|
||||
}
|
||||
}
|
||||
if (mEmojiSubtype != null) {
|
||||
return mEmojiSubtype;
|
||||
|
|
|
@ -151,25 +151,25 @@ public class AdditionalSubtypeUtilsTests extends AndroidTestCase {
|
|||
}
|
||||
|
||||
public void testRestorable() {
|
||||
final InputMethodSubtype EN_UK_DVORAK =
|
||||
final InputMethodSubtype EN_US_DVORAK =
|
||||
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||
Locale.US.toString(), "dvorak");
|
||||
final InputMethodSubtype ZZ_AZERTY =
|
||||
AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
|
||||
SubtypeLocaleUtils.NO_LANGUAGE, "azerty");
|
||||
assertEnUsDvorak(EN_UK_DVORAK);
|
||||
assertEnUsDvorak(EN_US_DVORAK);
|
||||
assertAzerty(ZZ_AZERTY);
|
||||
|
||||
// Make sure the subtype can be stored and restored in a deterministic manner.
|
||||
final InputMethodSubtype[] subtypes = { EN_UK_DVORAK, ZZ_AZERTY };
|
||||
final InputMethodSubtype[] subtypes = { EN_US_DVORAK, ZZ_AZERTY };
|
||||
final String prefSubtype = AdditionalSubtypeUtils.createPrefSubtypes(subtypes);
|
||||
final InputMethodSubtype[] restoredSubtypes =
|
||||
AdditionalSubtypeUtils.createAdditionalSubtypesArray(prefSubtype);
|
||||
assertEquals(2, restoredSubtypes.length);
|
||||
final InputMethodSubtype restored_EN_UK_DVORAK = restoredSubtypes[0];
|
||||
final InputMethodSubtype restored_EN_US_DVORAK = restoredSubtypes[0];
|
||||
final InputMethodSubtype restored_ZZ_AZERTY = restoredSubtypes[1];
|
||||
|
||||
assertEnUsDvorak(restored_EN_UK_DVORAK);
|
||||
assertEnUsDvorak(restored_EN_US_DVORAK);
|
||||
assertAzerty(restored_ZZ_AZERTY);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -310,9 +310,11 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
|
|||
assertNotNull("Hebrew", HEBREW);
|
||||
|
||||
for (final RichInputMethodSubtype subtype : mSubtypesList) {
|
||||
final InputMethodSubtype rawSubtype = subtype.getRawSubtype();
|
||||
final String subtypeName = SubtypeLocaleUtils
|
||||
.getSubtypeDisplayNameInSystemLocale(subtype.getRawSubtype());
|
||||
if (subtype.equals(ARABIC) || subtype.equals(FARSI) || subtype.equals(HEBREW)) {
|
||||
.getSubtypeDisplayNameInSystemLocale(rawSubtype);
|
||||
if (rawSubtype.equals(ARABIC) || rawSubtype.equals(FARSI)
|
||||
|| rawSubtype.equals(HEBREW)) {
|
||||
assertTrue(subtypeName, SubtypeLocaleUtils.isRtlLanguage(subtype));
|
||||
} else {
|
||||
assertFalse(subtypeName, SubtypeLocaleUtils.isRtlLanguage(subtype));
|
||||
|
|
Loading…
Reference in New Issue