am 3f91acdc: Add additional subtypes test
* commit '3f91acdc965ff9ad3127a659a0371193dafbbb45': Add additional subtypes testmain
commit
ecd40f37c2
|
@ -27,6 +27,7 @@ import android.text.TextUtils;
|
|||
import android.util.Log;
|
||||
import android.view.inputmethod.InputMethodSubtype;
|
||||
|
||||
import com.android.inputmethod.annotations.UsedForTesting;
|
||||
import com.android.inputmethod.compat.InputMethodSubtypeCompatUtils;
|
||||
import com.android.inputmethod.latin.R;
|
||||
|
||||
|
@ -42,6 +43,7 @@ public final class AdditionalSubtypeUtils {
|
|||
// This utility class is not publicly instantiable.
|
||||
}
|
||||
|
||||
@UsedForTesting
|
||||
public static boolean isAdditionalSubtype(final InputMethodSubtype subtype) {
|
||||
return subtype.containsExtraValueKey(IS_ADDITIONAL_SUBTYPE);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ import java.util.Locale;
|
|||
public class KeyboardLayoutSetTestsBase extends AndroidTestCase {
|
||||
private static final int NUMBER_OF_SUBTYPES = 63;
|
||||
private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 40;
|
||||
private static final int NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES = 2;
|
||||
|
||||
private static final KeyboardTheme DEFAULT_KEYBOARD_THEME =
|
||||
KeyboardSwitcher.KEYBOARD_THEMES[KeyboardSwitcher.THEME_INDEX_DEFAULT];
|
||||
|
@ -51,6 +52,8 @@ public class KeyboardLayoutSetTestsBase extends AndroidTestCase {
|
|||
private final ArrayList<InputMethodSubtype> mAllSubtypesList = CollectionUtils.newArrayList();
|
||||
private final ArrayList<InputMethodSubtype> mAsciiCapableSubtypesList =
|
||||
CollectionUtils.newArrayList();
|
||||
private final ArrayList<InputMethodSubtype> mAdditionalSubtypesList =
|
||||
CollectionUtils.newArrayList();
|
||||
|
||||
private Context mThemeContext;
|
||||
private int mScreenMetrics;
|
||||
|
@ -68,6 +71,10 @@ public class KeyboardLayoutSetTestsBase extends AndroidTestCase {
|
|||
final int subtypeCount = imi.getSubtypeCount();
|
||||
for (int index = 0; index < subtypeCount; index++) {
|
||||
final InputMethodSubtype subtype = imi.getSubtypeAt(index);
|
||||
if (AdditionalSubtypeUtils.isAdditionalSubtype(subtype)) {
|
||||
mAdditionalSubtypesList.add(subtype);
|
||||
continue;
|
||||
}
|
||||
mAllSubtypesList.add(subtype);
|
||||
if (InputMethodSubtypeCompatUtils.isAsciiCapable(subtype)) {
|
||||
mAsciiCapableSubtypesList.add(subtype);
|
||||
|
@ -101,6 +108,11 @@ public class KeyboardLayoutSetTestsBase extends AndroidTestCase {
|
|||
NUMBER_OF_ASCII_CAPABLE_SUBTYPES, mAsciiCapableSubtypesList.size());
|
||||
}
|
||||
|
||||
public final void testAdditionalSubtypesCount() {
|
||||
assertEquals(toString(mAdditionalSubtypesList),
|
||||
NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES, mAdditionalSubtypesList.size());
|
||||
}
|
||||
|
||||
protected final InputMethodSubtype getSubtype(final Locale locale,
|
||||
final String keyboardLayout) {
|
||||
for (final InputMethodSubtype subtype : mAllSubtypesList) {
|
||||
|
|
Loading…
Reference in New Issue