Search in sources :

Example 1 with AdBrowserActivity

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));
}
Also used : ViewGroup(android.view.ViewGroup) MraidVariableContainer(org.prebid.mobile.rendering.models.internal.MraidVariableContainer) AdBrowserActivity(org.prebid.mobile.rendering.views.browser.AdBrowserActivity) Test(org.junit.Test)

Aggregations

ViewGroup (android.view.ViewGroup)1 Test (org.junit.Test)1 MraidVariableContainer (org.prebid.mobile.rendering.models.internal.MraidVariableContainer)1 AdBrowserActivity (org.prebid.mobile.rendering.views.browser.AdBrowserActivity)1