Source:
public void testAvailableSubtypesReported() { Mockito.reset(mAnySoftKeyboardUnderTest.getInputMethodManager()); ArgumentCaptor<InputMethodSubtype[]> subtypesCaptor = ArgumentCaptor.forClass(InputMethodSubtype[].class); final List<KeyboardAddOnAndBuilder> keyboardBuilders = AnyApplication.getKeyboardFactory(getApplicationContext()).getAllAddOns(); mAnySoftKeyboardUnderTest.onAvailableKeyboardsChanged(keyboardBuilders); Mockito.verify(mAnySoftKeyboardUnderTest.getInputMethodManager()) .setAdditionalInputMethodSubtypes( Mockito.eq( new ComponentName( "com.menny.android.anysoftkeyboard", "com.menny.android.anysoftkeyboard.SoftKeyboard") .flattenToShortString()), subtypesCaptor.capture()); InputMethodSubtype[] reportedSubtypes = subtypesCaptor.getValue(); Assert.assertNotNull(reportedSubtypes); Assert.assertEquals(11, keyboardBuilders.size()); Assert.assertEquals(9, reportedSubtypes.length); final int[] expectedSubtypeId = new int[] { 1912895432, -1829357470, 390463609, 1819490062, 1618259652, -517805346, -1601329810, -1835196376, -1096117125 }; Assert.assertEquals(reportedSubtypes.length, expectedSubtypeId.length); int reportedIndex = 0; for (KeyboardAddOnAndBuilder builder : keyboardBuilders) { if (!TextUtils.isEmpty(builder.getKeyboardLocale())) { InputMethodSubtype subtype = reportedSubtypes[reportedIndex]; Assert.assertEquals(builder.getKeyboardLocale(), subtype.getLocale()); Assert.assertEquals(builder.getId(), subtype.getExtraValue()); Assert.assertEquals("keyboard", subtype.getMode()); Assert.assertEquals( "Expected different subtypeid for " + builder.getId() + " " + reportedIndex, expectedSubtypeId[reportedIndex], ReflectionHelpers.<Integer>getField(subtype, "mSubtypeId").intValue()); reportedIndex++; } } Assert.assertEquals(reportedIndex, reportedSubtypes.length); }

Target:
public void testAvailableSubtypesReported() { Mockito.reset(mAnySoftKeyboardUnderTest.getInputMethodManager()); ArgumentCaptor<InputMethodSubtype[]> subtypesCaptor = ArgumentCaptor.forClass(InputMethodSubtype[].class); final List<KeyboardAddOnAndBuilder> keyboardBuilders = AnyApplication.getKeyboardFactory(getApplicationContext()).getAllAddOns(); mAnySoftKeyboardUnderTest.onAvailableKeyboardsChanged(keyboardBuilders); Mockito.verify(mAnySoftKeyboardUnderTest.getInputMethodManager()) .setAdditionalInputMethodSubtypes( Mockito.eq( new ComponentName( "com.menny.android.anysoftkeyboard", "com.menny.android.anysoftkeyboard.SoftKeyboard") .flattenToShortString()), subtypesCaptor.capture()); InputMethodSubtype[] reportedSubtypes = subtypesCaptor.getValue(); Assert.assertNotNull(reportedSubtypes); Assert.assertEquals(10, keyboardBuilders.size()); Assert.assertEquals(8, reportedSubtypes.length); final int[] expectedSubtypeId = new int[] { 1912895432, -1829357470, 390463609, 1819490062, 1618259652, -517805346, -1601329810, -1835196376 }; Assert.assertEquals(reportedSubtypes.length, expectedSubtypeId.length); int reportedIndex = 0; for (KeyboardAddOnAndBuilder builder : keyboardBuilders) { if (!TextUtils.isEmpty(builder.getKeyboardLocale())) { InputMethodSubtype subtype = reportedSubtypes[reportedIndex]; Assert.assertEquals(builder.getKeyboardLocale(), subtype.getLocale()); Assert.assertEquals(builder.getId(), subtype.getExtraValue()); Assert.assertEquals("keyboard", subtype.getMode()); Assert.assertEquals( "Expected different subtypeid for " + builder.getId() + " " + reportedIndex, expectedSubtypeId[reportedIndex], ReflectionHelpers.<Integer>getField(subtype, "mSubtypeId").intValue()); reportedIndex++; } } Assert.assertEquals(reportedIndex, reportedSubtypes.length); }