public void runBasicMediationTest(ResultCode errorCode, boolean success, boolean checkLatency) { executeUTRequest(); executeAndAssertResponseURL(2, errorCode, checkLatency); assertCallbacks(success); assertEquals(success,interstitialAdView.isReady()); if(ResultCode.SUCCESS == errorCode){ interstitialAdView.show(); assertTrue(MediatedInterstitialSuccessful.showCalled); } }
@Test public void testDestroy() { String[] classNames = {"MediatedInterstitialNoFillView", "MediatedInterstitialSuccessful2"}; String[] responseURLs = {TestResponsesUT.RESPONSE_URL, TestResponsesUT.RESPONSE_URL}; server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.waterfall_CSM_Banner_Interstitial(classNames, responseURLs))); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); executeUTRequest(); executeAndAssertResponseURL(2, UNABLE_TO_FILL, CHECK_LATENCY_TRUE); //2 request are already taken out of queue current position of ResponseURL in queue is 1 executeAndAssertResponseURL(1, SUCCESS, CHECK_LATENCY_TRUE); Lock.pause(Settings.MEDIATED_NETWORK_TIMEOUT + 1000); assertCallbacks(true); assertTrue(MediatedInterstitialSuccessful2.didPass); assertTrue(MediatedInterstitialNoFillView.didDestroy); assertTrue(interstitialAdView.isReady()); interstitialAdView.show(); assertTrue(MediatedInterstitialSuccessful2.showCalled); }
@Test public void testHttp404ErrorResponseFromSuccess() { String[] classNames = {"MediatedInterstitialSuccessful"}; String[] responseURLs = {"http://wiki221random.devnxs.net/"}; server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.waterfall_CSM_Banner_Interstitial(classNames, responseURLs))); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); executeUTRequest(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); assertCallbacks(true); assertTrue(interstitialAdView.isReady()); }
@Test public void testHttp404ErrorResponseFromFailure() { String[] classNames = {"MediatedInterstitialNoFillView"}; String[] responseURLs = {"http://wiki221random.devnxs.net/"}; server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.waterfall_CSM_Banner_Interstitial(classNames, responseURLs))); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); executeUTRequest(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); assertCallbacks(false); assertFalse(interstitialAdView.isReady()); }
@Test public void testSkipFirstSuccessfulSecond() { String[] classNames = {"MediatedInterstitialNoFillView", "MediatedInterstitialSuccessful2"}; String[] responseURLs = {TestResponsesUT.RESPONSE_URL, TestResponsesUT.RESPONSE_URL}; server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.waterfall_CSM_Banner_Interstitial(classNames, responseURLs))); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); executeUTRequest(); executeAndAssertResponseURL(2, UNABLE_TO_FILL, CHECK_LATENCY_TRUE); //2 request are already taken out of queue current position of ResponseURL in queue is 1 executeAndAssertResponseURL(1, SUCCESS, CHECK_LATENCY_TRUE); assertCallbacks(true); assertTrue(interstitialAdView.isReady()); assertTrue(MediatedInterstitialSuccessful2.didPass); interstitialAdView.show(); assertTrue(MediatedInterstitialSuccessful2.showCalled); }
assertFalse(interstitialAdView.isReady()); assertNoAdURL();
@Test public void testTestNoFill() { String[] classNames = {"MediatedInterstitialNoFillView", "MediatedInterstitialNoFillView"}; String[] responseURLs = {TestResponsesUT.RESPONSE_URL, TestResponsesUT.RESPONSE_URL}; server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.waterfall_CSM_Banner_Interstitial(classNames, responseURLs))); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); // This is for NO_AD url executeUTRequest(); executeAndAssertResponseURL(2, UNABLE_TO_FILL, CHECK_LATENCY_TRUE); //2 request are already taken out of queue current position of ResponseURL in queue is 1 executeAndAssertResponseURL(1, UNABLE_TO_FILL, CHECK_LATENCY_TRUE); Lock.pause(Settings.MEDIATED_NETWORK_TIMEOUT + 1000); assertCallbacks(false); assertFalse(interstitialAdView.isReady()); assertNoAdURL(); }