diff options
author | Guang Zhu <guangzhu@google.com> | 2010-07-19 17:09:15 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-07-19 17:09:15 -0700 |
commit | 1c5fe40bbea43d4a2d8de74ce169f9f705896f26 (patch) | |
tree | 85fd820751e9b67df64855f5a3aae144f1498da7 | |
parent | e7c06a6eb880bec19bfe43a0ac09ca9c6d20c049 (diff) | |
parent | d5a12e80fcd3ff53a1c975db2f6a89c0f28ed6cc (diff) | |
download | packages_apps_Browser-1c5fe40bbea43d4a2d8de74ce169f9f705896f26.zip packages_apps_Browser-1c5fe40bbea43d4a2d8de74ce169f9f705896f26.tar.gz packages_apps_Browser-1c5fe40bbea43d4a2d8de74ce169f9f705896f26.tar.bz2 |
am d5a12e80: various fixes for browser test harness
Merge commit 'd5a12e80fcd3ff53a1c975db2f6a89c0f28ed6cc' into gingerbread-plus-aosp
* commit 'd5a12e80fcd3ff53a1c975db2f6a89c0f28ed6cc':
various fixes for browser test harness
-rw-r--r-- | tests/src/com/android/browser/PopularUrlsTest.java | 54 |
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 5b8cb86..b1760e9 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() { |