Methods Summary |
---|
private static final android.view.inputmethod.InputMethodSubtype | cloneViaParcel(android.view.inputmethod.InputMethodSubtype original)
Parcel parcel = null;
try {
parcel = Parcel.obtain();
original.writeToParcel(parcel, 0);
parcel.setDataPosition(0);
return InputMethodSubtype.CREATOR.createFromParcel(parcel);
} finally {
if (parcel != null) {
parcel.recycle();
}
}
|
private static final android.view.inputmethod.InputMethodSubtype | createDummySubtype(java.lang.String locale)
final InputMethodSubtypeBuilder builder = new InputMethodSubtypeBuilder();
return builder.setSubtypeNameResId(0)
.setSubtypeIconResId(0)
.setSubtypeLocale(locale)
.setIsAsciiCapable(true)
.build();
|
public void | testDeprecatedLocaleString()
// Make sure "iw" is not automatically replaced with "he".
final InputMethodSubtype subtypeIw = createDummySubtype("iw");
final InputMethodSubtype subtypeHe = createDummySubtype("he");
assertEquals("iw", subtypeIw.getLocale());
assertEquals("he", subtypeHe.getLocale());
assertFalse(Objects.equals(subtypeIw, subtypeHe));
assertFalse(Objects.equals(subtypeIw.hashCode(), subtypeHe.hashCode()));
final InputMethodSubtype clonedSubtypeIw = cloneViaParcel(subtypeIw);
final InputMethodSubtype clonedSubtypeHe = cloneViaParcel(subtypeHe);
assertEquals(subtypeIw, clonedSubtypeIw);
assertEquals(subtypeHe, clonedSubtypeHe);
assertEquals("iw", clonedSubtypeIw.getLocale());
assertEquals("he", clonedSubtypeHe.getLocale());
|
public void | testLocaleString()
// The locale string in InputMethodSubtype has accepted an arbitrary text actually,
// regardless of the validity of the text as a locale string.
verifyLocale("en_US");
verifyLocale("apparently invalid locale string");
verifyLocale("zz");
verifyLocale("iw");
verifyLocale("he");
|
public void | verifyLocale(java.lang.String localeString)
// InputMethodSubtype#getLocale() returns exactly the same string that is passed to the
// constructor.
assertEquals(localeString, createDummySubtype(localeString).getLocale());
// InputMethodSubtype#getLocale() should be preserved via marshaling.
assertEquals(createDummySubtype(localeString).getLocale(),
cloneViaParcel(createDummySubtype(localeString)).getLocale());
// InputMethodSubtype#getLocale() should be preserved via marshaling.
assertEquals(createDummySubtype(localeString).getLocale(),
cloneViaParcel(cloneViaParcel(createDummySubtype(localeString))).getLocale());
// Make sure InputMethodSubtype#hashCode() returns the same hash code.
assertEquals(createDummySubtype(localeString).hashCode(),
createDummySubtype(localeString).hashCode());
assertEquals(createDummySubtype(localeString).hashCode(),
cloneViaParcel(createDummySubtype(localeString)).hashCode());
assertEquals(createDummySubtype(localeString).hashCode(),
cloneViaParcel(cloneViaParcel(createDummySubtype(localeString))).hashCode());
|