MraidActivity extends BaseInterstitialActivity { public static void preRenderHtml(@NonNull final Context context, @NonNull final CustomEventInterstitialListener customEventInterstitialListener, @NonNull final String htmlData) { BaseWebView dummyWebView = new BaseWebView(context); dummyWebView.enablePlugins(false); dummyWebView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(final WebView view, final String url) { customEventInterstitialListener.onInterstitialLoaded(); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { return true; } }); dummyWebView.loadDataWithBaseURL(null, htmlData, "text/html", "UTF-8", null); }  static void preRenderHtml(@NonNull final Context context,
            @NonNull final CustomEventInterstitialListener customEventInterstitialListener,
            @NonNull final String htmlData); static void start(@NonNull Context context, @NonNull String htmlData,
            @NonNull AdConfiguration adConfiguration); @Override View getAdView(); @Override void onCreate(@Nullable Bundle savedInstanceState); @VisibleForTesting void setDebugListener(@Nullable MraidWebViewDebugListener debugListener);  }
@Ignore("Mraid 2.0") @Test public void preRenderHtml_shouldDisablePluginsSetListenersAndLoadHtml() throws Exception { MraidActivity.preRenderHtml(subject, customEventInterstitialListener, "3:27"); verify(mraidWebView).enablePlugins(eq(false)); verify(mraidController).setMraidListener(any(MraidListener.class)); verify(mraidWebView).setWebViewClient(any(WebViewClient.class)); verify(mraidBridge).setContentHtml(eq("3:27")); }
@Ignore("Mraid 2.0") @Test public void preRenderHtml_shouldCallCustomEventInterstitialOnInterstitialLoaded_whenMraidListenerOnReady() throws Exception { MraidActivity.preRenderHtml(subject, customEventInterstitialListener, ""); ArgumentCaptor<MraidListener> mraidListenerArgumentCaptorr = ArgumentCaptor.forClass(MraidListener.class); verify(mraidController).setMraidListener(mraidListenerArgumentCaptorr.capture()); MraidListener mraidListener = mraidListenerArgumentCaptorr.getValue(); mraidListener.onLoaded(null); verify(customEventInterstitialListener).onInterstitialLoaded(); }
@Ignore("Mraid 2.0") @Test public void preRenderHtml_shouldCallCustomEventInterstitialOnInterstitialFailed_whenMraidListenerOnFailure() throws Exception { MraidActivity.preRenderHtml(subject, customEventInterstitialListener, ""); ArgumentCaptor<MraidListener> mraidListenerArgumentCaptorr = ArgumentCaptor.forClass(MraidListener.class); verify(mraidController).setMraidListener(mraidListenerArgumentCaptorr.capture()); MraidListener mraidListener = mraidListenerArgumentCaptorr.getValue(); mraidListener.onFailedToLoad(); verify(customEventInterstitialListener).onInterstitialFailed(null); }
@Ignore("Mraid 2.0") @Test public void preRenderHtml_whenWebViewClientShouldOverrideUrlLoading_shouldReturnTrue() throws Exception { MraidActivity.preRenderHtml(subject, customEventInterstitialListener, ""); ArgumentCaptor<WebViewClient> webViewClientArgumentCaptor = ArgumentCaptor.forClass(WebViewClient.class); verify(mraidWebView).setWebViewClient(webViewClientArgumentCaptor.capture()); WebViewClient webViewClient = webViewClientArgumentCaptor.getValue(); boolean consumeUrlLoading = webViewClient.shouldOverrideUrlLoading(null, null); assertThat(consumeUrlLoading).isTrue(); verify(customEventInterstitialListener, never()).onInterstitialLoaded(); verify(customEventInterstitialListener, never()).onInterstitialFailed( any(MoPubErrorCode.class)); }
@Ignore("Mraid 2.0") @Test public void preRenderHtml_shouldCallCustomEventInterstitialOnInterstitialLoaded_whenWebViewClientOnPageFinished() throws Exception { MraidActivity.preRenderHtml(subject, customEventInterstitialListener, ""); ArgumentCaptor<WebViewClient> webViewClientArgumentCaptor = ArgumentCaptor.forClass(WebViewClient.class); verify(mraidWebView).setWebViewClient(webViewClientArgumentCaptor.capture()); WebViewClient webViewClient = webViewClientArgumentCaptor.getValue(); webViewClient.onPageFinished(null, null); verify(customEventInterstitialListener).onInterstitialLoaded(); }