@VisibleForTesting
  static int getIdForInsertionRequest(EditorInfo info) {
    return info == null
        ? 0
        : Arrays.hashCode(new int[] {info.fieldId, info.packageName.hashCode()});
  }
@Test
  public void testQueueImageInsertionTillTargetTextBoxEntered() {
    Assert.assertEquals(0, ShadowToast.shownToastCount());
    simulateFinishInputFlow();
    EditorInfo info = createEditorInfoTextWithSuggestionsForSetUp();
    EditorInfoCompat.setContentMimeTypes(info, new String[] {"image/gif"});
    simulateOnStartInputFlow(false, info);

    mAnySoftKeyboardUnderTest.simulateKeyPress(KeyCodes.IMAGE_MEDIA_POPUP);

    ArgumentCaptor<InsertionRequestCallback> argumentCaptor =
        ArgumentCaptor.forClass(InsertionRequestCallback.class);
    Mockito.verify(mRemoteInsertion)
        .startMediaRequest(Mockito.any(), Mockito.anyInt(), argumentCaptor.capture());

    simulateFinishInputFlow();

    argumentCaptor
        .getValue()
        .onMediaRequestDone(
            AnySoftKeyboardMediaInsertion.getIdForInsertionRequest(info),
            new InputContentInfoCompat(
                Uri.EMPTY,
                new ClipDescription("", EditorInfoCompat.getContentMimeTypes(info)),
                null));

    Assert.assertNull(mAnySoftKeyboardUnderTest.getCommitedInputContentInfo());

    Assert.assertEquals(1, ShadowToast.shownToastCount());
    Assert.assertNotNull(ShadowToast.getLatestToast());
    Assert.assertEquals(Toast.LENGTH_LONG, ShadowToast.getLatestToast().getDuration());
    Assert.assertEquals("Click text-box to insert image", ShadowToast.getTextOfLatestToast());

    // entering the actual text
    simulateOnStartInputFlow(false, info);
    Assert.assertNotNull(mAnySoftKeyboardUnderTest.getCommitedInputContentInfo());

    Assert.assertEquals(1, ShadowToast.shownToastCount());
  }