use of org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface in project prebid-mobile-android by prebid.
the class WebViewBanner method setMRAIDInterface.
public void setMRAIDInterface() {
BaseJSInterface mraid = new BannerJSInterface(getContext(), this, new JsExecutor(this, new Handler(Looper.getMainLooper()), new HandlerQueueManager()));
addJavascriptInterface(mraid, "jsBridge");
LogUtil.debug(TAG, "JS bridge initialized");
setBaseJSInterface(mraid);
}
use of org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface in project prebid-mobile-android by prebid.
the class MraidResizeTest method setUp.
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
PrebidWebViewBase prebidWebViewBase = mock(PrebidWebViewBase.class);
mMockContext = Robolectric.buildActivity(Activity.class).create().get().getApplicationContext();
mSpyBaseJsInterface = spy(new BaseJSInterface(mMockContext, mMockWebViewBase, mMockJsExecutor));
when(mSpyBaseJsInterface.getMraidVariableContainer()).thenReturn(mMockMraidVariableContainer);
when(mMockWebViewBase.post(any(Runnable.class))).thenAnswer(invocation -> {
Runnable runnable = invocation.getArgument(0);
runnable.run();
return null;
});
doAnswer(invocation -> {
Handler handler = invocation.getArgument(0);
Message message = new Message();
Bundle data = new Bundle();
data.putString(JSInterface.JSON_VALUE, "{\"width\":320,\"height\":250,\"customClosePosition\":\"top-right\",\"offsetX\":0,\"offsetY\":0,\"allowOffscreen\":true}");
message.setData(data);
handler.handleMessage(message);
return null;
}).when(mMockJsExecutor).executeGetResizeProperties(any(Handler.class));
when(mMockWebViewBase.getParent()).thenReturn(prebidWebViewBase);
when(mSpyBaseJsInterface.getDefaultAdContainer()).thenReturn(prebidWebViewBase);
mMraidResize = new MraidResize(mMockContext, mSpyBaseJsInterface, mMockWebViewBase, mMockManager);
}
use of org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface 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"));
}
Aggregations