From 3f91acdc965ff9ad3127a659a0371193dafbbb45 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Mon, 3 Mar 2014 17:12:12 +0900 Subject: [PATCH] Add additional subtypes test Change-Id: I2994fd72bc284c84757f5a2bfa8045aa574a8fbc --- .../latin/utils/AdditionalSubtypeUtils.java | 2 ++ .../keyboard/KeyboardLayoutSetTestsBase.java | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/java/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtils.java b/java/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtils.java index ef1d0f42c..2bb30a2ba 100644 --- a/java/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/AdditionalSubtypeUtils.java @@ -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); } diff --git a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java index 5c8a59843..cd97fc90e 100644 --- a/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java +++ b/tests/src/com/android/inputmethod/keyboard/KeyboardLayoutSetTestsBase.java @@ -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 mAllSubtypesList = CollectionUtils.newArrayList(); private final ArrayList mAsciiCapableSubtypesList = CollectionUtils.newArrayList(); + private final ArrayList 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) {