I have the following test code:
@Override
protected void setUp() throws Exception {
super.setUp();
final CountDownLatch lock = new CountDownLatch(1);
Client client = new Client(getInstrumentation().getTargetContext(), new IJavascriptLoadedListener() {
@Override
public void onLoaded() {
lock.countDown();
}
lock.await();
}));
and the client class looks like this:
public Client(Context context, Uri path, IJavascriptLoadedListener listener){
mContext = context;
mLoadedListener = listener;
//Load the the webview context for processing jay javascript
mWebView = new WebView(context);
mWebView.setWebViewClient(new WebViewClient(){
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
if (mLoadedListener != null) {
mLoadedListener.onLoaded();
}
}
});
mWebView.loadUrl("http://www.google.com");
}
This code runs fine when I am running the application, onPageFinished is called. When I run the same thing from a unit test, onPageFinished never gets called. Any idea what I am doing wrong?
Aucun commentaire:
Enregistrer un commentaire