use of org.prebid.mobile.rendering.models.internal.MraidVariableContainer in project prebid-mobile-android by prebid.
the class BaseJSInterfaceTest method setURLForLaunchingTest.
@Test
public void setURLForLaunchingTest() throws IllegalAccessException {
final MraidVariableContainer mraidVariableContainer = mSpyBaseJSInterface.getMraidVariableContainer();
assertEquals("", mraidVariableContainer.getUrlForLaunching());
mraidVariableContainer.setUrlForLaunching("test");
assertEquals("test", mraidVariableContainer.getUrlForLaunching());
}
use of org.prebid.mobile.rendering.models.internal.MraidVariableContainer in project prebid-mobile-android by prebid.
the class BaseJSInterfaceTest method getURLForLaunchingTest.
@Test
public void getURLForLaunchingTest() throws IllegalAccessException {
final MraidVariableContainer mraidVariableContainer = mSpyBaseJSInterface.getMraidVariableContainer();
assertEquals("", mraidVariableContainer.getUrlForLaunching());
mraidVariableContainer.setUrlForLaunching("test");
assertEquals("test", mraidVariableContainer.getUrlForLaunching());
}
use of org.prebid.mobile.rendering.models.internal.MraidVariableContainer in project prebid-mobile-android by prebid.
the class MraidExpand method performExpand.
private void performExpand(String url, CompletedCallBack completedCallBack) {
final Context context = mContext;
if (context == null) {
LogUtil.error(TAG, "Context is null");
return;
}
Handler uiHandler = new Handler(Looper.getMainLooper());
uiHandler.post(() -> {
try {
final MraidVariableContainer mraidVariableContainer = mJsi.getMraidVariableContainer();
String state = mraidVariableContainer.getCurrentState();
if (isContainerStateInvalid(state)) {
LogUtil.debug(TAG, "handleExpand: Skipping. Wrong container state: " + state);
return;
}
mJsi.setDefaultLayoutParams(mWebViewBanner.getLayoutParams());
if (url != null) {
mraidVariableContainer.setUrlForLaunching(url);
}
showExpandDialog(context, completedCallBack);
} catch (Exception e) {
LogUtil.error(TAG, "Expand failed: " + Log.getStackTraceString(e));
}
});
}
use of org.prebid.mobile.rendering.models.internal.MraidVariableContainer in project prebid-mobile-android by prebid.
the class AdBaseDialog method initOrientationProperties.
private void initOrientationProperties() {
final MraidVariableContainer mraidVariableContainer = mWebViewBase.getMRAIDInterface().getMraidVariableContainer();
JSONObject orientationProperties;
// IMP : must be true by default cos this is used if expand(url) is called as at line#if (!webViewBase.getMRAIDInterface().isLaunchWithURL()) check
boolean allowOrientationChange = true;
String forceOrientation = "none";
try {
orientationProperties = new JSONObject(mraidVariableContainer.getOrientationProperties());
allowOrientationChange = orientationProperties.optBoolean("allowOrientationChange", true);
forceOrientation = orientationProperties.optString("forceOrientation", "none");
} catch (Exception e) {
LogUtil.error(TAG, "Failed to get the orientation details from JSON for MRAID: " + Log.getStackTraceString(e));
}
if (!mraidVariableContainer.isLaunchedWithUrl()) {
mAllowOrientationChange = allowOrientationChange;
mForceOrientation = OrientationManager.ForcedOrientation.valueOf(forceOrientation);
}
}
use of org.prebid.mobile.rendering.models.internal.MraidVariableContainer in project prebid-mobile-android by prebid.
the class MraidCloseTest method closeThroughJSTest.
@Test
public void closeThroughJSTest() throws Exception {
ViewGroup mockViewGroup = mock(ViewGroup.class);
when(mSpyBaseJSInterface.getRootView()).thenReturn(mockViewGroup);
final MraidVariableContainer mraidVariableContainer = mSpyBaseJSInterface.getMraidVariableContainer();
mMraidClose = new MraidClose(null, mSpyBaseJSInterface, mMockWebViewBase);
mraidVariableContainer.setCurrentState(JSInterface.STATE_DEFAULT);
mMraidClose.closeThroughJS();
verify(mSpyBaseJSInterface, times(0)).onStateChange(anyString());
mMraidClose = new MraidClose(mTestActivity, mSpyBaseJSInterface, mMockWebViewBase);
mraidVariableContainer.setCurrentState(JSInterface.STATE_LOADING);
mMraidClose.closeThroughJS();
verify(mSpyBaseJSInterface, times(0)).onStateChange(anyString());
mraidVariableContainer.setCurrentState(JSInterface.STATE_DEFAULT);
mMraidClose.closeThroughJS();
verify(mSpyBaseJSInterface).onStateChange(eq(JSInterface.STATE_HIDDEN));
mraidVariableContainer.setCurrentState(JSInterface.STATE_EXPANDED);
mMraidClose.closeThroughJS();
verify(mSpyBaseJSInterface).onStateChange(eq(JSInterface.STATE_DEFAULT));
verify(mockViewGroup).removeView(any());
reset(mSpyBaseJSInterface);
AdBrowserActivity mockActivity = new AdBrowserActivity();
mMraidClose = new MraidClose(mockActivity, mSpyBaseJSInterface, mMockWebViewBase);
mraidVariableContainer.setCurrentState(JSInterface.STATE_EXPANDED);
mMraidClose.closeThroughJS();
verify(mSpyBaseJSInterface).onStateChange(eq(JSInterface.STATE_DEFAULT));
}
Aggregations