summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGuang Zhu <guangzhu@google.com>2010-07-19 17:00:22 -0700
committerGuang Zhu <guangzhu@google.com>2010-07-19 17:00:22 -0700
commitd5a12e80fcd3ff53a1c975db2f6a89c0f28ed6cc (patch)
tree47e0d738c0ab4b422fd8c08289c55bfd9e98fb89 /tests
parentf6915fbb568e513a1968f6a4311559b5c832064d (diff)
downloadpackages_apps_Browser-d5a12e80fcd3ff53a1c975db2f6a89c0f28ed6cc.tar.gz
packages_apps_Browser-d5a12e80fcd3ff53a1c975db2f6a89c0f28ed6cc.tar.bz2
packages_apps_Browser-d5a12e80fcd3ff53a1c975db2f6a89c0f28ed6cc.zip
various fixes for browser test harness
* the definitive way to determine page load finish seems to be onPageLoadFinished AND onProgressChanged==100, changing test harness logic to reflect that * webview does not seem to be happen if ClearCache is called too often (or for certain pages?). It may complain that failed to delete blahblah, then the test harness goes crazy. So changing cache clear to after an entire iteration of web pages have been loaded * browser will load default home page, which may be disruptive to the page load process. So for the test, the browser is now started with initial intent to visit about:blank, which does not trigger any page load at all Change-Id: I1cfbd8d0196a05caea6a1c5137f45f1f59cc4c5f
Diffstat (limited to 'tests')
-rw-r--r--tests/src/com/android/browser/PopularUrlsTest.java54
1 files changed, 40 insertions, 14 deletions
diff --git a/tests/src/com/android/browser/PopularUrlsTest.java b/tests/src/com/android/browser/PopularUrlsTest.java
index 5b8cb86f5..b1760e9cd 100644
--- a/tests/src/com/android/browser/PopularUrlsTest.java
+++ b/tests/src/com/android/browser/PopularUrlsTest.java
@@ -63,6 +63,7 @@ public class PopularUrlsTest extends ActivityInstrumentationTestCase2<BrowserAct
private Instrumentation mInst = null;
private CountDownLatch mLatch = new CountDownLatch(1);
private RunStatus mStatus;
+ private boolean pageLoadFinishCalled, pageProgressFull;
public PopularUrlsTest() {
super(BrowserActivity.class);
@@ -72,6 +73,8 @@ public class PopularUrlsTest extends ActivityInstrumentationTestCase2<BrowserAct
protected void setUp() throws Exception {
super.setUp();
+ Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("about:blank"));
+ setActivityIntent(i);
mActivity = getActivity();
mInst = getInstrumentation();
mInst.waitForIdleSync();
@@ -122,14 +125,18 @@ public class PopularUrlsTest extends ActivityInstrumentationTestCase2<BrowserAct
webView.setWebChromeClient(new TestWebChromeClient(webView.getWebChromeClient()) {
- /**
- * Reset the latch whenever page progress reaches 100%.
- */
@Override
public void onProgressChanged(WebView view, int newProgress) {
super.onProgressChanged(view, newProgress);
if (newProgress >= 100) {
- resetLatch();
+ if (!pageProgressFull) {
+ // void duplicate calls
+ pageProgressFull = true;
+ if (pageLoadFinishCalled) {
+ //reset latch and move forward only if both indicators are true
+ resetLatch();
+ }
+ }
}
}
@@ -206,20 +213,38 @@ public class PopularUrlsTest extends ActivityInstrumentationTestCase2<BrowserAct
String host, String realm) {
handler.proceed("user", "passwd");
}
+
+ /* (non-Javadoc)
+ * @see com.android.browser.TestWebViewClient#onPageFinished(android.webkit.WebView, java.lang.String)
+ */
+ @Override
+ public void onPageFinished(WebView view, String url) {
+ if (!pageLoadFinishCalled) {
+ pageLoadFinishCalled = true;
+ if (pageProgressFull) {
+ //reset latch and move forward only if both indicators are true
+ resetLatch();
+ }
+ }
+ }
+
});
}
void resetLatch() {
- CountDownLatch temp = mLatch;
- mLatch = new CountDownLatch(1);
- if (temp != null) {
- // Notify existing latch that it's done.
- while (temp.getCount() > 0) {
- temp.countDown();
- }
+ if (mLatch.getCount() != 1) {
+ Log.w(TAG, "Expecting latch to be 1, but it's not!");
+ } else {
+ mLatch.countDown();
}
}
+ void resetForNewPage() {
+ mLatch = new CountDownLatch(1);
+ pageLoadFinishCalled = false;
+ pageProgressFull = false;
+ }
+
void waitForLoad() throws InterruptedException {
boolean timedout = !mLatch.await(PAGE_LOAD_TIMEOUT, TimeUnit.MILLISECONDS);
if (timedout) {
@@ -372,18 +397,19 @@ public class PopularUrlsTest extends ActivityInstrumentationTestCase2<BrowserAct
}
while (mStatus.getIteration() < loopCount) {
+ if (clearCache) {
+ webView.clearCache(true);
+ }
while(iterator.hasNext()) {
page = iterator.next();
mStatus.setUrl(page);
mStatus.write();
Log.i(TAG, "start: " + page);
Uri uri = Uri.parse(page);
- if (clearCache) {
- webView.clearCache(true);
- }
final Intent intent = new Intent(Intent.ACTION_VIEW, uri);
long startTime = System.currentTimeMillis();
+ resetForNewPage();
mInst.runOnMainSync(new Runnable() {
public void run() {