use of org.prebid.mobile.rendering.views.webview.WebViewBase in project prebid-mobile-android by prebid.
the class MraidControllerTest method handleMraidEventWhenExpandEventAndHelperEmpty_InitExpand.
@Test
public void handleMraidEventWhenExpandEventAndHelperEmpty_InitExpand() {
MraidEvent event = createMraidEvent(JSInterface.ACTION_EXPAND, null);
HTMLCreative mockCreative = mock(HTMLCreative.class);
WebViewBase mockOldWebView = mock(WebViewBase.class);
when(mockOldWebView.getMraidListener()).thenReturn(mock(MraidEventsManager.MraidListener.class));
when(mockOldWebView.getContext()).thenReturn(mContext);
mMraidController.handleMraidEvent(event, mockCreative, mockOldWebView, mock(PrebidWebViewBase.class));
verify(mMraidController).initMraidExpand(any(View.class), any(MraidController.DisplayCompletionListener.class), any(MraidEvent.class));
}
use of org.prebid.mobile.rendering.views.webview.WebViewBase in project prebid-mobile-android by prebid.
the class MraidControllerTest method handleMraidEventWhenResizeEvent_CallResize.
@Test
public void handleMraidEventWhenResizeEvent_CallResize() throws Exception {
BaseJSInterface mockJsInterface = mock(BaseJSInterface.class);
MraidVariableContainer container = new MraidVariableContainer();
container.setCurrentState(JSInterface.STATE_LOADING);
when(mockJsInterface.getMraidVariableContainer()).thenReturn(container);
WebViewBase mockOldWebView = mock(WebViewBase.class);
when(mockOldWebView.getContext()).thenReturn(mContext);
when(mockOldWebView.getMRAIDInterface()).thenReturn(mockJsInterface);
mMraidController.handleMraidEvent(createMraidEvent(JSInterface.ACTION_RESIZE, null), mock(HTMLCreative.class), mockOldWebView, mock(PrebidWebViewBase.class));
assertNotNull(WhiteBox.getInternalState(mMraidController, "mMraidResize"));
}
use of org.prebid.mobile.rendering.views.webview.WebViewBase in project prebid-mobile-android by prebid.
the class MraidController method initMraidExpand.
@VisibleForTesting
protected void initMraidExpand(final View adBaseView, final DisplayCompletionListener displayCompletionListener, final MraidEvent mraidEvent) {
mMraidExpand = new MraidExpand(adBaseView.getContext(), ((WebViewBase) adBaseView), mInterstitialManager);
if (mraidEvent.mraidAction.equals(JSInterface.ACTION_EXPAND)) {
mMraidExpand.setMraidExpanded(true);
}
Handler handler = new Handler(Looper.getMainLooper());
handler.post(() -> {
try {
LogUtil.debug(TAG, "mraidExpand");
// send click event on expand
((WebViewBase) adBaseView).sendClickCallBack(mraidEvent.mraidActionHelper);
mMraidExpand.expand(mraidEvent.mraidActionHelper, () -> {
if (displayCompletionListener != null) {
displayCompletionListener.onDisplayCompleted();
// send expandedCallback to pubs
mInterstitialManager.getHtmlCreative().mraidAdExpanded();
}
});
} catch (Exception e) {
LogUtil.error(TAG, "mraidExpand failed at displayViewInInterstitial: " + Log.getStackTraceString(e));
}
});
}
use of org.prebid.mobile.rendering.views.webview.WebViewBase in project prebid-mobile-android by prebid.
the class HTMLCreative method createOmAdSession.
@Override
public void createOmAdSession() {
if (getCreativeView() == null || getCreativeView().getWebView() == null) {
LogUtil.error(TAG, "initOmAdSession error. Opex webView is null");
return;
}
OmAdSessionManager omAdSessionManager = mWeakOmAdSessionManager.get();
if (omAdSessionManager == null) {
LogUtil.error(TAG, "Error creating adSession. OmAdSessionManager is null");
return;
}
WebViewBase webView = getCreativeView().getWebView();
AdConfiguration adConfiguration = getCreativeModel().getAdConfiguration();
ContentObject contentObject = adConfiguration.getAppContent();
String contentUrl = null;
if (contentObject != null)
contentUrl = contentObject.getUrl();
omAdSessionManager.initWebAdSessionManager(webView, contentUrl);
startOmSession(omAdSessionManager, webView);
}
use of org.prebid.mobile.rendering.views.webview.WebViewBase 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