use of org.prebid.mobile.rendering.views.browser.AdBrowserActivity 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