summaryrefslogtreecommitdiffstats
path: root/android_webview
diff options
context:
space:
mode:
authorboliu <boliu@chromium.org>2015-03-31 18:04:37 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-01 01:05:40 +0000
commit53bcb9407608b3b6cf968c081cb96eee641b4b00 (patch)
tree3737b37cc0db5081975b9ca6429e7547ed47b1d0 /android_webview
parent4256409b82ce6c756f8ee45778c1276efbcba170 (diff)
downloadchromium_src-53bcb9407608b3b6cf968c081cb96eee641b4b00.zip
chromium_src-53bcb9407608b3b6cf968c081cb96eee641b4b00.tar.gz
chromium_src-53bcb9407608b3b6cf968c081cb96eee641b4b00.tar.bz2
Speculative deflake testCreateAndGcManyTimes
Suspicion is the single gc call did not kill off a AwContents due to transient internal strong refs during load. Suspect this is the problem due to logcat being completely empty for the 15 seconds when the poll at the end of the test happens. BUG=469803 Review URL: https://codereview.chromium.org/1039873004 Cr-Commit-Position: refs/heads/master@{#323159}
Diffstat (limited to 'android_webview')
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java36
1 files changed, 32 insertions, 4 deletions
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
index 0478a00..fa4bfd0 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsTest.java
@@ -19,6 +19,8 @@ import android.view.KeyEvent;
import android.view.View;
import android.webkit.JavascriptInterface;
+import static org.chromium.base.test.util.ScalableTimeout.scaleTimeout;
+
import org.apache.http.Header;
import org.apache.http.HttpRequest;
import org.chromium.android_webview.AwContents;
@@ -29,6 +31,8 @@ import org.chromium.base.annotations.SuppressFBWarnings;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.MinAndroidSdkLevel;
import org.chromium.content.browser.test.util.CallbackHelper;
+import org.chromium.content.browser.test.util.Criteria;
+import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content_public.browser.LoadUrlParams;
import org.chromium.net.test.util.TestWebServer;
@@ -188,12 +192,36 @@ public class AwContentsTest extends AwTestBase {
Runtime.getRuntime().gc();
- pollOnUiThread(new Callable<Boolean>() {
+ Criteria criteria = new Criteria() {
@Override
- public Boolean call() {
- return AwContents.getNativeInstanceCount() <= maxIdleInstances;
+ public boolean isSatisfied() {
+ try {
+ return runTestOnUiThreadAndGetResult(new Callable<Boolean>() {
+ @Override
+ public Boolean call() {
+ return AwContents.getNativeInstanceCount() <= maxIdleInstances;
+ }
+ });
+ } catch (Exception e) {
+ return false;
+ }
}
- });
+ };
+
+ // Depending on a single gc call can make this test flaky. It's possible
+ // that the WebView still has transient references during load so it does not get
+ // gc-ed in the one gc-call above. Instead call gc again if exit criteria fails to
+ // catch this case.
+ final long timeoutBetweenGcMs = scaleTimeout(1000);
+ for (int i = 0; i < 15; ++i) {
+ if (CriteriaHelper.pollForCriteria(criteria, timeoutBetweenGcMs, CHECK_INTERVAL)) {
+ break;
+ } else {
+ Runtime.getRuntime().gc();
+ }
+ }
+
+ assertTrue(criteria.isSatisfied());
}
@SmallTest