WebView testing with Robolectric

450 views
Skip to first unread message

Tyler Williamson

unread,
Aug 7, 2014, 11:12:05 AM8/7/14
to robol...@googlegroups.com
I'm currently migrating all my old Android tests over to Robolectric, since its so CI friendly.

However, I'm running into an issue testing my WebView.

Before calling webView.loadUrl("my url"), I invoke these methods


        Robolectric.getFakeHttpLayer().interceptHttpRequests(false);
        Robolectric.getFakeHttpLayer().interceptResponseContent(true);

I've also anonymously overridden all of the methods of the WebViewClient() and WebChromeClient() attached, and none of them are firing.

After calling loadUrl, I also try this as I've had to do it in a few other test cases due to multi-threading things.


            Robolectric.runBackgroundTasks();
            Robolectric.runUiThreadTasks();
            Robolectric.runUiThreadTasksIncludingDelayedTasks();

I can't seem to get the url to load in this webview.  I've also tried loading https://www.google.com into it, and its not working at all. Any help?
Reply all
Reply to author
Forward
0 new messages