@Test public void testANInterstitialWithAutoDismissAdDelay() throws InterruptedException { setInterstitialShowonLoad(true); setAutoDismissDelay(true); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.banner())); // First queue a regular HTML banner response assertTrue(interstitialAdView.getAdType() == AdType.UNKNOWN); // First 2tests if ad_type is UNKNOW initially executeInterstitialRequest(); //Checking if onAdLoaded is called or not assertTrue(adLoaded); //Creating shadow of the required activity ShadowActivity shadowActivity = shadowOf(activity); Intent startedIntent = shadowActivity.getNextStartedActivity(); //Checking if an AdActivity is opened or not assertEquals(AdActivity.class.getCanonicalName(), startedIntent.getComponent().getClassName()); //Checking if an INTENT_KEY_ACTIVITY_TYPE is equivalent to INTERSTITIAL or not assertEquals(startedIntent.getStringExtra(INTENT_KEY_ACTIVITY_TYPE), ACTIVITY_TYPE_INTERSTITIAL); //Checking if an INTENT_KEY_AUTODISMISS_DELAY is equual to 5 or not assertEquals(startedIntent.getIntExtra(INTENT_KEY_AUTODISMISS_DELAY, 0), 5); }
@Test public void testANInterstitialWithoutAutoDismissAdDelay() { setInterstitialShowonLoad(true); setAutoDismissDelay(false); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.banner())); // First queue a regular HTML banner response assertTrue(interstitialAdView.getAdType() == AdType.UNKNOWN); // First tests if ad_type is UNKNOWN initially executeInterstitialRequest(); //Checking if onAdLoaded is called or not assertTrue(adLoaded); //Creating shadow of the required activity ShadowActivity shadowActivity = shadowOf(activity); Intent startedIntent = shadowActivity.getNextStartedActivity(); //Checking if an AdActivity is opened or not assertEquals(AdActivity.class.getCanonicalName(), startedIntent.getComponent().getClassName()); //Checking if an INTENT_KEY_ACTIVITY_TYPE is equivalent to INTERSTITIAL or not assertEquals(startedIntent.getStringExtra(INTENT_KEY_ACTIVITY_TYPE), ACTIVITY_TYPE_INTERSTITIAL); //Checking if an INTENT_KEY_AUTODISMISS_DELAY is equual to 5 or not assertEquals(startedIntent.getIntExtra(INTENT_KEY_AUTODISMISS_DELAY, 0), -1); }