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

Commit c18cd393 authored by Yohei Yukawa's avatar Yohei Yukawa
Browse files

Make sure InputMethodInfo implements Parcelable transitively

This CL adds one more test to make sure InputMethodInfo
implements Parcelable correctly. This test makes sure that
one can marshall and unmarshall again from an unmarshalled
copy of InputMethodInfo.

BUG: 12954290
Change-Id: I5aa1552a8089fe0bac54513ba224e5bfc494be97
parent 03c6628f
Loading
Loading
Loading
Loading
+18 −12
Original line number Diff line number Diff line
@@ -101,20 +101,15 @@ public class InputMethodTest extends InstrumentationTestCase {

        final List<InputMethodInfo> clonedList = cloneViaParcel(originalList);
        assertNotNull(clonedList);
        assertEquals(originalList.size(), clonedList.size());
        final List<InputMethodInfo> clonedClonedList = cloneViaParcel(clonedList);
        assertNotNull(clonedClonedList);
        assertEquals(originalList, clonedList);

        assertEquals(clonedList, clonedClonedList);
        assertEquals(originalList.size(), clonedList.size());
        assertEquals(clonedList.size(), clonedClonedList.size());
        for (int imeIndex = 0; imeIndex < originalList.size(); ++imeIndex) {
            final InputMethodInfo original = originalList.get(imeIndex);
            final InputMethodInfo cloned = clonedList.get(imeIndex);
            assertEquals(original, cloned);
            assertEquals(original.getSubtypeCount(), cloned.getSubtypeCount());
            for (int subtypeIndex = 0; subtypeIndex < original.getSubtypeCount(); ++subtypeIndex) {
                final InputMethodSubtype originalSubtype = original.getSubtypeAt(subtypeIndex);
                final InputMethodSubtype clonedSubtype = cloned.getSubtypeAt(subtypeIndex);
                assertEquals(originalSubtype, clonedSubtype);
                assertEquals(originalSubtype.hashCode(), clonedSubtype.hashCode());
            }
            verifyEquality(originalList.get(imeIndex), clonedList.get(imeIndex));
            verifyEquality(clonedList.get(imeIndex), clonedClonedList.get(imeIndex));
        }
    }

@@ -132,6 +127,17 @@ public class InputMethodTest extends InstrumentationTestCase {
        }
    }

    private static void verifyEquality(InputMethodInfo expected, InputMethodInfo actual) {
        assertEquals(expected, actual);
        assertEquals(expected.getSubtypeCount(), actual.getSubtypeCount());
        for (int subtypeIndex = 0; subtypeIndex < expected.getSubtypeCount(); ++subtypeIndex) {
            final InputMethodSubtype expectedSubtype = expected.getSubtypeAt(subtypeIndex);
            final InputMethodSubtype actualSubtype = actual.getSubtypeAt(subtypeIndex);
            assertEquals(expectedSubtype, actualSubtype);
            assertEquals(expectedSubtype.hashCode(), actualSubtype.hashCode());
        }
    }

    private static InputMethodInfo createDummyInputMethodInfo(String packageName, String name,
            CharSequence label, boolean isAuxIme, boolean isDefault,
            List<InputMethodSubtype> subtypes) {