@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); }
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; } @Override public void onReceivedError(final WebView view, final int errorCode, final String description, final String failingUrl) { super.onReceivedError(view, errorCode, description, failingUrl); customEventInterstitialListener.onInterstitialFailed( MoPubErrorCode.MRAID_LOAD_ERROR); } }); dummyWebView.loadDataWithBaseURL(null, htmlData, "text/html", "UTF-8", null); }
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; } @Override public void onReceivedError(final WebView view, final int errorCode, final String description, final String failingUrl) { super.onReceivedError(view, errorCode, description, failingUrl); customEventInterstitialListener.onInterstitialFailed( MoPubErrorCode.MRAID_LOAD_ERROR); } }); dummyWebView.loadDataWithBaseURL(null, htmlData, "text/html", "UTF-8", null); } }
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; } @Override public void onReceivedError(final WebView view, final int errorCode, final String description, final String failingUrl) { super.onReceivedError(view, errorCode, description, failingUrl); customEventInterstitialListener.onInterstitialFailed( MoPubErrorCode.MRAID_LOAD_ERROR); } }); dummyWebView.loadDataWithBaseURL(null, htmlData, "text/html", "UTF-8", null); }  }
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; } @Override public void onReceivedError(final WebView view, final int errorCode, final String description, final String failingUrl) { super.onReceivedError(view, errorCode, description, failingUrl); customEventInterstitialListener.onInterstitialFailed( MoPubErrorCode.MRAID_LOAD_ERROR); } }); 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, @Nullable AdReport adreport, @NonNull String htmlData, long broadcastIdentifier); @Override View getAdView(); @Override void onCreate(@Nullable Bundle savedInstanceState); @VisibleForTesting void setDebugListener(@Nullable MraidWebViewDebugListener debugListener); }
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; } @Override public void onReceivedError(final WebView view, final int errorCode, final String description, final String failingUrl) { super.onReceivedError(view, errorCode, description, failingUrl); customEventInterstitialListener.onInterstitialFailed( MoPubErrorCode.MRAID_LOAD_ERROR); } }); 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, @Nullable AdReport adreport, @NonNull String htmlData, long broadcastIdentifier); @Override View getAdView(); @Override void onCreate(@Nullable Bundle savedInstanceState); @VisibleForTesting void setDebugListener(@Nullable MraidWebViewDebugListener debugListener);  }