コード例 #1
0
  @Test
  public void handleOpen_withHttpApplicationUrl_shouldStartMoPubBrowser() {
    String applicationUrl = "https://www.mopub.com/";

    subject.handleOpen(applicationUrl);

    Robolectric.getBackgroundThreadScheduler().advanceBy(0);
    Intent startedIntent = ShadowApplication.getInstance().getNextStartedActivity();
    assertThat(startedIntent).isNotNull();
    // Since we are not using an Activity context, we should have FLAG_ACTIVITY_NEW_TASK
    assertThat(Utils.bitMaskContainsFlag(startedIntent.getFlags(), Intent.FLAG_ACTIVITY_NEW_TASK))
        .isTrue();
    assertThat(startedIntent.getComponent().getClassName())
        .isEqualTo("com.mopub.common.MoPubBrowser");

    verify(mockMraidListener).onOpen();
  }
コード例 #2
0
  @Test
  public void handleOpen_withApplicationUrl_shouldStartNewIntent() {
    String applicationUrl = "amzn://blah";
    RuntimeEnvironment.getRobolectricPackageManager()
        .addResolveInfoForIntent(
            new Intent(Intent.ACTION_VIEW, Uri.parse(applicationUrl)), new ResolveInfo());

    subject.handleOpen(applicationUrl);

    Intent startedIntent = ShadowApplication.getInstance().getNextStartedActivity();
    assertThat(startedIntent).isNotNull();
    // Since we are not using an Activity context, we should have FLAG_ACTIVITY_NEW_TASK
    assertThat(Utils.bitMaskContainsFlag(startedIntent.getFlags(), Intent.FLAG_ACTIVITY_NEW_TASK))
        .isTrue();
    assertThat(startedIntent.getComponent()).isNull();

    verify(mockMraidListener).onOpen();
  }