@Test public void testMRAIDCloseToHidden() { String mraidCall = "mraid://close"; implementation.dispatch_mraid_call(mraidCall, true); assertTrue(mockAdWebView.hidden); }
@Test public void testMRAIDSetOrientationPropertiesSuccess() { String allowOrientationChange = "true"; String forceOrientation = "none"; String mraidCall = String.format("mraid://setOrientationProperties?allow_orientation_change=%s&force_orientation=%s", allowOrientationChange, forceOrientation); implementation.expanded = true; implementation.dispatch_mraid_call(mraidCall, true); }
Clog.v(Clog.mraidLogTag, url); if (isMRAIDEnabled) { implementation.dispatch_mraid_call(url, userInteracted); } else { String host = Uri.parse(url).getHost(); fireMRAIDEnabled(); } else if ((host != null) && host.equals("open")) { implementation.dispatch_mraid_call(url, userInteracted);
@Test public void testMRAIDCreateCalendarEventSuccess() { String event = "{\"id\":1}"; String mraidCall = String.format("mraid://createCalendarEvent?p=%s", event); implementation.dispatch_mraid_call(mraidCall, true); MockAdDispatcher mockAdDispatcher = (MockAdDispatcher) mockAdWebView.adView.getAdDispatcher(); assertTrue(mockAdDispatcher.adClicked); }
@Test public void testMRAIDOpenFailure() { String uri = ""; String mraidCall = String.format("mraid://open?uri=%s", uri); implementation.dispatch_mraid_call(mraidCall, true); assertEquals(mockAdWebView.testString, "default"); MockAdDispatcher mockAdDispatcher = (MockAdDispatcher) mockAdWebView.adView.getAdDispatcher(); assertFalse(mockAdDispatcher.adClicked); assertFalse(mockAdDispatcher.adClickedWithUrl); }
@Test public void testMRAIDPlayVideoSuccess() { // Robolectric framework overrides intent errors for data type, so any uri will do String uri = "http://www.appnexus.com"; String mraidCall = String.format("mraid://playVideo?uri=%s", uri); implementation.dispatch_mraid_call(mraidCall, true); MockAdDispatcher mockAdDispatcher = (MockAdDispatcher) mockAdWebView.adView.getAdDispatcher(); assertTrue(mockAdDispatcher.adClicked); }
@Test public void testMRAIDExpandSuccess() { int width = -1; int height = -1; String useCustomClose = "false"; String allowOrientationChange = "true"; String forceOrientation = "none"; String mraidCall = String.format("mraid://expand?w=%d&h=%d&useCustomClose=%s&allow_orientation_change=%s&force_orientation=%s", width, height, useCustomClose, allowOrientationChange, forceOrientation); implementation.dispatch_mraid_call(mraidCall, true); assertEquals(mockAdWebView.width, width); assertEquals(mockAdWebView.height, height); assertEquals(mockAdWebView.customClose, false); assertEquals(mockAdWebView.allowOrientationChange, true); assertEquals(mockAdWebView.orientation, AdActivity.OrientationEnum.none); assertTrue(implementation.expanded); MockAdDispatcher mockAdDispatcher = (MockAdDispatcher) mockAdWebView.adView.getAdDispatcher(); assertTrue(mockAdDispatcher.adExpanded); }
@Test public void testMRAIDOpenSuccessSDKBrowser() { String uri = "http://www.appnexus.com"; String mraidCall = String.format("mraid://open?uri=%s", uri); //Default ANClickThroughAction is ANClickThroughAction.OPEN_SDK_BROWSER implementation.dispatch_mraid_call(mraidCall, true); assertEquals(mockAdWebView.testString, uri); MockAdDispatcher mockAdDispatcher = (MockAdDispatcher) mockAdWebView.adView.getAdDispatcher(); assertEquals(ANClickThroughAction.OPEN_SDK_BROWSER, mockAdWebView.adView.getClickThroughAction()); assertTrue(mockAdDispatcher.adClicked); assertFalse(mockAdDispatcher.adClickedWithUrl); }
@Test public void testMRAIDPlayVideoFail() { String uri = ""; String mraidCall = String.format("mraid://playVideo?uri=%s", uri); implementation.dispatch_mraid_call(mraidCall, true); MockAdDispatcher mockAdDispatcher = (MockAdDispatcher) mockAdWebView.adView.getAdDispatcher(); assertFalse(mockAdDispatcher.adClicked); }
@Test public void testMRAIDCreateCalendarEventFailure() { String event = ""; String mraidCall = String.format("mraid://createCalendarEvent?p=%s", event); implementation.dispatch_mraid_call(mraidCall, true); MockAdDispatcher mockAdDispatcher = (MockAdDispatcher) mockAdWebView.adView.getAdDispatcher(); assertFalse(mockAdDispatcher.adClicked); }
@Test public void testMRAIDResizeSuccess() { // set to -1 to get around screen size check int width = -1; int height = -1; int offsetX = 5; int offsetY = 5; String customClosePosition = "top-left"; String allowOffscreen = "true"; String mraidCall = String.format("mraid://resize?w=%d&h=%d&offset_x=%d&offset_y=%d&custom_close_position=%s&allow_offscreen=%s", width, height, offsetX, offsetY, customClosePosition, allowOffscreen); implementation.dispatch_mraid_call(mraidCall, true); assertEquals(mockAdWebView.width, width); assertEquals(mockAdWebView.height, height); assertEquals(mockAdWebView.offsetX, offsetX); assertEquals(mockAdWebView.offsetY, offsetY); assertEquals(mockAdWebView.customClosePosition, MRAIDImplementation.CUSTOM_CLOSE_POSITION.top_left); assertEquals(mockAdWebView.allowOffscreen, true); assertTrue(implementation.resized); MockAdDispatcher mockAdDispatcher = (MockAdDispatcher) mockAdWebView.adView.getAdDispatcher(); assertTrue(mockAdDispatcher.adClicked); }
@Test public void testMRAIDOpenSuccessDeviceBrowser() { String uri = "http://www.appnexus.com"; String mraidCall = String.format("mraid://open?uri=%s", uri); mockAdWebView.adView.setClickThroughAction(ANClickThroughAction.OPEN_DEVICE_BROWSER); implementation.dispatch_mraid_call(mraidCall, true); assertEquals(mockAdWebView.testString, uri); MockAdDispatcher mockAdDispatcher = (MockAdDispatcher) mockAdWebView.adView.getAdDispatcher(); assertEquals(ANClickThroughAction.OPEN_DEVICE_BROWSER, mockAdWebView.adView.getClickThroughAction()); assertTrue(mockAdDispatcher.adClicked); assertFalse(mockAdDispatcher.adClickedWithUrl); }
@Test public void testMRAIDOpenSuccessReturnUrl() { String uri = "http://www.appnexus.com"; String mraidCall = String.format("mraid://open?uri=%s", uri); mockAdWebView.adView.setClickThroughAction(ANClickThroughAction.RETURN_URL); implementation.dispatch_mraid_call(mraidCall, true); assertEquals(mockAdWebView.testString, uri); MockAdDispatcher mockAdDispatcher = (MockAdDispatcher) mockAdWebView.adView.getAdDispatcher(); assertEquals(ANClickThroughAction.RETURN_URL, mockAdWebView.adView.getClickThroughAction()); assertFalse(mockAdDispatcher.adClicked); assertTrue(mockAdDispatcher.adClickedWithUrl); }