Permalink
Browse files

DO NOT MERGE:backport test imrpovements from newer platform

This change contains the following changes:
I41758a87 some improvements for browser test harness
I7785f66c prevent browser test from launching non-http urls
Id2f49549 throw RuntimeException if failed to stop a timedout site

Change-Id: Ic44f747c5da4328be8fa15b882ce72f56204b142
  • Loading branch information...
1 parent 9acdeec commit 74891977d6943e793f92bacca3d965d6dc462093 Guang Zhu committed Jan 27, 2011
Showing with 29 additions and 1 deletion.
  1. +29 −1 tests/src/com/android/browser/PopularUrlsTest.java
@@ -23,6 +23,7 @@
import android.os.Environment;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;
+import android.webkit.DownloadListener;
import android.webkit.HttpAuthHandler;
import android.webkit.JsPromptResult;
import android.webkit.JsResult;
@@ -180,6 +181,16 @@ public boolean onJsPrompt(WebView view, String url, String message,
return true;
}
+
+ /*
+ * Skip the unload confirmation
+ */
+ @Override
+ public boolean onJsBeforeUnload(
+ WebView view, String url, String message, JsResult result) {
+ result.confirm();
+ return true;
+ }
});
webView.setWebViewClient(new TestWebViewClient(webView.getWebViewClient()) {
@@ -228,6 +239,23 @@ public void onPageFinished(WebView view, String url) {
}
}
+ @Override
+ public boolean shouldOverrideUrlLoading(WebView view, String url) {
+ if (!(url.startsWith("http://") || url.startsWith("https://"))) {
+ Log.v(TAG, String.format("suppressing non-http url scheme: %s", url));
+ return true;
+ }
+ return super.shouldOverrideUrlLoading(view, url);
+ }
+ });
+
+ webView.setDownloadListener(new DownloadListener() {
+
+ @Override
+ public void onDownloadStart(String url, String userAgent, String contentDisposition,
+ String mimetype, long contentLength) {
+ Log.v(TAG, String.format("Download request ignored: %s", url));
+ }
});
}
@@ -258,7 +286,7 @@ public void run() {
// try to wait for count down latch again
timedout = !mLatch.await(5000, TimeUnit.MILLISECONDS);
if (timedout) {
- Log.e(TAG, "failed to stop the timedout site in 5s");
+ throw new RuntimeException("failed to stop timedout site, is browser pegged?");
}
}
}

0 comments on commit 7489197

Please sign in to comment.