@Test public void onPageStarted_whenLoadedUrlStartsWithRedirectAndHasClickthrough_withUserClick_shouldNotChangeUrl_shouldOpenInBrowser() throws Exception { stub(htmlWebView.wasClicked()).toReturn(true); String url = "redirectUrlToLoad"; WebView view = mock(WebView.class); subject.onPageStarted(view, url, null); verify(view).stopLoading(); Intent intent = Robolectric.getShadowApplication().getNextStartedActivity(); assertThat(intent.getStringExtra(MoPubBrowser.DESTINATION_URL_KEY)).isEqualTo(url); assertThat(intent.getFlags() & Intent.FLAG_ACTIVITY_NEW_TASK).isNotEqualTo(0); assertThat(intent.getComponent().getClassName()).isEqualTo("com.mopub.common.MoPubBrowser"); }
@Override public void onPageStarted(WebView view, String url, Bitmap favicon) { if (mRedirectUrl != null && url.startsWith(mRedirectUrl)) { view.stopLoading(); if (mHtmlWebView.wasClicked()) { try { Intents.showMoPubBrowserForUrl(mContext, Uri.parse(url)); } catch (IntentNotResolvableException e) { MoPubLog.d(e.getMessage()); } } else { MoPubLog.d("Attempted to redirect without user interaction"); } } }
HtmlWebViewClient extends WebViewClient { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { if (mRedirectUrl != null && url.startsWith(mRedirectUrl)) { view.stopLoading(); if (mHtmlWebView.wasClicked()) { try { Intents.showMoPubBrowserForUrl(mContext, Uri.parse(url)); } catch (IntentNotResolvableException e) { MoPubLog.d(e.getMessage()); } } else { MoPubLog.d("Attempted to redirect without user interaction"); } } } }
HtmlWebViewClient extends WebViewClient { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { if (mRedirectUrl != null && url.startsWith(mRedirectUrl)) { view.stopLoading(); if (mHtmlWebView.wasClicked()) { try { Intents.showMoPubBrowserForUrl(mContext, Uri.parse(url)); } catch (IntentNotResolvableException e) { MoPubLog.d(e.getMessage()); } } else { MoPubLog.d("Attempted to redirect without user interaction"); } } } HtmlWebViewClient(HtmlWebViewListener htmlWebViewListener, BaseHtmlWebView htmlWebView, String clickthrough, String redirect); }
HtmlWebViewClient extends WebViewClient { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { if (mRedirectUrl != null && url.startsWith(mRedirectUrl)) { view.stopLoading(); if (mHtmlWebView.wasClicked()) { try { Intents.showMoPubBrowserForUrl(mContext, Uri.parse(url)); } catch (IntentNotResolvableException e) { MoPubLog.d(e.getMessage()); } } else { MoPubLog.d("Attempted to redirect without user interaction"); } } } HtmlWebViewClient(HtmlWebViewListener htmlWebViewListener, BaseHtmlWebView htmlWebView, String clickthrough, String redirect); @Override boolean shouldOverrideUrlLoading(final WebView view, final String url); @Override void onPageStarted(WebView view, String url, Bitmap favicon); }
HtmlWebViewClient extends WebViewClient { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { if (mRedirectUrl != null && url.startsWith(mRedirectUrl)) { view.stopLoading(); if (mHtmlWebView.wasClicked()) { try { Intents.showMoPubBrowserForUrl(mContext, Uri.parse(url)); } catch (IntentNotResolvableException e) { MoPubLog.d(e.getMessage()); } } else { MoPubLog.d("Attempted to redirect without user interaction"); } } } HtmlWebViewClient(HtmlWebViewListener htmlWebViewListener, BaseHtmlWebView htmlWebView, String clickthrough, String redirect); @Override boolean shouldOverrideUrlLoading(final WebView view, final String url); @Override void onPageStarted(WebView view, String url, Bitmap favicon);  }