use of org.prebid.mobile.rendering.views.webview.WebViewBanner in project prebid-mobile-android by prebid.
the class InterstitialManagerTest method displayPrebidWebViewForMraid_CallDelegateDisplayPrebidWebViewForMRAID.
@Test
public void displayPrebidWebViewForMraid_CallDelegateDisplayPrebidWebViewForMRAID() throws Exception {
WebViewBanner mockWebView = mock(WebViewBanner.class);
MraidEvent mockEvent = mock(MraidEvent.class);
mockEvent.mraidAction = JSInterface.ACTION_EXPAND;
mockEvent.mraidActionHelper = "test";
when(mockWebView.getMraidEvent()).thenReturn(mockEvent);
mSpyInterstitialManager.displayPrebidWebViewForMraid(mockWebView, true);
verify(mMockMraidDelegate).displayPrebidWebViewForMraid(mockWebView, true, mockEvent);
}
use of org.prebid.mobile.rendering.views.webview.WebViewBanner in project prebid-mobile-android by prebid.
the class MraidControllerTest method expandWhenHelperNotEmpty_NewWebViewSetEvent.
@Test
public void expandWhenHelperNotEmpty_NewWebViewSetEvent() {
WebViewBase mockOldWebView = mock(WebViewBase.class);
PrebidWebViewBase mockNewWebView = mock(PrebidWebViewBase.class);
MraidEvent event = createMraidEvent(JSInterface.ACTION_EXPAND, "twoPart");
WebViewBanner mockBanner = mock(WebViewBanner.class);
when(mockNewWebView.getMraidWebView()).thenReturn(mockBanner);
when(mockOldWebView.getMraidListener()).thenReturn(mock(MraidEventsManager.MraidListener.class));
mMraidController.expand(mockOldWebView, mockNewWebView, event);
verify(mockNewWebView, times(1)).getMraidWebView();
verify(mockBanner).setMraidEvent(eq(event));
}
use of org.prebid.mobile.rendering.views.webview.WebViewBanner in project prebid-mobile-android by prebid.
the class InterstitialManager method interstitialClosed.
@Override
public void interstitialClosed(View viewToClose) {
LogUtil.debug(TAG, "interstitialClosed");
try {
if (!mViewStack.isEmpty() && mMraidDelegate != null) {
View poppedViewState = mViewStack.pop();
// take the old one & display(ex: close of a video inside of an expanded ad
// should take it back to the defaultview of the ad.
mMraidDelegate.displayViewInInterstitial(poppedViewState, false, null, null);
return;
}
// IMPORTANT: HAS to be there inspite of calling close above.
if ((mMraidDelegate == null || !mMraidDelegate.collapseMraid()) && mInterstitialDialog != null) {
mInterstitialDialog.nullifyDialog();
mInterstitialDialog = null;
}
if (mMraidDelegate != null) {
mMraidDelegate.closeThroughJs((WebViewBase) viewToClose);
}
// resize->click->expandedview->click on playvideo->pressback->goes back to the expanded state. We should not send clickthrough event to pub, for this case.
if (mInterstitialDisplayDelegate != null && !(viewToClose instanceof WebViewBanner)) {
mInterstitialDisplayDelegate.interstitialAdClosed();
}
} catch (Exception e) {
LogUtil.error(TAG, "InterstitialClosed failed: " + Log.getStackTraceString(e));
}
}
use of org.prebid.mobile.rendering.views.webview.WebViewBanner in project prebid-mobile-android by prebid.
the class MraidClose method closeThroughJS.
public void closeThroughJS() {
final Context context = mContext;
if (context == null) {
LogUtil.error(TAG, "Context is null");
return;
}
Handler uiHandler = new Handler(Looper.getMainLooper());
uiHandler.post(() -> {
try {
String state = mJsi.getMraidVariableContainer().getCurrentState();
WebViewBase webViewBase = mWebViewBase;
if (isContainerStateInvalid(state)) {
LogUtil.debug(TAG, "closeThroughJS: Skipping. Wrong container state: " + state);
return;
}
changeState(state);
if (webViewBase instanceof WebViewBanner && webViewBase.getMRAIDInterface().getDefaultLayoutParams() != null) {
webViewBase.setLayoutParams(webViewBase.getMRAIDInterface().getDefaultLayoutParams());
}
} catch (Exception e) {
LogUtil.error(TAG, "closeThroughJS failed: " + Log.getStackTraceString(e));
}
});
}
Aggregations