Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 781d7512 authored by Jean Chalard's avatar Jean Chalard Committed by Android Git Automerger
Browse files

am ee8ebeec: Merge "Fix unit tests"

* commit 'ee8ebeec':
  Fix unit tests
parents 5ce1a5eb ee8ebeec
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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
+5 −2
Original line number Diff line number Diff line
@@ -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;
+5 −5
Original line number Diff line number Diff line
@@ -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);
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -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));