public void testImport() throws Exception { server.enqueue(new MockResponse().setBody(BATCH_CALENDAR_RESPONSE)); server.enqueue(new MockResponse().setResponseCode(201).setBody(BATCH_EVENT_RESPONSE)); server.start();
public void setFailFast(boolean failFast) { MockResponse failFastResponse = failFast ? new MockResponse().setResponseCode(HttpURLConnection.HTTP_NOT_FOUND) : null; setFailFast(failFastResponse); }
@Test public void getWhenInternalErrorReturnsResponse() throws MalformedURLException { server().enqueue(new MockResponse().setResponseCode(500).setBody("<html><body>" + "<div itemscope='itemscope' itemtype='http://i' itemid='http://x'/>" + "</body></html>")); MicrodataDocument actual = newBrowser().get(url(server())); assertThat("response", actual.getItem("http://i"), is(item("http://x"))); } }
@Test public void testNoResponseURL() { String[] classNames = {"FakeClass", "MediatedInterstitialNoFillView", "MediatedInterstitialSuccessful"}; String[] responseURLs = {"", null, 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())); runBasicMediationTest(SUCCESS, ASSERT_AD_LOAD_SUCESS, CHECK_LATENCY_TRUE); assertTrue(MediatedInterstitialSuccessful.didPass); }
@Test public void testgetAdTypeBanner() { server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.banner())); // First queue a regular HTML banner response assertTrue(bannerAdView.getAdType() == AdType.UNKNOWN); // First tests if ad_type is UNKNOW initially executeBannerRequest(); assertTrue(bannerAdView.getAdType() == AdType.BANNER); // If a HTML banner is served then BANNER }
@Test public void testBannerANClickThroughActionDeviceBrowser() { bannerAdView.setClickThroughAction(ANClickThroughAction.OPEN_DEVICE_BROWSER); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.banner())); // First queue a regular HTML banner response executeBannerRequest(); waitUntilExecuted(); assertTrue(adClicked); assertFalse(adClickedWithUrl); }
@Test public void testgetCreativeIdBannerNativeCreativeId() { server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.anNative())); // First queue a banner Native response executeBannerRequest(); assertEquals("47772560", bannerAdView.getCreativeId()); }
@Test public void testNoClassMediationCall() { server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.mediatedFakeClassBannerInterstitial())); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); // This is for NO_AD url runBasicMediationTest(MEDIATED_SDK_UNAVAILABLE, ASSERT_AD_LOAD_FAIL, CHECK_LATENCY_FALSE); assertNoAdURL(); }
@Test public void testErrorThrownMediationCall() { server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.mediatedOutOfMemoryInterstitial())); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); // This is for NO_AD url runBasicMediationTest(INTERNAL_ERROR, ASSERT_AD_LOAD_FAIL, CHECK_LATENCY_TRUE); assertNoAdURL(); }
@Test public void testNoClassMediationCall() { server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.mediatedFakeClass_Native())); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank()));// This is for No Ad URL runBasicMediationTest(MEDIATED_SDK_UNAVAILABLE, ASSERT_AD_LOAD_FAIL,CHECK_LATENCY_FALSE); assertNoAdURL(); }
@Test public void testVideoANClickThroughActionReturnURL() { videoAd.setClickThroughAction(ANClickThroughAction.RETURN_URL); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestUTResponses.video())); // First queue a regular HTML banner response executeVideoRequest(); waitForTasks(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); assertTrue(adClickedWithUrl); assertFalse(adClicked); }
@Test public void testVideoANClickThroughActionSDKBrowser() { videoAd.setClickThroughAction(ANClickThroughAction.OPEN_SDK_BROWSER); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestUTResponses.video())); // First queue a regular HTML banner response executeVideoRequest(); waitForTasks(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); assertTrue(adClicked); assertFalse(adClickedWithUrl); }
@Test public void testNotifyURLForVideo() throws Exception { server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.rtbVASTVideo())); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); executeUTRequest(); assertCallbacks(true); assertTrue(bannerAdView.mAdFetcher.getState() == AdFetcher.STATE.STOPPED); request = server.takeRequest(); // Discard the first request since its a HTTP Post for /ut/v3 ad request call request = server.takeRequest(); assertNotifyURL(request); }
@Test public void testToggleAutoRefresh() throws Exception { server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.rtbVASTVideo())); ShadowCustomVideoWebView.simulateDelayedVideoError = true; executeBannerRequest(); assertCallbacks(true); assertTrue(bannerAdView.mAdFetcher.getState() == AdFetcher.STATE.STOPPED); waitForTasks(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); assertTrue(bannerAdView.mAdFetcher.getState() == AdFetcher.STATE.AUTO_REFRESH); }
private void executionSteps(){ utAdRequest = new UTAdRequest(this); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); utAdRequest.execute(); waitForTasks(); clearAAIDAsyncTasks(); }
@Test public void test1CookiesSync() { server.enqueue(new MockResponse().setResponseCode(200).setHeader("Set-Cookie", TestResponsesUT.UUID_COOKIE_1).setBody(TestResponsesUT.banner())); requestManager.execute(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); String wvcookie = WebviewUtil.getCookie(); //Asserts the Cookie stored in the device is the same as that of the one we sent back in the response. assertEquals(getUUId2(wvcookie), getUUId2(TestResponsesUT.UUID_COOKIE_1)); }
@Test public void testRequestNativeSucceeded() { setNativeRequestParams(); adRequest = new UTAdRequest(this); server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.anNative())); adRequest.execute(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); assertReceiveServerResponseSuccessful(true); assertServerResponseHasAds(true); assertEquals(MediaType.NATIVE, response.getMediaType()); }
@Test public void testBannerAdFailed() { server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); requestManager = new AdViewRequestManager(bannerAdView); requestManager.execute(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); assertCallbacks(false); }
@Test public void testInterstitialAdLoaded() { server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.banner())); requestManager = new AdViewRequestManager(interstitialAdView); requestManager.execute(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); assertCallbacks(true); }
@Test public void testBannerNativeAdFailed() { server.enqueue(new MockResponse().setResponseCode(200).setBody(TestResponsesUT.blank())); requestManager = new AdViewRequestManager(bannerAdView); requestManager.execute(); Robolectric.flushBackgroundThreadScheduler(); Robolectric.flushForegroundThreadScheduler(); assertCallbacks(false); } }