I'm trying to test out some content in a WebView
using Robolectric, however there is no data coming into it.
I have called the following before loadUrl()
on the WebView
.
Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
Robolectric.getFakeHttpLayer().interceptResponseContent(true);
And I have also called the following in order to try and flush whatever is queued up in Robolectric-land. I do have to do this in order for me to get a few other things to kick through.
Robolectric.runBackgroundTasks();
Robolectric.runUiThreadTasks();
Robolectric.runUiThreadTasksIncludingDelayedTasks();
Here is the code that loads the url
WebView webView = new WebView(this);
webView.getSettings().setUseWideViewPort(false);
webView.getSettings().setSupportMultipleWindows(false);
webView.getSettings().setCacheMode(WebSettings.LOAD_NO_CACHE);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setAppCacheEnabled(false);
webView.getSettings().setDomStorageEnabled(false);
webView.getSettings().setLoadWithOverviewMode(true);
webView.setInitialScale(1);
webView.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
Log.d(TAG, newProgress + " URL: " + view.getUrl());//this never happens!
}
});
webView.loadUrl("https://the-url.to/load");
Log.d(TAG, "Loading: " + url);//i see this..
I really like Robolectric and how it solves the emulator overhead problems, but I need it to work with the WebView implementation above. Any ideas?